• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Combo System

Status
Not open for further replies.
Level 19
Joined
Apr 21, 2013
Messages
1,194
Okay guys, here's another question,

How can I implement a combo system.

I have three quick combos and three heavy combos.


The unit quick attacks if pressed 'Q' and heavy attacks when pressed 'E'.

So the question here is; I want the unit to attack only seperate attacks if the buttons are not pressed fast enough.

For example: Q...Q...Q...Q...

if the player hits fast enough it will turn into a combo.

Ex: Q.Q.Q ( A three hit combo repeats if continues to hit Q fastly)

If the player stops hitting Q or the character runs out of stamina the combo will be broken where it is left.

But I have combos in my mind with different animations for each combo, here's a list for now, if any way can be found or exists I may add more:

Quick Combos
Q.Q.Q

Q.Q.E

Q.E.Q

Heavy Combos:
E.E.E

E.E.Q

E.Q.E


Another note here is; I dont want the player to spam buttons and deal the damage without animation. I want the animation to be finished first to get to the next hit. And the attacks will be open to blocks or can be distrupted by another attack from another unit.(taking damage)
 
Basicly you can imagine a sequence of AbilityIds (integers). For example "Q" "Q" "Q".

When ever the unit uses ability Q we start the sequence for the unit and also a timer.
The unit Sequence looks like this now: "Q"

When the unit uses Q again we go in add a step of the sequence.
The unit Sequence looks like this now: "Q" , "Q"

When the unit's sequence becomes: "Q" , "Q" , "Q" .. you will do your combo.

But at same time when the unit uses "E", while it is at the "Q" sequence then the sequence gets destroyed.
And the sequence will also be destroyed when the timer is elapsed.
(After each cast you need to reset the timer)

Now you need to create sequences for all your combos, and have to watch to destroy them properly if a combo sequence gets "broken".

I think this is basicly the theroy.

Do you know JASS. If yes, this might help as idea:
I created a ArrowKey Sequence system.
The same idea can be used for all integers, not only for Arrow Keys.
 
Level 19
Joined
Apr 21, 2013
Messages
1,194
Nice explanation and thanks I've made it with the help of your explanation. But there's one problem, if i press the Q button within the time gap of 1 seconds, it jumps to the next step of the combo and only the last move is played.

What I want is a system where I can push as fast as I can but the game should ignore everything I press when the attack animation is played, then take account of the new Q I press, and so on.

I'll put the code here too, I didn't want to post code on the world edit zone, feel free to move it to triggers part.

Unfortunately, I dont know Jass, but I bookmarked your page I'll read it detailed when I have more time. I may learn Jass on summer tho.

  • Combo1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Quick Attack
    • Actions
      • Set combo1Counter = (combo1Counter + 1)
      • Wait 0.00 seconds
      • Set attack1Caster = (Triggering unit)
      • -------- IF FIRST ATTACK --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • combo1Counter Equal to 1
        • Then - Actions
          • Custom script: call SetUnitAnimationByIndex(udg_attack1Caster, 78)
          • Trigger - Run Combo1 Timer QQQ <gen> (ignoring conditions)
        • Else - Actions
      • -------- IF SECOND ATTACK --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • combo1Counter Equal to 2
              • (Remaining time for combo1Timer) Greater than 0.00
        • Then - Actions
          • Custom script: call SetUnitAnimationByIndex(udg_attack1Caster, 79)
          • Trigger - Run Combo1 Timer QQQ <gen> (ignoring conditions)
        • Else - Actions
      • -------- IF THIRD ATTACK --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • combo1Counter Equal to 3
              • (Remaining time for combo1Timer) Greater than 0.00
        • Then - Actions
          • Custom script: call SetUnitAnimationByIndex(udg_attack1Caster, 77)
          • Set combo1Counter = 1
        • Else - Actions
      • Set caster1Loc = (Position of attack1Caster)
      • Set attack1Target = (caster1Loc offset by 55.00 towards (Facing of attack1Caster) degrees)
      • Unit Group - Pick every unit in (Units within 125.00 of attack1Target) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked unit) Equal to attack1Caster
            • Then - Actions
            • Else - Actions
              • Unit - Cause attack1Caster to damage (Picked unit), dealing 55.00 damage of attack type Normal and damage type Normal
      • Custom script: call RemoveLocation(udg_caster1Loc)
      • Custom script: call RemoveLocation(udg_attack1Target)
  • Combo1 Timer QQQ
    • Events
    • Conditions
    • Actions
      • Countdown Timer - Start combo1Timer as a One-shot timer that will expire in 1.00 seconds
  • If Combo1Timer Runs Out
    • Events
      • Time - combo1Timer expires
    • Conditions
    • Actions
      • Set combo1Counter = 0

EDIT: I just added a 0.6 second cooldown for attack so spamming won't affect the animations. It is working almost flawless now yay!
Now to work on other combos!
 
Level 19
Joined
Apr 21, 2013
Messages
1,194
I found how to do the coding for different types mixed in too. It needed a better solution than this previous attempt.

I dont have time right now but ill do it tomorrow. Every combo needs a counter and then it is just a matter of checking the pressed button in the combo time gap. Else it is just a new combo starting attack.

The new mountain to climb for me will be the breaking combos with enemies and parries :(

And i just noticed i reset the counter with a wrong number after the last move of combo. Thanks for pointing it out :)

If i remove the wait, the custom animations do not play as i want it to be. Idk why or how but it works :p


Edit: i wrote the pseudo code on paper, i will try them on editor. And if i succeed ill post it in resources section. Then once i implement the stagger, parry, defend systems it'll be on hive's resources if accepted!!
 
Last edited:
Status
Not open for further replies.
Top