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

Increase a units stats

Status
Not open for further replies.
Level 3
Joined
Apr 4, 2020
Messages
31
Hello,

im working on a summon spell, where the units that are spawned have stats based on the hero that summons then.

  • Unit Group - Pick every unit in CallToArms and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Real((Level of Captain Bonus for (Picked unit)))) Greater than or equal to 1.00
          • (CTA_Caster is alive) Equal to Wahr
        • Then - Actions
          • Unit - Set Base Damage of (Picked unit) to ((Base Damage of (Triggering unit) for weapon index 0) + (Integer(((Real((Strength of CTA_Caster (Include bonuses)))) x 0.50)))) for weapon index: 0
          • Unit - Set Max HP of (Triggering unit) to (Integer(((Life of (Triggering unit)) + ((Real((Intelligence of CTA_Caster (Include bonuses)))) x 2.00))))
          • Unit - Set Armor of (Triggering unit) to ((Real((Integer(((Real((Agility of CTA_Caster (Exclude bonuses)))) x 0.01))))) + 3.00)
        • Else - Actions
Now the part with the max HP just sets the hp to the current units max hp and i'm not quite sure how i'm supposed to change that. I want the unit to have extra hp based on the INT of the casting hero. Is there a way to somehow add this?
 
Level 19
Joined
Feb 27, 2019
Messages
592
If you take a closer look at the trigger you might find the issue. Hint: Test the map and take a look at your triggering unit's hp and armor when it uses the summon spell.

Edit: Can you also post the entire trigger? There might be a bigger issue.
 
Level 3
Joined
Apr 4, 2020
Messages
31
I am aware that it doesn't work, but the question is how do i make it work?
Here is the rest of the trigger:
  • Call to Arms Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Call to Arms
    • Actions
      • Set VariableSet CTA_Caster = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Real((Level of Call to Arms for (Triggering unit)))) Equal to 1.00
        • Then - Actions
          • Unit - Create 2 Elite Soldier for (Owner of (Triggering unit)) at ((Position of (Triggering unit)) offset by 200.00 towards 0.00 degrees.) facing (Facing of CTA_Caster) degrees
          • Set VariableSet CallToArms = (Units within 250.00 of (Position of CTA_Caster) matching (((Unit-type of (Matching unit)) Equal to Elite Soldier) or (((Unit-type of (Matching unit)) Equal to Templar) or (((Unit-type of (Matching unit)) Equal to Captain) or ((Unit-type of (Matching unit)) E
          • Unit Group - Pick every unit in CallToArms and do (Actions)
            • Loop - Actions
              • Unit - Add Captain Bonus to (Picked unit)
              • Unit - Add a (15.00 + ((Real((Level of Call to Arms for CTA_Caster))) x 5.00)) second Generic expiration timer to (Picked unit)
              • Unit - Set level of Captain Bonus for (Picked unit) to 2
              • Trigger - Run Call to Arms Stats <gen> (ignoring conditions)
        • Else - Actions
The dmg part works as intended, the rest doesn't.
 
Level 19
Joined
Feb 27, 2019
Messages
592
To make it work you have to set max HP of (Picked unit) instead of (Triggering unit) and the same goes for the Armor. The (Triggering unit) is the unit in the event. The (Picked unit) is the unit that is currently picked in the group. When you pick a unit from a group it runs the loop actions for as many units in the group that are picked.

There are also a few efficiency changes you could do, prevent leaks and reduce the load on the game aswell as game-play changes to improve the trigger.

Efficiency:
A reason to set variables is so that the game doesnt have to figure out which data you want to use each time. Basically the game asks: Who is the triggering unit? every time its used. So setting it to a variable causes the game not having to ask. Instead of adding the created units to a group one could use a loop that is For each integer A from 1 to 2 do actions.

Leaks:
You leak several points, to prevent point leaks the points are set to a point variable and then removed with the custom script: "call RemoveLocation(udg_Your_Variable_Name)" without the ". This includes the offset. You also leak a unit group. You set the unit group correctly but the only add-on needed is to destroy the group when done with it using the custom script call DestroyGroup(udg_CallToArms) more on leaks here: Things That Leak

Game-play:
The units will not be treated as summoned units by the game. Perheaps you want it that way and then its all good.

Although why dont you do something like this (example):
  • Summon Spell
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Spirit Wolf (Level 1)
    • Actions
      • Unit - Set Max HP of (Summoned unit) to 500
EDIT: Do you want to continually change the summoned units max hp, damage and armor through a periodic event? Is that what Call to Arms Stats does?
 
Last edited:
Level 3
Joined
Apr 4, 2020
Messages
31
EDIT: Do you want to continually change the summoned units max hp, damage and armor through a periodic event? Is that what Call to Arms Stats does?

Yeah thats the plan. And that they dont count as summoned units is planned aswell.
Thanks for the info on what i did wrong :)
 
Status
Not open for further replies.
Top