- Joined
- Jun 23, 2009
- Messages
- 299
I got a spell that applies Parasite after the targeted units are hit by a Rain Of Fire FX, this works 100% with no issues for at least Player 1 but when an AI hero uses it the dummies don't cast Parasite on the targets, I tried a bunch of stuff, giving the dummy base spell more range, giving dummies some more timed life, changing base spell from the Naga Parasite to the Neutral Parasite, changing the base spell to Black Arrow (this totally broke it), using a different dummy (which actually confirmed through animations they wouldn't cast it for AI), preloading all skills and buffs through xepreload, nothing worked.
Actually, that's not true, the only thing I tested that works is giving the AI player a bunch of Naga Sirens so they cast Parasite on units, after they've done that the spell worked as intended for them.
I've spent a bunch of hours already trying to figure out a solution for this with little result. Any ideas? Heck, I'd settle for a clean, invisible way to use the Naga Siren workaround.
Here's the code, although I feel there's nothing inherently wrong with it:
Actually, that's not true, the only thing I tested that works is giving the AI player a bunch of Naga Sirens so they cast Parasite on units, after they've done that the spell worked as intended for them.
I've spent a bunch of hours already trying to figure out a solution for this with little result. Any ideas? Heck, I'd settle for a clean, invisible way to use the Naga Siren workaround.
Here's the code, although I feel there's nothing inherently wrong with it:
vJASS:
scope FireBarrage initializer Init
globals
private constant integer SPELL = 'Bek4'
private constant integer DUMMY_SPELL = 'Bem4'
private constant integer Damage = 50
private constant integer Times = 2 //+ spell level
private constant real Range = 600.00
private group ENUM
private unit CASTER
private player OP
private integer T
private integer L
private boolean Existing = false
endglobals
private struct fire
unit t
unit c
integer l
static method create takes unit target, unit caster, integer level returns fire
local fire fy = fire.allocate()
set fy.t = target
set fy.c = caster
set fy.l = level
return fy
endmethod
endstruct
private function Effect takes nothing returns nothing
local fire f = GetTimerData(GetExpiredTimer())
local unit dummy = CreateUnit(GetOwningPlayer(f.c), TWKDummy, GetUnitX(f.t), GetUnitY(f.t), bj_UNIT_FACING)
call UnitDamageTarget(f.c, f.t, Damage * f.l, true, true, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
call UnitAddAbility(dummy, DUMMY_SPELL)
call IssueTargetOrder(dummy, "parasite", f.t)
call UnitApplyTimedLife(dummy, 'BTLF', 1)
call ReleaseTimer(GetExpiredTimer())
call f.destroy()
endfunction
private function Target takes nothing returns boolean
local fire f
local timer t = null
if T != 0 and IsUnitEnemy(GetFilterUnit(), OP) and GetWidgetLife(GetFilterUnit()) > 0.405 and not (IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) or IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) or IsUnitType(GetFilterUnit(), UNIT_TYPE_ANCIENT) or IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) or IsTWKDummy(GetFilterUnit())) and (GetOwningPlayer(GetFilterUnit()) != Player(bj_PLAYER_NEUTRAL_EXTRA) and GetOwningPlayer(GetFilterUnit()) != Player(PLAYER_NEUTRAL_PASSIVE) and GetOwningPlayer(GetFilterUnit()) != Player(bj_PLAYER_NEUTRAL_VICTIM)) then
set T = T - 1
set f = fire.create(GetFilterUnit(), CASTER, L)
set t = NewTimer()
call SetTimerData(t, f)
call TimerStart(t, 0.8, false, function Effect)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Demon\\RainOfFire\\RainOfFireTarget.mdl", GetFilterUnit(), "origin"))
endif
return false
endfunction
private function Main takes nothing returns boolean
if GetSpellAbilityId() == SPELL then
set OP = GetOwningPlayer(GetTriggerUnit())
set CASTER = GetTriggerUnit()
set L = GetUnitAbilityLevel(GetTriggerUnit(), SPELL)
set T = Times + L
call GroupEnumUnitsInRange(ENUM, GetUnitX(GetTriggerUnit()), GetUnitY(GetTriggerUnit()), Range, Condition(function Target))
endif
return false
endfunction
private function TargetsCheck takes nothing returns boolean
if not Existing and IsUnitEnemy(GetFilterUnit(), OP) and GetWidgetLife(GetFilterUnit()) > 0.405 and not (IsUnitType(GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) or IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) or IsUnitType(GetFilterUnit(), UNIT_TYPE_ANCIENT) or IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) or IsTWKDummy(GetFilterUnit())) and (GetOwningPlayer(GetFilterUnit()) != Player(bj_PLAYER_NEUTRAL_EXTRA) and GetOwningPlayer(GetFilterUnit()) != Player(PLAYER_NEUTRAL_PASSIVE) and GetOwningPlayer(GetFilterUnit()) != Player(bj_PLAYER_NEUTRAL_VICTIM)) then
set Existing = true
endif
return false
endfunction
private function TargetsExist takes nothing returns boolean
if GetIssuedOrderId() == OrderId("starfall") and GetUnitAbilityLevel(GetOrderedUnit(), SPELL) != 0 then
set OP = GetOwningPlayer(GetOrderedUnit())
set Existing = false
call GroupEnumUnitsInRange(ENUM, GetUnitX(GetOrderedUnit()), GetUnitY(GetOrderedUnit()), Range, Condition(function TargetsCheck))
if not Existing then
call AbortSpell(GetOrderedUnit(), SPELL_TARGET_ERROR, " ")
endif
endif
return false
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
set ENUM = CreateGroup()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_ORDER)
call TriggerAddCondition(t, Condition(function TargetsExist))
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function Main))
endfunction
endscope