• 🏆 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] Integer/Real Variable Size Issues

Status
Not open for further replies.
Level 8
Joined
Mar 17, 2016
Messages
133
I'm faced with an issue I didn't think possible, so I'm not sure why exactly it's occurring but this is what I have so far.

My issue is involving a respawn system, where a unit dies, wait X seconds, you get the idea. However, I noticed that when I tested the respawn it worked, but when I tried to implement it with correct values it no longer worked. The timer is using a variable that is not an array and set to 0, though this still happens when it's replaced with the numbers.

I begun tested what numbers worked and what didn't, and this is what I found:

Here is the respawn (only the relevant parts)

  • The Respawn NH
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in RespawnUnitGroup.) Equal to True
    • Actions
      • Custom script: call GameTimeWait(udg_Respawn_Timer_Creep) <-------------------------------------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Neutral Hostile
        • Then - Actions
          • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at Creep_Point[(Custom value of (Triggering unit))] facing (Random angle) degrees
          • Unit Group - Add (Last created unit) to RespawnUnitGroup
And here are the values I've narrowed it down to

  • TestCommands Copy Copy Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing 2 as An exact match
    • Conditions
    • Actions
      • Set VariableSet Respawn_Timer_Creep = 95.00
  • TestCommands Copy Copy Copy Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing 3 as An exact match
    • Conditions
    • Actions
      • Set VariableSet Respawn_Timer_Creep = 92.00


So when I set the value to 95 or anything above, the trigger will not respawn the unit. I will wait for eternity and it will not come. However, when I change the value down by 3 to 92, for whatever reason every unit that died will respawn flawlessly.

My only good idea is that since my map is quite big it could be that the system is forgetting the values if it waits too long. Not sure if that's even a possibility, though.


I know that I must be missing something. Anyone know what it is?
 
I'm faced with an issue I didn't think possible, so I'm not sure why exactly it's occurring but this is what I have so far.

My issue is involving a respawn system, where a unit dies, wait X seconds, you get the idea. However, I noticed that when I tested the respawn it worked, but when I tried to implement it with correct values it no longer worked. The timer is using a variable that is not an array and set to 0, though this still happens when it's replaced with the numbers.

I begun tested what numbers worked and what didn't, and this is what I found:

Here is the respawn (only the relevant parts)

  • The Respawn NH
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in RespawnUnitGroup.) Equal to True
    • Actions
      • Custom script: call GameTimeWait(udg_Respawn_Timer_Creep) <-------------------------------------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Neutral Hostile
        • Then - Actions
          • Unit - Create 1 (Unit-type of (Triggering unit)) for Neutral Hostile at Creep_Point[(Custom value of (Triggering unit))] facing (Random angle) degrees
          • Unit Group - Add (Last created unit) to RespawnUnitGroup
And here are the values I've narrowed it down to

  • TestCommands Copy Copy Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing 2 as An exact match
    • Conditions
    • Actions
      • Set VariableSet Respawn_Timer_Creep = 95.00
  • TestCommands Copy Copy Copy Copy
    • Events
      • Player - Player 1 (Red) types a chat message containing 3 as An exact match
    • Conditions
    • Actions
      • Set VariableSet Respawn_Timer_Creep = 92.00


So when I set the value to 95 or anything above, the trigger will not respawn the unit. I will wait for eternity and it will not come. However, when I change the value down by 3 to 92, for whatever reason every unit that died will respawn flawlessly.

My only good idea is that since my map is quite big it could be that the system is forgetting the values if it waits too long. Not sure if that's even a possibility, though.


I know that I must be missing something. Anyone know what it is?

A possible explanation is that the unit is removed during that timeframe. The game removes units automatically after decaying.

At that point in your trigger, it's trying to create a unit based on the unit type of a formerly dead unit which no longer exists. This can only happen when the delay is greater than or equal to 95 in your case.

