• 🏆 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!

[General] Unit Attack AI

Status
Not open for further replies.
Level 12
Joined
Feb 22, 2010
Messages
1,115
?
  • Untitled Trigger 001
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • Unit - Order (Attacking unit) to Stop
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Please don't respond with GUI : ), I won't look at it, so ur just wasting ur time with that

Gave +rep for trying to help tho =), even if the post only had "?" ^)^


Still looking for a solution. I'm going to note that giving 0 attack cooldown and ordering a unit to stop while attacking is the exact opposite of what I wanted, lol. The whole point here is to not have them fire off tons of events.

Did that in this old lib here http://www.hiveworkshop.com/forums/submissions-414/system-unit-attack-213779/

JASS:
        private static method onInit takes nothing returns nothing
            local integer i = 15
            local trigger t = CreateTrigger()
            
            call TriggerAddCondition(t, Condition(function thistype.attack))
            call TriggerAddCondition(resetTrigger, Condition(function thistype.reset))
            
            set table = Table.create()
            
            loop
                call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_ATTACKED, null)
                call TriggerRegisterPlayerUnitEvent(resetTrigger, Player(i), EVENT_PLAYER_UNIT_ISSUED_ORDER, null)
                call TriggerRegisterPlayerUnitEvent(resetTrigger, Player(i), EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER, null)
                call TriggerRegisterPlayerUnitEvent(resetTrigger, Player(i), EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER, null)
                exitwhen 0 == i
                set i = i - 1
            endloop
            
            set t = null
        endmethod

So if anyone's thinking that spamming attacks is the solution to disabling attacks, that's actually the opposite. I don't want attacks to fire, I want them disabled, not spammed ^)^.

Is there a way to enable/disable unit attacks while keeping the combat AI on the unit enabled so that they follow enemies, acquire targets, and so on w/o attacking until the attack is enabled?
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
You just said you need to stop unit from actually attacking without disabling combat AI, all I said is stop attacking unit when it begins its attack animation.You don't need to change its attack cooldown or something like that.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Chance to miss still wouldn't work. I don't want the unit to be attacking at all. When I enable the attack, I want it to start attacking again, so it should be instantly ready.

Think of it like this. Let's say that I give it 1000000000000 cooldown so that it never attacks, then when I want it to attack, I lower the cooldown to 0 and then raise it back up to 1000000000000. That is what I want.
 
Status
Not open for further replies.
Top