• 🏆 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!

[Trigger] Requesting Creep Respawn System Without Setting Custom Values

Status
Not open for further replies.
Level 4
Joined
Apr 22, 2022
Messages
31
Hey everyone, I have been having issues with my current creep respawn system as it sets a unit's custom value and that is conflicting with the unit indexer I have on my map and causing serious performance issues. My current respawn system is set up like this:
(on map init to set the value of preplaced units)
  • Set VariableSet Creeps = (Units owned by Neutral Hostile.)
  • Unit Group - Pick every unit in Creeps and do (Actions)
    • Loop - Actions
      • Set VariableSet I = (I + 1)
      • Unit - Set the custom value of (Picked unit) to I
      • Set VariableSet Angle[I] = (Facing of (Picked unit))
      • Set VariableSet Position = (Position of (Picked unit))
      • Set VariableSet X[I] = (X of Position)
      • Set VariableSet Y[I] = (Y of Position)
      • Custom script: call RemoveLocation(udg_Position)
  • Custom script: call DestroyGroup(udg_Creeps)
  • Set VariableSet I = 0
(when a unit owned by neutral hostile dies)
  • Set VariableSet I = (I + 1)
  • Set VariableSet Creep[I] = (Dying unit)
  • Wait 417.00 game-time seconds
  • Set VariableSet Position = (Center of (Playable map area))
  • Set VariableSet J = (J + 1)
  • Unit - Create 1 (Unit-type of Creep[J]) for Neutral Hostile at (Position offset by (X[(Custom value of Creep[J])], Y[(Custom value of Creep[J])])) facing Angle[(Custom value of Creep[J])] degrees
  • Custom script: call RemoveLocation(udg_Position)
  • Unit - Set the custom value of (Last created unit) to (Custom value of Creep[J])
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • I Greater than or equal to 8000
    • Then - Actions
      • Set VariableSet I = 0
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • J Greater than or equal to 8000
    • Then - Actions
      • Set VariableSet J = 0
    • Else - Actions
I do not have any performance issues if I don't use the system requiring the unit indexer, but I would like to use that system. My issue is that I plan to use a unit indexer for another system on my map, so how would I go about having a creep respawn system that doesn't involve setting a unit's custom value? I have been told there are much better creep respawn systems that don't set custom values, but I have yet to find any on here or elsewhere on the internet. Thanks!
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Here's a simple fix with some optimizations. Change the first trigger to this:
  • Set Variable Creeps = (Units owned by Neutral Hostile.)
  • Unit Group - Pick every unit in Creeps and do (Actions)
    • Loop - Actions
      • Set Variable Creep = (Picked unit)
      • Set Variable CV = Custom value of Creep
      • Set Variable Angle[CV] = (Facing of Creep)
      • Custom script: set udg_X[udg_CV] = GetUnitX(udg_Creep)
      • Custom script: set udg_Y[udg_CV] = GetUnitY(udg_Creep)
  • Custom script: call DestroyGroup(udg_Creeps)
Then modify the second trigger to work like this:
  • Actions
  • Custom script: local real udg_RespawnX
  • Custom script: local real udg_RespawnY
  • Custom script: local real udg_RespawnAngle
  • Custom script: local integer udg_RespawnType
  • Set Variable Creep = (Triggering unit)
  • Set Variable CV = Custom value of Creep
  • Custom script: set udg_RespawnX = udg_X[udg_CV]
  • Custom script: set udg_RespawnY = udg_Y[udg_CV]
  • Custom script: set udg_RespawnAngle = udg_Angle[udg_CV]
  • Custom script: set udg_RespawnType = GetUnitTypeId(udg_Creep)
  • Wait 417.00 game-time seconds
  • Set Variable RespawnPoint = Point(RespawnX, RespawnY)
  • Unit - Create 1 RespawnType for Neutral Hostile at RespawnPoint facing RespawnAngle degrees
  • Custom script: call RemoveLocation(udg_RespawnPoint)
  • Set Variable Creep = (Last created unit)
  • Set Variable CV = Custom value of Creep
  • Custom script: set udg_X[udg_CV] = RespawnX
  • Custom script: set udg_Y[udg_CV] = RespawnY
  • Custom script: set udg_Angle[udg_CV] = RespawnAngle
Variables:
RespawnX = Real
RespawnY = Real
RespawnAngle = Real
RespawnType = Unit-type
RespawnPoint = Point
Creep = Unit
CV = Integer

