• 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.

Change stats of a Unit-Type befor they exist

Status
Not open for further replies.
Level 2
Joined
Jul 21, 2020
Messages
14
Is it possible to change the
- Hit Points Maximum
- Defense Base
- Attack Base
of a Unit-Type bevor they exist?

I want to calculate the HP, Defense and Attack and than set it to the Unit-Type. So if they spawn, they have the new HP, Attack and Defence.
If i want to change the difficulty of the map, i can easy change the number of the calculation and dont need to change the HP of every single Unit.

Code:
UnitStatsCalculation
    Events
        Map initialization
    Conditions
    Actions
        Set VariableSet UnitMathHealthFlatt = 80
        Set VariableSet UnitMathHealthMultiplicator = 4
        Set VariableSet UnitMathHealthMultiplier = 20
        Set VariableSet UnitHealth = ((UnitMathHealthMultiplier x ((WaveNo / UnitMathHealthMultiplicator) x (WaveNo / UnitMathHealthMultiplicator))) + UnitMathHealthFlatt)

and then something like this:

Unit - Set Max HP of "Unit-Type" to UnitHealth​

but this is not working with a Unit-Type, only with existing Units


(sorry for my bad english and i have no idea how to upload my trigger correctly)
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
How To Post Your Trigger

Why don't you just use Bear form or chaos ability instead ?

Anyway, if you want to set Max HP of a "Unit-Type" do this :

  • Max HP
    • Events
    • Conditions
    • Actions
      • Set VariableSet FootmanGroup = (Units of type Footman)
      • Unit Group - Pick every unit in FootmanGroup and do (Actions)
        • Loop - Actions
          • Unit - Set Max HP of (Picked unit) to UnitHealth
      • Custom script: call DestroyGroup (udg_FootmanGroup)
 
I don't think you can modify a unit template.
It is only possible for the ability templates, and most API functions are not functional in patch 1.32...

Best is to apply the stats modification in a trigger on event "Unit - a unit enters <entire map>" I think.. It is how I do it in my Xnd Hero Siege map, to set armor/life/damage/attack speed
 
Level 2
Joined
Jul 21, 2020
Messages
14
Thanks a lot guys, that helped me a lot.
For the Units they already existing on the map, too show witch wave is comming next, i´ve did this:
  • UnitStatsCalculation
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet UnitMathHealthFlatt = 80
      • Set VariableSet UnitMathHealthMultiplicator = 4
      • Set VariableSet UnitMathHealthMultiplier = 20
      • Set VariableSet UnitMathHealthBoss = 50
      • Trigger - Run UnitSet <gen> (checking conditions)
  • UnitSet
    • Events
    • Conditions
    • Actions
      • -------- Wave --------
      • Set VariableSet UnitTypeWave01 = Wolf
      • Set VariableSet UnitTypeWave02 = Goblin
      • Set VariableSet UnitTypeWave03 = Troll
      • -------- Start Trigger --------
      • Trigger - Run UnitStatsHealthMinions <gen> (checking conditions)
  • UnitStatsHealthMinions
    • Events
    • Conditions
    • Actions
      • Set VariableSet UnitMathInteger = 1
      • Set VariableSet UnitHealth = (((UnitMathHealthMultiplier x (((UnitMathInteger x 100) / UnitMathHealthMultiplicator) x ((UnitMathInteger x 100) / UnitMathHealthMultiplicator))) / 10000) + UnitMathHealthFlatt)
      • Set VariableSet UnitMathGroup = (Units of type UnitTypeWave01)
      • Unit Group - Pick every unit in UnitMathGroup and do (Unit - Set Max HP of (Picked unit) to UnitHealth)
      • Unit Group - Pick every unit in UnitMathGroup and do (Unit - Set life of (Picked unit) to 100.00%)
      • -------- ----------------------------------------------- --------
      • Set VariableSet UnitMathInteger = (UnitMathInteger + 1)
      • Set VariableSet UnitHealth = (((UnitMathHealthMultiplier x (((UnitMathInteger x 100) / UnitMathHealthMultiplicator) x ((UnitMathInteger x 100) / UnitMathHealthMultiplicator))) / 10000) + UnitMathHealthFlatt)
      • Set VariableSet UnitMathGroup = (Units of type UnitTypeWave02)
      • Unit Group - Pick every unit in UnitMathGroup and do (Unit - Set Max HP of (Picked unit) to UnitHealth)
      • Unit Group - Pick every unit in UnitMathGroup and do (Unit - Set life of (Picked unit) to 100.00%)
      • -------- ----------------------------------------------- --------
      • Set VariableSet UnitMathInteger = (UnitMathInteger + 1)
      • Set VariableSet UnitHealth = (((UnitMathHealthMultiplier x (((UnitMathInteger x 100) / UnitMathHealthMultiplicator) x ((UnitMathInteger x 100) / UnitMathHealthMultiplicator))) / 10000) + UnitMathHealthFlatt)
      • Set VariableSet UnitMathGroup = (Units of type UnitTypeWave03)
      • Unit Group - Pick every unit in UnitMathGroup and do (Unit - Set Max HP of (Picked unit) to UnitHealth)
      • Unit Group - Pick every unit in UnitMathGroup and do (Unit - Set life of (Picked unit) to 100.00%)
      • -------- ----------------------------------------------- --------
      • Set VariableSet UnitMathInteger = (UnitMathInteger + 1)

And for the Units they are spawning i´ve did this:
  • UnitStatsHealthWave
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 12 (Brown)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to UnitTypeWave01
        • Then - Actions
          • Set VariableSet UnitHealth = (((UnitMathHealthMultiplier x (((WaveNr x 100) / UnitMathHealthMultiplicator) x ((WaveNr x 100) / UnitMathHealthMultiplicator))) / 10000) + UnitMathHealthFlatt)
          • Unit - Set Max HP of (Triggering unit) to UnitHealth
          • Unit - Set life of (Triggering unit) to 100.00%
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to UnitTypeWave02
        • Then - Actions
          • Set VariableSet UnitHealth = (((UnitMathHealthMultiplier x (((WaveNr x 100) / UnitMathHealthMultiplicator) x ((WaveNr x 100) / UnitMathHealthMultiplicator))) / 10000) + UnitMathHealthFlatt)
          • Unit - Set Max HP of (Triggering unit) to UnitHealth
          • Unit - Set life of (Triggering unit) to 100.00%
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to UnitTypeWave03
        • Then - Actions
          • Set VariableSet UnitHealth = (((UnitMathHealthMultiplier x (((WaveNr x 100) / UnitMathHealthMultiplicator) x ((WaveNr x 100) / UnitMathHealthMultiplicator))) / 10000) + UnitMathHealthFlatt)
          • Unit - Set Max HP of (Triggering unit) to UnitHealth
          • Unit - Set life of (Triggering unit) to 100.00%
        • Else - Actions
 
Status
Not open for further replies.
Top