- Joined
- Sep 14, 2009
- Messages
- 284
I gone through my code countless times, and I just cannot find what is the problem here. The spell deals damage sometimes, and sometimes it does not. But the dummy using soulburn inside the loop always works, but the damage does not.
And no, it's not becuase it's non-MUI. There is only one unit with the ability on the entire map.
Code:
And no, it's not becuase it's non-MUI. There is only one unit with the ability on the entire map.
Code:
JASS:
globals
boolean darkEruptionOnCD = false
unit darkEruptionCaster = null
endglobals
//===========================================================================
function DarkEruptionResetCD takes nothing returns nothing
call DestroyTimer(GetExpiredTimer())
set darkEruptionOnCD = false
endfunction
function DarkEruptionDummyIndicatorDeath_Conditions takes nothing returns boolean
return GetUnitTypeId(GetTriggerUnit()) == 'u001'
endfunction
function DarkEruptionDummyIndicatorDeath_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local group g = CreateGroup()
local player p = GetOwningPlayer(u)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local unit dum = null
call DestroyEffect(AddSpecialEffect("MDX\\Effect_DarkEruption.mdx", x, y))
call GroupEnumUnitsInRange(g, x, y, 220, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if IsUnitEnemy(u, p) and GetUnitState(u, UNIT_STATE_LIFE) > 0 and GetUnitAbilityLevel(u, dumAbility) == 0 then
set dmgTypeAbility = true
set dmgTypeMagic = true
call UnitDamageTarget(darkEruptionCaster, u, 800, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
set dmgTypeMagic = false
set dmgTypeAbility = false
set dum = CreateUnit(p, 'uloc', GetUnitX(u), GetUnitY(u), 0)
call UnitApplyTimedLife(dum, 'BTLF', 1.5)
call UnitAddAbility(dum, 'A00L')
call SetUnitAbilityLevel(dum, 'A00L', 2)
call IssueTargetOrder(dum, "soulburn", u)
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
set g = null
set p = null
set dum = null
endfunction
//===========================================================================
function DarkEruptionCast_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00K'
endfunction
function DarkEruptionCast_Actions takes nothing returns nothing
local unit targ = GetSpellTargetUnit()
local unit dum = null
set darkEruptionCaster = GetTriggerUnit()
set darkEruptionOnCD = true
set dum = CreateUnit(GetOwningPlayer(darkEruptionCaster), 'u001', GetUnitX(targ), GetUnitY(targ), GetRandomReal(0, 360))
call UnitApplyTimedLife(dum, 'BTLF', 5)
call UnitRemoveAbility(darkEruptionCaster, 'A00K')
call TimerStart(CreateTimer(), 12.5, false, function DarkEruptionResetCD)
set targ = null
set dum = null
endfunction
//===========================================================================
function DarkEruption_Conditions takes nothing returns boolean
local unit atkd = GetTriggerUnit()
local boolean b = false
if darkEruptionOnCD == false and GetUnitAbilityLevel(atkd, 'A00G') >= 1 and GetUnitState(atkd, UNIT_STATE_LIFE) <= 0.55 * GetUnitState(atkd, UNIT_STATE_MAX_LIFE) then
set b = true
endif
set atkd = null
return b
endfunction
function DarkEruption_Actions takes nothing returns nothing
local unit atkd = GetTriggerUnit()
call UnitAddAbility(atkd, 'A00K')
call IssueTargetOrder(atkd, "forkedlightning", GetAttacker())
set atkd = null
endfunction
//===========================================================================
function InitTrig_DarkEruption takes nothing returns nothing
local trigger DarkEruptionCast = CreateTrigger()
local trigger DarkEruptionDummyIndicatorDeath = CreateTrigger()
set gg_trg_DarkEruption = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_DarkEruption, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(gg_trg_DarkEruption, Condition(function DarkEruption_Conditions))
call TriggerAddAction(gg_trg_DarkEruption, function DarkEruption_Actions)
//----------
call TriggerRegisterAnyUnitEventBJ(DarkEruptionCast, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(DarkEruptionCast, Condition(function DarkEruptionCast_Conditions))
call TriggerAddAction(DarkEruptionCast, function DarkEruptionCast_Actions)
//----------
call TriggerRegisterAnyUnitEventBJ(DarkEruptionDummyIndicatorDeath, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(DarkEruptionDummyIndicatorDeath, Condition(function DarkEruptionDummyIndicatorDeath_Conditions))
call TriggerAddAction(DarkEruptionDummyIndicatorDeath, function DarkEruptionDummyIndicatorDeath_Actions)
endfunction