• 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.

Prevent "friendly fire"

Status
Not open for further replies.
Level 6
Joined
Feb 25, 2005
Messages
230
Can someone please tell me a nice trigger, or tell me were i can find one here, thet prevents allies from attacking eachother. I'vve tried simple ones, like just order unit to stop, but its kinda buggy and only works from time to time.
 
You can still order a unit to attack a friendly unit... Example: You have two grunts, you click the attack icon and select your other grunt.
Example: You have a grunt and your ally has a grunt, you can order you grunt to attack his grunt.

Those fields in the unit object editor only apply to the units AI, it is still capable of attacking other things.
 
Level 3
Joined
Jul 16, 2005
Messages
27
Code:
Event: Unit is attacked
Conditions: Boolean - ((Owner of attacking unit) is an ally of (owner of attacked unit) equal to TRUE)
Actions: Unit - Order Attacking unit to (Stop), Unit (Pause) (Attacking unit), wait 2 seconds, Unit (unpause) (attacking unit).

That will stop from attacking and make thier unit freeze for 2 second penalty. This has always worked for me along with:
Code:
Event: Unit is attacked
Condition: Boolean - ((Owner of attacking unit) is an ally of (owner of attacked unit) equal to TRUE)
Actions:
  Unit - Order (attacking unit) to stop
  Set Penalty[Player number of attacking unit] = Player[player number of attacking unit] + 1
  If/then/else
    If Integer - Player[player number of attacking unit] equal to 3
    then Unit - Kill attacking unit, Game - Display to [owner of attacking unit]: You have tried to team kill to many times!
    else Do nothing

For that make Player an integer variable with however many numbers of players as the array, then it sets it to +1, so pretty much if they attack 3 times thier guy dies... Good in a resident evil game i suppose... You could go with a smaller penalty like gold loss, turn em into a sheep (;) kam) or just freeze em again. You can also add a wait then set it to -1, so if they try to attack 3 times in 2 seconds it happens etc...
 
Level 6
Joined
Feb 25, 2005
Messages
230
Ok, im gonna use one of thoose triggers, since the "targets allowed" are just data on the units AI.

But while were talking about sheeps, how to turn it into a sheep? Do you need dummy units?, cause i havent learned to use dummy units yet...

If not, just tell me the trigger... :)
 
Level 3
Joined
Aug 11, 2005
Messages
26
Kam said:
You can still order a unit to attack a friendly unit... Example: You have two grunts, you click the attack icon and select your other grunt.
Example: You have a grunt and your ally has a grunt, you can order you grunt to attack his grunt.

Those fields in the unit object editor only apply to the units AI, it is still capable of attacking other things.

no, you're completely wrong. If in the object editor it has enemy checked and allied unchecked when you try to target an ally it will say 'Cannot target allied units'
 
Level 3
Joined
Aug 11, 2005
Messages
26
Kam said:
With a spell, jesus. The basic attack can target your own units. Do I really have to make a video for you when you can just play any wc map and see for yourself? I just did it, took me two secs to map a new map to test. You do it.

But does the unit attack himself? no... thats what the guy needs
 
Level 6
Joined
Feb 25, 2005
Messages
230
Man, yhis is one hot discussion... :shock:
Just to get things sorted out, i meant a trigger to prevent "assholes" from using the "attack" aiming to kill allied players on my map.

And to add my own opinion, to fill in the boxes in "targets allowed" didnt work for me. I had no allied or friend, but i had enemy signed as a target, but i could still attack my allies.

I will use trigger, since that also punishes the player who attacks...
 
Events

A unit is attacked

Conditions

(Owner of (Attacking unit)) Not equal to (Owner of (Attacked unit))
(((Attacked unit) is A ground unit) Equal to true) or ((((Attacked unit) is A flying unit) Equal to True) or (((Attacked unit is A structure) Equal to True))
((Attacked unit) belongs to an ally of (Owner of (Attacking unit))) Equal to True
((Attacked unit) is A neutral unit) Equal to False

Actions

Unit - Explode (Attacking unit)
 
Status
Not open for further replies.
Top