Rejuvenation That Heals % Per Second

XeRo13g

New Member
Reaction score
3
I need an ability to act like Rejuvenation but restore a % of the Unit's HP per second instead of a set number. Is there ability like that, or do I have to use a trigger?

Blood_Wraith asked if there is an ability to act like rejuvenation or does he HAVE to use a trigger.
The answer is:
-Yes there is such an ability
-No, he doesn't have to use a trigger.

The solution offered is calling around over 90 functions, several if arguments and 14 very inaccurate waits. It also heals spasmodically, let alone that it's trying to heal the target unit even if it's at max hit points.

GFreak45, not sure what is your point in making such posts but consider the possibility that even if you feel comfortable using such triggers, maybe Blood_Wraith or any other who is searching for a similar query and stumbles to this thread, doesn't.
Cheers.-
 

Blood_Wraith

New Member
Reaction score
2
Thanks for trying to help XeRo13g, but the trigger I posted above works just fine for me. Or it does so far, I haven't tested it very much. I've tested it enough to know it heals 75% of the Unit's Max HP over 15 seconds (That's 5 percent a second, every second, for 15 seconds). I might however try the version you posted though.
 

Inflicted

Currently inactive
Reaction score
63
Blood_Wraith asked if there is an ability to act like rejuvenation or does he HAVE to use a trigger.
The answer is:
-Yes there is such an ability
-No, he doesn't have to use a trigger.
Firstly, there is no ability that does exactly what he wants. Secondly, you are using Triggers to implement this and critisizing us of mentioning some. Thirdly, yours is far more complex and risky.

GFreak45, not sure what is your point in making such posts but consider the possibility that even if you feel comfortable using such triggers, maybe Blood_Wraith or any other who is searching for a similar query and stumbles to this thread, doesn't.
Cheers.-

He is merely pointing out the problems with your trigger. Calm the fvck down.

--

As for the problem. I'm quite sure than the trigger than was labeled as the solution leaks that Unit Variable. Perhaps just use some simple locals or something to fix it?

EDIT:
Thanks for trying to help XeRo13g, but the trigger I posted above works just fine for me. Or it does so far, I haven't tested it very much. I've tested it enough to know it heals 75% of the Unit's Max HP over 15 seconds (That's 5 percent a second, every second, for 15 seconds). I might however try the version you posted though.

Did you test that with only one unit casting the ability at a time? Try multiple units, I'm sure than something will go wrong..
(eg, some other trigger causes udg_TempUnit to be set to some other unit, then the new unit will be healed instead.)

--

One final question, do you want if the maximum hit points increases whilest the ability is restoring. Must the heal restore a % of the old max hp or new max hp?
 

XeRo13g

New Member
Reaction score
3
As for the problem. I'm quite sure than the trigger than was labeled as the solution leaks that Unit Variable. Perhaps just use some simple locals or something to fix it?

Inflicted is right, it does leak a local unit.

Trigger:
  • Custom script: set Target=null
 

Inflicted

Currently inactive
Reaction score
63
Inflicted is right, it does leak a local unit.

Trigger:
  • Custom script: set Target=null

That is a global.


I've made a demo map to show how you should use it, simple effective but possibly a large amount of lines of code. I've done both types or rejuvination, giving him choice as to which type he wants to use.
Remove the comments if you want it smaller :/

One could easily argue that I should have done it in Jass, yes. But as one might not be comftable with Jass, this is much nicer to implement.
It is GUI, MUI, and stackable. Adjust it how you want. Yw.

Hope this helps:
 

Attachments

  • Rejuvination types.w3x
    11.4 KB · Views: 214

XeRo13g

New Member
Reaction score
3
Did you test that with only one unit casting the ability at a time? Try multiple units, I'm sure than something will go wrong..
(eg, some other trigger causes udg_TempUnit to be set to some other unit, then the new unit will be healed instead.)

Uh oh, I thought that the variable shadowing was correct but it seems Inflicted is right about this also. If another unit casts the ability, the code fails.
I missed the fact that you actually need this spell to be targeted at a unit but if you are to use custom scripts to shadow local variables, you may as well use something like this and be safe:

Trigger:
  • Regenerate
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Regen
    • Actions
    • Custom script: local integer i=15
    • Custom script: local unit u=GetSpellTargetUnit()
    • Custom script: loop
    • Custom script: call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+GetUnitState(u,UNIT_STATE_MAX_LIFE)*0.05)
    • Custom script: set i=i-1
    • Custom script: exitwhen i<=0
    • Wait 1.00 seconds
    • Custom script: endloop
    • Custom script: set u=null


Or simply:
Trigger:
  • Regenerate
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Regen
    • Actions
    • Custom script: local unit u=GetSpellTargetUnit()
    • //--------------------------Copy paste this 15 times----
    • Custom script: call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+GetUnitState(u,UNIT_STATE_MAX_LIFE)*0.05)
    • Wait 1.00 seconds
    • //----------------------------------------------------------
    • Custom script: set u=null
 

Blood_Wraith

New Member
Reaction score
2
Ah you're right! I suspected that might happen, where if you cast it on another unit while it is already active, it will heal that unit instead, thus only healing one unit at a time, damn. Guess I'll try the map posted above and see how that works.
 

vypur85

