//*************************************************************
//TEST THE SPELL FIRST TO CONFIGURE ANYTHING BELOW THIS
//*************************************************************
function FS_Ability takes nothing returns integer
return 'A000'
//Raw code of the ability
endfunction
function FS_Animation takes nothing returns integer
return 2
//Animation index
endfunction
function FS_ChargeTime takes nothing returns real
return 0.2
//Time to charge the attack
endfunction
function FS_DistanceM takes nothing returns real
return 150.
//Distance after the attack
endfunction
function FS_Effect1 takes nothing returns string
return "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl"
//Weapon effect
endfunction
function FS_Effect1AP takes nothing returns string
return "weapon"
//Weapon attach point
endfunction
function FS_Effect2 takes nothing returns string
return "Abilities\\Spells\\Undead\\OrbOfDeath\\OrbOfDeathMissile.mdl"
//Movement effect
endfunction
function FS_Effect3 takes nothing returns string
return "Objects\\Spawnmodels\\Undead\\UndeadBlood\\UndeadBloodNecromancer.mdl"
//Blood effect
endfunction
function FS_Velocity takes nothing returns real
return 1600.
//Movement speed
endfunction
function FS_Range takes nothing returns real
return 125.
//Attack range
endfunction
function FS_AttackType takes nothing returns attacktype
return ATTACK_TYPE_NORMAL
//Attack type
endfunction
function FS_DamageType takes nothing returns damagetype
return DAMAGE_TYPE_NORMAL
//Damage type
endfunction
function FS_WeaponType takes nothing returns weapontype
return WEAPON_TYPE_METAL_MEDIUM_SLICE
//Weapon type
endfunction
function FS_Damage takes integer level returns real
return 175. * level
//Damage per level
endfunction
function FS_RechargeEnergy takes nothing returns real
return 2.
//Time to recharge the energy
endfunction
function FS_TimerInterval takes nothing returns real
return 0.025
//FPS || Default = 0.025 (1 / 0.025 = 40 FPS)
endfunction
//*************************************************************
//TOUCH ANYTHING BELOW THIS ONLY IF YOU KNOW JASS
//*************************************************************
function FS_Distance takes unit c, unit tar returns real
return SquareRoot((GetUnitX(tar) - GetUnitX(c)) * (GetUnitX(tar) - GetUnitX(c)) + (GetUnitY(tar) - GetUnitY(c)) * (GetUnitY(tar) - GetUnitY(c)))
endfunction
function FS_Loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer i = GetHandleId(t)
local unit c = LoadUnitHandle(udg_FS_HashTable, i, 0)
local unit tar = LoadUnitHandle(udg_FS_HashTable, i, 1)
local integer level = LoadInteger(udg_FS_HashTable, i, 2)
local real ready = LoadReal(udg_FS_HashTable, i, 3)
local real distance = LoadReal(udg_FS_HashTable, i, 4)
local real angle = LoadReal(udg_FS_HashTable, i, 5)
local boolean finish = LoadBoolean(udg_FS_HashTable, i, 6)
local boolean attack = LoadBoolean(udg_FS_HashTable, i, 7)
local real interval = LoadReal(udg_FS_HashTable, i, 9)
local real wait = LoadReal(udg_FS_HashTable, i, 10)
local real x
local real y
local real int = FS_TimerInterval()
if distance < FS_DistanceM() and not IsTerrainPathable(GetUnitX(c), GetUnitY(c), PATHING_TYPE_WALKABILITY) == true then
if ready > int and not finish and not IsUnitType(c, UNIT_TYPE_DEAD) then
call SaveReal(udg_FS_HashTable, i, 3, ready - int)
else
call SaveBoolean(udg_FS_HashTable, i, 6, true)
endif
if finish then
set x = GetUnitX(c) + FS_Velocity() * int * Cos(angle * bj_DEGTORAD)
set y = GetUnitY(c) + FS_Velocity() * int * Sin(angle * bj_DEGTORAD)
call DestroyEffect(AddSpecialEffect(FS_Effect2(), x, y))
if distance > (0. - 10.) and not attack then
if FS_Distance(c, tar) <= FS_Range() then
call DestroyEffect(LoadEffectHandle(udg_FS_HashTable, i, 8))
call UnitDamageTarget(c, tar, FS_Damage(level), true, false, FS_AttackType(), FS_DamageType(), FS_WeaponType())
call SetUnitTimeScale(c, 0)
call SaveBoolean(udg_FS_HashTable, i, 7, true)
else
call LoadEffectHandle(udg_FS_HashTable, i, 8)
call SaveBoolean(udg_FS_HashTable, i, 7, true)
endif
endif
if attack then
call DestroyEffect(AddSpecialEffectTarget(FS_Effect3(), tar, "chest"))
call DestroyEffect(AddSpecialEffectTarget(FS_Effect3(), c, "weapon"))
endif
call SetUnitX(c, x)
call SetUnitY(c, y)
call SaveReal(udg_FS_HashTable, i, 4, distance + FS_Velocity() * int)
endif
else
if wait > int and attack then
call SaveReal(udg_FS_HashTable, i, 10, wait - int)
else
call SetUnitPathing(c, true)
call SetUnitTimeScale(c, 1)
call SetUnitAnimation(c, "stand")
call PauseUnit(c, false)
call PauseTimer(t)
call FlushChildHashtable(udg_FS_HashTable, i)
call DestroyTimer(t)
endif
endif
set c = null
set tar = null
set t = null
endfunction
function FS_Actions takes nothing returns boolean
local unit c
local unit tar
local integer level
local timer t
local integer i
local real int = FS_TimerInterval()
if GetSpellAbilityId() == FS_Ability() then
set c = GetTriggerUnit()
set tar = GetSpellTargetUnit()
set level = GetUnitAbilityLevel(c, FS_Ability())
set t = CreateTimer()
set i = GetHandleId(t)
call SaveAgentHandle(udg_FS_HashTable, i, 0, c)
call SaveAgentHandle(udg_FS_HashTable, i, 1, tar)
call SaveInteger(udg_FS_HashTable, i, 2, level)
call SaveReal(udg_FS_HashTable, i, 3, FS_ChargeTime())
call SaveReal(udg_FS_HashTable, i, 4, 0 - FS_Distance(c, tar))
call SaveReal(udg_FS_HashTable, i, 5, bj_RADTODEG * Atan2(GetUnitY(tar) - GetUnitY(c), GetUnitX(tar) - GetUnitX(c)))
call SaveBoolean(udg_FS_HashTable, i, 6, false)
call SaveBoolean(udg_FS_HashTable, i, 7, false)
call SaveAgentHandle(udg_FS_HashTable, i, 8, AddSpecialEffectTarget(FS_Effect1(), c, FS_Effect1AP()))
call SaveReal(udg_FS_HashTable, i, 9, 0)
call SaveReal(udg_FS_HashTable, i, 10, FS_RechargeEnergy())
call TimerStart(t, int, true, function FS_Loop)
call PauseUnit(c, true)
call SetUnitPathing(c, false)
call SetUnitAnimation(c, "stand")
call SetUnitAnimationByIndex(c, FS_Animation())
set c = null
set tar = null
set t = null
endif
return false
endfunction
function InitTrig_FS takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function FS_Actions))
set udg_FS_HashTable = InitHashtable()
set t = null
endfunction