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

Something wrong with variables

Status
Not open for further replies.
Level 7
Joined
Jul 4, 2007
Messages
249
Something has gone completely mad with my variables, I have absolutely no idea why it happens. It's just so random, things that worked before has just stopped working without any major changes. I've loaded my backup from 17 days ago and it's also broken and it was certainly working back then. Does someone know what's happening? I'm using 1.31 and have done since a few weeks ago.
 
Level 7
Joined
Jul 4, 2007
Messages
249
Actually I'm starting to sort things out and it wasn't as bad as I first thought (as usual). I recently implemented a few new systems at the same time without really understanding how they work, and I had so many plans on what I was going to do with the help of these new systems and then some random spells that I hadn't been working on unexpectedly stopped working. So I felt like fine, I'll just check with the older version that is working, but it wasn't, so I guess I panicked a little bit. It turns out not as many spells from the old version were broken as I first expected, and not for the same reasons. So there were the bugs in the new version, and the bugs in the old version mixing everything up in my head.
 
Level 7
Joined
Jul 4, 2007
Messages
249
Okay so here's one thing I can't wrap my head around, value of unit is changed after Pick every unit, but how?
  • Houdini Time Freeze start
    • Events
    • Conditions
    • Actions
      • Set unit = (Casting unit)
      • Set tempLoc = (Position of unit)
      • Set unitGrp = (Units within 2000.00 of tempLoc)
      • Custom script: call RemoveLocation(udg_tempLoc)
      • Game - Display to (All players) the text: (Name of unit)
      • Unit Group - Pick every unit in unitGrp and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff (Item Ankh) Buff ) Equal to False
            • Then - Actions
              • Unit Group - Add (Picked unit) to Houdini_freezeUnitGrp
              • Unit - Pause (Picked unit)
              • Animation - Change (Picked unit)'s animation speed to 0.00% of its original speed
            • Else - Actions
      • Custom script: call DestroyGroup(udg_unitGrp)
      • Game - Display to (All players) the text: (Name of unit)
      • Unit - Unpause unit
      • Set Houdini_freezeOn = True
      • Animation - Change unit's animation speed to 100.00% of its original speed
      • Countdown Timer - Start Houdini_timeFreezeTimer as a One-shot timer that will expire in Houdini_timeFreezeDur[(Level of (Houdini) Time Freeze (Trigger) for unit)] seconds
      • Unit - For unit, Ability (Houdini) Time Freeze (Trigger), Disable ability: True, Hide UI: True
      • Unit - For unit, Ability (Houdini) Freeze Releaze , Disable ability: False, Hide UI: False
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,888
Not sure what you mean, but Pick every unit basically does:
Picks the first created unit (in the map) from the group, does whatever actions you tell it to do, then picks another unit and repeats the process again.
 
Level 7
Joined
Jul 4, 2007
Messages
249
Not sure what you mean, but Pick every unit basically does:
Picks the first created unit (in the map) from the group, does whatever actions you tell it to do, then picks another unit and repeats the process again.
This variable changes
  • Set unit = (Casting unit)
After this
  • Unit Group - Pick every unit in unitGrp and do (Actions)
This text is just to check the variable
  • Game - Display to (All players) the text: (Name of unit)
 
Level 7
Joined
Jul 4, 2007
Messages
249
Then put several game messages before and after each action in the pick every unit action to see when it changes.
It looks like this, Magic Arts Master is the correct and Lord of the Seven is where it flips
Untitled.jpg
When doing this
  • Game - Display to (All players) the text: (1 + (Name of unit))
  • Unit Group - Pick every unit in unitGrp and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) has buff (Item Ankh) Buff ) Equal to False
        • Then - Actions
          • Unit Group - Add (Picked unit) to Houdini_freezeUnitGrp
          • Game - Display to (All players) the text: (2 + (Name of unit))
          • Game - Display to (All players) the text: ((Picked) + (Name of (Picked unit)))
          • Unit - Pause (Picked unit)
          • Animation - Change (Picked unit)'s animation speed to 0.00% of its original speed
        • Else - Actions
It's always this specific unit affecting the variable when getting added to the group.
 
