• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Anti Attack

Status
Not open for further replies.
Level 10
Joined
Jun 20, 2017
Messages
337
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:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,208
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.
 

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,898
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.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,208
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.
 
Level 14
Joined
Nov 17, 2010
Messages
1,265
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?
 
Level 10
Joined
Jun 20, 2017
Messages
337
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.
Top