I want Pharah to deal extra damage to airborn enemies so I have this code:
Player Took Damage (All, All)
Is In Air(Event Player) == True
Attacker == Hero(Pharah)
Damage(Victim, Attacker, 999)
This doesn’t work and I don’t know why. And if you know how to make it so that the damage from this code doesn’t trigger itself, please let me know!
1 Like
Try pasting this into the workshop editor:
rule("Pharah bonus damage")
{
event
{
Player Dealt Damage;
All;
All;
}
conditions
{
Hero Of(Event Player) == Hero(Pharah);
Is In Air(Victim) == True;
}
actions
{
Damage(Victim, Event Player, 999);
}
}
I think the issue is that Attacker returns a player value rather than a hero value, so you need to use the Hero Of() function. I’ve rewritten the rule to trigger with dealing damage rather than taking damage although this is just preference. I don’t think damage events can trigger their own rule again? If it does let me know and I’ll add to it.
its been a long time since i’ve used the workshop but i think they can, at least under certain conditions, If that does happen i usually avoid it by checking for which weapon did the damage- I cant remember if workshop damage triggers as event ability null or event ability primary fire though.
However there is also a very simple solution that always works, just add wait for 0.016 aka a single frame, to the end of the rule and it cant trigger the rule on the next frame.
(i might be misremembering the frame duration, i cant recall if its 0.0016 or 0.016 but its the lowest value it lets you set the wait to so you can just find out by using 0.0016)
Also im noticing 999 is a very large number, likely just for testing but if the OP wants to deal a % of more damage you can do Event Damage * 0.1to deal 10% extra damage or any other number.. 0.01x is 1% more damage while 1x would be double damage
Finally, and this is very important- since we are dealing with pharah here she has an AOE weapon which when rules try to detect it with damage dealt it doesn’t work.. the AOE hits multiple targets on the same frame but the damage dealt can only trigger once pre frame so it ignores all but one player who get hurt. You would need to use Damage Taken to avoid that bug with AOE attacks. then you can just swap where you use Attacker/Event Player & Victim around
(I first discovered that AOE interaction years ago while testing a custom effect for wreaking ball piledriver)
yeah workshop damage is event ability = null so you just need to add a condition that event ability != null
Good catch on the AoE, didn’t even cross my mind.
It instantly kills the target. What I think is happening is that the KB is applied at the same time as the damage, so the target is considered airborne even if you shoot them while they’re on the ground.
The damage is set to the default 999, just tweak that and it should be alright. I didn’t know how much extra you wanted. A good way of adding extra damage could be to set the damage value to Event Damage x 0.3 or something, then it scales with the AoE.
Just re-read your comment now I’m fully awake - I’ll have a look in the workshop myself when I can as I never actually tested it, just write it on the workshop.codes editor.
do an altitude check instead of is on ground the knockback on the weapon is very small so just check if the players altitude is greater then 0.1 or something and it’ll only apply when the player is higher than 0.1 meters from the ground, if that doesn’t help just try increasing the check minimum requirement
1 Like