Last edited:
Level 7
Joined
Jul 4, 2007
Messages
249
These are the rest of the triggers where Houdini_freezeUnitGrp is used, but it's all irrelevant anyways.
Can't be triggered because timer wasn't started yet when problem occurs.
  • Houdini Time Freeze end
    • Events
      • Time - Houdini_timeFreezeTimer expires
    • Conditions
    • Actions
      • Set unit = Magic Arts Master 0005 <gen>
      • Set Houdini_freezeOn = False
      • Unit Group - Pick every unit in Houdini_freezeUnitGrp and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) has buff (Item Ankh) Buff ) Equal to False
            • Then - Actions
              • Unit - Unpause (Picked unit)
              • Animation - Change (Picked unit)'s animation speed to 100.00% of its original speed
            • Else - Actions
      • Custom script: call DestroyGroup(udg_Houdini_freezeUnitGrp)
      • Set Houdini_freezeUnitGrp = (Units of type No unit-type)
      • Unit - For unit, Ability (Houdini) Freeze Releaze , Disable ability: True, Hide UI: True
      • Unit - For unit, Ability (Houdini) Time Freeze (Trigger), Disable ability: False, Hide UI: False
Triggered by another ability
  • Houdini Time Freeze unfreeze
    • Events
    • Conditions
    • Actions
      • Set target = (Target unit of ability being cast)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (target has buff (Item Ankh) Buff ) Equal to True
        • Then - Actions
          • Animation - Change target's animation speed to 100.00% of its original speed
          • Unit - Unpause target
          • Unit - Make target Vulnerable
          • Unit - Remove classification of Mechanical from target
          • Unit - Remove (Item Ankh) Buff buff from target
          • Unit - Set life of target to 50.00%
          • Animation - Play target's stand animation
          • Special Effect - Create a special effect attached to the origin of target using Abilities\Spells\Human\ReviveHuman\ReviveHuman.mdl
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Destroy (Load 0 of (Key (Target unit of ability being cast)) in ankhHash)
          • Hashtable - Clear all child hashtables of child (Key (Target unit of ability being cast)) in ankhHash
        • Else - Actions
          • Unit - Unpause target
          • Animation - Change target's animation speed to 100.00% of its original speed
      • Unit Group - Remove target from Houdini_freezeUnitGrp
Only affects enemies (Lord of the Seven is an ally)
  • Houdini Time Freeze unit within
    • Events
      • Unit - A unit comes within 2000.00 of Magic Arts Master 0005 <gen>
    • Conditions
      • ((Triggering unit) belongs to an enemy of (Owner of Magic Arts Master 0005 <gen>)) Equal to True
      • Houdini_freezeOn Equal to True
    • Actions
      • Set unit = (Triggering unit)
      • Unit - Pause unit
      • Animation - Change unit's animation speed to 0.00% of its original speed
      • Unit Group - Add unit to Houdini_freezeUnitGrp
 
Last edited:
Level 6
Joined
Mar 7, 2011
Messages
124
Are there any other triggers which can set the global var "unit"'s value, besides:

  • Houdini Time Freeze unit within
    • Events
      • Unit - A unit comes within 2000.00 of Magic Arts Master 0005 <gen>
    • Conditions
      • ((Triggering unit) belongs to an enemy of (Owner of Magic Arts Master 0005 <gen>)) Equal to True
      • Houdini_freezeOn Equal to True
    • Actions
      • Set unit = (Triggering unit)
      • Unit - Pause unit
      • Animation - Change unit's animation speed to 0.00% of its original speed
      • Unit Group - Add unit to Houdini_freezeUnitGrp

An event can fire in response to another piece of code, and the corresponding actions for that event will occur immediately, short-cutting original execution. Imagine you have a function to kill a unit and then tell all players about it. But say that there's an event for a specific unit's death, and we just happen to be killing that unit. The actions related to the event of the units death will kick off immediately on it's death, and will execute before your code to tell all players about it

Try adding a print message right before every single instance that you call "Set unit = ...", particularly the one I just quoted above, just to check if its somehow running despite your expectations
 
Level 7
Joined
Jul 4, 2007
Messages
249
Are there any other triggers which can set the global var "unit"'s value, besides:



An event can fire in response to another piece of code, and the corresponding actions for that event will occur immediately, short-cutting original execution. Imagine you have a function to kill a unit and then tell all players about it. But say that there's an event for a specific unit's death, and we just happen to be killing that unit. The actions related to the event of the units death will kick off immediately on it's death, and will execute before your code to tell all players about it

