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: 228

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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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