• 🏆 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!

Deal damage after 3rd attack

Status
Not open for further replies.
Level 2
Joined
Mar 1, 2020
Messages
22
I want create a passive spell like title.
Every 3rd attack, hero will cause more damage to target. I dont know how to count the number of attack. So... Thank for your help (and sorry for my bad english XD)
 
Level 2
Joined
Mar 5, 2020
Messages
10
Hey Norris,
I think you can create a variable called : NumberOfAttack and increments it each time your hero is doing an attack.
Like this :

upload_2020-3-9_11-21-17.png


There is not event : A unit is attacking, so you have to use "a unit is attacked".

In order :
- Create an integer variable and set it initial value to 0
- Create the trigger where the event detected is : "A unit is attacked" in Unit
- Set your condition to the attacker equals your Hero
- Increment the NumberOfAttack in Action
- Create a If/then/else
- Add condition : Every X attack
- In unit, select the action you want. You can use a buff and remove it, deal specific damages with the amount you want
- Reset NumberOfAttack if it reaches 3
 
Last edited:
Level 2
Joined
Mar 1, 2020
Messages
22
Hey Norris,
I think you can create a variable called : NumberOfAttack and increments it each time your hero is doing an attack.
Like this :

View attachment 349120

There is not event : A unit is attacking, so you have to use "a unit is attacked".

In order :
- Create an integer variable and set it initial value to 0
- Create the trigger where the event detected is : "A unit is attacked" in Unit
- Set your condition to the attacker equals your Hero
- Increment the NumberOfAttack in Action
- Create a If/then/else
- Add condition : Every X attack
- In unit, select the action you want. You can use a buff and remove it, deal specific damages with the amount you want
- Reset NumberOfAttack if it reaches 3

Very detailed and easy to understand. Thank you
 
Hey Norris,
I think you can create a variable called : NumberOfAttack and increments it each time your hero is doing an attack.
Like this :

View attachment 349120

There is not event : A unit is attacking, so you have to use "a unit is attacked".

In order :
- Create an integer variable and set it initial value to 0
- Create the trigger where the event detected is : "A unit is attacked" in Unit
- Set your condition to the attacker equals your Hero
- Increment the NumberOfAttack in Action
- Create a If/then/else
- Add condition : Every X attack
- In unit, select the action you want. You can use a buff and remove it, deal specific damages with the amount you want
- Reset NumberOfAttack if it reaches 3

This have two mistakes, first of all use Damage Engine by Bribe, with "Unit is attacked" the trigger will still fire regardless if the unit attacked or the attack command has been canceled by the attacker.

Here's a multi unit version, this utilize UnitIndexer and DamageEngine both made by Bribe. Test map included.


  • Attack Counter
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Set AT_DamageSourceID = (Custom value of DamageEventSource)
      • Set AT_DamageUnitNew[AT_DamageSourceID] = DamageEventSource
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AT_DamageUnitNew[AT_DamageSourceID] Equal to AT_DamageUnitPrev[AT_DamageSourceID]
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AT_Counter[AT_DamageSourceID] Greater than or equal to 2
            • Then - Actions
              • Set DamageEventAmount = (DamageEventAmount x 25.00)
              • Set AT_Counter[AT_DamageSourceID] = 0
            • Else - Actions
              • Set AT_Counter[AT_DamageSourceID] = (AT_Counter[AT_DamageSourceID] + 1)
        • Else - Actions
          • Set AT_Counter[AT_DamageSourceID] = 1
      • Game - Display to (All players) the text: (String(AT_Counter[AT_DamageSourceID]))
      • Set AT_DamageUnitPrev[AT_DamageSourceID] = DamageEventSource
This is tested and working properly.

Notes:
- Change the 25.00 to 3.00 since you want it to deal three times the damage every third attack

If you want the counter to reset every time the source unit changes the target unit you can just switch

  • AT_DamageUnitNew[AT_DamageSourceID] = DamageEventSource