To reduce variable usage and improve efficiency you could rely on more Custom script and change the second trigger to this:
  • Actions
  • Custom script: local unit U = GetTriggerUnit()
  • Custom script: local integer CV = GetUnitUserData(U)
  • Custom script: local real RespawnX = udg_X[CV]
  • Custom script: local real RespawnY = udg_Y[CV]
  • Custom script: local real RespawnAngle = udg_Angle[CV]
  • Custom script: local integer RespawnType = GetUnitTypeId(U)
  • Wait 417.00 game-time seconds
  • Custom script: set U = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), RespawnType, RespawnX, RespawnY, RespawnAngle)
  • Custom script: set CV = GetUnitUserData(U)
  • Custom script: set udg_X[CV] = GetUnitX(U)
  • Custom script: set udg_Y[CV] = GetUnitY(U)
  • Custom script: set udg_Angle[CV] = GetUnitFacing(U)
  • Custom script: set U = null
Local variables are preserved throughout the trigger even after Waits. At this point you're practically writing the entire trigger in Jass due to all of the Custom script (maybe that'd be smarter).



Also, if your Unit Indexer doesn't recycle unused custom values then you could simplify this by only tracking the dying unit and it's custom value. You'd also want a new variable that tracks the creep's Unit-type which you'd set alongside X/Y/Angle:
  • Actions
  • Custom script: local unit U = GetTriggerUnit()
  • Custom script: local integer CV = GetUnitUserData(U)
  • Wait 417.00 game-time seconds
  • Custom script: set U = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_Type[CV], udg_X[CV], udg_Y[CV], udg_Angle[CV])
  • Custom script: set CV = GetUnitUserData(U)
  • Custom script: set udg_X[CV] = GetUnitX(U)
  • Custom script: set udg_Y[CV] = GetUnitY(U)
  • Custom script: set udg_Angle[CV] = GetUnitFacing(U)
  • Custom script: set udg_Type[CV] = GetUnitTypeId(U)
  • Custom script: set U = null
The problem with recycling is that during the 417.00 second Wait the Creep's custom value could be given to ANY newly created unit.
 
Last edited:
Level 4
Joined
Apr 22, 2022
Messages
31
Thanks for the detailed help! I tried your suggestions above (that is still partially GUI) and I couldn't exactly replicate your suggestion, but I have this
  • Set VariableSet RespawnPoint = (RespawnPoint offset by (RespawnX, RespawnY))
If that is what you meant by "Set Variable RespawnPoint = Point(RespawnX, RespawnY)"
Now I dont have units respawning in their original position (or at all for that matter unless they are respawning in a hidden spot that I cannot see.)
I am using Bribe's Unit Indexer included with his Heal Event system - Heal Event for GUI, version 1.1.1.1
I am not sure if it recycles values or if it even indexes preplaced units.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Bribe's Unit Indexer does recycle values and it does index preplaced units.

You need to use the function: Conversion - Convert Coordinates to Point
  • Set VariableSet Point = (Point(0.00, 0.00))
What you're currently doing is setting RespawnPoint to be equal to RespawnPoint but it hasn't been set to anywhere yet so that's not going to work. You can't offset nothing.

Edit: Ignore that last part about the original triggers (if you even saw it).

I've edited these posts a few times now, sorry for any confusion.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Also, make sure you're using up to date systems.

The [index] max array size is now 32,768 and Warcraft 3 supports up to 24 players. Some of these older systems were using the outdated values of 8,198 and 12 players. I often find myself updating Bribe's Unit Indexer in other people's maps because they were using an outdated version that came packaged with one of his other systems. The other system was usually up to date, but the Unit Indexer that came with it wasn't.
 
Last edited:
Level 4
Joined
Apr 22, 2022
Messages
31
Thanks a ton, I have my first trigger looking like your original suggestion up above, and changed my 2nd trigger to look exactly like
  • actions.gif
    Actions
  • page.gif
    Custom script: local unit U = GetTriggerUnit()
  • page.gif
    Custom script: local integer CV = GetUnitUserData(U)
  • page.gif
    Custom script: local real RespawnX = udg_X[CV]
  • page.gif
    Custom script: local real RespawnY = udg_Y[CV]
  • page.gif
    Custom script: local real RespawnAngle = udg_Angle[CV]
  • page.gif
    Custom script: local integer RespawnType = GetUnitTypeId(U)
  • zzz.gif
    Wait 417.00 game-time seconds
  • page.gif
    Custom script: set U = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), RespawnType, RespawnX, RespawnY, RespawnAngle)
  • page.gif
    Custom script: set CV = GetUnitUserData(U)
  • page.gif
    Custom script: set udg_X[CV] = GetUnitX(U)
  • page.gif
    Custom script: set udg_Y[CV] = GetUnitY(U)
  • page.gif
    Custom script: set udg_Angle[CV] = GetUnitFacing(U)
  • page.gif
    Custom script: set U = null
