- Joined
- Jul 26, 2010
- Messages
- 167
And even if I click it with the attack comand. How I do it?
dude its leaking somewhere cuz it still attacks allies. Maybe cuz the target is an object and not a unit?
mevermind that is the same thing, the condition works but unit doesnt stopnevermind the problem was that the issued order was STOP and my wc3 is in spanish and here puts DENETER xD
Change attack targets Combat - Attack 1 - Targets Allowed: Enemy, Derbs, Items, Wards
That allows the unit to attack only enemies. May be missing a filter
function AntiAttack takes nothing returns nothing
if IsUnitAlly(GetTriggerUnit(),GetOwningPlayer(GetAttacker())) == true then
if GetUnitState(GetTriggerUnit(),UNIT_STATE_LIFE) > (GetUnitState(GetTriggerUnit(),UNIT_STATE_MAX_LIFE) * 0.05) then
call IssueImmediateOrder(GetAttacker(),"stop")
endif
endif
endfunction
function InitTrig_AntiAttack takes nothing returns nothing
local integer i = 0
set gg_trg_AntiAttack = CreateTrigger( )
loop
exitwhen i == bj_MAX_PLAYER_SLOTS
call TriggerRegisterPlayerUnitEvent(gg_trg_AntiAttack,Player(i),EVENT_PLAYER_UNIT_ATTACKED,null)
set i = i + 1
endloop
call TriggerAddAction(gg_trg_AntiAttack,function AntiAttack)
endfunction
Do you even know the meaning of "leak" in computer programming ?
If you don't know, don't use it @@"
function NoKill takes nothing returns nothing
local unit A=GetAttacker()
local unit D=GetTriggerUnit()
local player P=GetOwningPlayer(A)
if IsUnitAlly(D,P)then
call IssueImmediateOrder(A,"stop")
endif
set A=null
set D=null
set P=null
endfunction
function InitTrig_NoTeamKill takes nothing returns nothing
local integer I=0
set gg_trg_NoTeamKill=CreateTrigger()
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_NoTeamKill,Player(I),EVENT_PLAYER_UNIT_ATTACKED,null)
set I=I+1
exitwhen I>11
endloop
call TriggerAddAction(gg_trg_NoTeamKill,function NoKill)
endfunction
function NoKill takes unit A,unit D returns nothing
local player P=GetOwningPlayer(A)
if IsUnitAlly(D,P)then
call IssueImmediateOrder(A,"stop")
endif
set A=null
set D=null
set P=null
endfunction
GetAttacker()
and GetTriggerUnit()
with variables, or anything, as long as the attacking unit is the first one, and what it is attacking is the second one.Why not use this system. Saves you having to wait. This also allows you to attack your own units. Just remove the second condition if thats not what you want.
- Friendly Fire
- Events
- Unit - A unit Is attacked
- Conditions
- ((Attacked unit) belongs to an ally of (Owner of (Attacking unit))) Equal to True
- (Owner of (Attacking unit)) Not equal to (Owner of (Attacked unit))
- Actions
- Unit - Order (Attacking unit) to Stop