1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GMS 2 How to Set Up a Darkest Dungeon-esk Combat System?

Discussion in 'Programming' started by Dusk_Ealain, Aug 3, 2017.

  1. Dusk_Ealain

    Dusk_Ealain Member

    Joined:
    May 25, 2017
    Posts:
    18
    Howdy, so this will hopefully be my last "Help" related post for a while, but my project has evolved quite a bit and is now looking a bit more like a traditional RPG. But I wanted to give it a bit more of a 2D perspective, which was pretty easy to do, but combat has gotten into the mix and now I've got a couple of questions.

    Darkest Dungeon is one of my favourite RPGs in recent years (and if you haven't tried it out, I'd recommend it wholeheartedly) and I especially enjoy how they do combat, be it from the visual appearance to the gameplay it provides, it's definitely more interesting than just "click any attack, click any enemy, done." For if you don't know every player character and monster has a "slot" up to 4 per side (though I will be extending this on the enemy's side for "horde" situations) and attacks can only hit certain areas. For visuals, instead of a full-on animation, you're presented with each character in a "pose" with the attack or spell being used on the enemy or ally.

    So my questions consist of:
    • How would I set up a "slot" system?
    • How would I restrict attacks to specific "slots"?
    • How do I tell GMS2 which characters to bring up when actions are being made (So for instance if the Knight attacks a Skeleton in the back, how do I tell the system to specifically use those two characters with those two sprites?)
    Any help or method would be appreciated and I thank you in advance. Sorry if this isn't descriptive enough and if so I'd be more than happy to help. I know when it comes to damage, status chances or resistances, that's just an internal numbers game. This is a case in which I more so need help with getting the visuals to "look right" if that makes sense.
     
  2. Cloaked Games

    Cloaked Games Member

    Joined:
    Jul 4, 2016
    Posts:
    801
    I can't really directly answer your question, even with pseudo-code without spending a while thinking about it. I've never been particularly good at visuals, and especially animation stuff.

    Here's what I can recommend, in case nobody with a better answer comes along:

    If you haven't already, learn about Finite State Machines and Action Actor Model. Those are good ways to do AI and tell a lot of different things to do the right thing based on simple numbers. It would probably apply here and if not... well, it's good to learn anyways. Use what you can of it.

    Also, try to boil everything down to be defined by a set of variables. Like, group all of the enemies that react the same way to a particular type of item under a common variable so that you can program their reaction once, and everything that should will behave the same way.

    Finally, use the animation end event for detecting when an animation ends. It's nice 'cause you can change the animation length, pause in the middle, and don't have to count steps to make sure everything works fluidly.
     
  3. Dusk_Ealain

    Dusk_Ealain Member

    Joined:
    May 25, 2017
    Posts:
    18
    That's what I was saying Cloaked, they don't really use animations as much as they use still images. Here's a video from the alpha to help illustrate my point a bit, sorry I forgot to include this in the original post:

    Hopefully, this clears some things up.

    May elaborate what you mean on this though?
     
  4. Cloaked Games

    Cloaked Games Member

    Joined:
    Jul 4, 2016
    Posts:
    801
    This usually helps no matter what you're doing. What I mean is, try to avoid writing code that only serves one specific purpose. For example, if you enemies can get hurt, have the variables used to manage damage be the same for all enemies, the scripts used for dealing damage to work with any situation, deal damage to anything that can take damage etc. If you can use the same code for hurting enemies that you use for hurting the player, that's even better.

    Like, instead of having code that looks like this:
    Code:
    //Attacking with bow
    if (distance to enemy > 3)
     {
     enemy3.health -= (10 + (irandom_range(-2, 20));
     player.arrows -= 1;
     }
    Code:
    //Attacking with axe
    if (distance to enemy < 2)
     {
     enemy2.health -= (40 + (irandom_range(-5, 5)));
     enemy1.health -= 10;
     }
    You can have one script that looks like this:
    Code:
    scr(target enemy, damage, damage variation, range, penalties);
     
  5. Dusk_Ealain

    Dusk_Ealain Member

    Joined:
    May 25, 2017
    Posts:
    18
    Oh okay, so essentially you add "labels", if you will, to things to make coding cleaner and easier?

    So instead of needing to specify, for instance, light-based attacks do %40 more damage on every enemy it applies to, I just give them a "dark/unholy" label and set light-based attacks to do %40 more damage to anything with said label?
     
  6. Cloaked Games

    Cloaked Games Member

    Joined:
    Jul 4, 2016
    Posts:
    801
    Roughly. It's more complicated than that, but I think you get it.

    After a few seconds: "labels"... hm... that's probably the best way to explain it.

    But to top that off, once you have labels, you can create scripts to do everything instead of copy-pasting code.
     
  7. Dusk_Ealain

    Dusk_Ealain Member

    Joined:
    May 25, 2017
    Posts:
    18
    Indeed, so you can set up labels for enemy types, armour types, weapon types, magic types, etc. and focus the coding within the object itself to be with what makes it unique from the rest, rather than having to copy and paste the basic coding for i.e Axe type weapons over and over.
     
  8. RefresherTowel

    RefresherTowel Member

    Joined:
    Jul 13, 2016
    Posts:
    1,216
    Enums (or macros) are a good fit for what you're thinking of as "labels".
     
  9. Dusk_Ealain

    Dusk_Ealain Member

    Joined:
    May 25, 2017
    Posts:
    18
    Ah, thank you. I looked it up and that sounds about right.
     
    RefresherTowel likes this.
  10. Cloaked Games

    Cloaked Games Member

    Joined:
    Jul 4, 2016
    Posts:
    801
    Yes. I use enums. Everything in my game is contained in a single ds_grid and several enumerators.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice