So why does it work when we make the Bunkers variable a simple unit variable?
EDIT: And like I said in my previous post here, it's definitely behaving like events are registered by reference rather than value.
Also, I should point out that if you made the initial value of gv_bunkers (still an array variable in this experiment) point to the nydus network building, it still screws up.
Not quite. As he said, and as I tested it, it works fine if you use a simple unit variable. It's when you turn it into an array (and register the event with a valid slot in the array) that things go awry. While I understand that it's a coding practice carried over from WC3 to avoid using variables in events, since WC3 binds events by value, these experiments have shown that the event responds as if it binds by reference.
EDIT: Experimented with it again, I made a trigger that changes the Bunker variable (not an array anymore) to the Nydus Network building upon typing "-test". I first had the marines attack the Bunker - trigger fired. Then I typed "-test" and it started reporting the Nydus Network building's decay damage.
Further evidence that this event appears to function by reference.
EDIT 2: "Unit is Attacked" behaves the exact same way as reported above in every post in this thread.
Also, while it's true that using the condition solves the problem, it is inefficient. You now have the trigger firing every time any unit takes damage (and it checks the condition). If we could get it so array variables are ok with events, then you can dramatically reduce the number of trigger calls.
It's not game breaking or anything, I'm just pointing out that it is more inefficient than it should be.
I'll take a crack at this. I'll edit this post when I've come to a conclusion. :)
EDIT: Okay, looked at it. Apparently, it also fires if the marines shoot at each other. So it's not just zerg building decay. I'd love to know the reason behind this (what's going on with the memory stack), but it does appear that the event is unstable with unit arrays.
Congrats sir, you deserve at least a month of premium Curse.
Assuming that's true, then shouldn't Blizzard make UnitRefFromVariable capable of parsing array brackets?
That's probably a 2 minutes fix.
@MotiveMe: Go
So why does it work when we make the Bunkers variable a simple unit variable?
EDIT: And like I said in my previous post here, it's definitely behaving like events are registered by reference rather than value.
Also, I should point out that if you made the initial value of gv_bunkers (still an array variable in this experiment) point to the nydus network building, it still screws up.
So no, sorry, it's not working as intended.
@progammer: Go
Not quite. As he said, and as I tested it, it works fine if you use a simple unit variable. It's when you turn it into an array (and register the event with a valid slot in the array) that things go awry. While I understand that it's a coding practice carried over from WC3 to avoid using variables in events, since WC3 binds events by value, these experiments have shown that the event responds as if it binds by reference.
EDIT: Experimented with it again, I made a trigger that changes the Bunker variable (not an array anymore) to the Nydus Network building upon typing "-test". I first had the marines attack the Bunker - trigger fired. Then I typed "-test" and it started reporting the Nydus Network building's decay damage.
Further evidence that this event appears to function by reference.
EDIT 2: "Unit is Attacked" behaves the exact same way as reported above in every post in this thread.
Also, while it's true that using the condition solves the problem, it is inefficient. You now have the trigger firing every time any unit takes damage (and it checks the condition). If we could get it so array variables are ok with events, then you can dramatically reduce the number of trigger calls.
It's not game breaking or anything, I'm just pointing out that it is more inefficient than it should be.
@KelvCM: Go
I'll take a crack at this. I'll edit this post when I've come to a conclusion. :)
EDIT: Okay, looked at it. Apparently, it also fires if the marines shoot at each other. So it's not just zerg building decay. I'd love to know the reason behind this (what's going on with the memory stack), but it does appear that the event is unstable with unit arrays.
Congrats sir, you deserve at least a month of premium Curse.