//**************************************************************************************************
//*
//* Handle Variables Functions by Vexorian ([url]http://jass.sourceforge.net/doc/[/url])
//*
//* -------------------------------
//* Enables usage of game cache for
//* transphering local variables
//* beetveen functions.
//* -------------------------------
//*
//* Requires:
//* ¯¯¯¯¯¯¯¯¯
//* A global variable with name "cache" and type "GameCache" as an exact match
//* note that the "LocalVars" function must be placed before anything in this
//* map header expect this kind of comments
//**************************************************************************************************
function LocalVars takes nothing returns gamecache
if udg_cache==null then
set udg_cache=InitGameCache("cache")
endif
return udg_cache
endfunction
//-------------------------------------------------
function H2I takes handle h returns integer
return h
return 0
endfunction
function H2U takes handle h returns unit
return h
return null
endfunction
//-------------------------------------------------
function SetHandleInt takes handle subject, string name, integer value returns nothing
if value==0 then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
//-------------------------------------------------
function SetHandleReal takes handle subject, string name, real value returns nothing
if value==0 then
call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
else
call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
//-------------------------------------------------
function SetHandleHandle takes handle subject, string name, handle value returns nothing
call SetHandleInt( subject, name, H2I(value) )
endfunction
//-------------------------------------------------
function GetHandleInt takes handle subject, string name returns integer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
//-------------------------------------------------
function GetHandleReal takes handle subject, string name returns real
return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction
//-------------------------------------------------
function GetHandleHandle takes handle subject, string name returns handle
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
//-------------------------------------------------
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
//=================================================
//= My Functions
//=================================================
function H2G takes handle h returns group
return h
return null
endfunction
//-------------------------------------------------
function H2SFX takes handle h returns effect
return h
return null
endfunction
//------------------------------------------------
function DestroyTrees takes nothing returns nothing
if(GetDestructableTypeId(GetEnumDestructable()) == 'LTlt') then
call KillDestructable(GetEnumDestructable())
endif
endfunction
//------------------------------------------------
function KnockBack takes nothing returns nothing
local timer kbtime = GetExpiredTimer()
local unit u
local integer kbcount = GetHandleInt(kbtime, "kbcount")
local real kbspeed = GetHandleReal(kbtime, "kbspeed")
local real kbslow = GetHandleReal(kbtime, "kbslow")
local real kbangle
local group kbgroup = H2G(GetHandleHandle(kbtime, "kbgroup"))
local location locA
local location locB
loop
set u = FirstOfGroup(kbgroup)
exitwhen u == null
call GroupRemoveUnit(kbgroup, u)
set kbangle = GetHandleReal(u, "kbangle")
set locA = GetUnitLoc(u)
set locB = Location(GetLocationX(locA) + kbspeed * Cos(kbangle * bj_DEGTORAD), GetLocationY(locA) + kbspeed * Sin(kbangle * bj_DEGTORAD))
call SetUnitPositionLoc(u, locB)
if (IsTerrainPathable(GetLocationX(locA), GetLocationY(locA), PATHING_TYPE_FLOATABILITY))then
call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl", locA))
else
call DestroyEffect(AddSpecialEffectLoc("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl", locA))
endif
set locA = null
set locB = null
endloop
set kbspeed = kbspeed - kbslow
call SetHandleReal(kbtime, "kbspeed", kbspeed)
set kbcount = kbcount - 1
call SetHandleInt(kbtime, "kbcount", kbcount)
set u = null
set locA = null
set locB = null
if (kbcount <= 0) then
call PauseTimer(kbtime)
call DestroyTimer(kbtime)
call FlushHandleLocals(kbtime)
endif
endfunction
//--------------------------------------------------
function UnitPathable takes location locA returns boolean
local unit u = CreateUnitAtLoc(Player(15), 'n000', locA, 0.0)
local location locB = GetUnitLoc(u)
local real dx
local real dy
call RemoveUnit(u)
set locA = null
set locB = null
set u = null
set dx = GetLocationX(locB) - GetLocationX(locA)
set dy = GetLocationY(locB) - GetLocationY(locA)
return (SquareRoot(dx * dx + dy * dy) == 0.0)
endfunction
//==================================================
function Trig_InfernalSmash_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A001')
endfunction
function Trig_InfernalSmash_Actions takes nothing returns nothing
local timer kbtime = CreateTimer()
local unit caster = GetTriggerUnit()
local unit u
local integer kbcount = 33
local real rad = 375.0
local real damage = GetUnitAbilityLevel(caster, GetSpellAbilityId()) * 50.0
local real kbangle
local real kbspeed
local real kbslow
local location locA = GetUnitLoc(caster)
local location locB
local group ug = CreateGroup()
local group kbgroup = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(ug, locA, rad, null)
loop
set u = FirstOfGroup(ug)
exitwhen u == null
call GroupRemoveUnit(ug, u)
call GroupAddUnit(kbgroup, u)
if GetBooleanAnd(GetUnitState(u, UNIT_STATE_LIFE) == 0.0 , GetBooleanAnd(IsUnitEnemy(u, GetOwningPlayer(caster)), IsUnitType(u, UNIT_TYPE_FLYING) == false))then
call UnitDamageTarget(caster, u, damage, false, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE, null)
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl", u, "chest"))
set locB = GetUnitLoc(u)
set kbangle = bj_RADTODEG * Atan2(GetLocationY(locB) - GetLocationY(locA), GetLocationX(locB) - GetLocationX(locA))
call SetHandleReal(u, "kbangle", kbangle)
call SetHandleReal(kbtime, "kbspeed", kbspeed)
call SetHandleReal(kbtime, "kbslow", kbslow)
endif
set u = null
endloop
call SetHandleHandle(kbtime, "kbgroup", kbgroup)
call SetHandleInt(kbtime, "kbcount", kbcount)
call TimerStart(kbtime, 0.03, true, function KnockBack)
set caster = null
set ug = null
set kbgroup = null
endfunction
//===========================================================================
function InitTrig_InfernalSmash takes nothing returns nothing
set gg_trg_InfernalSmash = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_InfernalSmash, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_InfernalSmash, Condition(function Trig_InfernalSmash_Conditions))
call TriggerAddAction( gg_trg_InfernalSmash, function Trig_InfernalSmash_Actions )
endfunction