Except I still dont have any units respawning, not sure what I am doing wrong. I realize the heal event system hasn't been updated in awhile so I tried switching to GUI Unit Indexer 1.4.0.0 and my map almost completely freezes once you load in. I noticed this near the bottom of the Unit Indexer Trigger
  • -------- This is the "Unit Indexer Initialized" event, use it instead of "Map Initialization" for best results --------
  • Set VariableSet IsUnitPreplaced[0] = False
  • Set VariableSet UnitIndexEvent = 3.00
So for any trigger that starts with a Map Initialization event just change the event to "UnitIndexEvent = 3.00" ??
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
Thanks a ton, I have my first trigger looking like your original suggestion up above, and changed my 2nd trigger to look exactly like
  • actions.gif
    Actions
  • page.gif
    Custom script: local unit U = GetTriggerUnit()
  • page.gif
    Custom script: local integer CV = GetUnitUserData(U)
  • page.gif
    Custom script: local real RespawnX = udg_X[CV]
  • page.gif
    Custom script: local real RespawnY = udg_Y[CV]
  • page.gif
    Custom script: local real RespawnAngle = udg_Angle[CV]
  • page.gif
    Custom script: local integer RespawnType = GetUnitTypeId(U)
  • zzz.gif
    Wait 417.00 game-time seconds
  • page.gif
    Custom script: set U = CreateUnit(Player(PLAYER_NEUTRAL_AGGRESSIVE), RespawnType, RespawnX, RespawnY, RespawnAngle)
  • page.gif
    Custom script: set CV = GetUnitUserData(U)
  • page.gif
    Custom script: set udg_X[CV] = GetUnitX(U)
  • page.gif
    Custom script: set udg_Y[CV] = GetUnitY(U)
  • page.gif
    Custom script: set udg_Angle[CV] = GetUnitFacing(U)
  • page.gif
    Custom script: set U = null
Except I still dont have any units respawning, not sure what I am doing wrong. I realize the heal event system hasn't been updated in awhile so I tried switching to GUI Unit Indexer 1.4.0.0 and my map almost completely freezes once you load in. I noticed this near the bottom of the Unit Indexer Trigger
  • -------- This is the "Unit Indexer Initialized" event, use it instead of "Map Initialization" for best results --------
  • Set VariableSet IsUnitPreplaced[0] = False
  • Set VariableSet UnitIndexEvent = 3.00
So for any trigger that starts with a Map Initialization event just change the event to "UnitIndexEvent = 3.00" ??
Yeah, the units haven't been given their custom values until a certain point in time during the initialization process. That real Event runs when this process is finished. So your first trigger should use that as it's Event since it's referencing custom value.
  • Events
  • Game - UnitIndexEvent Becomes Equal to 3.00
If that doesn't fix the issue, the other problem could have something to do with RespawnType not working the way I thought it did.
 
Level 4
Joined
Apr 22, 2022
Messages
31
So the only trigger I have that uses the Map Initialization event now is the Unit Indexer trigger, my other one that did have it now has Game - UnitIndexEvent Becomes Equal to 3.00, but the freeze still occurs. It loads up fine if I disable the Unit Indexer trigger and switch my original map init trigger event back.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,543
So the only trigger I have that uses the Map Initialization event now is the Unit Indexer trigger, my other one that did have it now has Game - UnitIndexEvent Becomes Equal to 3.00, but the freeze still occurs. It loads up fine if I disable the Unit Indexer trigger and switch my original map init trigger event back.
Not too sure but you may have multiple copies of the same system causing issues or something along those lines. You can send me your map if you'd like.

There's always the Elapsed Time event that runs after Map Initialization.
 
