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

How do I make a spell that deals full damage on a single target, put splits out all the damage equally with several targets?

Status
Not open for further replies.
Level 4
Joined
Nov 16, 2019
Messages
55
So to explain further:
I am making a boss, a large fire elemental. I want it to apply a debuff to a target, which will cause an explosion on the target after a while. The twist is, I want this explosion to deal x amount of damage when this target stands alone with no friendlies nearby, or y amount of damage to the target (as well as the target's allies) when allies stand nearby the target.

I guess the trigger would have to be an "if, then, else" action. But not sure of how to make the damage distribute to all friendly units within a certain range of the target with the debuff. If anyone has a smart setup for this, it would be very helpful.
 
Is the damage a set amount that will be evenly distributed amongst the units in range? Meaning max damage is, say 10000, and if there are 10 units (including the target with the debuff) all of them will take 1000 damage each, while if there are 5 they will take 2000 each and if there is just one it will take the full 10000 damage?

Should look something like this:

  • Units in Range
    • Events
      • Time - BuffTimer expires
    • Conditions
    • Actions
      • Set UnitCounter = 0.00
      • Set TempLoc[0] = (Position of BuffUnit)
      • Set TempGroup[0] = (Units within 1000.00 of TempLoc[0] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of BuffUnit)) Equal to True)))
      • Unit Group - Pick every unit in TempGroup[0] and do (Actions)
        • Loop - Actions
          • Set UnitCounter = (UnitCounter + 1.00)
          • Unit - Cause Boss to damage (Picked unit), dealing (BossDamage / UnitCounter) damage of attack type Spells and damage type Normal
      • Custom script: call RemoveLocation (udg_TempLoc[0])
      • Custom script: call DestroyGroup (udg_TempGroup[0])
 
Last edited:
Level 4
Joined
Nov 16, 2019
Messages
55
Is the damage a set amount that will be evenly distributed amongst the units in range? Meaning max damage is, say 10000, and if there are 10 units (including the target with the debuff) all of them will take 1000 damage each, while if there are 5 they will take 2000 each and if there is just one it will take the full 10000 damage?

Should look something like this:

  • Units in Range
    • Events
      • Time - BuffTimer expires
    • Conditions
    • Actions
      • Set UnitCounter = 0.00
      • Set TempLoc[0] = (Position of BuffUnit)
      • Set TempGroup[0] = (Units within 1000.00 of TempLoc[0] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of BuffUnit)) Equal to True)))
      • Unit Group - Pick every unit in TempGroup[0] and do (Actions)
        • Loop - Actions
          • Set UnitCounter = (UnitCounter + 1.00)
          • Unit - Cause Boss to damage (Picked unit), dealing (BossDamage / UnitCounter) damage of attack type Spells and damage type Normal
      • Custom script: call RemoveLocation (udg_TempLoc[0])
      • Custom script: call DestroyGroup (udg_TempGroup[0])
Exactly what I was looking for! Thank you so much!
 
Level 4
Joined
Nov 16, 2019
Messages
55
Is the damage a set amount that will be evenly distributed amongst the units in range? Meaning max damage is, say 10000, and if there are 10 units (including the target with the debuff) all of them will take 1000 damage each, while if there are 5 they will take 2000 each and if there is just one it will take the full 10000 damage?

Should look something like this:

  • Units in Range
    • Events
      • Time - BuffTimer expires
    • Conditions
    • Actions
      • Set UnitCounter = 0.00
      • Set TempLoc[0] = (Position of BuffUnit)
      • Set TempGroup[0] = (Units within 1000.00 of TempLoc[0] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of BuffUnit)) Equal to True)))
      • Unit Group - Pick every unit in TempGroup[0] and do (Actions)
        • Loop - Actions
          • Set UnitCounter = (UnitCounter + 1.00)
          • Unit - Cause Boss to damage (Picked unit), dealing (BossDamage / UnitCounter) damage of attack type Spells and damage type Normal
      • Custom script: call RemoveLocation (udg_TempLoc[0])
      • Custom script: call DestroyGroup (udg_TempGroup[0])
How do you make the BuffTimer for events? It's a variable, that I can see, but what type of variable do you use in this instance?
 
