- Joined
- Mar 16, 2008
- Messages
- 941
Hey guys, it's me again
I'm working on something I'd call an effect stack, meaning you can add effects to a list and them run the entire list at once.
The stuff is actually working, but it seems that Vexorian doesn't like me o.o
That's the code:
STACKS and EPS are constants, both with the value 50.
AllocateTimer() is some sort of TimerUltis, RemoveEffect is another part of this effect system But all that doesn't matter... when I run this script:
it works, the effects are shown in this rythm.
BUT, I get a message on the screen:
"Unable to allocate id for an object of type: EffectSystem_Stack"
I mean, it works... why the hell do I get this message?
It has to do something with the allocation (orly?) but I don't know what it is, I never got it before...
Hope anyone can help me, Justify
[Edit]PS: Why isn't there a [vJass] prefix in the list?
I'm working on something I'd call an effect stack, meaning you can add effects to a list and them run the entire list at once.
The stuff is actually working, but it seems that Vexorian doesn't like me o.o
That's the code:
JASS:
private struct Stack [STACKS]
string array path [EPS]
real array x [EPS]
real array y [EPS]
unit array target [EPS]
string array point [EPS]
location array loc [EPS]
real array wait [EPS]
real array dur [EPS]
real duration
real max
real period
integer count
integer id
boolean start
timer tim
static method CreateStack takes nothing returns integer
local Stack dat = Stack.allocate()
set dat.duration = 0.
set dat.max = 0.
set dat.count = 0
set dat.id = StructCount
set dat.start = false
set StackArray[StackCount] = dat
set StackCount = StackCount+1
return StackCount-1
endmethod
static method AddEffect takes integer stack, real x, real y, string path, real wait, real dur returns nothing
local Stack dat = StackArray[stack]
set dat.path[dat.count] = path
set dat.x[dat.count] = x
set dat.y[dat.count] = y
set dat.target[dat.count] = null
set dat.point[dat.count] = null
set dat.loc[dat.count] = null
set dat.max = dat.max+wait
set dat.wait[dat.count] = dat.max
set dat.dur[dat.count] = dur
set dat.count = dat.count+1
endmethod
static method AddEffectTarget takes integer stack, unit u, string point, string path, real wait, real dur returns nothing
local Stack dat = StackArray[stack]
set dat.path[dat.count] = path
set dat.x[dat.count] = 0.
set dat.y[dat.count] = 0.
set dat.target[dat.count] = u
set dat.point[dat.count] = point
set dat.loc[dat.count] = null
set dat.max = dat.max+wait
set dat.wait[dat.count] = dat.max
set dat.dur[dat.count] = dur
set dat.count = dat.count+1
endmethod
static method AddEffectLoc takes integer stack, location l, string path, real wait, real dur returns nothing
local Stack dat = StackArray[stack]
set dat.path[dat.count] = path
set dat.x[dat.count] = 0.
set dat.y[dat.count] = 0.
set dat.target[dat.count] = null
set dat.point[dat.count] = null
set dat.loc[dat.count] = l
set dat.max = dat.max+wait
set dat.wait[dat.count] = dat.max
set dat.dur[dat.count] = dur
set dat.count = dat.count+1
endmethod
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
static method Run takes nothing returns nothing
local Stack dat = StackArray[GetTimerIntData(GetExpiredTimer())]
local integer i = 0
set dat.duration = dat.duration+dat.period
loop
exitwhen i >= dat.count
if dat.wait[i] <= dat.duration and dat.wait[i] > dat.duration-dat.period then
if dat.target[i] != null then
call RemoveEffect.execute(AddSpecialEffectTarget(dat.path[i], dat.target[i], dat.point[i]), dat.dur[i])
elseif dat.loc[i] != null then
call RemoveEffect.execute(AddSpecialEffectLoc(dat.path[i], dat.loc[i]), dat.dur[i])
else
call RemoveEffect.execute(AddSpecialEffect(dat.path[i], dat.x[i], dat.y[i]), dat.dur[i])
endif
endif
set i = i+1
endloop
if dat.duration >= dat.max then
call dat.StopStack()
endif
endmethod
//---------------------------------------------------------------------------------
//---------------------------------------------------------------------------------
static method DestroyStack takes integer stack returns nothing
endmethod
method StopStack takes nothing returns nothing
call PauseTimer(.tim)
set .duration = 0.
endmethod
static method ResumeStack takes integer stack returns nothing
call TimerStart(StackArray[stack].tim, StackArray[stack].period, true, function Stack.Run)
endmethod
static method PauseStack takes integer stack returns nothing
call PauseTimer(StackArray[stack].tim)
endmethod
static method StartStack takes integer stack, real period returns nothing
local Stack dat = StackArray[stack]
if not dat.start then
set dat.start = true
set dat.period = period
set dat.tim = AllocateTimer()
call SetTimerIntData(dat.tim, stack)
call TimerStart(dat.tim, period, true, function Stack.Run)
endif
endmethod
method onDestroy takes nothing returns nothing
endmethod
endstruct
//---------------------------------------------------------------------------------
//--------------------------WRAPPER FUNCTIONS--------------------------------------
function CreateEffectStack takes nothing returns integer
return Stack.CreateStack()
endfunction
function AddEffectToStack takes integer stack, real x, real y, string path, real wait, real dur returns nothing
call Stack.AddEffect(stack, x, y, path, wait, dur)
endfunction
function StartEffectStack takes integer stack returns nothing
call Stack.StartStack(stack, 0.01)
endfunction
AllocateTimer() is some sort of TimerUltis, RemoveEffect is another part of this effect system But all that doesn't matter... when I run this script:
JASS:
local integer i = CreateEffectStack()
call AddEffectToStack(i, 0., 0., "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", 0.2, 1.)
call AddEffectToStack(i, 0., 0., "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", 0.2, 1.)
call AddEffectToStack(i, 0., 0., "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", 0.5, 1.)
call AddEffectToStack(i, 0., 0., "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", 1., 1.)
call AddEffectToStack(i, 0., 0., "Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", 0.2, 1.)
call StartEffectStack(i)
BUT, I get a message on the screen:
"Unable to allocate id for an object of type: EffectSystem_Stack"
I mean, it works... why the hell do I get this message?
It has to do something with the allocation (orly?) but I don't know what it is, I never got it before...
Hope anyone can help me, Justify
[Edit]PS: Why isn't there a [vJass] prefix in the list?