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 Help with a Cutscene [SOLVED]

Discussion in 'Programming' started by Abaddon_Ascidhiz, Oct 30, 2019.

  1. Abaddon_Ascidhiz

    Abaddon_Ascidhiz Member

    Joined:
    Sep 11, 2019
    Posts:
    7
    Greetings.


    I´m trying to implement a kind of finisher in a fighting game I´m creating.


    My idea was to create a hit object that collides with the obj player during a specific attack. (This part is done.)

    Then, it would check if the player has the proper conditions to be finished (one round lost and 20 or less hp), only in this case it would damage the player and trigger a cutscene (I was thinking about using the draw GUI event to set the sprites of the cutscene).

    I have set some variables:

    Loss: to assign the number of rounds lost

    And then a global variable called “vulnerable” that would be true in the case of 1 round lost and 20 or less hp.

    And finally a variable called “finisher” to be used on the draw GUI, that, if true, would cause the cutscene to be drawn.

    But I´m having trouble with the coding, since nothing I tried was able to trigger the “vulnerable” condition.

    Alternatively, I was thinking about doing this as an state.

    I would appreciate if someone could help me with that.

    Thanks!
     
  2. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,018
    I wouldn't worry about any of those variables.

    so is your game based around number of losses, or is it based around number of wins? In some fighting games, it doesn't matter if you have two losses, if the other player also has two losses, it goes to a tiebreaker. another important distinction is are you giving a Lost icon to the player that loses a fight, or are you giving a win icon to the player that wins the fight? If you are already giving the winning player a win, then there's no point in taking count of losses.

    You don't need to tell the game if a player is vulnerable. All you need to do is check if the fighter dealing the damage has one or more wins than the other fighter, and if that attack is going to deal as much or more damage than the victims current health.
     
  3. Abaddon_Ascidhiz

    Abaddon_Ascidhiz Member

    Joined:
    Sep 11, 2019
    Posts:
    7
    Thanks for replying.

    I´m using the win system. When a player has 2 wins, the fight ends and the player goes to the next opponent or back to the character select screen (in 2 players mode).
    As for the cutscene, it will work like a mortal kombat "fatality", so, if a player has one round win, during the second round (or the third), when the opponent´s health is low, he can perform a move, that, if hit, will trigger the cutscene, or he can choose to not finish the opponent, just using other moves, that will do a simple ko and end the fight.
    Maybe it was not my best choice, but the finishing move can be performed any moment by pressing a button, that is the reason I need something to make the collision works only when the opponent is with low health.
     
  4. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,018
    Got it.

    So then did you make sure your issue wasn't you had a single global.vulnerable shared by both fighters? And did you make sure since each fighter should have its own vulnerable variable that you were looking at the correct one each time? In other words, maybe P1's vulnerable was false and P2's was true, but you were trying to read P1's vulnerable instead. (Or if you're using the Debugger's WATCH tab, you need to specify the instance you're actually watching).

    You'd want to use states, not a GUI. P1's state would be normal (assuming he's the one going in for the kill, just as an example here) until actually doing the finishing move, in which case his state should be the performance of the finisher; while P2's state would be essentially a stun-lock state while the finisher is being performed.

    Personally, I wouldn't handle it as "is so-and-so vulnerable", but instead as "can I finish so-and-so?" In other words, have each player track their wins ("do I have more wins than him?") and health ("and does he have less than 20 hp?"). Personally, that would be a lot easier to handle in my opinion.
     
  5. Abaddon_Ascidhiz

    Abaddon_Ascidhiz Member

    Joined:
    Sep 11, 2019
    Posts:
    7
    I followed your advice and created a state, and it worked. Now the hit is only performed when the player has 1 win and the enemy has less than 20 hp.
    Now, probably I will add the animation of the finisher as an effect of the collision.

    Thanks very much!
     
  6. Abaddon_Ascidhiz

    Abaddon_Ascidhiz Member

    Joined:
    Sep 11, 2019
    Posts:
    7
    Ok, here I am again.

    I figured that maybe the best way for calling the cutscene is creating an object to do this work. But I´m having difficulty coding the script to set the correct sprites to be drawn.

    I have a switch script to handle the player´s sprites:

    Switch (argument0):

    Case CHAR_X:

    Sp_idle = spr_char_x_idle... etc...



    But for the cutscene its not enough (since its not the player sprite that is changing), and since it must take in consideration not only the player that is the source of the collision object, but also the player being hit.

    So, I believe it should be something like:

    Switch (argument0):

    if owner == CHAR_X and opponent == CHAR_Y:

    Sp_finisher = spr_char_X_finisher1


    if owner == CHAR_X and opponent == CHAR_Z

    sp_finisher = spr_char_X_finisher2



    But its not working (and very probably my code above is wrong)

    Can someone elucide me about how to code such kind of script correctly?

    Thanks!
     
  7. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,018
    You should have your sprites organized so that every sprite for a particular character is together in the exact same order as every other character; or have every sprite for a particular action together in the same order as every other action (e.g., CHAR_X's punch sprite, then CHAR_Y's punch sprite, then CHAR_Z's punch sprite). Unfortunately in a fighting game neither of these may be easily valid. Sure, everyone has an idle, a jump, a step, a normal punch, normal kick, maybe a taunt, a duck, a high block, a low block, a knockout sprite; but then you have all the special sprites and some characters might even have more actions than others. But the idea is then you could use enumerators for each state, create an array to hold every sprite for that character. So suppose you had an enumerator:

    enum states {
    idle,
    walk,
    jump,
    fall,
    duck,
    block_stand,
    block_duck
    punch1_stand,
    punch1_duck,
    punch1_jump,
    punch2_stand,
    punch2_duck,
    punch2_jump,
    kick1_stand,
    kick1_duck,
    kick1_jump,
    kick2_stand,
    kick2_duck,
    kick2_jump,
    wounded,
    knockout
    }

    You could then fill an array of all the sprites to use for each character.

    sprites[CHAR_X,states.idle] = spr_char_x_idle;

    That way you don't need a conditional to check what character either player is, just pass that variable holding the player's character into the array to get any sprite associated with that character.
     
  8. Abaddon_Ascidhiz

    Abaddon_Ascidhiz Member

    Joined:
    Sep 11, 2019
    Posts:
    7
    That is what I did for the characters. But now I need to do something like that for the sprites of the object that will play the cutscenes, for example:
    if player1 == character_x and opponent == character_y
    sp_cutscene(of the object_cutscene) = spr_cutscene1

    if player1 == character_x and opponent == character_z
    sp_cutscene = spr_cutscene2

    So the sprite drawn by the object cutscene will be drawn according to the players causing the collision. In this case, I´m not changing the players sprite, but trying to draw a GUI that will cover the screen with a cinematic. I can do that if I assign a specific sprite to the object_cutscnene, but the problem is that this object`s sprite must change according to the players involved.
     
  9. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,018
    You need to store the selected characters for each player and a pair of variables. Then use those two variables to index the array of all the sprites. Make another array (or other data structure) sequencing each character's cutscene. You'd need to store state/action index, timer for how long the action should go on.

    I still think you should be using the players themselves, not a GUI overlay.
     
  10. Abaddon_Ascidhiz

    Abaddon_Ascidhiz Member

    Joined:
    Sep 11, 2019
    Posts:
    7
    Well, initially my idea was to use the players, but then, for aesthetic purposes, I decided for the GUI (so the finishers can be shown in the style of the more recent "Mortal Kombat" games).
    But, anyway, it worked!

    Thanks for the help!
     

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