Making units neutral/hostile?

jak3u

New Member
Reaction score
0
How do you make units (i.e. Footman, Archer, etc.) hostile/neutral so that they won't attack you if they see you, but if you attack them, they'll attack back?
 

Chao

Setting sail for fail in the sea of lame.
Reaction score
63
Event:
A Unit is Attacked
Condition:
Unit owned by Neutral Passive ((Assuming you want them left alone))
Owner of Attacking Unit = Whomever you'd like
Actions:
Change Owner of Attacked Unit to Neutral Hostile
Order Attacked Unit to attack Attacking Unit
 

jak3u

New Member
Reaction score
0
Event:
A Unit is Attacked
Condition:
Unit owned by Neutral Passive ((Assuming you want them left alone))
Owner of Attacking Unit = Whomever you'd like
Actions:
Change Owner of Attacked Unit to Neutral Hostile
Order Attacked Unit to attack Attacking Unit

Ahh thanks thanks!!
Uhmm is there anyway you can like make the neutral/hostile patrol?
& is there also a way so that if a neutral/hostile unit "saw" another unit being attacked, then they will help out and chase you?

Like uhmm, ok my plan is to make a village (done) and then make the villagers neutral/hostile so that if they get attacked they will attack back, and also get like guards to patrol the village and when they "see" a villager being attacked they will attack the attacker .
 

jig7c

Stop reading me...-statement
Reaction score
123
try making the villagers a computer player... and when a user attacks a villager, change the alliance of the computer player so the computer and the user become enemies... and then when there is no user unit in the village (make a region for this), change the alliance again...
 

Chao

Setting sail for fail in the sea of lame.
Reaction score
63
Here's how I would do everything you need:

Event:
Map Init
Actions:
Set MemsaverA = Point A
Set MemsaverB = Point B
Order unit to Patrol from Point A to Point B
Call Script = Removepoint(udg_MemsaverA)
Call Script = Removepoint(udg_MemsaverB)
Pick every unit of type (Villager) and add to Villagergroup<2>

That other plan, not too difficult, either... here's how I would do it:

Trigger A:
Event:
A unit is attacked
Condition:
Attacked unit = villager
Attacked unit in Villagergroup equal to True
Action:
Set Villager[VillagerNumber]<1>= Attacked Unit
Remove (attacked unit) from Villagergroup

<1> You'll need to create an array that has a size value equal to the number of villagers in the town.
<2> The villagergroup function will allow you to remove units from the group, thus making that array not multiply over itself as a single unit gets attacked 50 times.

Event:
Every 0.5 seconds of Game Time
Action:
Pick every unit in (units of type = guard) and do actions:
For each integer A from 1 to VillagerNumber do actions:
IF
Picked Unit is in range (1000) of Villager[Integer A]
THEN
Set MemorySaverPoint = Position of Villager[Integer A]
Order Picked Unit to Attack-Move to MemorySaverPoint
Call Script = RemovePoint(UDG_MemorySaverPoint)
ELSE
Do Nothing

I know it's a lot more to take in, but I hope that works for you ..
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top