GMS 2 How to handle turn based combat?

Discussion in 'Programming' started by trentallain, Jun 12, 2019.

  1. trentallain

    trentallain Member

    Aug 6, 2016
    What is the best way to handle turn based combat for a grid game (like fire emblem)?

    I realized that my current setup isn't very good because I was doing this for testing it:
    // With the enemy clicked on
    with (instance_position(mouse_x, mouse_y, obj_character)) {
        // Exchange damage
        hp -= _id.attack;
        _id.hp -= attack;
    And this doesn't allow for attack animations etc.

    Should I be using a state system for this or some sort of ds_queue or stack?

    My general game can be broken up into:
    initialization -> unit placement (for testing) -> players/AI take turns

    And for the units:
    (optional) Get player/AI input for where to move to -> (optional) attack another unit -> stop

    But then attacking can be broken up into:
    get unit to deal damage to -> create effect/camera shake/flash white -> show damage numbers and negate it from the unit -> unit you were attacking create effect/camera shake/flash white -> show damage numbers and negate it from the you -> if either health is <= 0 destroy/create even more effects/camera shake -> stop

    And when its this and allowing for animations to complete etc, it gets messy.

    So, what should I do to make this as simple and expandable as possible for when I add multiplayer and AI (and for just in general)?
    Last edited: Jun 12, 2019
  2. zATARA_0

    zATARA_0 Member

    Apr 10, 2019
    A state system would be perfect for this. Just have a move,attack,hit,die, then if you want differrent attacks for the different units you can alter their attack state or use switch object_type for smaller differences. This sort of thing is an ideal candidate for a state machiene.

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