//Potion stats system by Zaio for Spartipilo
//===============================================================
//======================== CONFIGURABLES ========================
//===============================================================
function PH1 takes nothing returns integer
return 'I007' // Level 1 heal potion ID
endfunction
function PH2 takes nothing returns integer
return 'I00B' // Level 2 heal potion ID
endfunction
function PH3 takes nothing returns integer
return 'I008' // Level 3 heal potion ID
endfunction
function PH4 takes nothing returns integer
return 'I009' // Level 4 heal potion ID
endfunction
function PH5 takes nothing returns integer
return 'I00A' // Level 5 heal potion ID
endfunction
function PM1 takes nothing returns integer
return 'I00C' // Level 1 mana potion ID
endfunction
function PM2 takes nothing returns integer
return 'I00G' // Level 2 mana potion ID
endfunction
function PM3 takes nothing returns integer
return 'I00E' // Level 3 mana potion ID
endfunction
function PM4 takes nothing returns integer
return 'I00D' // Level 4 mana potion ID
endfunction
function PM5 takes nothing returns integer
return 'I00F' // Level 5 mana potion ID
endfunction
function PR1 takes nothing returns real
return 60.00 // Level 1 heal/mana
endfunction
function PR2 takes nothing returns real
return 120.00 // Level 2 heal/mana
endfunction
function PR3 takes nothing returns real
return 180.00 // Level 3 heal/mana
endfunction
function PR4 takes nothing returns real
return 240.00 // Level 4 heal/mana
endfunction
function PR5 takes nothing returns real
return 300.00 // Level 5 heal/mana
endfunction
function PRS1 takes nothing returns real
return 0.8 // Percentage of stats heal/mana increment // 0.8 = 80%
endfunction
function PRS2 takes nothing returns real
return 1.6 // Percentage of stats heal/mana increment // 1.6 = 160%
endfunction
function PRS3 takes nothing returns real
return 2.4 // Percentage of stats heal/mana increment // 2.4 = 240%
endfunction
function PRS4 takes nothing returns real
return 3.2 // Percentage of stats heal/mana increment // 3.2 = 320%
endfunction
function PRS5 takes nothing returns real
return 4.0 // Percentage of stats heal/mana increment // 4.0 = 400%
endfunction
function PROT takes nothing returns integer
return 10 // The time it will do the restore in (it will still do the full amount, but this value is the time it takes)
endfunction
function RAP takes nothing returns string
return "chest" // attachment point for the rejuvenation sfx
endfunction
//=============================================================================================================
//================================ END CONFIGURABLES =====================================================
//===================================================================================================
function Loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local real r = LoadReal(udg_Hash, id, 0)
local unit u = LoadUnitHandle(udg_Hash, id, 1)
local integer i = LoadInteger(udg_Hash, id, 2)
local boolean b = LoadBoolean(udg_Hash, id, 3)
local effect e
if IsUnitType(u, UNIT_TYPE_DEAD) or 0 >= i then
set e = LoadEffectHandle(udg_Hash, id, 4)
call DestroyEffect(e)
call ReleaseTimer(t)
call FlushChildHashtable(udg_Hash, id)
set e = null
else
if b == true then
call SetUnitState(u, UNIT_STATE_LIFE, (GetUnitState(u, UNIT_STATE_LIFE) + r))
elseif b == false then
call SetUnitState(u, UNIT_STATE_MANA, (GetUnitState(u, UNIT_STATE_MANA) + r))
endif
set i = (i - 1)
call SaveInteger(udg_Hash, id, 2, i)
endif
set t = null
set u = null
endfunction
function Start takes nothing returns boolean
local unit u
local timer t
local real r
local real r2
local real r3
local integer i
local integer id
local integer i2 = GetItemTypeId(GetManipulatedItem())
local boolean b
local effect e
if i2 == PH1() or i2 == PH2() or i2 == PH3() or i2 == PH4() or i2 == PH5() or i2 == PM1() or i2 == PM2() or i2 == PM3() or i2 == PM4() or i2 == PM5() then
set u = GetTriggerUnit()
set t = NewTimer()
set id = GetHandleId(t)
set e = AddSpecialEffectTarget("Abilities\\Spells\\NightElf\\Rejuvenation\\RejuvenationTarget.mdl", u, RAP())
if i2 == PH1() then
set r = PR1()
set i = GetHeroStr(u, true)
set r2 = r + (PRS1() * i)
set b = true
elseif i2 == PH2() then
set r = PR2()
set i = GetHeroStr(u, true)
set r2 = r + (PRS2() * i)
set b = true
elseif i2 == PH3() then
set r = PR3()
set i = GetHeroStr(u, true)
set r2 = r + (PRS3() * i)
set b = true
elseif i2 == PH4() then
set r = PR4()
set i = GetHeroStr(u, true)
set r2 = r + (PRS4() * i)
set b = true
elseif i2 == PH5() then
set r = PR5()
set i = GetHeroStr(u, true)
set r2 = r + (PRS5() * i)
set b = true
elseif i2 == PM1() then
set r = PR1()
set i = GetHeroInt(u, true)
set r2 = r + (PRS1() * i)
set b = false
elseif i2 == PM2() then
set r = PR2()
set i = GetHeroInt(u, true)
set r2 = r + (PRS2() * i)
set b = false
elseif i2 == PM3() then
set r = PR3()
set i = GetHeroInt(u, true)
set r2 = r + (PRS3() * i)
set b = false
elseif i2 == PM4() then
set r = PR4()
set i = GetHeroInt(u, true)
set r2 = r + (PRS4() * i)
set b = false
elseif i2 == PM5() then
set r = PR5()
set i = GetHeroInt(u, true)
set r2 = r + (PRS5() * i)
set b = false
endif
set r3 = (r2 / PROT())
call SaveReal(udg_Hash, id, 0, r3)
call SaveUnitHandle(udg_Hash, id, 1, u)
call SaveInteger(udg_Hash, id, 2, PROT())
call SaveBoolean(udg_Hash, id, 3, b)
call SaveEffectHandle(udg_Hash, id, 4, e)
call TimerStart(t, 1., true, function Loop)
set u = null
set e = null
set t = null
endif
return false
endfunction
function InitTrig_Potions takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddCondition( t, Condition( function Start ) )
set udg_Hash = InitHashtable()
set t = null
endfunction