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

Increase damage for each enemy?

Status
Not open for further replies.
Level 7
Joined
Oct 6, 2022
Messages
135
How to increase attack damage for each enemy on the field with a maximum of 15 enemy units on the field?
Hope you guys could help me, thanks in advance
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
The basic idea would be to track the unit that should have its damage increased in a variable and have a trigger that periodically (i.e. every 1 sec) checks number of nearby living non-structure enemies.
Store the unit count in an integer variable and check if the count is higher than 15 - if yes, just update the number to 15.
Finally, create an ability with 16 levels (with first level giving no bonus damage), give the ability to the unit in object editor and in trigger set the level of that ability for your unit to 1 + the count you stored in other variable.
Something like this

  • Untitled Trigger 001
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet your_unitLoc = (Position of your_unit)
      • Custom script: set bj_wantDestroyGroup = true
      • Set VariableSet unitCount = (Number of units in (Units within 512.00 of your_unitLoc matching ((((Matching unit) belongs to an enemy of (Owner of your_unit).) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) is A structure) Equal to False))).))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • unitCount Greater than 15
        • Then - Actions
          • Set VariableSet unitCount = 15
        • Else - Actions
      • Unit - Set level of damageBonusAbility for your_unit to (1 + unitCount)
      • Custom script: call RemoveLocation(udg_your_unitLoc)

The trigger complexity can vary depending on whether this damage increase passive is used by only a single unit in the entire map (this is the least complex and is what I showed in the trigger above) or single unit per player or any number of units per player.
As for the ability itself, if you just need a flat damage increase then you can use the "Item Damage Bonus" item ability (used by claws of attack).
If you want a percentage increase, then that becomes a bit more complicated. You could use the "Inner Fire" spell (and have a dummy unit cast it on your unit) but the disadvantage is that it can be dispelled/spell stolen.
Another option would be to use an aura type spell like War Drums that is set up to only benefit the caster - but the disadvantage is that auras do not update their effects immediately (it takes about 1 second on average for an aura effect to update).
I think you can on latest version also update unit's damage via triggers, but I would avoid that option when calculating percentage bonuses.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,570
@BigMacNCheese
In the future please provide more information in your post, it's vague and we can only assume so much. Remember that there is hardly ever one single solution to a problem because everything depends on how your map works and how you want said thing to work. Your map could be a recreation of Pong for all we know, a lot is possible in Warcraft 3 modding.

Anyway, I assume Nichilus answered your question, but here are some questions that come to mind when I read your post:

Is what you're describing an Ability? Will multiple units have this ability/effect? You say "on the field", does this mean that it's a global ability/effect? Or does it act like an Aura that finds nearby units within it's Area of Effect? Is there ability scaling per level? Is it a Hero ability? What version of Warcraft 3 are you using? Flat attack damage, percentage attack damage?

The more information you give us the better the solution we can provide. Also, you may wind up with something even better than you originally asked for since we can expand upon your idea. Thanks!
 
Status
Not open for further replies.
Top