How do you make the BuffTimer for events? It's a variable, that I can see, but what type of variable do you use in this instance?
Well you'd need to start the timer somehow. Whenever you buff the unit you make an action to start the timer, and then when it expires you also remove the buff.

The example I made isn't complete, it just shows you how to do it. It's up to you to actually implement it into a working system in your map.

EDIT: The variable type of BuffTimer is a Timer variable.
 
Level 4
Joined
Nov 16, 2019
Messages
55
Well you'd need to start the timer somehow. Whenever you buff the unit you make an action to start the timer, and then when it expires you also remove the buff.

The example I made isn't complete, it just shows you how to do it. It's up to you to actually implement it into a working system in your map.
Yea I get that. But I am not sure of how you make the variable for the BuffTimer (I suck at variables, only just touched the tip of that iceberg recently). I'm guessing I need to make a trigger with a "A unit begins casting a spell" event, and set it to said spell being cast on the target. But how would I set up a variable that then comes into the picture of the trigger you made? There are so many types of variables that I still have yet to understand the use of.
 
I edited my post, it's a Timer variable and creating it is really simple.
Screenshot_1.png
 
Level 4
Joined
Nov 16, 2019
Messages
55
Okay, so I tried it out, I think I got the timer stuff right, but it doesn't run the "Mark Of Golraath Cast" trigger for some reason. Can you pinpoint what I've done wrong? I have a feeling it might be the GolraathLoc being in the other trigger, but I just didn't know how to classify the buffed target otherwise in the Mark Of Golraath Cast trigger.

1619712589533.png
 
Level 4
Joined
Nov 16, 2019
Messages
55
Use a unit starts the effect of an ability. Also you have to set GolraathLoc when the timer expires, before setting the TempGroup unit group, not when he casts the ability.
Okay, so I tried doing this:

1619713565376.png


It still isn't working.
I'm thinking it may be the position of unit for GolraathLoc? I just don't know what else to set it as other than "Target unit of ability being cast", even though I know this trigger isn't the one in which an ability is being cast.
 
You're setting GoraathLoc = Position of (Target unit of ability being cast)) when target unit of ability being cast = null since the event is not an ability event. You have to save the location of the point where the explosion is coming from. If the explosion comes from the buffed unit then you have to save the position of the buffed unit.
 
Level 4
Joined
Nov 16, 2019
Messages
55
You're setting GoraathLoc = Position of (Target unit of ability being cast)) when target unit of ability being cast = null since the event is not an ability event. You have to save the location of the point where the explosion is coming from. If the explosion comes from the buffed unit then you have to save the position of the buffed unit.
But how do I set the position to the buffed unit when the event of the trigger isn't a spell-cast? How do I specify the buffed unit so it can be used in the "Mark Of Golraath Cast" trigger?
 
There are multiple ways, but ideally it would be done in your Mark of Goliath timer trigger like so;

  • Mark of Goliath Timer
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Banish
    • Actions
      • Set BuffedUnit = (Target unit of ability being cast)
      • Countdown Timer - Start BuffTimer as a One-shot timer that will expire in 6.00 seconds
 
Level 25
Joined
Sep 26, 2009
Messages
2,381
Is the damage a set amount that will be evenly distributed amongst the units in range? Meaning max damage is, say 10000, and if there are 10 units (including the target with the debuff) all of them will take 1000 damage each, while if there are 5 they will take 2000 each and if there is just one it will take the full 10000 damage?

Should look something like this:

  • Units in Range
    • Events
      • Time - BuffTimer expires
    • Conditions
    • Actions
      • Set UnitCounter = 0.00
      • Set TempLoc[0] = (Position of BuffUnit)
      • Set TempGroup[0] = (Units within 1000.00 of TempLoc[0] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an ally of (Owner of BuffUnit)) Equal to True)))
      • Unit Group - Pick every unit in TempGroup[0] and do (Actions)
        • Loop - Actions
          • Set UnitCounter = (UnitCounter + 1.00)
          • Unit - Cause Boss to damage (Picked unit), dealing (BossDamage / UnitCounter) damage of attack type Spells and damage type Normal
      • Custom script: call RemoveLocation (udg_TempLoc[0])
      • Custom script: call DestroyGroup (udg_TempGroup[0])