Level 4
Joined
Apr 22, 2022
Messages
31
Through the process of elimination I found out that the Heal Configuration trigger is causing my issue with the map freezing when using the Unit Indexer.

  • Set VariableSet HEAL_THRESHOLD = 45.00
  • Set VariableSet HEAL_CHECK_INTERVAL = 0.01
  • Countdown Timer - Start heal_timer as a Repeating timer that will expire in HEAL_CHECK_INTERVAL seconds
  • Set VariableSet REGEN_STRENGTH_VALUE = 0.06
  • Set VariableSet REGEN_THRESHOLD = 35.00
  • Set VariableSet REGEN_EVENT_INTERVAL = 1.50
Tried setting the check interval to 0.05 instead of 0.01 and it reduced the lag a tiny bit but still basically frozen. The timer expiring runs the heal check loop trigger:
  • Set VariableSet heal_exitwhen = (heal_count - 1)
  • For each (Integer heal_integer) from 0 to heal_exitwhen, do (Actions)
    • Loop - Actions
      • Set VariableSet heal_integer = heal_indices[heal_integer]
      • Set VariableSet heal_target = UDexUnits[heal_integer]
      • Set VariableSet heal_life = (Life of heal_target)
      • Set VariableSet heal_diff = (heal_life - heal_lastLife[heal_integer])
      • Set VariableSet heal_lastLife[heal_integer] = heal_life
      • Set VariableSet heal_amount = (heal_diff - (Max(0.00, heal_regen[heal_integer])))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of heal_target) Equal to Player 1 (Red)
          • MaxLifeDiff[1] Less than or equal to 0.00
          • heal_amount Greater than or equal to HEAL_THRESHOLD
        • Then - Actions
          • Set VariableSet HealEvent = 1.00
          • Set VariableSet HealEvent = 0.00
        • Else - Actions
          • Set VariableSet heal_regen[heal_integer] = ((heal_regen[heal_integer] + heal_diff) x 0.50)
          • Set VariableSet regen_buildup[heal_integer] = (regen_buildup[heal_integer] + heal_diff)
          • Set VariableSet regen_timeleft[heal_integer] = (regen_timeleft[heal_integer] - HEAL_CHECK_INTERVAL)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • regen_timeleft[heal_integer] Less than or equal to 0.00
            • Then - Actions
              • Set VariableSet regen_timeleft[heal_integer] = REGEN_EVENT_INTERVAL
              • Set VariableSet heal_amount = regen_buildup[heal_integer]
              • Set VariableSet regen_buildup[heal_integer] = 0.00
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (heal_target is A Hero) Equal to True
                • Then - Actions
                  • Set VariableSet heal_diff = (heal_amount - ((Real((Strength of heal_target (Include bonuses)))) x REGEN_STRENGTH_VALUE))
                • Else - Actions
                  • Set VariableSet heal_diff = heal_amount
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of heal_target) Equal to Player 1 (Red)
                  • MaxLifeDiff[1] Less than or equal to 0.00
                  • heal_diff Greater than or equal to REGEN_THRESHOLD
                • Then - Actions
                  • Set VariableSet HealEvent = 0.50
                  • Set VariableSet HealEvent = 0.00
                • Else - Actions
            • Else - Actions
      • Set VariableSet heal_integer = heal_indexRef[heal_integer]
Your respawn suggestions up above work perfectly with the Unit Indexer system so no issues there. I am wondering if it is something within the heal loop trigger that is causing the performance issues, cause making the timer longer does help a little bit, but not by much and I sort of need it to be a quick timer to detect close to the instance of healing. The player condition checks are to determine which player the heal is going out to and if the heal text should be shown or not. (Tried removing the player checks and still the same issue) I really appreciate all your help so far and it has improved my knowledge and also my map, so thank you!

There are also these 2 triggers included with the heal event system that I did not turn off or disable during my checks to find my issue.
Heal Add Unit:
  • Events
    • Game - UnitIndexEvent becomes Equal to 1.00
    • Game - DeathEvent becomes Equal to 2.00
  • Conditions
    • heal_inSys[UDex] Equal to False
  • Actions
    • Custom script: if GetUnitAbilityLevel(udg_UDexUnits[udg_UDex], 'Aloc') > 0 then
    • Skip remaining actions
    • Custom script: endif
    • Set VariableSet heal_inSys[UDex] = True
    • Set VariableSet heal_indices[heal_count] = UDex
    • Set VariableSet heal_indexRef[UDex] = heal_count
    • Set VariableSet heal_lastLife[UDex] = (Life of UDexUnits[UDex])
    • Set VariableSet regen_timeleft[UDex] = REGEN_EVENT_INTERVAL
    • Set VariableSet heal_count = (heal_count + 1)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • heal_count Equal to 1
      • Then - Actions
        • Trigger - Turn on Heal Check Loop <gen>
      • Else - Actions
