// ===========================
function H2I takes handle h returns integer
return h
return 0
endfunction
// ===========================
function LocalVars takes nothing returns gamecache
if udg_cach == null then
call FlushGameCache(InitGameCache("cach"))
set udg_cach=InitGameCache("cach")
endif
return udg_cach
endfunction
function SetHandleHandle takes handle subject, string name, handle value returns nothing
if value==null then
call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
else
call StoreInteger(LocalVars(), I2S(H2I(subject)), name, H2I(value))
endif
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 SetHandleString takes handle subject, string name, string value returns nothing
if value==null then
call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
else
call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
endif
endfunction
function GetHandleHandle takes handle subject, string name returns handle
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
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 GetHandleString takes handle subject, string name returns string
return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction
function GetHandleUnit takes handle subject, string name returns unit
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleTimer takes handle subject, string name returns timer
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleTrigger takes handle subject, string name returns trigger
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleEffect takes handle subject, string name returns effect
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleGroup takes handle subject, string name returns group
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function GetHandleTextTag takes handle subject, string name returns texttag
return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
return null
endfunction
function FlushHandleLocals takes handle subject returns nothing
call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction
//$$$$$$$$$$$$$$$$$$$$
//AUXILIARY FUNCTIONS
//$$$$$$$$$$$$$$$$$$$$
function GetDistanceBetweenPoints takes real x1, real y1, real x2, real y2 returns real
return SquareRoot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
endfunction
function PolarProjectionX takes real x, real dist, real angle returns real
return x+dist*Cos(angle*bj_DEGTORAD)
endfunction
function PolarProjectionY takes real y, real dist, real angle returns real
return y+dist*Sin(angle*bj_DEGTORAD)
endfunction
function GetAngleBetweenPoints takes real x1, real y1, real x2, real y2 returns real
return bj_RADTODEG*Atan2(y2-y1, x2-x1)
endfunction
function SubjectManaBurn takes unit whichUnit, player inflictor, real amount returns real
local unit dumb
local real RealAmount
local real mana = GetUnitState(whichUnit, UNIT_STATE_MANA)
local real life = GetUnitState(whichUnit, UNIT_STATE_LIFE)
if mana<=0 then
return 0.00
endif
if amount>mana then
set amount = GetUnitState(whichUnit, UNIT_STATE_MANA)
endif
set dumb = CreateUnit(inflictor, 'nalb', GetUnitX(whichUnit), GetUnitY(whichUnit), 0.00)
//call ShowUnit(dumb, false)
call UnitDamageTarget(dumb, whichUnit, amount, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MIND, WEAPON_TYPE_WHOKNOWS)
set RealAmount = life-GetUnitState(whichUnit, UNIT_STATE_LIFE)
call SetUnitState(whichUnit, UNIT_STATE_MANA, mana-RealAmount)
call RemoveUnit(dumb)
set dumb = null
return RealAmount
endfunction
function IsUnitInvulnerable takes unit whichUnit returns boolean
local unit helper = CreateUnit(Player(15), 'nalb', GetUnitX(whichUnit), GetUnitY(whichUnit), 0.00)
local real life = GetUnitState(whichUnit, UNIT_STATE_LIFE)
if life<GetUnitState(whichUnit, UNIT_STATE_MAX_LIFE) then
call SetUnitState(whichUnit, UNIT_STATE_LIFE, life+0.01)
set life = life+0.01
call UnitDamageTarget(helper, whichUnit, 0.01, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
call RemoveUnit(helper)
if GetUnitState(whichUnit, UNIT_STATE_LIFE)<life then
return false
else
call SetUnitState(whichUnit, UNIT_STATE_LIFE, life-0.01)
return true
endif
else
call UnitDamageTarget(helper, whichUnit, 0.01, false, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
call RemoveUnit(helper)
if GetUnitState(whichUnit, UNIT_STATE_LIFE)<life then
call SetUnitState(whichUnit, UNIT_STATE_LIFE, life)
return false
else
return true
endif
endif
endfunction
function GroupGetUnitMaxMana takes group g returns unit
local group k = CreateGroup()
local unit u
local unit max
local real quota
if FirstOfGroup(g)!=null then
call GroupAddGroup(g,k)
set max = FirstOfGroup(k)
set quota = GetUnitState(max, UNIT_STATE_MANA)
call GroupRemoveUnit(k,max)
loop
set u = FirstOfGroup(k)
exitwhen u==null
call GroupRemoveUnit(k,u)
if GetUnitState(u, UNIT_STATE_MANA)>quota then
set quota = GetUnitState(u, UNIT_STATE_MANA)
set max = u
endif
set u = FirstOfGroup(k)
endloop
return max
endif
return null
endfunction
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//SIMULATE FLOATNG TEXT FOR MANA BURN
function ManaBurnText_Remove takes nothing returns nothing
local timer t = GetExpiredTimer()
call DestroyTextTag(GetHandleTextTag(t, "burntext"))
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
endfunction
function ManaBurnText takes real amount, unit whichUnit returns nothing
local texttag tt = CreateTextTag()
local timer t = CreateTimer()
call SetTextTagText(tt, "-"+I2S(R2I(amount)), 0.023)
call SetTextTagPosUnit(tt, whichUnit, -50.00)
call SetTextTagColor(tt, 90, 70, 255, 255)
call SetTextTagVelocityBJ( tt, 64, 90 )
call SetHandleHandle(t, "burntext",tt)
call TimerStart(t, 2.50, false, function ManaBurnText_Remove)
set tt = null
endfunction