• 🏆 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!

[Discussion] Anti Friendly Fire

Status
Not open for further replies.
Level 8
Joined
Oct 2, 2013
Messages
288
So I wanted to remove all friendly fire mechanics -> Meaning you cannot -attack- allied units.

  • Unit - Any Unit is issued an order to Attack
  • (Player (Owner of (Triggering unit)) is giving player (Owner of (Target unit for (Triggering order))) Allied Chat) == True
  • Unit - Order (Triggering unit) to ( Stop) (Replace Existing Orders)
My first thought was this trigger, but I quickly came to wonder if there were better ways.
The trigger seems to work fine. But would it be better to provide anti-friendly-fire features through the Data Editor? I know you can denie Weapons from hitting allied units. Or maybe somebody knows an even better trigger than the one I've made.

Either way, I was just wondering what people's thoughts are about anti-friendly-fire mechanics and how to provide them.

Thanks for your interest!
 
Level 13
Joined
Mar 19, 2010
Messages
870
JASS:
scope FriendlyAttackSystem initializer init

    private function Actions takes nothing returns nothing
        call IssueImmediateOrder(GetAttacker(), "stop")
    endfunction
    
    private function Conditions takes nothing returns boolean
        return IsUnitAlly(GetAttacker(), GetOwningPlayer(GetTriggerUnit()))
    endfunction

    private function init takes nothing returns nothing
        local trigger t = CreateTrigger()
        
        call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ATTACKED)
        call TriggerAddCondition(t, Condition( function Conditions ))
        call TriggerAddAction(t, function Actions )
    
        set t = null
    endfunction

endscope
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Does it work for you or did I do something wrong?
No, it is meant to throw a syntax error as this is StarCraft II and not Warcraft III.

Generally friendly fire systems are not needed unless your map is infested by trolls. In any case you should not deny players from killing their own units as there are times one may want to (eg if they get stuck).
 
Level 8
Joined
Oct 2, 2013
Messages
288
rofl

I feel you, and I agree about killing own units. As for troll infestations, I want make it safe in worst case scenario. As much as I hate to think about it, there will always be trolls somewhere, no matter where you go on the internet.
 
Status
Not open for further replies.
Top