- Joined
- Aug 1, 2013
- Messages
- 4,658
Well... with my great idea of giving heroes experience over time to give you a slightly better view on how much experience you gained, I wrote TimedExperience.
To my greatest surprise, it didn't have any errors when I saved it after completing the code, but it didn't really work as expected.
With a few BJDebugMsg()s, I managed to find out that there was nothing wrong with my system, but it is actually Warcraft III that is unable to give experience in such a short time.
If there is anyone who can enlighten me about it, then please do.
To my greatest surprise, it didn't have any errors when I saved it after completing the code, but it didn't really work as expected.
With a few BJDebugMsg()s, I managed to find out that there was nothing wrong with my system, but it is actually Warcraft III that is unable to give experience in such a short time.
JASS:
library TimedExperience uses TimerUtils
//! runtextmacro CREATE_UNIQUE_ID("TimedExp")
globals
real TIMEDEXP_INTERVAL = 0.1
integer TIMEDEXP_STEPS = 10
unit array timedExp_Hero
integer array timedExp_Steps
integer array timedExp_Exp_Total
integer array timedExp_Exp_Current
boolean array timedExp_EyeCandy
endglobals
function AddHeroXPTimed_Callback takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetTimerData(t)
local integer newExp
set timedExp_Steps[id] = timedExp_Steps[id] -1
if timedExp_Steps[id] > 0 then
set newExp = R2I(timedExp_Exp_Total[id] * (TIMEDEXP_STEPS-timedExp_Steps[id]) * TIMEDEXP_INTERVAL)
call AddHeroXP(timedExp_Hero[id], newExp - timedExp_Exp_Current[id], timedExp_EyeCandy[id])
call BJDebugMsg("EXP added: " + I2S(newExp - timedExp_Exp_Current[id]))
set timedExp_Exp_Current[id] = newExp
else
call AddHeroXP(timedExp_Hero[id], timedExp_Exp_Total[id] - timedExp_Exp_Current[id], timedExp_EyeCandy[id])
call BJDebugMsg("EXP added: " + I2S(timedExp_Exp_Total[id] - timedExp_Exp_Current[id]))
set timedExp_Hero[id] = null
set timedExp_Steps[id] = 0
set timedExp_Exp_Total[id] = 0
set timedExp_Exp_Current[id] = 0
set timedExp_EyeCandy[id] = false
call TimedExp_ReleaseId(id)
call ReleaseTimer(t)
endif
set t = null
endfunction
function AddHeroXPTimed takes unit whichHero, integer xpToAdd, boolean showEyeCandy returns nothing
local integer id = TimedExp_CreateId()
local timer t = NewTimerEx(id)
set timedExp_Hero[id] = whichHero
set timedExp_Steps[id] = TIMEDEXP_STEPS
set timedExp_Exp_Total[id] = xpToAdd
set timedExp_Exp_Current[id] = 0
set timedExp_EyeCandy[id] = showEyeCandy
call TimerStart(t, TIMEDEXP_INTERVAL, true, function AddHeroXPTimed_Callback)
set t = null
endfunction
endlibrary
If there is anyone who can enlighten me about it, then please do.
Last edited by a moderator: