Unit HP speed

djb4cc1o94

TH.net Regular
Reaction score
5
Was thinking about a thing,when hero is full hp he is 100% his normal speed when his hp is 90% he is 1% slower when 80% hp 2% slower etc... how could i do that? with triggers,obviously.

Idea from "Left 4 Dead" wich less is your hp less is your speed.
 

Tawnttoo

New Member
Reaction score
36
This oughta do it. You can tweak the numbers to your liking.

Trigger:
  • HP Speed
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Unit - Your Unit movement speed to ((Default movement speed of Your Unit) x (1.00 - ((100.00 - (Percentage life of Your Unit)) / 100.00)))
 

tommerbob

Minecraft. :D
Reaction score
110
Wouldn't he run into problems if a unit picks up boots or something else that increases his move speed?
 

Tawnttoo

New Member
Reaction score
36
I'm not sure whether or not boots affect "default movement speed". The movement speed can of course be stored into a variable.
 

djb4cc1o94

TH.net Regular
Reaction score
5
Does the speed get back to normally if i heal to 100% hp?I will test if it gives some problems and let you know.
Speed doesnt even change

Trigger:
  • HP Speed
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Unit - Set (Picked unit) movement speed to ((Default movement speed of (Picked unit)) x (100.00 - ((Percentage life of (Picked unit)) / 100.00)))


I think picked unit wrong so i've tried with a selected unit and it has just changed his speed to maximum speed -.-
Even if he loses hp speed doesnt change.I think this method is weak.Need a better one
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
If you don't have a Pick Every Unit action, how would there be a Picked Unit?

Anyway, the action should be this:
Trigger:
  • Unit - Set (YourUnit) movement speed to ((Default movement speed of (YourUnit)) x ((Percentage life of (YourUnit)) / 100.00))


The way you're doing it, if the unit was at 50% health, the speed would be set to 99.5%.
 

inevit4ble

Well-Known Member
Reaction score
38
The correct formula is:
(Current Movement Speed) x (1.00 - ((100 - (Percentage of HP))/1000.00)

That way at 90% Hp Movement Speed will be reduce by 1% ; 85% > 1.5% etc
 

inevit4ble

Well-Known Member
Reaction score
38
My Version of the trigger:
Trigger:
  • HP Movement Speed
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Set MyPlayerGroup = (All players controlled by a User player)
      • Player Group - Pick every player in MyPlayerGroup and do (Actions)
        • Loop - Actions
          • Set MyUnitGroup = (Units owned by (Picked player) matching (((Picked player) controller) Equal to User))
          • Unit Group - Pick every unit in MyUnitGroup and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Percentage life of (Picked unit)) Less than or equal to 98.00
                • Then - Actions
                  • Set TempMovementSpeed = (Current movement speed of (Picked unit))
                  • Unit - Set (Picked unit) movement speed to (TempMovementSpeed x (1.00 - ((100.00 - (Percentage life of (Picked unit))) / 1000.00)))
                  • Set HP_Affected[(Player number of (Picked player))] = True
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Percentage life of (Picked unit)) Greater than or equal to 99.00
                  • HP_Affected[(Player number of (Picked player))] Equal to True
                • Then - Actions
                  • Unit - Set (Picked unit) movement speed to (Default movement speed of (Picked unit))
                  • Set HP_Affected[(Player number of (Picked player))] = False
                  • Set MyUnit = (Picked unit)
                  • Trigger - Run HP MS Reset <gen> (ignoring conditions)
                • Else - Actions
      • Custom script: call DestroyForce(udg_MyPlayerGroup)
      • Custom script: call DestroyGroup(udg_MyUnitGroup)

And this one is to reset item movement speed gains
Trigger:
  • HP MS Reset
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Drop the item from slot (Integer A) of MyUnit
          • Unit - Order MyUnit to Right-Click (Last dropped item)


Theoretically I feel this should work.
If anyone can offer comments to improve it, please advise.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
the trigger at the beginning should work if you arent using items that increase movement speed, or if you would like to you could remove the ability on the item and increase the default movement speed and save it as a variable for later use if needed
 

inevit4ble

Well-Known Member
Reaction score
38
His system uses items like boots of speed and stuff like that as well as armor that decreases speed
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top