• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[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:
Level 2
Joined
Feb 27, 2019
Messages
14
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.
Top