and
  • AT_DamageUnitPrev[AT_DamageSourceID] = DamageEventSource
to

  • AT_DamageUnitNew[AT_DamageSourceID] = DamageEventTarget
and
  • AT_DamageUnitPrev[AT_DamageSourceID] = DamageEventTarget

Edit:
I realized the trigger 'Attack Init' isn't necessary at all, just remove/ignore this trigger. I removed it at v4.

  • Attack Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 8196, do (Actions)
        • Loop - Actions
          • Set AT_Counter[(Integer A)] = 1
 

Attachments

  • Attack Counter (DE) v3.w3x
    43.3 KB · Views: 23
  • Attack Counter (DE) v4.w3x
    43 KB · Views: 26
Last edited:
Level 2
Joined
Mar 1, 2020
Messages
22
This have two mistakes, first of all use Damage Engine by Bribe, with "Unit is attacked" the trigger will still fire regardless if the unit attacked or the attack command has been canceled by the attacker.

Here's a multi unit version, this utilize UnitIndexer and DamageEngine both made by Bribe. Test map included.

  • Attack Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 8196, do (Actions)
        • Loop - Actions
          • Set AT_Counter[(Integer A)] = 1
  • Attack Counter
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Set AT_DamageSourceID = (Custom value of DamageEventSource)
      • Set AT_DamageUnitNew[AT_DamageSourceID] = DamageEventSource
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • AT_DamageUnitNew[AT_DamageSourceID] Equal to AT_DamageUnitPrev[AT_DamageSourceID]
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • AT_Counter[AT_DamageSourceID] Greater than or equal to 2
            • Then - Actions
              • Set DamageEventAmount = (DamageEventAmount x 25.00)
              • Set AT_Counter[AT_DamageSourceID] = 0
            • Else - Actions
              • Set AT_Counter[AT_DamageSourceID] = (AT_Counter[AT_DamageSourceID] + 1)
        • Else - Actions
          • Set AT_Counter[AT_DamageSourceID] = 1
      • Game - Display to (All players) the text: (String(AT_Counter[AT_DamageSourceID]))
      • Set AT_DamageUnitPrev[AT_DamageSourceID] = DamageEventSource
This is tested and working properly.

Notes:
- Change the 25.00 to 3.00 since you want it to deal three times the damage every third attack

If you want the counter to reset every time the source unit changes the target unit you can just switch

  • AT_DamageUnitNew[AT_DamageSourceID] = DamageEventSource
and
  • AT_DamageUnitPrev[AT_DamageSourceID] = DamageEventSource
to

  • AT_DamageUnitNew[AT_DamageSourceID] = DamageEventTarget
and
  • AT_DamageUnitPrev[AT_DamageSourceID] = DamageEventTarget

I don't think it will be that complicated XD. I will try this one. Thanks everyone
 
Level 2
Joined
Mar 1, 2020
Messages
22
You can just spam interrupt to deal huge amounts of damage with the first solution. There might be other issues with small interrupt intervals (for example when "moving" a unit with triggers). I'd highly recommend you to use Strydhaizers solution
Yes. In sh4d's trigger, looks like the damage was caused before the projectile touched the target. I don't know why ^^
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
"A unit is attacked" happens before a unit takes damage, therefore a player can exploit this. It's similar to how the Event "A unit begins casting an ability" works, as that can be canceled (issue a "stop" order in response) and the trigger will still go off despite the fact that the ability was never used.

These two Events are the biggest traps for newcomers when it comes to mapmaking. The solution to "A unit is attacked" is a Damage Engine like the others have said, which is a system you can import into your map that once mastered will open up a lot of possibilities in regards to manipulating damage. The solution to "A unit begins casting an ability" is to use the "A unit starts the effect of an ability" Event instead, as this one runs when the ability would go on cooldown/spend mana.
 
Status
Not open for further replies.
Top