• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

How to prevent a player from attacking his allies

Status
Not open for further replies.
Level 4
Joined
Aug 24, 2005
Messages
50
hi,
the title is the question already.

how can i make a unit ordered to attack an allied unit to stop without defining it again and again for each player/playergroup, just by checking if the 2 units are allied?
(in other words, how can i script such an ally-check system?)
 
event
unit is attacked

condition
attacking unit belongs to an ally of owner of attacked unit equal to true

action
order attacking unit to stop

this doesnt seem to work.
i tried to use conditions this way:
a unit is attacked
-attacking unit is p1
-attacked unit is p2 (p1+p2 are allied)
->order attacking unit to "stop"

this had absolutely no effect :/

and the way with the variable for the attacking unit .. this should work for sure but using it on a map with lots of units might cause problems i think - besides, i always prefer to use a short way to keep the map as small as possible :)
 
this doesnt seem to work.
i tried to use conditions this way:
a unit is attacked
-attacking unit is p1
-attacked unit is p2 (p1+p2 are allied)
->order attacking unit to "stop"

this had absolutely no effect :/

and the way with the variable for the attacking unit .. this should work for sure but using it on a map with lots of units might cause problems i think - besides, i always prefer to use a short way to keep the map as small as possible :)

Try doing what darkrider said instead.
(Owner of (Attacked unit)) is an ally of (Owner of (Attacking unit))
 
  • AntiAllyAttack
    • Events
      • Unit - A unit is attacked
    • Conditions
      • ((Triggering unit) belongs to an ally of (Owner of (Attacking unit))) equal to True
    • Actions
      • Unit - Order (Attacking unit) to stop
Strange, trigger listed above works fine for me...

...Well, the only solution I see is to pause unit before giving order and unpause after that:

  • AntiAllyAttack
    • Events
      • Unit - A unit is attacked
    • Conditions
      • ((Triggering unit) belongs to an ally of (Owner of (Attacking unit))) equal to True
    • Actions
      • Unit - Pause (Attacking unit)
      • Unit - Order (Attacking unit) to stop
      • Unit - Unpause (Attacking unit)
Pausing unit should break his current order (attack).
 
Maybe this will work

  • Attack
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(attack))
      • ((Target unit of issued order) belongs to an ally of (Owner of (Triggering unit))) Equal to True
    • Actions
      • Unit - Order (Triggering unit) to Stop
 
Copied straight from my map for you, so I know it works.

Events
Unit - A unit Is attacked
Conditions
((Attacked unit) belongs to an ally of (Owner of (Attacking unit))) Equal to True
(Unit-type of (Attacking unit)) Not equal to Dummy Unit
Actions
Unit - Order (Attacking unit) to Stop
 
Newbie

Can't you just change the 'targets allowed' in the object editor. Just check the box that says 'Enemy' and uncheck the box that says 'Friend'
That should stop units from attacking other allied unit
:spell_breaker:
 
Status
Not open for further replies.
Back
Top