EDIT: (Removed apostrophe from unit's)
 
Last edited:
Level 8
Joined
Mar 17, 2016
Messages
133
That's actually a very likely explanation, in the gameplay constants i believe the decay time is 88 so maybe the death animation and whatever else adds on those few more seconds.

Could I fix this simply by making a "Unit type" array variable and storing the type there when it dies, then calling upon it during the respawn instead of "Triggering Unit"? Or is there a better way
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
^What MyPad said.

How you can fix it:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in RespawnGroup.) Equal to True
    • Actions
      • Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
      • Custom script: local location l = udg_Creep_Point[GetUnitUserData(GetTriggerUnit())]
      • Unit Group - Remove (Triggering unit) from RespawnGroup.
      • Wait 2.00 seconds
      • Custom script: set udg_Creep_Point[0] = l
      • Custom script: set udg_Creep_Type = i
      • Unit - Create 1 Creep_Type for Neutral Hostile at Creep_Point[0] facing Default building facing degrees
      • Unit Group - Add (Last created unit) to RespawnGroup
      • Custom script: call RemoveLocation (l)
      • Custom script: set l = null
Creep_Type = Unit-Type var

Don't forget to remove the Dying unit from RespawnGroup
 
Last edited:
Level 8
Joined
Mar 17, 2016
Messages
133
So I thought that I understood, but clearly I don't because this respawn is still buggy. So the issue I'm now faced with is that not all units are respawning. Some of them respawn flawlessly, though others will simply be lost to the void. I don't understand the internal workings really enough to understand why. My best guess is that the custom values go above 8192 or whatever the max size for an array is.

This is what I have now, everything is there.
And just to be clear I'm using Bribe's Unit Indexer for the custom value thingy

Also to clarify, the units that are not respawning are regular units, not Ancients.


  • RespawnInitialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet Respawn_Timer_Creep = 10.00
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units owned by Neutral Hostile matching ((((Matching unit) is A Hero) Equal to False) and ((((Matching unit) is An Ancient) Equal to False) and ((((Matching unit) is selectable) Equal to True) and (((Matching unit) is A structure) Equal to False)))).) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to RespawnUnitGroup
          • Set VariableSet Creep_Point[(Custom value of (Picked unit))] = (Position of (Picked unit))
  • The Respawn NH
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in RespawnUnitGroup.) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from RespawnUnitGroup.
      • -------- - --------
      • Set VariableSet Creep_Write = (Creep_Write + 1)
      • Set VariableSet Creep_CV_Dying[Creep_Write] = (Custom value of (Triggering unit))
      • Set VariableSet Creep_Type[Creep_Write] = (Unit-type of (Triggering unit))
      • -------- - --------
      • Custom script: call GameTimeWait(udg_Respawn_Timer_Creep)
      • -------- - --------
      • Set VariableSet Creep_Read = (Creep_Read + 1)
      • Unit - Create 1 Creep_Type[Creep_Read] for Neutral Hostile at Creep_Point[Creep_CV_Dying[Creep_Read]] facing (Random angle) degrees
      • Unit Group - Add (Last created unit) to RespawnUnitGroup
      • -------- - --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Moonlight Gargoyle
        • Then - Actions
          • Unit - Order (Last created unit) to Undead Gargoyle - Stone Form.
          • Unit - For Unit (Last created unit), start cooldown of ability Stone Form For Stonebois " over "650.00 seconds.
        • Else - Actions
      • Set VariableSet Creep_CV_Spawning = (Custom value of (Last created unit))
      • Custom script: call RemoveLocation(udg_Creep_Point[udg_Creep_CV_Dying[udg_Creep_Write]])
      • Set VariableSet Creep_Point[Creep_CV_Spawning] = (Position of (Last created unit))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Creep_Read Equal to Creep_Write
        • Then - Actions
          • Set VariableSet Creep_Write = 0
          • Set VariableSet Creep_Read = 0
        • Else - Actions
  • [/hidden]
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
Oh, I see the issue. Bribe's Unit Indexer assigns custom values to units AFTER Map Initialization. There's an Event that he provides that you can use instead, or you can rely on an Elapsed Time event.

