• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Solved] Anti Attack

Status
Not open for further replies.
Level 11
Joined
Jun 20, 2017
Messages
380
Any ideas + Rep

About this why wouldn't work?! When I attack it, it will be destroyed
  • Cant Attack Flag
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to (==) Flag
      • (((Attacking unit) is in UnitGroup_Humans) Equal to (==) True) and (((Attacked unit) is in UnitGroup_Humans) Equal to (==) True)
    • Actions
      • Unit - Order (Attacking unit) to Stop
 
Last edited:
I used many ways, but can't find out that how to stop attacking some unit
Cant Attack Flag Copy will not work because the stop order is issued before the attack order.

Cant Attack Flag will not work because it is ordering the attacked unit to stop instead of the attacking unit.
 
I already told you, you need to put a wait before ordering to stop...
  • Anti team kill
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • ((Owner of (Triggering unit)) is an ally of (Owner of (Attacking unit))) Equal to True
    • Actions
      • Wait 0.00 seconds
      • Unit - Order (Attacking unit) to Stop
You mean 0.1 seconds at least? Yeh that is why one should not use TriggerSleepAction…
Not true actually, 0 seconds is enough. I've done this way many times.
 
Not true actually, 0 seconds is enough. I've done this way many times.
0 seconds still has a huge, lag and game speed based delay. Most units will be able to fire off their attack in that time.
no I don't want anti team kill. I want my unit,hero,tower can't attack 1 building but they can attack other building
Same mechanics, different conditions.
 
Would you be able to catch the order being issued and check to see if it is an attack order on the flag unit by a friendly unit and order it to stop?
 
I found out with this jass, but can't figure it out how to return boolean in gui
JASS:
function Trig_AttackFlag_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'h00B'
endfunction

function Trig_AttackFlag_Actions takes nothing returns nothing
local unit Attacker = GetAttacker()
local unit Attacked = GetTriggerUnit()
if IsUnitInGroup(Attacker, udg_UnitGroup_Vampires) != true
call IssueImmediateOrder(Attacker, "stop")
endif
set Attacker = null
set Attacked = null
endfunction

function InitTrig_AttackFlag takes nothing returns nothing
set gg_trg_AttackFlag = CreateTrigger(  )
call TriggerRegisterAnyUnitEventBJ( gg_trg_AttackFlag, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( gg_trg_AttackFlag, Condition( function Trig_AttackFlag_Conditions ) )
call TriggerAddAction( gg_trg_AttackFlag, function Trig_AttackFlag_Actions )
endfunction
 
Status
Not open for further replies.
Back
Top