- Joined
- Feb 22, 2006
- Messages
- 960
So i try to write my castbar system into vJass but it doens't want to work
what did i wrong?
what did i wrong?
JASS:
library castsystem
globals
private constant real Interval = 0.01
private timer Ti = CreateTimer()
private constant string Bar = "|"
private castbar Dat
endglobals
private function CreateTextTagNew takes string s , location loc, real zOffset, real size, real red, real green, real blue, real transparency returns texttag
local texttag tt
set tt = CreateTextTagLocBJ( s, loc, zOffset, size, red, green, blue, transparency )
call SetTextTagVisibility( tt, true )
return tt
endfunction
struct castbar
unit u
texttag tt
texttag tg
texttag ttt
location loc
real duration
real interval
real counter = 0
real dur
string text = ""
static method create takes unit u, location loc,real dur returns castbar
local castbar dat = castbar.allocate()
set dat.u = u
set dat.loc = loc
set dat.duration = dur
return dat
endmethod
method onDestroy takes nothing returns nothing
set this.u = null
set this.tt = null
set this.tg = null
set this.ttt = null
set this.loc = null
endmethod
endstruct
private function castbarexecute takes nothing returns nothing
local timer t = GetExpiredTimer()
set Dat.duration = Dat.duration + Interval
set Dat.counter = Dat.counter + Interval
set Dat.dur = Dat.dur + Interval
if (Dat.counter >= Dat.interval) then
set Dat.text = Dat.text + Bar
call SetTextTagTextBJ(Dat.tg,Dat.text,10)
call SetTextTagTextBJ(Dat.ttt,R2S(Dat.dur),8)
set Dat.counter = 0
endif
if (Dat.dur >= Dat.duration) then
call castbar.destroy(Dat)
call DestroyTimer(t)
set t = null
endif
set t = null
endfunction
function castbarAction takes real time,unit u returns nothing
local location loc = GetUnitLoc(u)
local string newtext = ""
local integer loopint = 0
set Dat = castbar.create(u,loc,time)
call RemoveLocation(loc)
set loc = null
loop
exitwhen loopint >= 100
set newtext = newtext + Bar
set loopint = loopint + 1
endloop
set Dat.duration = time
set Dat.interval = Dat.duration/100
set Dat.tt = CreateTextTagNew(newtext,loc,200.00,10,10,10,10,0)
set Dat.tg = CreateTextTagNew(Dat.text,loc,200.00,10,100,0,0,0)
set Dat.ttt = CreateTextTagNew(R2S(Dat.dur),loc,200.00,8,100,100,100,0)
call TimerStart(Ti,Interval,true,function castbarexecute)
endfunction
endlibrary
Last edited: