- Joined
- Jan 2, 2016
- Messages
- 472
I'm interested if this spell will be buggy.If you find anything out of the ordinary please tell me.
JASS:
scope ShadowIncineration
globals
private group g = CreateGroup()
private unit caster
private string effect_path = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdl"
endglobals
function Trig_AoESpell_Conditions takes nothing returns boolean
if GetSpellAbilityId() =='A00K' then
return true
endif
return false
endfunction
function TimerEnds takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer hnd_id = GetHandleId(t)
local integer unitID = LoadInteger(udg_ghash,hnd_id,0)
local real unit_default_speed
local real unit_default_turn_speed
local unit u
loop
set u = FirstOfGroup(g)
exitwhen(u == null)
if GetUnitTypeId(u) == unitID then
set unit_default_speed = GetUnitDefaultMoveSpeed(u)
set unit_default_turn_speed = GetUnitDefaultTurnSpeed(u)
call SetUnitMoveSpeed(u,unit_default_speed)
call SetUnitTurnSpeed(u,unit_default_turn_speed)
call UnitRemoveAbility(u,'A00A')
call GroupRemoveUnit(g,u)
endif
endloop
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_ghash,hnd_id)
set u = null
set t = null
endfunction
function Pick takes nothing returns nothing
local unit u = GetFilterUnit()
local integer unitID = GetUnitTypeId(u)
local real unit_life = GetUnitState(u,UNIT_STATE_LIFE)
local real unit_max_life = GetUnitState(u,UNIT_STATE_MAX_LIFE)
local real unit_default_speed = GetUnitDefaultMoveSpeed(u)
local real unit_default_turn_speed = GetUnitDefaultTurnSpeed(u)
local real new_speed = unit_default_speed * 0.3
local real new_turn_speed = unit_default_turn_speed * 0.3
local effect damage_effect
local timer t = CreateTimer()
local integer hnd_id = GetHandleId(t)
local real damage = 25.0 * GetUnitAbilityLevel(caster,'A00K') + GetHeroAgi(caster,true) * 0.75
if unit_life <= unit_max_life * 0.3 and IsUnitEnemy(u,Player(0)) == true then
call SetUnitMoveSpeed(u,new_speed )
call SetUnitTurnSpeed(u,new_turn_speed )
call UnitAddAbility(u,'A00A')
call GroupAddUnit(g,u)
call SaveInteger(udg_ghash, hnd_id, 0, unitID)
call TimerStart(t,15.0,false, function TimerEnds)
elseif IsUnitEnemy(u,Player(0)) == true then
set damage_effect = AddSpecialEffectTarget(effect_path,u,"origin")
call DestroyEffect(damage_effect)
call UnitDamageTarget(caster,u,damage,false,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_MAGIC,null)
endif
set damage_effect = null
set t = null
set u = null
endfunction
function Trig_AoESpell_Actions takes nothing returns nothing
local location loc = GetSpellTargetLoc()
set caster = GetTriggerUnit()
call GroupEnumUnitsInRangeOfLoc(g,loc,200.0,Filter(function Pick))
set loc = null
endfunction
//===========================================================================
function InitTrig_ShadowIncineration takes nothing returns nothing
set gg_trg_ShadowIncineration = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ShadowIncineration, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_ShadowIncineration, Condition( function Trig_AoESpell_Conditions ) )
call TriggerAddAction( gg_trg_ShadowIncineration, function Trig_AoESpell_Actions )
endfunction
endscope