- 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.
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