After some reading I discovered the "unit dies" event can be very demanding. Since a lot of units die in my map, I'm trying to create an alternative to using this event at all costs. I seen someone somewhere say something about using a behavior/effect, then detecting the effect with an event. But I'm running into a slight issue.
If I don't need the killing unit, using a behavior with "Combat: Death Response" and a dummy effect works great. From this point I can use the effect used event. But it has the limitation of not knowing who dealt the killing blow, which is not great. This is useless to me when trying to track how many kills a player has obtained, since you can only retrieve "Caster, Sourge, Target, etc.." from the effect itself.
So I've been toying with "Combat: Damage Response" hoping this is the solution I'm looking for, if I can at least get someone who killed a unit then great, I can give him a +1 to Kills. But I can't even get it to work, it never fires the effect when I kill something. I've added the behavior to my unit, set the chance to 1, placed my effect in the "Handled" area, checked "Fatal", with Location to "Attacker". This in my head looks right, but the game doesn't think so. I've even tried adding the effect to "Exhausted", tried "Defender" for Location, everything I can think of. The problem is the effect never fires.
Maybe I misunderstand how Damage Response works. If so can anyone help me out with how I can accomplish this task? All I need is some way to detect a unit killing something and getting the killing unit from it.
Select "Attacker" in the location of the damage response (or however it is called).
Then the dummy effect that you entered should be executed from the unit with the behavior (caster) to the attacker (target).
Also, it's very helpful to create a small trigger with an effect which prints the caster/target/outer/origin/source unit names, if you need to check which references you currently got inside the effect.
Edit:
Also, yes. Using that might be better than running a trigger with unit dies event, if you only need to detect some chosen units dieing in your map.
Scratch off my last post. After much fiddling and digging around, I finally got it to work! I'm not sure what I changed that fixed it completely, but here is what does work. I'll type up only the relevant fields.
I tested by killing a hostile unit as player 1. The output of the trigger displayed Player: Hostile, Caster: Zergling, Origin: (Nothing), Source: Zergling, Target: Killing Hero. So this means success! I now have a means to get both the dying unit and the killing unit without using "Unit Dies" event.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
After some reading I discovered the "unit dies" event can be very demanding. Since a lot of units die in my map, I'm trying to create an alternative to using this event at all costs. I seen someone somewhere say something about using a behavior/effect, then detecting the effect with an event. But I'm running into a slight issue.
If I don't need the killing unit, using a behavior with "Combat: Death Response" and a dummy effect works great. From this point I can use the effect used event. But it has the limitation of not knowing who dealt the killing blow, which is not great. This is useless to me when trying to track how many kills a player has obtained, since you can only retrieve "Caster, Sourge, Target, etc.." from the effect itself.
So I've been toying with "Combat: Damage Response" hoping this is the solution I'm looking for, if I can at least get someone who killed a unit then great, I can give him a +1 to Kills. But I can't even get it to work, it never fires the effect when I kill something. I've added the behavior to my unit, set the chance to 1, placed my effect in the "Handled" area, checked "Fatal", with Location to "Attacker". This in my head looks right, but the game doesn't think so. I've even tried adding the effect to "Exhausted", tried "Defender" for Location, everything I can think of. The problem is the effect never fires.
Maybe I misunderstand how Damage Response works. If so can anyone help me out with how I can accomplish this task? All I need is some way to detect a unit killing something and getting the killing unit from it.
Select "Attacker" in the location of the damage response (or however it is called).
Then the dummy effect that you entered should be executed from the unit with the behavior (caster) to the attacker (target).
Also, it's very helpful to create a small trigger with an effect which prints the caster/target/outer/origin/source unit names, if you need to check which references you currently got inside the effect.
Edit:
Also, yes. Using that might be better than running a trigger with unit dies event, if you only need to detect some chosen units dieing in your map.
Still nothing happening when the unit with the behavior dies. :(
I can't figure it out. I posted some screenshots of everything I did. It all looks legit to me, but the trigger is never firing.
Scratch off my last post. After much fiddling and digging around, I finally got it to work! I'm not sure what I changed that fixed it completely, but here is what does work. I'll type up only the relevant fields.
Behavior: Buff > Damage Response - Chance:1 - Fatal:Enabled - Handled:"The Effect" - Combat Minimum:0.01 - Combat Minimum Clamp:0.01 - Combat Location: Defender
Effect: Modify Unit > Target Impact Unit: Source
I tested by killing a hostile unit as player 1. The output of the trigger displayed Player: Hostile, Caster: Zergling, Origin: (Nothing), Source: Zergling, Target: Killing Hero. So this means success! I now have a means to get both the dying unit and the killing unit without using "Unit Dies" event.