[Solved] Player is enemy or vice versa (Wurst)

Status
Not open for further replies.
Level 2
Joined
Feb 27, 2019
Messages
14
Is the following check necessary so that the killer receives bounty if either they are enemies with killed or vice versa?

If I'm not mistaken, a player may be an enemy towards another without the reverse being true, and hence this check. Just wanted to confirm whether I'm doing a useless check or not, thanks.
Wurst:
function unit.checkBountyValidFor(player killer) returns bool
    let killed = this.getOwner()
    return (killed != killer) and
           (killed.isEnemyOf(killer) or killer.isEnemyOf(killed))
Usage example:
Wurst:
public function unit.bountyOnHeroFor (player killer)
    if this.checkBountyValidFor(killer)
       let lvl = GetHeroLevel(this) * 2 + 20
       killer.earnGoldFrom(this, GetRandomInt(0, 200) + lvl * lvl )
 
Last edited:
Thanks. I have checked it works like that in Warcraft but was for some reason unsure does it carry over to jass and wurst. Thanks for confirming
 
Status
Not open for further replies.
Back
Top