• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] AI Spellcasting problem... again

Status
Not open for further replies.
Level 11
Joined
Sep 14, 2009
Messages
284
This is a continue from this thread:http://www.hiveworkshop.com/forums/triggers-scripts-269/spellcasting-ai-problem-260526/ (closed).

I have an enemy unit that is supposed to cast a spell based off silence. He is supposed to use it when he attacks (not attacked, and has 25 sec cd). However, as he is ordered to do so, he just freezes and remains freezed until he is killed. This is my problem.

A00U = rawcode of silence spell.
Abun = Orc burrow ability (he has this ability during another channeled spell to avoid interruption. Abun disables auto-attack).
udg_PartyMember[] = The only player units in this fight.

Adding a wait and then ordering him to stop will not work, since that might interrupt his other channeled ability.
I could give him a target unit ability instead and order a dummy to cast the silence spell, but this is a last resort since it feels quite overcomplicated to such a small problem.

EDIT: None of the suggestions in the previous thread works.

JASS:
function SporeBurstUse_Conditions takes nothing returns boolean
    return GetUnitAbilityLevelSwapped('A00U', GetAttacker()) == 1 and GetUnitAbilityLevelSwapped('Abun', GetAttacker()) != 1
endfunction

function SporeBurstUse_Actions takes nothing returns nothing
    local unit cast = GetAttacker()
    local location p = GetUnitLoc(udg_PartyMember[GetRandomInt(1, 2)])
    call DisableTrigger(GetTriggeringTrigger())
    if p != null then
        call IssuePointOrderLoc(cast, "silence", p)
    endif
    call RemoveLocation(p)
    set p = null
    set cast = null
    call TriggerSleepAction(2.00)
    call EnableTrigger(GetTriggeringTrigger())
endfunction

//===========================================================================
function InitTrig_SporeBurstUse takes nothing returns nothing
    set gg_trg_SporeBurstUse = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_SporeBurstUse, EVENT_PLAYER_UNIT_ATTACKED)
    call TriggerAddCondition(gg_trg_SporeBurstUse, Condition(function SporeBurstUse_Conditions))
    call TriggerAddAction(gg_trg_SporeBurstUse, function SporeBurstUse_Actions)
endfunction
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Use this trigger to print the orders units are given. You can use a unit type filter or some other filter to only print the orders of the one unit. This will help detecting if the units is locked due to repeated orders.
  • OrderID
    • Events
      • Unit - A unit Is issued an order with no target
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
    • Actions
      • Custom script: call BJDebugMsg(OrderId2String(GetIssuedOrderId()) + " ---- " + I2S(GetIssuedOrderId()))
 
Level 11
Joined
Sep 14, 2009
Messages
284
@Maker. Try your idea. And this is what happened:

The stop orders are irrelevant. They have something to do with combat initiation.
As you can see, he is only ordered the silence one time. And just stops and freezes there. So strange.

180023-albums7569-picture99631.jpg
 
Status
Not open for further replies.
Top