Hibernate
Reaction score
803
Try the below. Not sure if works though. Seems more 'simplified' [del]than the ones have here[/del].
Code:
Regenerate
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Regen 
    Actions
        Custom script:   local unit udg_TempUnit = GetSpellTargetUnit()
        Custom script:   local integer i = 0
        Custom script:   loop
        Custom script:   exitwhen (i >= 15) or ( GetUnitState (udg_TempUnit ,UNIT_STATE_LIFE)<0.415 )
        Custom script:   set i = i + 1
        Unit - Set life of TempUnit to ((Life of TempUnit) + ((Max life of TempUnit) x 0.05))
        Wait 1.00 game-time seconds
        Custom script:   endloop
        Set TempUnit = No unit

Edit: Oops... Seems like I'm a lil slow.
 

Blood_Wraith

New Member
Reaction score
2
Okay I guess the triggers in the map above seem to work good while on multiple units, thing is, I don't know what the hell the differences are between the two. So what are the differences?

Edit: Oh wait, I think Regen #2 is 5% of CURRENT HP per second, #1 is MAX HP per second, I think... give me a sec.
 

XeRo13g

New Member
Reaction score
3
That won't do the job either.
udg_TempUnit is a global variable and it will be overwritten, it also doesn't need nulling.
 

Blood_Wraith

New Member
Reaction score
2
Okay this is most likely the trigger I'm going to be using, what custom script do I modify if I want it to effect target unit of ability being cast? Cause it only works on the triggering unit.

Trigger:
  • Custom Spell 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Rejuvination #2
    • Actions
      • Custom script: local unit u = GetTriggerUnit()
      • Custom script: local real r = ( GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetTriggerUnit()) * 0.05 )
      • -------- 1 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 2 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 3 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 4 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 5 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 6 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 7 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 8 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 9 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 10 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 11 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 12 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 13 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 14 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 15 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )


(Trigger taken from map posted above)
 

XeRo13g

New Member
Reaction score
3
This is getting confusing. Unit u is now the caster, not the target. Also, setting the max health into a variable at the beginning will reduce the accuracy of the healing in case it's value somehow changes in those 15 seconds. BTW, I would personally prefer that inaccuracy to save a few function calls.

The custom script you are using in this code, calls BJ's, which call the functions in the last code I've posted.

Bottom line, if you want a unit to cast the ability to another unit and wish the TARGET unit to be healed, use the last code I've posted.

PS. If you want it to heal based on current HP's, change "UNIT_STATE_MAX_LIFE" into "UNIT_STATE_LIFE". Simple as that. (In this case, don't save the starting hit points into a variable)

EDIT:
Trigger:
  • Regenerate
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Regen
    • Actions
    • Custom script: local unit u=GetSpellTargetUnit()
    • Custom script: local real r= GetUnitState(u,UNIT_STATE_MAX_LIFE)*0.05
    • //--------------------------Copy paste this 15 times----
    • Custom script: call SetUnitState(u,UNIT_STATE_LIFE,GetUnitState(u,UNIT_STATE_LIFE)+r)
    • Wait 1.00 seconds
    • //----------------------------------------------------------
    • Custom script: set u=null
 

Blood_Wraith

New Member
Reaction score
2
Okay I've got it working here's (most likely) the FINAL trigger.

Trigger:
  • Regen
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Regen
    • Actions
      • Custom script: local unit u = GetSpellTargetUnit()
      • Custom script: local real r = ( GetUnitStateSwap(UNIT_STATE_MAX_LIFE, GetSpellTargetUnit()) * 0.05 )
      • -------- 1 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 2 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 3 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 4 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 5 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 6 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 7 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 8 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 9 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 10 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 11 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 12 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 13 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 14 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )
      • Wait 1.00 seconds
      • -------- 15 --------
      • Custom script: call SetUnitLifeBJ( u, ( GetUnitStateSwap(UNIT_STATE_LIFE, u) + r ) )


Here's your rep Inflicted, you've earned it.
 

Inflicted

Currently inactive
Reaction score
63
Basically replace this line:
Trigger:
  • local unit u = GetTriggerUnit()

with:
Trigger:
  • local unit u = GetSpellTargetUnit()


--

EDIT: Looks like you beat me too it. gj lol. Glad it's fixed. Tell me if there are any other problems.

Reminder: I know it's obvious, but remember to change target type to unit and that range must be adjusted. Aswel as setting Targets Allowed.

--

EDIT2:
This is getting confusing. Unit u is now the caster, not the target. Also, setting the max health into a variable at the beginning will reduce the accuracy of the healing in case it's value somehow changes in those 15 seconds. BTW, I would personally prefer that inaccuracy to save a few function calls.

The custom script you are using in this code, calls BJ's, which call the functions in the last code I've posted.

Bottom line, if you want a unit to cast the ability to another unit and wish the TARGET unit to be healed, use the last code I've posted.

PS. If you want it to heal based on current HP's, change "UNIT_STATE_MAX_LIFE" into "UNIT_STATE_LIFE". Simple as that. (In this case, don't save the starting hit points into a variable)

You obviously havent read all the posts or looked at the map I uploaded.
I offered both options of healing. He has selected the one based on the initial maximum hit points. What you are saying is obvious, please just look next time.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
no u do need to null local units at the end
anything with a handle has to be nulled
groups, units, locations, triggers, and i believe regions and codes
integers, reals, etc do not have to be nulled

Checked the map.
Still using BJ's and both leak a local.
there is no problem with using BJ's in a code for a GUI user, as every single one of their triggers will have them any way
 
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