Heal Remove Unit:
  • Events
    • Game - DeathEvent becomes Equal to 0.50
    • Game - DeathEvent becomes Equal to 1.00
    • Game - DeathEvent becomes Equal to 3.00
    • Game - UnitIndexEvent becomes Equal to 2.00
  • Conditions
    • heal_inSys[UDex] Equal to True
  • Actions
    • Set VariableSet heal_inSys[UDex] = False
    • Set VariableSet heal_count = (heal_count - 1)
    • Set VariableSet heal_indices[heal_indexRef[UDex]] = heal_indices[heal_count]
    • Set VariableSet heal_indexRef[heal_indices[heal_count]] = heal_indexRef[UDex]
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • heal_count Equal to 0
      • Then - Actions
        • Trigger - Turn off Heal Check Loop <gen>
      • Else - Actions
On a fresh map the Unit Indexer and Heal Event system don't collide, but here it is so you can look at the triggers. I am going to try to go through the variables and triggers and copy them over again incase something glitched when I brought them into my map. The Crash test is also a .w3m file but my map is a .w3x file.

Edit: Tried removing all heal event and unit indexer related variables and triggers and recopied them over (Unit Indexer first then Heal Event) and still no good. Thinking that the Heal Event for GUI, version 1.1.1.1 isn't compatible with the latest GUI Unit Indexer 1.4.0.0 but just on my map lol, possibly because its 3 player and has more units than the crash test map.
 

Attachments

  • Crash Test.w3m
    25.4 KB · Views: 6
