• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[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