- Joined
- Dec 12, 2008
- Messages
- 7,385
Timer Tools now supports .03125 timeouts

Timer tools max timeout is now 25

Timer Tools now supports .03125 timeouts
Timer tools max timeout is now 25
scope MetalShot
private struct MetalShot
unit caster
unit array arrows[3]
player owner
integer lvl
real array cos[3]
real array sin[3]
real dmg
real dist
private static constant real TIMEOUT = 0.031250000
private static hashtable ht = InitHashtable()
private group tmpGroup = bj_lastCreatedGroup
implement CTT
local unit f
local integer i
local real x
local real y
implement CTTExpire
if dist > 0 then
set i = 0
loop
exitwhen i >= 3
set x = GetUnitX(this.arrows[i]) + 21 * this.cos[i]
set y = GetUnitY(this.arrows[i]) + 21 * this.sin[i]
call SetUnitX(this.arrows[i],x)
call SetUnitY(this.arrows[i],y)
call GroupEnumUnitsInRange(tmpGroup,x,y,250,null)
loop
set f = FirstOfGroup(tmpGroup)
exitwhen f == null
call GroupRemoveUnit(tmpGroup,f)
if IsUnitEnemy(f,this.owner) and not IsUnitType(f,UNIT_TYPE_STRUCTURE) and UnitAlive(f) and not HaveSavedBoolean(ht,this,GetHandleId(f)) then
call UnitDamageTarget(this.caster,f,this.dmg,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC,null)
call SaveBoolean(ht,this,GetHandleId(f),true)
endif
endloop
set i = i + 1
endloop
set dist = dist - 21
else
set i = 0
loop
exitwhen i >= 3
call RemoveUnit(this.arrows[i])
set i = i + 1
endloop
call FlushChildHashtable(ht,this)
call this.destroy()
endif
implement CTTNull
set f = null
implement CTTEnd
static method start takes nothing returns boolean
local thistype this = thistype.create()
local integer i = 0
local real angle
set this.caster = GetTriggerUnit()
set this.owner = GetTriggerPlayer()
set this.lvl = GetUnitAbilityLevel(this.caster,'A009')
set this.dist = 700
set this.dmg = 1000
set angle = GetUnitFacing(this.caster)-45
loop
exitwhen i >= 3
set this.arrows[i] = CreateUnit(Player(15),'h006',GetUnitX(this.caster),GetUnitY(this.caster),angle)
set this.cos[i] = Cos(angle*bj_DEGTORAD)
set this.sin[i] = Sin(angle*bj_DEGTORAD)
set angle = angle + 45
set i = i + 1
endloop
return false
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent('A009',function thistype.start)
endmethod
endstruct
endscope
private struct MetalShot
Nes Nes is awesome
By Nes Nes
Nes Nes is so awesome
That I wrote this awesome poem
How awesome
Nes, you should indicate in the documentation that a particular timer loop cannot run under 'X real', coz I've tested CTC and it cant run under 0.4, and CTTC cant run above 0.3...CTC might use a timeout of 2 or 5
Maybe it's an option, coz I've tested it and worked just fineit has to extend array
************************************************************************************
*
* SETTINGS
*/
Haha, thanks for pointing that out.What does this tell you? Using standard timers is smart and better than using TimerUtils >.>, lolz.
... assuming that there is nothing in the function attached to the timers.The noticeable difference starts at 60-ish timers with average specs![]()
return
or exitwhen true
but instead.. the current instance onlyscope DragonUppercut
private struct DUppercut extends array
unit caster
unit target
player owner
real ux
real uy
real dmg
integer count
integer lvl
private static constant real TIMEOUT = 0.031250000
private static constant real TIME = (0.7/TIMEOUT)
private static boolean b = false
implement CTTC
local real x
local real y
local real conv
local real height
local real speed
implement CTTCExpire
if this.count <= TIME then
set conv = (50/TIME)*this.count
set height = Pow(conv-25,2)
call SetUnitFlyHeight(this.target, 200-height,0)
set this.count = this.count + 1
else
call UnitDamageTarget(this.caster,this.target,this.dmg,false,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null)
call SetUnitFlyHeight(this.target,GetUnitDefaultFlyHeight(this.target),0)
call PauseUnit(this.target,false)
call IssueImmediateOrder(this.target,"stop")
call ResetHeroBurningMode(this.caster)
call this.destroy()
endif
if not UnitAlive(this.target) then
call SetUnitFlyHeight(this.target,GetUnitDefaultFlyHeight(this.target),0)
call PauseUnit(this.target,false)
call ResetHeroBurningMode(this.caster)
call this.destroy()
endif
implement CTTCEnd
static method start takes nothing returns boolean
local thistype this = thistype.create()
set this.caster = GetTriggerUnit()
set this.target = GetSpellTargetUnit()
set this.owner = GetTriggerPlayer()
set this.ux = GetUnitX(this.target)
set this.uy = GetUnitY(this.target)
set this.count = 1
set this.lvl = GetUnitAbilityLevel(this.caster,'A00C')
call IssueImmediateOrder(this.target,"stop")
call PauseUnit(this.target,true)
if UnitAddAbility(this.target,'Arav') then
call UnitRemoveAbility(this.target,'Arav')
endif
set this.dmg = (1+(0.4*this.lvl))*GetHeroStr(this.caster,true)
return false
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent('A00C',function thistype.start)
call AbilityPreload('A00C')
endmethod
endstruct
endscope
implement CTTCExpire
implement CTL
local boolean continue = true
implement CTLExpire
loop
if continue then
// code
if count[this] <= 0 then
call this.destroy()
//exitwhen true
set continue = false
endif
if continue then
// more code
endif
endif
endloop
set continue = true
implement CTLNull
implement CTLEnd
scope ArrowStorm
private struct Data extends array
boolean posNeg
integer times
real maxAngle
real dist
real angle
real dx
real dy
endstruct
private struct AStorm extends array
unit caster
player owner
integer count
boolean allArrows
real ux
real uy
real nextAngle
real wait
private static constant real TIMEOUT = 0.031250000
private static hashtable ht = InitHashtable()
private static group tmpGroup
implement CTTC
local unit d
local boolean b = false
local integer i = 0
local integer int
local real x
local real y
implement CTTCExpire
loop
exitwhen i == this.count
call BJDebugMsg("Loop: " +I2S(i))
set d = LoadUnitHandle(ht,this,i)
set int = GetUnitId(d)
if Data[int].posNeg then
set Data[int].angle = Data[int].angle + 3
if Data[int].angle >= Data[int].maxAngle then
set x = Data[int].dx + Data[int].dist * Cos(Data[int].maxAngle * bj_DEGTORAD)
set y = Data[int].dy + Data[int].dist * Sin(Data[int].maxAngle * bj_DEGTORAD)
set b = true
else
set x = Data[int].dx + Data[int].dist * Cos(Data[int].angle * bj_DEGTORAD)
set y = Data[int].dy + Data[int].dist * Sin(Data[int].angle * bj_DEGTORAD)
endif
call BJDebugMsg("Set data positive")
else
set Data[int].angle = Data[int].angle - 3
if Data[int].angle <= Data[int].maxAngle then
set x = Data[int].dx + Data[int].dist * Cos(Data[int].maxAngle * bj_DEGTORAD)
set y = Data[int].dy + Data[int].dist * Sin(Data[int].maxAngle * bj_DEGTORAD)
set b = true
else
set x = Data[int].dx + Data[int].dist * Cos(Data[int].angle * bj_DEGTORAD)
set y = Data[int].dy + Data[int].dist * Sin(Data[int].angle * bj_DEGTORAD)
endif
call BJDebugMsg("Set data negative")
endif
if b then
if Data[int].times >= 5 then
call RemoveUnit(d)
set this.count = this.count - 1
else
set Data[int].dist = Data[int].dist + 100
set Data[int].times = Data[int].times + 1
set Data[int].dx = x + Data[int].dist * Cos(Data[int].maxAngle * bj_DEGTORAD)
set Data[int].dy = y + Data[int].dist * Sin(Data[int].maxAngle * bj_DEGTORAD)
set Data[int].angle = Data[int].angle + 180
if Data[int].posNeg then
set Data[int].posNeg = false
set Data[int].maxAngle = Data[int].angle - 270
else
set Data[int].posNeg = true
set Data[int].maxAngle = Data[int].angle + 270
endif
call BJDebugMsg("times")
endif
endif
call SetUnitX(d,x)
call SetUnitY(d,y)
set b = false
set i = i + 1
endloop
if this.count <= 0 then
call FlushChildHashtable(ht,this)
call this.destroy()
call BJDebugMsg("destroy all")
/*elseif not this.allArrows then
if this.wait >= 0.4 then
set d = CreateUnit(Player(15),'hpea',this.ux,this.uy,0)
call SaveUnitHandle(ht,this,0,d)
set int = GetUnitId(d)
set Data[int].posNeg = true
set Data[int].maxAngle = 360
set Data[int].dist = 150
set Data[int].angle = this.nextAngle
set Data[int].times = 0
set Data[int].dx = this.ux
set Data[int].dy = this.uy
set this.count = this.count + 1
set this.wait = 0
call BJDebugMsg("create unit " + I2S(this.count))
if this.count >= 5 then
set this.allArrows = true
call BJDebugMsg("limit unit")
endif
else
set this.wait = this.wait + TIMEOUT
endif*/
endif
implement CTTCNull
set d = null
implement CTTCEnd
static method start takes nothing returns boolean
local thistype this = thistype.create()
local unit d
local integer int
set this.caster = GetTriggerUnit()
set this.owner = GetTriggerPlayer()
set this.ux = GetUnitX(this.caster)
set this.uy = GetUnitY(this.caster)
set this.count = 1
set this.allArrows = false
set this.wait = 0
set d = CreateUnit(Player(15),'hpea',this.ux,this.uy,0)
call SaveUnitHandle(ht,this,0,d)
set int = GetUnitId(d)
set Data[int].posNeg = true
set Data[int].maxAngle = 360
set Data[int].dist = 150
set Data[int].angle = GetRandomReal(0,360)
set Data[int].times = 0
set Data[int].dx = this.ux
set Data[int].dy = this.uy
set this.nextAngle = Data[int].angle
set d = null
return false
endmethod
static method onInit takes nothing returns nothing
call RegisterSpellEffectEvent('A000',function thistype.start)
endmethod
endstruct
endscope
exitwhen i == this.count
to exitwhen i >= this.count
function Trig_Position_Actions takes nothing returns nothing
if Red == true then
call S(1)
endif
endfunction
function InitTrig_Position takes nothing returns nothing
set gg_trg_Position = CreateTrigger( )
call TriggerRegisterTimerEvent(gg_trg_Position, 0.01, true)
call TriggerAddAction( gg_trg_Position, function Trig_Position_Actions )
endfunction
Kinda confuse how do I set up the timers..
How would this look using your timer system.
JASS:function Trig_Position_Actions takes nothing returns nothing if Red == true then call S(1) endif endfunction function InitTrig_Position takes nothing returns nothing set gg_trg_Position = CreateTrigger( ) call TriggerRegisterTimerEvent(gg_trg_Position, 0.01, true) call TriggerAddAction( gg_trg_Position, function Trig_Position_Actions ) endfunction
I learn by examples so please show me how the top jass code would look like using your system.
@scope Position initializer Init@
@private @function Actions takes nothing returns nothing
if Red/* == true*/ then
call S(1)
endif
endfunction
@private @function Init takes nothing returns nothing
@call TimerStart(CreateTimer(), 0.01, true, function Actions)@
/*
set gg_trg_Position = CreateTrigger( )
call TriggerRegisterTimerEvent(gg_trg_Position, 0.01, true)
call TriggerAddAction( gg_trg_Position, function Trig_Position_Actions )
*/
endfunction
@endscope@
local timer t=NewTimer()
call TimerStart(t, 0.01, true, function Handlerfunc)
set t=null
call TimerStart(NewTimer(), 0.01, true, function Handlerfunc)
Scope makes everything inside inaccessible from the outside.
Private means that nothing outside the scope or library can use it.
It's usually useless to use private inside Scopes because they make things private anyways.
By the way, your code can be changed to:
call TimerStart(NewTimer(), 0.01, true, function Handlerfunc)