• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Increase Attack Speed every # attacks

Status
Not open for further replies.
Level 12
Joined
May 20, 2009
Messages
822
I remember seeing a thread for this a while ago, but I can't seem to find it. But basically, what I want to do is:

A unit attacks a unit. That unit that is attacking gains % bonus attack speed every 2-3 attacks. If it stops attacking for a full 5 seconds, then it loses the bonuses.

Like Jax' passive in LoL.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
so basically you need 2 triggers. One with the event unit takes damage (DDS) and one with every 0.03 seconds.

In the unit takes damage trigger you count the attacks for each unit. When it reaches 2-3 you add it into a unit group.

in the loop trigger you pick every unit in that group and create an counter to keep track of the time before the effect wears off.

I'd suggest learning hashtables to pull this off.
 
Level 12
Joined
May 20, 2009
Messages
822
Could you explain a bit more in-depth? Because I'm having complications here.

And Hashtables will really only complex things more then they need to be.

Also, it needs to scale up after another 2-3 hits.

It'll be like,

It gets 3 hits off then it gets a 5% attack speed bonus.
It performs another 3 without stopping attacking for more then 5 seconds, then it gets a 10% attack speed bonus. (Not stacking, basically +5%)


EDIT: Okay so, I'm doing ANOTHER thing that'll be easier to script then this but is basically the same. So if I get this easier thing done, I could use it for this too. This is what I go so far:

  • Infernal First Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Attacking unit)) Equal to Infernal
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Attacking unit) is in InfernalUnitGroup) Equal to False
            • Then - Actions
              • Unit Group - Add (Attacking unit) to InfernalUnitGroup
              • Unit - Add Infernal Double Attack to (Attacking unit)
              • Set InfernalMaxIndex = (InfernalMaxIndex + 1)
              • Set InfernalAttackIndex[InfernalMaxIndex] = 1
              • Set InfernalUnit[InfernalMaxIndex] = (Attacking unit)
            • Else - Actions
        • Else - Actions
  • Infernal Attack Update
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • For each (Integer InfernalUpdateInit) from 1 to InfernalMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Attacking unit) Equal to InfernalUnit[InfernalUpdateInit]
              • ((Attacking unit) is in InfernalUnitGroup) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • InfernalAttackIndex[InfernalUpdateInit] Equal to 1
                • Then - Actions
                  • Set InfernalAttackIndex[InfernalUpdateInit] = 2
                • Else - Actions
            • Else - Actions
  • Infernal Attack Calc
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer InfernalInit) from 1 to InfernalMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • InfernalAttackIndex[InfernalUpdateInit] Equal to 2
            • Then - Actions
              • Unit Group - Remove InfernalUnit[InfernalInit] from InfernalUnitGroup
              • Unit - Add Infernal Double Attack to InfernalUnit[InfernalInit]
              • Set InfernalAttackIndex[InfernalInit] = InfernalAttackIndex[InfernalMaxIndex]
              • Set InfernalAttackIndex[InfernalMaxIndex] = 0
              • Set InfernalUnit[InfernalInit] = InfernalUnit[InfernalMaxIndex]
              • Set InfernalUnit[InfernalMaxIndex] = No unit
              • Set InfernalMaxIndex = (InfernalMaxIndex - 1)
            • Else - Actions
It doesn't work, but what this is suppose to do is basically when the Infernal Attacks, it gets an attack speed bonus that makes it's next attack come very quickly, then it's removed right after so it waits for it's normal attack cooldown.

Basically, the idea here is to make Multiple Attacks like Zealots in SC2. Zealots in SC2 do two attacks, one right after the other with a very small but still there delay, and then their actual attack cooldown kicks in.