If the problem still persists after fixing that then I think it's safe to assume that the issue is either the Point getting removed or the Unit getting removed.

Also, I overlooked some things in my previous trigger, I think this one should work properly:
  • Untitled Trigger 001
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in RespawnGroup.) Equal to True
    • Actions
      • Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())
      • Custom script: local real x = GetLocationX(udg_Creep_Point[GetUnitUserData(GetTriggerUnit())])
      • Custom script: local real y = GetLocationY(udg_Creep_Point[GetUnitUserData(GetTriggerUnit())])
      • Custom script: call RemoveLocation (udg_Creep_Point[GetUnitUserData(GetTriggerUnit())])
      • Unit Group - Remove (Triggering unit) from RespawnGroup.
      • Wait 2.00 seconds
      • Custom script: set udg_Creep_Point[0] = Location(x, y)
      • Custom script: set udg_Creep_Type = i
      • Unit - Create 1 Creep_Type for Neutral Hostile at Creep_Point[0] facing Default building facing degrees
      • Set VariableSet Creep_Point[(Custom value of (Last created unit))] = (Position of (Last created unit))
      • Unit Group - Add (Last created unit) to RespawnGroup
      • Custom script: call RemoveLocation (udg_Creep_Point[0])
 
Last edited:
Level 8
Joined
Mar 17, 2016
Messages
133
Tried changing the intialize to 0.5 seconds of game time elapsed, still no difference. It seems like every time a unit dies there's a random chance as to whether or not they will be respawned correctly with the trigger that I have.
I would use the trigger you posted, but I don't understand a lot of it.

Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())

Is "local integer i" an arbitrary example for an Integer Variable, or is it actually used like that in the trigger editor?


Custom script: set udg_Creep_Point[0] = Location(x, y)

Is this zero array used? Or is it just an example to put the custom value variable in
Also, I need the units to respawn where they are in the editor instead of the position of where they die


Custom script: set udg_Creep_Type = i

How is it that a creep type is set to an integer? I thought it was a string or something
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,539
1) Try using the Event Bribe provides. I think it's something like: UnitIndexEvent becomes equal to 3.0. He describes it in the Unit Indexing system, I think near the bottom of the trigger.

2) Nothing there is arbitrary or an example. I store the coordinates of the dying unit's Creep_Point as "x/y" and I store the unit's Unit-Type Id as "i". Local variables act like "Triggering unit", by that I mean they won't change from outside sources, so their values will remain the same throughout the entire trigger (unless you intentionally set them to something else inside the same trigger). They're a lot more useful than global variables in this sense and part of the reason why GUI is so limited in the first place (since it lacks them).

3) Creep_Point[0] is just an efficient way for me to create a Point using the variables you've provided in your trigger. The Unit Indexer doesn't use Index 0, so you don't have to worry about destroying/leaking Creep_Point[0], it's not going to be set to anything by your Creep System.

4) And speaking on Creep_Type being an Integer. Unit-Type's are Integer values, it's just that you never see this number in GUI because GUI hides all of that ugly stuff from you. So whenever you're using the "Unit-Type" variable in GUI, you're actually storing an Integer value, because that's how the Unit-Types are stored. Like 10213134 = Footman, 13210324 = Huntress, etc... (Not their actual id's).

So to summarize my trigger:
When a creep dies, I use local variables to store it's Unit-Type and the coordinates of it's Creep_Point. I then remove the unit's Creep_Point since it's no longer needed and run the Wait. After the Wait, I convert these stored coordinates back into a Point for us to use in GUI, this is done in the form of Creep_Point[0]. And to create the correct Unit-Type, I set Creep_Type to be equal to "i" (our unit-type id). It's a hybrid Jass/GUI trigger, I tried to keep the important functions as GUI so you would be able to adjust them without issues.
 
Last edited:
Status
Not open for further replies.
Top