Last edited:
Level 4
Joined
Apr 22, 2022
Messages
31
After further testing I have found my issue to be the Heal Check Loop trigger. I removed the timer entirely and changed my trigger to:
  • Time - Every 0.06 seconds of game time
  • Actions
    • Set VariableSet heal_exitwhen = (heal_count - 1)
    • For each (Integer heal_integer) from 0 to heal_exitwhen, do (Actions)
      • Loop - Actions
        • Set VariableSet heal_integer = heal_indices[heal_integer]
        • Set VariableSet heal_target = UDexUnits[heal_integer]
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Owner of heal_target) Equal to Player 1 (Red)
          • Then - Actions
            • Set VariableSet heal_life = (Life of heal_target)
            • Set VariableSet heal_diff = (heal_life - heal_lastLife[heal_integer])
            • Set VariableSet heal_lastLife[heal_integer] = heal_life
            • Set VariableSet heal_amount = (heal_diff - (Max(0.00, heal_regen[heal_integer])))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • MaxLifeDiffP1 Less than or equal to 0.00
                • heal_amount Greater than or equal to HEAL_THRESHOLD
              • Then - Actions
                • Set VariableSet HealEvent = 1.00
                • Set VariableSet HealEvent = 0.00
              • Else - Actions
                • Set VariableSet heal_regen[heal_integer] = ((heal_regen[heal_integer] + heal_diff) x 0.50)
                • Set VariableSet regen_buildup[heal_integer] = (regen_buildup[heal_integer] + heal_diff)
                • Set VariableSet regen_timeleft[heal_integer] = (regen_timeleft[heal_integer] - HEAL_CHECK_INTERVAL)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • regen_timeleft[heal_integer] Less than or equal to 0.00
                  • Then - Actions
                    • Set VariableSet regen_timeleft[heal_integer] = REGEN_EVENT_INTERVAL
                    • Set VariableSet heal_amount = regen_buildup[heal_integer]
                    • Set VariableSet regen_buildup[heal_integer] = 0.00
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (heal_target is A Hero) Equal to True
                      • Then - Actions
                        • Set VariableSet heal_diff = (heal_amount - ((Real((Strength of heal_target (Include bonuses)))) x REGEN_STRENGTH_VALUE))
                      • Else - Actions
                        • Set VariableSet heal_diff = heal_amount
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • MaxLifeDiffP1 Less than or equal to 0.00
                        • heal_diff Greater than or equal to REGEN_THRESHOLD
                      • Then - Actions
                        • Set VariableSet HealEvent = 0.50
                        • Set VariableSet HealEvent = 0.00
                      • Else - Actions
                  • Else - Actions
            • Set VariableSet heal_integer = heal_indexRef[heal_integer]
          • Else - Actions
    • Set VariableSet heal_exitwhen = (heal_count - 1)
    • For each (Integer heal_integer) from 0 to heal_exitwhen, do (Actions)
      • Loop - Actions
        • Set VariableSet heal_integer = heal_indices[heal_integer]
        • Set VariableSet heal_target = UDexUnits[heal_integer]
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Owner of heal_target) Equal to Player 2 (Blue)
          • Then - Actions
            • Set VariableSet heal_life = (Life of heal_target)
            • Set VariableSet heal_diff = (heal_life - heal_lastLife[heal_integer])
            • Set VariableSet heal_lastLife[heal_integer] = heal_life
            • Set VariableSet heal_amount = (heal_diff - (Max(0.00, heal_regen[heal_integer])))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • MaxLifeDiffP2 Less than or equal to 0.00
                • heal_amount Greater than or equal to HEAL_THRESHOLD
              • Then - Actions
                • Set VariableSet HealEvent = 1.00
                • Set VariableSet HealEvent = 0.00
              • Else - Actions
                • Set VariableSet heal_regen[heal_integer] = ((heal_regen[heal_integer] + heal_diff) x 0.50)
                • Set VariableSet regen_buildup[heal_integer] = (regen_buildup[heal_integer] + heal_diff)
                • Set VariableSet regen_timeleft[heal_integer] = (regen_timeleft[heal_integer] - HEAL_CHECK_INTERVAL)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • regen_timeleft[heal_integer] Less than or equal to 0.00
                  • Then - Actions
                    • Set VariableSet regen_timeleft[heal_integer] = REGEN_EVENT_INTERVAL
                    • Set VariableSet heal_amount = regen_buildup[heal_integer]
                    • Set VariableSet regen_buildup[heal_integer] = 0.00
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (heal_target is A Hero) Equal to True
                      • Then - Actions
                        • Set VariableSet heal_diff = (heal_amount - ((Real((Strength of heal_target (Include bonuses)))) x REGEN_STRENGTH_VALUE))
                      • Else - Actions
                        • Set VariableSet heal_diff = heal_amount
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • MaxLifeDiffP2 Less than or equal to 0.00
                        • heal_diff Greater than or equal to REGEN_THRESHOLD
                      • Then - Actions
                        • Set VariableSet HealEvent = 0.50
                        • Set VariableSet HealEvent = 0.00
                      • Else - Actions
                  • Else - Actions
            • Set VariableSet heal_integer = heal_indexRef[heal_integer]
          • Else - Actions
    • Set VariableSet heal_exitwhen = (heal_count - 1)
    • For each (Integer heal_integer) from 0 to heal_exitwhen, do (Actions)
      • Loop - Actions
        • Set VariableSet heal_integer = heal_indices[heal_integer]
        • Set VariableSet heal_target = UDexUnits[heal_integer]
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Owner of heal_target) Equal to Player 3 (Teal)
          • Then - Actions
            • Set VariableSet heal_life = (Life of heal_target)
            • Set VariableSet heal_diff = (heal_life - heal_lastLife[heal_integer])
            • Set VariableSet heal_lastLife[heal_integer] = heal_life
            • Set VariableSet heal_amount = (heal_diff - (Max(0.00, heal_regen[heal_integer])))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • MaxLifeDiffP3 Less than or equal to 0.00
                • heal_amount Greater than or equal to HEAL_THRESHOLD
              • Then - Actions
                • Set VariableSet HealEvent = 1.00
                • Set VariableSet HealEvent = 0.00
              • Else - Actions
                • Set VariableSet heal_regen[heal_integer] = ((heal_regen[heal_integer] + heal_diff) x 0.50)
                • Set VariableSet regen_buildup[heal_integer] = (regen_buildup[heal_integer] + heal_diff)
                • Set VariableSet regen_timeleft[heal_integer] = (regen_timeleft[heal_integer] - HEAL_CHECK_INTERVAL)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • regen_timeleft[heal_integer] Less than or equal to 0.00
                  • Then - Actions
                    • Set VariableSet regen_timeleft[heal_integer] = REGEN_EVENT_INTERVAL
                    • Set VariableSet heal_amount = regen_buildup[heal_integer]
                    • Set VariableSet regen_buildup[heal_integer] = 0.00
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (heal_target is A Hero) Equal to True
                      • Then - Actions
                        • Set VariableSet heal_diff = (heal_amount - ((Real((Strength of heal_target (Include bonuses)))) x REGEN_STRENGTH_VALUE))
                      • Else - Actions
                        • Set VariableSet heal_diff = heal_amount
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • MaxLifeDiffP3 Less than or equal to 0.00
                        • heal_diff Greater than or equal to REGEN_THRESHOLD
                      • Then - Actions
                        • Set VariableSet HealEvent = 0.50
                        • Set VariableSet HealEvent = 0.00
                      • Else - Actions
                  • Else - Actions
            • Set VariableSet heal_integer = heal_indexRef[heal_integer]
          • Else - Actions
    • Set VariableSet heal_exitwhen = (heal_count - 1)
    • For each (Integer heal_integer) from 0 to heal_exitwhen, do (Actions)
      • Loop - Actions
        • Set VariableSet heal_integer = heal_indices[heal_integer]
        • Set VariableSet heal_target = UDexUnits[heal_integer]
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Or - Any (Conditions) are true
              • Conditions
                • (Owner of heal_target) Equal to Player 21 (Coal)
                • (Owner of heal_target) Equal to Neutral Hostile
          • Then - Actions
            • Set VariableSet heal_life = (Life of heal_target)
            • Set VariableSet heal_diff = (heal_life - heal_lastLife[heal_integer])
            • Set VariableSet heal_lastLife[heal_integer] = heal_life
            • Set VariableSet heal_amount = (heal_diff - (Max(0.00, heal_regen[heal_integer])))
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • heal_amount Greater than or equal to HEAL_THRESHOLD
              • Then - Actions
                • Set VariableSet HealEvent = 1.00
                • Set VariableSet HealEvent = 0.00
              • Else - Actions
                • Set VariableSet heal_regen[heal_integer] = ((heal_regen[heal_integer] + heal_diff) x 0.50)
                • Set VariableSet regen_buildup[heal_integer] = (regen_buildup[heal_integer] + heal_diff)
                • Set VariableSet regen_timeleft[heal_integer] = (regen_timeleft[heal_integer] - HEAL_CHECK_INTERVAL)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • regen_timeleft[heal_integer] Less than or equal to 0.00
                  • Then - Actions
                    • Set VariableSet regen_timeleft[heal_integer] = REGEN_EVENT_INTERVAL
                    • Set VariableSet heal_amount = regen_buildup[heal_integer]
                    • Set VariableSet regen_buildup[heal_integer] = 0.00
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • (heal_target is A Hero) Equal to True
                      • Then - Actions
                        • Set VariableSet heal_diff = (heal_amount - ((Real((Strength of heal_target (Include bonuses)))) x REGEN_STRENGTH_VALUE))
                      • Else - Actions
                        • Set VariableSet heal_diff = heal_amount
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • heal_diff Greater than or equal to REGEN_THRESHOLD
                      • Then - Actions
                        • Set VariableSet HealEvent = 0.50
                        • Set VariableSet HealEvent = 0.00
                      • Else - Actions
                  • Else - Actions
            • Set VariableSet heal_integer = heal_indexRef[heal_integer]
          • Else - Actions