Okay, so some stupidity on my part was part of the problem of this not working. However there was still a little bit that was needed for the trigger. Here are the changes:



  • Infernal First Attack
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of source) Equal to Infernal
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (source is in InfernalUnitGroup) Equal to False
            • Then - Actions
              • Game - Display to (All players) the text: FIRED!
              • Unit Group - Add source to InfernalUnitGroup
              • Unit - Add Infernal Double Attack to source
              • Set InfernalMaxIndex = (InfernalMaxIndex + 1)
              • Set InfernalAttackIndex[InfernalMaxIndex] = 1
              • Set InfernalUnit[InfernalMaxIndex] = source
            • Else - Actions
        • Else - Actions


  • Infernal Attack Update
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • For each (Integer InfernalUpdateInit) from 1 to InfernalMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • InfernalAttackIndex[InfernalUpdateInit] Equal to 1
              • InfernalAttackCooldown[InfernalUpdateInit] Equal to 33
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • source Equal to InfernalUnit[InfernalUpdateInit]
                  • (source is in InfernalUnitGroup) Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: FIRED!
                  • Set InfernalAttackIndex[InfernalUpdateInit] = 2
                • Else - Actions
            • Else - Actions


  • Infernal Attack Calc
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer InfernalInit) from 1 to InfernalMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • InfernalAttackIndex[InfernalInit] Equal to 1
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • InfernalAttackCooldown[InfernalInit] Less than 33
                • Then - Actions
                  • Set InfernalAttackCooldown[InfernalInit] = (InfernalAttackCooldown[InfernalInit] + 1)
                • Else - Actions
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • InfernalAttackCooldown[InfernalInit] Equal to 33
              • InfernalAttackIndex[InfernalInit] Equal to 1
            • Then - Actions
              • Unit Group - Remove InfernalUnit[InfernalInit] from InfernalUnitGroup
              • Unit - Remove Infernal Double Attack from InfernalUnit[InfernalInit]
              • Set InfernalAttackIndex[InfernalInit] = InfernalAttackIndex[InfernalMaxIndex]
              • Set InfernalAttackIndex[InfernalMaxIndex] = 0
              • Set InfernalAttackCooldown[InfernalInit] = InfernalAttackCooldown[InfernalMaxIndex]
              • Set InfernalUnit[InfernalInit] = InfernalUnit[InfernalMaxIndex]
              • Set InfernalAttackCooldown[InfernalMaxIndex] = 0
              • Set InfernalUnit[InfernalMaxIndex] = No unit
              • Set InfernalMaxIndex = (InfernalMaxIndex - 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • InfernalAttackIndex[InfernalInit] Equal to 2
            • Then - Actions
              • Unit Group - Remove InfernalUnit[InfernalInit] from InfernalUnitGroup
              • Unit - Remove Infernal Double Attack from InfernalUnit[InfernalInit]
              • Set InfernalAttackIndex[InfernalInit] = InfernalAttackIndex[InfernalMaxIndex]
              • Set InfernalAttackIndex[InfernalMaxIndex] = 0
              • Set InfernalAttackCooldown[InfernalInit] = InfernalAttackCooldown[InfernalMaxIndex]
              • Set InfernalAttackCooldown[InfernalMaxIndex] = 0
              • Set InfernalUnit[InfernalInit] = InfernalUnit[InfernalMaxIndex]
              • Set InfernalUnit[InfernalMaxIndex] = No unit
              • Set InfernalMaxIndex = (InfernalMaxIndex - 1)
            • Else - Actions



Anything else I need or will this do it? I'm not sure if this is 100% bug-proof.

The only thing I can see now is that if the Infernal doesn't do the second attack, something might not work properly but I'm not sure what. I just have that feeling it will.

EDIT: Okay, here's what this thread was originally meant for. I haven't tested it yet, but here is what I got so far for the "Berserker" ability, this is based off the Infernal one slightly:



  • Berserker First Attack
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of source) Equal to Burning Berserker
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (source is in BerserkerUnitGroup) Equal to False
            • Then - Actions
              • Game - Display to (All players) the text: FIRED!
              • Unit Group - Add source to BerserkerUnitGroup
              • Set BerserkerMaxIndex = (BerserkerMaxIndex + 1)
              • Set BerserkerUnit[BerserkerMaxIndex] = source
            • Else - Actions
        • Else - Actions


  • Berserker Attack Update
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • For each (Integer BerserkerUpdateInit) from 1 to BerserkerMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BerserkerAttCooldown[BerserkerUpdateInit] Less than 166
              • source Equal to BerserkerUnit[BerserkerUpdateInit]
              • (source is in BerserkerUnitGroup) Equal to True
            • Then - Actions
              • Set BerserkerAttCooldown[BerserkerUpdateInit] = 0
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BerserkerAttCooldown[BerserkerUpdateInit] Less than 166
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • source Equal to BerserkerUnit[BerserkerUpdateInit]
                  • (source is in BerserkerUnitGroup) Equal to True
                • Then - Actions
                  • Game - Display to (All players) the text: FIRED!
                  • Set BerserkerAttIndex[BerserkerUpdateInit] = (BerserkerAttIndex[BerserkerUpdateInit] + 1)
                • Else - Actions
            • Else - Actions


  • Berserker Attack Calc
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer BerserkerInit) from 1 to BerserkerMaxIndex, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BerserkerAttCooldown[BerserkerInit] Less than 166
            • Then - Actions
              • Set BerserkerAttCooldown[BerserkerInit] = (BerserkerAttCooldown[BerserkerInit] + 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BerserkerAttIndex[BerserkerInit] Equal to 2
            • Then - Actions
              • Unit - Set level of Berserker Attack Speed Bonus for BerserkerUnit[BerserkerInit] to 2
              • Unit - Set level of Berserker Move Speed Bonus for BerserkerUnit[BerserkerInit] to 2
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BerserkerAttIndex[BerserkerInit] Equal to 4
            • Then - Actions
              • Unit - Set level of Berserker Attack Speed Bonus for BerserkerUnit[BerserkerInit] to 3
              • Unit - Set level of Berserker Move Speed Bonus for BerserkerUnit[BerserkerInit] to 3
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BerserkerAttIndex[BerserkerInit] Equal to 6
            • Then - Actions
              • Unit - Set level of Berserker Attack Speed Bonus for BerserkerUnit[BerserkerInit] to 4
              • Unit - Set level of Berserker Move Speed Bonus for BerserkerUnit[BerserkerInit] to 4
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BerserkerAttIndex[BerserkerInit] Equal to 8
            • Then - Actions
              • Unit - Set level of Berserker Attack Speed Bonus for BerserkerUnit[BerserkerInit] to 5
              • Unit - Set level of Berserker Move Speed Bonus for BerserkerUnit[BerserkerInit] to 5
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BerserkerAttCooldown[BerserkerInit] Equal to 166
            • Then - Actions
              • Unit - Set level of Berserker Attack Speed Bonus for BerserkerUnit[BerserkerInit] to 1
              • Unit - Set level of Berserker Move Speed Bonus for BerserkerUnit[BerserkerInit] to 1
              • Unit Group - Remove BerserkerUnit[BerserkerInit] from BerserkerUnitGroup
              • Set BerserkerAttCooldown[BerserkerInit] = BerserkerAttCooldown[BerserkerMaxIndex]
              • Set BerserkerAttCooldown[BerserkerMaxIndex] = 0
              • Set BerserkerAttIndex[BerserkerInit] = BerserkerAttIndex[BerserkerMaxIndex]
              • Set BerserkerAttIndex[BerserkerMaxIndex] = 0
              • Set BerserkerUnit[BerserkerInit] = BerserkerUnit[BerserkerMaxIndex]
              • Set BerserkerUnit[BerserkerMaxIndex] = No unit
              • Set BerserkerMaxIndex = (BerserkerMaxIndex - 1)
            • Else - Actions

 
Last edited:
I've made such ability for HeroContest #4. Basically what I did was adding hidden ability (actual movement speed bonus) with certain amount of levels available.
Now, with any DDS (damage detection system) you can retrieve proper damage-event and add a damage handler. With such, I was checking if the target is the same as unit my hero was previously attacking - if so, level of ability has been raised - if not, it has been decreased.

After each damage-event I have been re-starting timer to make sure that when unit is idle (doesn't attack anyone) the bonus will be reseted.
 
Status
Not open for further replies.
Top