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

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.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      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