• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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