I wrote something similar to this earlier but not really the same thing as it had more to do with machine performance, so I thought i would start fresh.
I'm working on a siege map and what I want to do is that when a player (except player11) attacks player12, the attacked unit shall attack the attacking unit (which always is a hero), I came up with some code to cover it but i'm having big trouble with it , which i will explain later:
But what I didn't think of is that every time a unit owned by ex player1 attacks player12 that unit will attack them: meaning that if p1 hits p12, then it works perfectly and p12 attacks p1. But the second time when p1 attacks the same unit again, it may happen (and definitely will) that p12 already has started to attack p1 again, but the attack order is canceled and replaced with another attack order issued by this trigger, meaning that the continued attacks of p1 will interrupt p12's original attack orders already targeting p1. This means that the p12 unit will not be able to get an normal attack flow but will sort of be lagging by first starting to attack then starting to attack again, hitting, attacking, attacking hitting and so on :banghead:
I'm having a hard time explaining this...
What I want instead is that the trigger will only be run if p12 is NOT attacking p1 but I haven't found any good way of dealing with it. Before I tried this trigger out I tried changing priority of heroes to 20 but that didn't work either, even if I specifically ordered an attack order on a unit, the unit continued it's previous attack order and target...
Ideas or any code is welcome. Thx.
I'm working on a siege map and what I want to do is that when a player (except player11) attacks player12, the attacked unit shall attack the attacking unit (which always is a hero), I came up with some code to cover it but i'm having big trouble with it , which i will explain later:
Code:
HeroAttackPriority
Events
Unit - A unit owned by Player 12 (Brown) Is attacked
Conditions
((Owner of (Attacking unit)) is an ally of Player 1 (Red)) Equal to True
(Owner of (Attacking unit)) Not equal to Player 11 (Dark Green)
Actions
Unit Group - Pick every unit in (Units within 512.00 of (Position of (Attacked unit)) matching ((Owner of (Matching unit)) Equal to Player 12 (Brown))) and do (Actions)
Loop - Actions
Unit - Order (Picked unit) to Attack (Attacking unit)
I'm having a hard time explaining this...
What I want instead is that the trigger will only be run if p12 is NOT attacking p1 but I haven't found any good way of dealing with it. Before I tried this trigger out I tried changing priority of heroes to 20 but that didn't work either, even if I specifically ordered an attack order on a unit, the unit continued it's previous attack order and target...
Ideas or any code is welcome. Thx.