Rejuvenation That Heals % Per Second

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.-
 
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.
 
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?
 
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 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: 232
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
 
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.
 
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.
 
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.
 
That won't do the job either.
udg_TempUnit is a global variable and it will be overwritten, it also doesn't need nulling.
 
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)
 
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
 
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.
 
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.
 
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.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good
  • The Helper The Helper:
    I would like to see it again like Ghan had it the first time with pagination though - without the pagination that view will not work but with pagination it just might...
  • The Helper The Helper:
    This drink recipe I have had more than a few times back in the day! Mind Eraser https://www.thehelper.net/threads/cocktail-mind-eraser.194720/
  • The Helper The Helper:
    Happy Thursday!
  • Ghan Ghan:
    I'm not so sure, there's still a lot of Thursday left for it to become unhappy.
    +3
  • The Helper The Helper:
    still a few hours
  • The Helper The Helper:
    Its Friday!!!!
    +1
  • Ghan Ghan:
    Thursday 7/10 would Thursday again
    +3
  • The Helper The Helper:
    New forum coming soon going to be for my friend Saylor who is blind and he is doing motivational speaking and has an internet radio show and podcast. I am going to put a forum to promote him and other inspirational speaker stuff going to have some good stuff in it.
  • The Helper The Helper:
    his audio only music mix
  • The Helper The Helper:
    it just makes sense right?

      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