Hitpoints X seconds ago

FannyShaver

Well-Known Member
Reaction score
31
Trying to make a spell for one single hero only that when cast will set his hitpoints to hitpoints he had (5 seconds + (1 second x ability level)) ago. I pretty much have no clue how to start :D
 

meOme

New Member
Reaction score
31
You need two triggers: One to save your hitpoints of the last seconds for specific intervals, and one to restore your hitpoints.

here's one way to do it, but it only works if there really is just one single unit in the game with this ability. Otherwise you'd have to change it a bit.

Trigger:
  • start
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Unit_Hero = <Your Unit>

Trigger:
  • remember hp
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 99, do (Actions)
        • Loop - Actions
          • Set Real_Array_HP[(101 - (Integer A))] = Real_Array_HP[(100 - (Integer A))]
      • Set Real_Array_HP[1] = (Percentage life of Unit_Hero)

Trigger:
  • reset
    • Events
      • Unit - A unit Starts the Effect of an Ability
    • Conditions
      • (Ability being cast) Equal to Reset
    • Actions
      • Unit - Set life of Unit_Hero to Real_Array_HP[(10 x (4 + (Level of Reset for (Triggering unit))))]%
 

Arberden

Active Member
Reaction score
0
Basically, the first trigger records how much life that unit has every 0.1 seconds. Then the second trigger sets the units life to what it was recorded x seconds ago.
 

NoobImbaPro

You can change this now in User CP.
Reaction score
60
@Arberden
Dear man, we know that. This is what the poster asked.
@End

He complicated it too much. And made 100 actions per 0.1 seconds. But he is clever.

He made an array with 100 length, every 0.1 sec he passes the first value to the second, the second to third....the 99th to 100th.
So it passes every 0.1 seconds a value to the next array.
E.g half second has passed. Trigger runs 5 times. So hero's hp % is Real_Array_HP[1]=100%, Real_Array_HP[2]=97%, Real_Array_HP[3]=92%, Real_Array_HP[4]=80%, Real_Array_HP[5]=81% (some regen here :p).

100 * 0.1 = 10 seconds. So this trigger provides you up to 10 seconds hp% rollback.
So to rollback your hp you have to multiply the seconds you want by 10. e.g 3 seconds ago = Real_Array_HP[30].
Man ensure that you get the ability after 10 secs !

ReEdit:
He could made this.
Use custom variables, they're faster, better to type. All are integers
MaxIndex = 100
Hp[MaxIndex] This is Real
Array = 0
Rollback

Trigger 1
every 0.1 sec do these
actions
set Array = Array +1
if Array > MaxIndex then
set Array = 1
endif
set Hp[Array] = current Hp of unit

Trigger 2
Ability is clicked
conditions blablabla....
actions
Set Rollback = Array - 10 * (seconds formula)
If Rollback < 0 then
Set Rollback = MaxIndex + Rollback (We don't reduce, it is already negative or zero)
endif
If Hp[Rollback] > 0 then
Set Hero's hp = Hp[Rollback]
endif
Set Rollback = 0

Use this, it is better, faster and easier to understand.You can put whatever value you want eg 200, for 20 seconds past hp. Also it doesn't kill you if past hp was 0% (you were dead then)
 

TheOverWhelm

Member
Reaction score
16
meOme is a single-unit hero check.
If you add an array, it's a player-hero hero check (if each player has one hero). Could extend that to a lot more units, mind you, if you do a Loop check if the trig unit == Unit[Arrayvalue]
 

FannyShaver

Well-Known Member
Reaction score
31
There is actually a VERY MAXIMUM of two units that could possibly have this ability. So I guess I would have to create another Real_Array_HP. but will it work for like entire game? Not just for let's say, first few minutes?
 

TheOverWhelm

Member
Reaction score
16
If you do some sort of quick indexing thing it could be done for infinite amount of units.
Unit Learns Skill
Loop 1 to 100
If UnitArray[Loop]==null then
Set Unit THAT SHIT


Periodic .10
Loop 1 to 99
If Unit[loop]=Null then
loop b 1 to 99
set Life[(loopb*100)] to Current Life [Do the "remember hp" trigger above, but the loopb*100 for it]

Might work, haven't tested tho.
 

FannyShaver

Well-Known Member
Reaction score
31
You need two triggers: One to save your hitpoints of the last seconds for specific intervals, and one to restore your hitpoints.

here's one way to do it, but it only works if there really is just one single unit in the game with this ability. Otherwise you'd have to change it a bit.

Trigger:
  • start
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set Unit_Hero = &lt;Your Unit&gt;

Trigger:
  • remember hp
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 99, do (Actions)
        • Loop - Actions
          • Set Real_Array_HP[(101 - (Integer A))] = Real_Array_HP[(100 - (Integer A))]
      • Set Real_Array_HP[1] = (Percentage life of Unit_Hero)

Trigger:
  • reset
    • Events
      • Unit - A unit Starts the Effect of an Ability
    • Conditions
      • (Ability being cast) Equal to Reset
    • Actions
      • Unit - Set life of Unit_Hero to Real_Array_HP[(10 x (4 + (Level of Reset for (Triggering unit))))]%

How big is this array supposed to be?

Anyway, it works now, as always I pay credits in the F9. Thanks me0me.
 

FannyShaver

Well-Known Member
Reaction score
31
That's the trigger I use:

Trigger:
  • Ancestral Rift DG
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 99, do (Actions)
        • Loop - Actions
          • Set CR_HP_DG[(101 - (Integer A))] = CR_HP_DG[(100 - (Integer A))]
      • Set CR_HP_DG[1] = (Percentage life of AncientDG)
      • Game - Display to (All players) the text: (String(CR_HP_DG[1]))


I added text just for testing purposes after I spotted an error, I thought there is some 0% comeing up, but it isn't.

Trigger:
  • Ancestral Rift 2 DG
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Casting unit) Equal to AncientDG
      • (Ability being cast) Equal to Ancestral Rift
    • Actions
      • Unit - Set life of AncientDG to CR_HP_DG[(10 x (5 + (Level of Ancestral Rift for AncientDG)))]%
      • Special Effect - Create a special effect attached to the origin of AncientDG using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl


After certain time unit when casting this spell gets killed. Any clue why? There are ABSOLUTELY no other triggers related to this ability being cast.
 

TheOverWhelm

Member
Reaction score
16
Could be the unit had 0 HP 5 seconds prior to cast, but that'd the only thought I have.
Make it display the "life its reverting to" just in case.
 

TheOverWhelm

Member
Reaction score
16
Mmmm, odd
Unless someone else can see it I can't help much more
Just do more debugging, does it do it to all the hero levels? What about just setting the Array# to its straight value? Etcetc
 

FannyShaver

Well-Known Member
Reaction score
31
It's completely various, sometimes level 1, sometimes 6, etc. I'll try setting to the value then, shall see what happens.

/found an error, sorted. Thanks.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top