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

[JASS] AI Spellcasting problem... again

Not open for further replies.
Level 11
Sep 14, 2009
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.

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

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)
    call RemoveLocation(p)
    set p = null
    set cast = null
    call TriggerSleepAction(2.00)
    call EnableTrigger(GetTriggeringTrigger())

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)
Level 37
Mar 6, 2006
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
Sep 14, 2009
@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.

Not open for further replies.