Which makes my map playable although still some performance lag, but I noticed it is now causing bugs with the heal text being delayed (sometimes by 1-3 seconds) and causing the heal text to display even when it shouldn't. I just have a real value variable check (MaxLifeDiff) 0 = run actions(and show text), 1 = do not run actions (and don't show text). There is another trigger that sets the variable to 0 every so often (also tried using a wait and setting it to 0 after an event of it being set to 1, still no good) so the system can catch and show regen incase the variable gets set to 1 from other triggers. This makes me think it is storing the heal value and not clearing it if the conditions aren't met to run the actions, and when they do get met it shows the heal that should have never been shown when MaxLifeDiff gets set to 0.

Wondering how else the Heal Check Loop trigger could be optimized to help with the performance issue and to not show heal text that shouldn't be shown. It also seems like the Heal Check Loop trigger is constantly running and looping, but I think that is how it is supposed to be with the Heal Event system.
 
Level 4
Joined
Apr 22, 2022
Messages
31
For now I guess I just have to scrap the heal event system entirely since everything else works well (Unit Indexer 1.4 with the respawn system suggested above.) Hopefully one day I can get them to all work together cause I would like to have +healing text displayed. @Uncle Thanks a ton for all the help and suggestions!
 
Status
Not open for further replies.
Top