I am almost certain that this has to do with threading inside the game itself. Whenever the unit dies, the game probably spawns one thread to clean up the unit's data (Remove it from unit groups, play the death animation, so on...), and another one to check for triggers. If the cleanup thread has already disposed of the buffs on the unit, your trigger is not going to work, but it is impossible to determine which is going to happen first (Depends on which gets cpu time first).
This is really just a guess, but I have seen similar behaviors in some triggers that I was trying, so I decided to take different approaches to what I was doing. You could add some debugging message outside and inside of your if condition in your trigger just to see if this seems like it is accurate for your situation though...
Try changing it to 'Unit takes fatal damage' and add a 'Make unit take no damage' at the start and 'kill unit' at the end. Should make sure it checks it before the unit dies.
This may actually work, because when I had a bunch of units spawn and gave them an attack command at the exact same time, they wouldn't go, but if I added a split second after they spawned to command them to attack, it worked perfectly.
Well considering the Unit is dead .... It prolly doesnt have any buffs on it any more youd think.
This could be it. But it still works some times...
I tried the .1 wait, it doesn't change anything, still randomly works. The problem isn't the attacking, they still attack when they actually spawn, it's that they don't always spawn.
I may have to try a different route, unless anyone else has some ideas.
This could be it. But it still works some times...
I tried the .1 wait, it doesn't change anything, still randomly works. The problem isn't the attacking, they still attack when they actually spawn, it's that they don't always spawn.
I may have to try a different route, unless anyone else has some ideas.
It's very likely that's the problem, because I have a trigger that spawns something with the event Any Unit Dies and the trigger has no problem identifying the location of where that unit was to spawn the item on their corpse. Your trigger is very similar to mine except that I'm not checking for a buff.
Is there a way to do this in the data editor, perhaps how some zerg buildings spawn mobs when they die, but checking for that infestor condition?
If you have to test buffs, attributes, etc... it's always better to use the 'Unit Takes Damage' with the fatal damage checked. That way the unit isn't dead when you test for buffs (and cleared). If that doesn't work then you might want to recheck how your buff is applied, and if there's a duration on the buff. If the buff isn't even present when your trigger checks then it won't spawn even if the trigger is perfectly coded.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Ok, I created a trigger. It's supposed to check if the unit dying has the behavior buff : infected on them.
If they do, the killer of the unit gets a new unit spawned in the place of the dying unit.
Now it works..... but only some times. I tested it out, sometimes the new unit spawns, other times nothing happens. How could this be?
@HatTruck: Go
I am almost certain that this has to do with threading inside the game itself. Whenever the unit dies, the game probably spawns one thread to clean up the unit's data (Remove it from unit groups, play the death animation, so on...), and another one to check for triggers. If the cleanup thread has already disposed of the buffs on the unit, your trigger is not going to work, but it is impossible to determine which is going to happen first (Depends on which gets cpu time first).
This is really just a guess, but I have seen similar behaviors in some triggers that I was trying, so I decided to take different approaches to what I was doing. You could add some debugging message outside and inside of your if condition in your trigger just to see if this seems like it is accurate for your situation though...
Try changing it to 'Unit takes fatal damage' and add a 'Make unit take no damage' at the start and 'kill unit' at the end. Should make sure it checks it before the unit dies.
Thanks, but that didn't work either :(
Blizzard is fucking me again!
I even tried moving the condition to the trigger instead of the if-then statement, but no dice.
@HatTruck: Go
maybe if you insert a 0.1 second game time wait before the create unit? :)
(guessing)
@piepgras: Go
This may actually work, because when I had a bunch of units spawn and gave them an attack command at the exact same time, they wouldn't go, but if I added a split second after they spawned to command them to attack, it worked perfectly.
@Xenothral: Go
Well considering the Unit is dead .... It prolly doesnt have any buffs on it any more youd think.
This is a perfect expample of things that should be done in the Data Editor.
Basically it looks like your trying to spawn specific units when a unit dies that has a specific debuff on it.
I would suggest looking for how to make an actuall ability that does this.
This could be it. But it still works some times...
I tried the .1 wait, it doesn't change anything, still randomly works. The problem isn't the attacking, they still attack when they actually spawn, it's that they don't always spawn.
I may have to try a different route, unless anyone else has some ideas.
It's very likely that's the problem, because I have a trigger that spawns something with the event Any Unit Dies and the trigger has no problem identifying the location of where that unit was to spawn the item on their corpse. Your trigger is very similar to mine except that I'm not checking for a buff.
Is there a way to do this in the data editor, perhaps how some zerg buildings spawn mobs when they die, but checking for that infestor condition?
If you have to test buffs, attributes, etc... it's always better to use the 'Unit Takes Damage' with the fatal damage checked. That way the unit isn't dead when you test for buffs (and cleared). If that doesn't work then you might want to recheck how your buff is applied, and if there's a duration on the buff. If the buff isn't even present when your trigger checks then it won't spawn even if the trigger is perfectly coded.