• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[GUI] Simple Stop Regeneration System v1.1 [GUI]

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
- This system allows you to stop unit's regeneration (currently, only HP).
- It is useful for certain situations, let your imagination runs wild.
- This system aims for simple trigger spells, if you have a complicated spell (requires in-depth HP/MP calculation, this is not the system you're looking for, it could intercept with the system itself that will cause a bug)

I have seen many people are asking how to stop unit's HP/MP Regeneration for a period of time, that's what inspired me to create this system.

CONS
- Could have endless of possibilities of changing HP/MP occur.


External Instructions
- Open World Editor > File - Preferences... > General Tab > Tick the Automatically create unknown variables while pasting trigger data
- Copy the Simple Stop Regeneration System folder.

Internal Instructions
- To stop unit's HP Regeneration, simply set these 2 variables and run the SR Save trigger;
  • Set SR_FreezeUnit = YourUnit
  • Set SR_Duration = YourDuration
  • Trigger - Run SR Save <gen> (ignoring conditions)
- If you have a spell that heals a target unit, simply set these 2 variables and run the SR Save trigger;
  • Set SR_FreezeUnit = YourUnit
  • Set SR_HealValue = YourHealingValue
  • Trigger - Run SR Save <gen> (ignoring conditions)
- By running this trigger, even if the unit's HP Regeneration is stopped, it still gets new HP registered (it stops regeneration, but does not stop healing-based spell)


  • SR Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_SR_Hashtable = InitHashtable()
      • Set SR_Interval = 0.03
      • Trigger - Add to SR Loop <gen> the event (Time - Every SR_Interval seconds of game time)
  • SR Save
    • Events
    • Conditions
    • Actions
      • Custom script: set udg_SR_Key = GetHandleId(udg_SR_FreezeUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SR_HealValue Greater than 0.00
        • Then - Actions
          • Custom script: call SetWidgetLife(udg_SR_FreezeUnit, GetWidgetLife(udg_SR_FreezeUnit) + udg_SR_HealValue)
          • Set SR_HealValue = 0.00
        • Else - Actions
          • Hashtable - Save SR_Duration as 0 of SR_Key in SR_Hashtable
          • Unit Group - Add SR_FreezeUnit to SR_Group
          • Trigger - Turn on SR Loop <gen>
      • Custom script: set udg_SR_FreezeHP = GetWidgetLife(udg_SR_FreezeUnit)
      • Hashtable - Save SR_FreezeHP as 1 of SR_Key in SR_Hashtable
  • SR Loop
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (SR_Group is empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit Group - Pick every unit in SR_Group and do (Actions)
            • Loop - Actions
              • Set SR_FreezeUnit = (Picked unit)
              • Custom script: set udg_SR_Key = GetHandleId(udg_SR_FreezeUnit)
              • Set SR_Duration = (Load 0 of SR_Key from SR_Hashtable)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SR_Duration Greater than 0.00
                  • (SR_FreezeUnit is alive) Equal to True
                • Then - Actions
                  • Custom script: call SetWidgetLife(udg_SR_FreezeUnit, LoadReal(udg_SR_Hashtable, udg_SR_Key, 1))
                  • Hashtable - Save (SR_Duration - SR_Interval) as 0 of SR_Key in SR_Hashtable
                • Else - Actions
                  • Hashtable - Clear all child hashtables of child SR_Key in SR_Hashtable
                  • Unit Group - Remove SR_FreezeUnit from SR_Group
  • SR Damage Taken
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamagedUnit is in SR_Group) Equal to True
    • Actions
      • Custom script: set udg_SR_FreezeHP = GetWidgetLife(udg_GDD_DamagedUnit) - udg_GDD_Damage
      • Custom script: set udg_SR_Key = GetHandleId(udg_GDD_DamagedUnit)
      • Hashtable - Save SR_FreezeHP as 1 of SR_Key in SR_Hashtable
The community for requesting this kind of system, which in the first place inspired me to create it.
Weep - For his GUI Damage Detection System
baassee - Function optimization


v1.0
- Initial release

v1.1
- Trigger function has been optimized
- Reduced some function calls
- Removed local variables


- Stop MP Regeneration


Keywords:
simple, stop, hp, mp, regeneration, system, defskull, damage, taken, weep, heal, stay.
Contents

Just another Warcraft III map (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. 05:14, 26th Aug 2012 Magtheridon96: Fix the healing bug by providing an onHeal trigger. The user would just set the healed unit, and you would do the work to fix the stored amount. By the...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.

05:14, 26th Aug 2012
Magtheridon96: Fix the healing bug by providing an onHeal trigger. The user would just set the healed unit, and you would do the work to fix the stored amount.

By the way, in my maps, i code regeneration from scratch just so I can do these things with no trouble ;p
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Reserved.

If you guys can help me list out the possibilities of a unit to have a decrease/increase of its HP/MP, I'd be gladful :)

Currently for HP;
- Takes damage
- Healed by spells
- Using spells that damages Caster (just thought about this, will implement in next version)

Currently for MP (next version);
- Uses spell (that uses Mana)
- Spells that gives Mana
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Personally, I don't like playing with a unit's HP but this seems fair enough.

As you seem to like to play with custom scripts let me help you on that part.


Save Trigger.
  • Unit - Set life of SR_FreezeUnit to ((Life of SR_FreezeUnit) + SR_HealValue)
-->>>>

call SetWidgetLife(udg_FreezeUnit, GetWidgetLife(udg_FreezeUnit) + udg_SR_HealValue)

  • Set SR_FreezeHP = (Life of SR_FreezeUnit)

-->>>>

set udg_SR_FreezeHP = GetWidgetLife(udg_SR_FreezeUnit)


Loop Trigger.

  • Unit - Set life of SR_FreezeUnit to (Load 1 of SR_Key from SR_Hashtable)
-->>>>

call SetWidgetLife(udg_FreezeUnit, LoadReal(udg_SR_Hashtable, udg_SR_Key, 1))

Damage Taken Trigger.

I personally don't know why you use these locals, they're pretty useless here. You have to understand when storing is good and when it's not good and it's not useful when you only use things once.

You should replace all those actions to just this.

JASS:
set udg_SR_FreezeHP = GetWidgetLife(udg_GDD_DamagedUnit) - udg_GDD_Damage
set udg_SR_Key = GetHandleId(udg_GDD_DamagedUnit)
  • Hashtable - Save SR_FreezeHP as 1 of SR_Key in SR_Hashtable
Ah I remember when you could shadow globals, lovely time.

I guess I could say more things but I mentioned the most important. Playing with HP in GUI is rather slow and these actions does not exist in the GUI table (AFAIK) so I helped you out with the line of codes.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
So the main code would be WidgetLife function, eh ?
I'll change that !

LOL I forgot that Weep's system already provide those globals, why the hell I created locals for it >.>"

Also, if you're giving me these suggestions (changing it to function in JASS instead BJs converted by GUI), it's better I convert all the function to JASS, does it ?

v1.1 is uploaded.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Nah keep it GUI, people tend to not find JASS stuff as interesting.
They're not suggestions - GUI uses GetUnitState (or actually GetUnitStateSwap) - which are slower than GetWidgetLife. Although GetWidgetMana does not exist thus GetUnitState to get mana is the only option when you want to retrive a unit's MP. Lots of these stuff in JASS as GetUnitX > GetWidgetX (where GetUnitX is faster than GetWidgetX) and such.

GUI is just made of BJs thus the coder him/herself must update the code if it is not fast enough.

EDIT:

Maybe you should update the title of the resource - still v1.0 ^^
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
GUI actually uses few natives, KillUnit for instance :D
as newcomer finding lots of SetWidgetLife custom scripts is just what is that? and GUI is not that slow to drop FPS if you know what you are doing
if speed is all that matters why make GUI system hmmm...(to baassee)
Ill test this later and give you some feedback
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
if speed is all that matters why make GUI system hmmm...(to baassee)
Because it's for GUI-users :)
That does not want to install JNGP.

But you've got point, if we're so afraid of speed of trigger, why approve GUI Trigger ?

But baassee also got his point, SOME of the function (SOME of it), really needs to change GUI function to JASS ones (because he sees that I play with Custom script very much), then he's thinking "why not you do this if you understand some of JASS functions ?"

Like SetUnitX/Y > SetUnitPositionLoc
AddLightningEx > AddLightningLoc

And so on.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Cause GUI will always be GUI. Most BJs can be removed by optimizing map with Vexorian's optimizer to remove the most useless ones (like PauseUnitBJ).

It is slow if you think of the amount of extra calls you can save if you do everything in complete custom script ^^ I just make systems for GUIers, made in all languages anyway.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Ahhh normal heal such as Holy Light ?
I don't know, pretty much you have to trigger all your healing spells :/

Checking difference (like 10 for example) won't work because what if the unit has regen > CheckingValue ?
It runs the trigger, thus saves new HP for the unit (doesn't work this way).
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
flashed his life from 13 to 30 but still reverted to 13
Well this is because the interval < natural HP regen
You said that natural HP regen occurs once every 0.005s, right ?
0.005 is so small compared to 0.03, that's why.

I can of course lower the interval, but I'm afraid it would lag the game while this system is in effect (I want to lower it to 0.01, but that would make it 100 checks per second)
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
well, you can test it :D
btw the 0.005 may not be exact, its more like interval <0.0045, 0.0055> because when I displayed health of unit every 0.00125 second(crazy :D) it showed the same number 4 times, 4*0.00125 is 0.005 :D but it doesnt need to be that fast really
I think its fine as it is but its good to let people know they have to trigger their heals :D but its not big deal
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Reserved.

If you guys can help me list out the possibilities of a unit to have a decrease/increase of its HP/MP, I'd be gladful :)

Currently for HP;
- Takes damage
- Healed by spells
- Using spells that damages Caster (just thought about this, will implement in next version)

Currently for MP (next version);
- Uses spell (that uses Mana)
- Spells that gives Mana


Spells which destroy mana... Mana burn, Feedback etc.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
this is primally made to stop units regeneration as the topic name says, the list is only what this is capable off when he updates it(possibly)
I suggest you that you could pre-code to the map the hard coded abilities that heals to give people better example how to do it
 
Top