Try adding a print message right before every single instance that you call "Set unit = ...", particularly the one I just quoted above, just to check if its somehow running despite your expectations
Uhm yes, I'm using the unit variable in pretty much every trigger. The only thing I can think of that would change the value is if 1, some other trigger picks every unit from unit group (like in Houdini Time Freeze end trigger) or 2, another trigger has the same event. Neither of those are true.
But yea, maybe I should just give seperate variables to all triggers, but in a way it's quite nice to have it like this to get a better understanding of how things operate.

So I've tried with only the start trigger enabled without success. What's interesting is that if I do this it works fine
  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing aa as An exact match
    • Conditions
    • Actions
      • Set unit = Magic Arts Master 0005 <gen>
      • Game - Display to (All players) the text: (Name of unit)
      • Unit Group - Add Lord of the Seven 0141 <gen> to Houdini_freezeUnitGrp
      • Game - Display to (All players) the text: (Name of unit)
So I thought it might be because of the unitGrp variable, but I disabled all the triggers I use that in and it still doesn't work.
 
Last edited:
Level 6
Joined
Mar 7, 2011
Messages
124
Uhm yes, I'm using the unit variable in pretty much every trigger
well you made me laugh during an otherwise very long day, so that's something

youre trying to solve the problem as if you know all possible explanations for it, because you keep looking at it as "well its not X or Y, so result Z shouldn't be possible." instead look at it in the reverse, assume the result makes sense, and try to figure which variable FDSA you didn't account for

But yea, maybe I should just give seperate variables to all triggers, but in a way it's quite nice to have it like this to get a better understanding of how things operate.
what about trying it temporarily, as an alternative to adding a debug call before any set unit call. create a new unit global and use it just for the Houdini functionality, and see if the bug still happens. If it doesn't happen, then it was something outside of the Houdini module interferring, if it does still happen, then it's likely something inside the module, maybe some weird interaction with the group enum...
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
  • Game - Display to (All players) the text: (1 + (Name of unit))
  • Unit Group - Pick every unit in unitGrp and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) has buff (Item Ankh) Buff ) Equal to False
        • Then - Actions
          • Unit Group - Add (Picked unit) to Houdini_freezeUnitGrp
          • Game - Display to (All players) the text: (2 + (Name of unit))
          • Game - Display to (All players) the text: ((Picked) + (Name of (Picked unit)))
          • Unit - Pause (Picked unit)
          • Animation - Change (Picked unit)'s animation speed to 0.00% of its original speed
        • Else - Actions
Nothing in this bit of code (or anything else in the whole trigger, for that matter) causes an event to fire. There is no "unit is added to group" event, no "unit is paused" event, and no "unit animation speed is changed" event. Checking a buff just checks the level of the ability for the unit. Picking units in a group doesn't have an event associated with it either. I'm honestly baffled.

The only thing that springs to mind is that I know displaying text can be a little slow (printing a message in a 0.03 periodic trigger will noticeably slow it down, for example) so it is possible that simply printing the information interrupts the thread briefly and in that time another queued trigger runs that changes the value of the variable before the print 'finishes'. You could test this by using another variable to temporarily store the value of unit:

  • Game - Display to (All players) the text: (1 + (Name of unit))
  • Unit Group - Pick every unit in unitGrp and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Picked unit) has buff (Item Ankh) Buff ) Equal to False
        • Then - Actions
          • Unit Group - Add (Picked unit) to Houdini_freezeUnitGrp
          • Unit - Pause (Picked unit)
          • Animation - Change (Picked unit)'s animation speed to 0.00% of its original speed
        • Else - Actions
  • Set OtherUnit = unit
  • Game - Display to (All players) the text: (2 + (Name of OtherUnit))
Honestly I don't expect this to be any different, though.
 
Level 7
Joined
Jul 4, 2007
Messages
249
youre trying to solve the problem as if you know all possible explanations for it, because you keep looking at it as "well its not X or Y, so result Z shouldn't be possible."
No I'm not I'm just saying that this is all I can think of, and that's why I'm asking for help.

what about trying it temporarily
I've tried it and it works, but that was kinda expected. Still good to be certain though.
So the question is, how is this possible, when I do the exact same thing in another trigger and it doesn't give the same result.