Wait, am I missing something? The trigger won't do 10.000 damage split evenly, since the UnitCounter is incremented inside the loop.
So looking at the trigger and assuming the spell should deal 10.000 damage and there are 5 units (one which is exploding and 4 allies), then the t rigger will damage units like this:
  • One unit takes 10.000 damage
  • Second unit takes 5.000 dmg
  • Third unit takes 3.333 dmg
  • Fourth unit takes 2.500 dmg
  • Fifth unit takes 2.000 dmg
  • Total: 22.833 dmg

I think the trigger should actually be like this:
  • Set VariableSet UnitCount = (Number of units in TempGroup[0])
  • Unit Group - Pick every unit in TempGroup[0] and do (Actions)
    • Loop - Actions
      • Unit - Cause Boss to damage (Picked unit), dealing (BossDamage / Real(UnitCount)) damage of attack type Spells and damage type Normal
 
Wait, am I missing something? The trigger won't do 10.000 damage split evenly, since the UnitCounter is incremented inside the loop.
So looking at the trigger and assuming the spell should deal 10.000 damage and there are 5 units (one which is exploding and 4 allies), then the t rigger will damage units like this:
  • One unit takes 10.000 damage
  • Second unit takes 5.000 dmg
  • Third unit takes 3.333 dmg
  • Fourth unit takes 2.500 dmg
  • Fifth unit takes 2.000 dmg
  • Total: 22.833 dmg

I think the trigger should actually be like this:
  • Set VariableSet UnitCount = (Number of units in TempGroup[0])
  • Unit Group - Pick every unit in TempGroup[0] and do (Actions)
    • Loop - Actions
      • Unit - Cause Boss to damage (Picked unit), dealing (BossDamage / Real(UnitCount)) damage of attack type Spells and damage type Normal
You're right, good catch.
 
Level 4
Joined
Nov 16, 2019
Messages
55
Wait, am I missing something? The trigger won't do 10.000 damage split evenly, since the UnitCounter is incremented inside the loop.
So looking at the trigger and assuming the spell should deal 10.000 damage and there are 5 units (one which is exploding and 4 allies), then the t rigger will damage units like this:
  • One unit takes 10.000 damage
  • Second unit takes 5.000 dmg
  • Third unit takes 3.333 dmg
  • Fourth unit takes 2.500 dmg
  • Fifth unit takes 2.000 dmg
  • Total: 22.833 dmg

I think the trigger should actually be like this:
  • Set VariableSet UnitCount = (Number of units in TempGroup[0])
  • Unit Group - Pick every unit in TempGroup[0] and do (Actions)
    • Loop - Actions
      • Unit - Cause Boss to damage (Picked unit), dealing (BossDamage / Real(UnitCount)) damage of attack type Spells and damage type Normal
Ah! Thank you! Will get that fixed immediately :thumbs_up:
 
Level 4
Joined
Nov 16, 2019
Messages
55
Wait, am I missing something? The trigger won't do 10.000 damage split evenly, since the UnitCounter is incremented inside the loop.
So looking at the trigger and assuming the spell should deal 10.000 damage and there are 5 units (one which is exploding and 4 allies), then the t rigger will damage units like this:
  • One unit takes 10.000 damage
  • Second unit takes 5.000 dmg
  • Third unit takes 3.333 dmg
  • Fourth unit takes 2.500 dmg
  • Fifth unit takes 2.000 dmg
  • Total: 22.833 dmg

I think the trigger should actually be like this:
  • Set VariableSet UnitCount = (Number of units in TempGroup[0])
  • Unit Group - Pick every unit in TempGroup[0] and do (Actions)
    • Loop - Actions
      • Unit - Cause Boss to damage (Picked unit), dealing (BossDamage / Real(UnitCount)) damage of attack type Spells and damage type Normal

Had to come back here, because I cannot make the variable work. Is the "UnitCount" variable a "real" in your function @Nichilus ? And if so, how did you make it equal to the number of units within a unit-group? Because I've tried, and I can't find any function that sets a "real" equal to the unit-count within a unit-group.
 
Status
Not open for further replies.
Top