Nothing in this bit of code (or anything else in the whole trigger, for that matter) causes an event to fire. There is no "unit is added to group" event, no "unit is paused" event, and no "unit animation speed is changed" event. Checking a buff just checks the level of the ability for the unit. Picking units in a group doesn't have an event associated with it either. I'm honestly baffled
Exactly what I was thinking, I'm so confused.
The only thing that springs to mind is that I know displaying text can be a little slow (printing a message in a 0.03 periodic trigger will noticeably slow it down, for example) so it is possible that simply printing the information interrupts the thread briefly and in that time another queued trigger runs that changes the value of the variable before the print 'finishes'.
The whole point of using the text messages in the first place is because the trigger didn't function properly. It seems logical too that when the value of unit changes it changes into the current picked unit, which always is the same one aswell, so I'm pretty sure the text messages are correct.
 
Last edited:
Level 6
Joined
Mar 7, 2011
Messages
124
Nothing in this bit of code (or anything else in the whole trigger, for that matter) causes an event to fire. There is no "unit is added to group" event, no "unit is paused" event, and no "unit animation speed is changed" event. Checking a buff just checks the level of the ability for the unit. Picking units in a group doesn't have an event associated with it either. I'm honestly baffled.
that's a really good point...

Sk0, you should also try:
commenting out the DestroyGroup call after the group enum in Houdini Time Freeze start, i wonder if group recycling is relevant
create a new unit of the same type as Lord of the Seven and see if the bug happens for the new unit as well, i wonder if the original units handle has become corrupted / non unique
pyro's suggestion, because while it might not have caused the original issue, it might be causing a new issue
 
Level 7
Joined
Jul 4, 2007
Messages
249
that's a really good point...

Sk0, you should also try:
commenting out the DestroyGroup call after the group enum in Houdini Time Freeze start, i wonder if group recycling is relevant
create a new unit of the same type as Lord of the Seven and see if the bug happens for the new unit as well, i wonder if the original units handle has become corrupted / non unique
pyro's suggestion, because while it might not have caused the original issue, it might be causing a new issue
Tried creating a new unit and it works. What does this mean?

It has functioned properly before I'd like to mention
 
Level 6
Joined
Mar 7, 2011
Messages
124
I've tried it and it works, but that was kinda expected. Still good to be certain though.
So the question is, how is this possible, when I do the exact same thing in another trigger and it doesn't give the same result.
First off, Pyro's point about no relevant WC events is still really good. I'm not sure what in your houdini code would cause an event to fire

But im not sure what you mean by kinda expected, i still think this is an important clue. It suggests that execution is switching to entirely different code when it was supposed to just be enumerating the group. That different code is what's likely overwriting the value of the unit to be the lord of the seven, not the code you originally posted

I'd suggest reverting back again, and then putting a debug message before every line you set the unit global, to see which of those lines (if any) is actually the one running unexpectedly. Because everything seems to revolve around the lord of the seven dude, i'd start with that functionality and expand my search testing every handful of debug messages. Essentially what you're looking for is:

2 Magic Arts Master
(Picked) Lord of the Seven
2 Lord of the Seven

to become this:

2 Magic Arts Master
(Picked) Lord of the Seven
LOLOL I wasn't supposed to fire right now!!
2 Lord of the Seven

Tried creating a new unit and it works. What does this mean?

It has functioned properly before I'd like to mention
Did you fully replace the original lord of the seven unit, triggers too? This clue has a few different explanations, the most likely one being that the original lord of the seven has related functionality/triggers that are contributing to the problem, while the new one doesn't. More complicated answers are still possible, but i think this is the most likely
 
Level 7
Joined
Jul 4, 2007
Messages
249
Did you fully replace the original lord of the seven unit, triggers too? This clue has a few different explanations, the most likely one being that the original lord of the seven has related functionality/triggers that are contributing to the problem, while the new one doesn't. More complicated answers are still possible, but i think this is the most likely
No it's not fully replaced with triggers, but is greatly reduced in numbers so it should be much easier to find now. I'll take a quick look at it today but I'm going away for the weekend so might not have time to solve it.

Anyways thanks everyone for your help, it has been very educational :D

Actually I found it instantly, I had this trigger event in another trigger which caused it
  • Unit - Lord of the Seven 0141 <gen> Is issued an order with no target
I'm still not sure why this is triggered though, any ideas?
This trigger is also one of the first triggers I've done on the map, and it hasn't been triggered before.
 
Last edited:
Status
Not open for further replies.
Top