- Joined
- Dec 14, 2005
- Messages
- 10,532
anyways, im leaking or something somewhere, as this gets obscenely laggy after awhile, and i was hoping that one of you guys could pick it up
anyways, basically, the problem has bbout a 99% chance of being in the WhirlfuryIniter function, as it didnt lag until i added that one in
the funcs look fine to me... but im probably missing something
EDIT: those funcs at the top are really constant, but i removed constant from the front of them cuz it was messing w/ the indenting :?
anyways, basically, the problem has bbout a 99% chance of being in the WhirlfuryIniter function, as it didnt lag until i added that one in
the funcs look fine to me... but im probably missing something
EDIT: those funcs at the top are really constant, but i removed constant from the front of them cuz it was messing w/ the indenting :?
JASS:
function Whirlfury_Rawcode takes nothing returns integer
return 'A004'//rawcode of the Whirlfury spell
endfunction
function Whirlfury_HitsAllied takes nothing returns boolean
return false//does not hit allies
endfunction
function Whirlfury_Damage takes real level returns real
return 0 + level * 50//the damage per second dealt
endfunction
function Whirlfury_AOE takes real level returns real
return 300 + level * 0//the AOE of whirlfury
endfunction
function Whirlfury_Anginc takes real level returns real
return 18 + level * 0//the angle ( rotation ) increases by 360 degrees per second ( 3.6 degree per 0.01 seconds )
endfunction
function Whirlfury_Duration takes real level returns real
return 10 + level * 0//how long whirlfury lasts
endfunction
function Whirlfury_MaxTargets takes real level returns real
return 2 + level * 1//how many units Whirlfury can pick up
endfunction
function WhirlfuryLoop2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit( t, "targ" )
local real angle = GetHandleReal( t, "ang" )
local real time = GetHandleReal( t, "time" ) + 0.01
call SetUnitX( u, GetUnitX( u ) + 2 * Cos( angle * bj_DEGTORAD ) )
call SetUnitY( u, GetUnitY( u ) + 2 * Sin( angle * bj_DEGTORAD ) )
if time == GetHandleReal( t, "maxtime" ) then
call PauseTimer( t )
call FlushHandleLocals( t )
call DestroyTimer( t )
call PauseUnit( u, false )
else
call SetHandleReal( t, "time", time )
endif
set u = null
set t = null
endfunction
function WhirlfuryLoop takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit( t, "targ" )
local unit u2 = GetHandleUnit( t, "cast" )
local real angle = GetHandleReal( t, "ang" ) + GetHandleReal( t, "anginc" )
local real initdist = GetHandleReal( t, "initdist" )
local real time = GetHandleReal( t, "time" ) + 0.01
local real maxtime = GetHandleReal( t, "maxtime" )
call UnitDamageTarget( u2, u, GetHandleReal( t, "dmg" ), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null )
if angle > 360 then
set angle = angle - 360
endif
call SetUnitX( u, GetUnitX( u2 ) + initdist * Cos( angle * bj_DEGTORAD ) )
call SetUnitY( u, GetUnitY( u2 ) + initdist * Sin( angle * bj_DEGTORAD ) )
if time == maxtime then
call PauseTimer( t )
call FlushHandleLocals( t )
call DestroyTimer( t )
set t = CreateTimer()
call SetHandleReal( t, "ang", Atan2( GetUnitY( u ) - GetUnitY( u2 ), GetUnitX( u ) - GetUnitX( u2 ) ) * bj_RADTODEG )
call SetHandleHandle( t, "cast", u2 )
call SetHandleHandle( t, "targ", u )
call SetHandleReal( t, "maxtime", 2 )
call SetHandleReal( t, "time", 0 )
call TimerStart( t, 0.01, true, function WhirlfuryLoop2 )
else
call SetHandleReal( t, "time", time )
call SetHandleReal( t, "ang", angle )
endif
set u = null
set u2 = null
set t = null
endfunction
function WhirlfuryInitLoop takes unit u, unit u2, integer i, real duration returns nothing
local timer t = CreateTimer()
call SetHandleReal( t, "dmg", Whirlfury_Damage(i)/100 )
call SetHandleReal( t, "anginc", Whirlfury_Anginc(i) )
call SetHandleReal( t, "ang", Atan2( GetUnitY( u2 ) - GetUnitY( u ), GetUnitX( u2 ) - GetUnitX( u ) ) * bj_RADTODEG )
call SetHandleHandle( t, "cast", u2 )
call SetHandleHandle( t, "targ", u )
call SetHandleReal( t, "initdist", SquareRoot( ( GetUnitX( u2 ) - GetUnitX( u ) ) * ( GetUnitX( u2 ) - GetUnitX( u ) ) + ( GetUnitY( u2 ) - GetUnitY( u ) ) * ( GetUnitY( u2 ) - GetUnitY( u ) ) ) )
call SetHandleReal( t, "maxtime", duration )
call SetHandleReal( t, "time", 0 )
call PauseUnit( u, true )
call TimerStart( t, 0.01, true, function WhirlfuryLoop )
set t = null
endfunction
function WhirlfuryIniter takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit( t, "u" )
local integer i = GetUnitAbilityLevel( u, Whirlfury_Rawcode() )
local group g = CreateGroup()
local group safety = GetHandleGroup( t, "safe" )
local group safety2 = CreateGroup()
local unit u2
local unit u3
local integer maxTargs = GetHandleInt( t, "maxTargs" )
local real Time = GetHandleReal( t, "timeelapsed" ) + .5
local boolean b = false
call GroupEnumUnitsInRange( g, GetUnitX( u ), GetUnitY( u ), Whirlfury_AOE(i), null )
loop
set u2 = FirstOfGroup( g )
exitwhen u2 == null
call GroupAddGroup( safety, safety2 )
loop
set u3 = FirstOfGroup( safety2 )
exitwhen u3 == null
if u2 == u3 then
set b = true
endif
call GroupRemoveUnit( safety2, u3 )
endloop
if maxTargs != Whirlfury_MaxTargets(i) and ( IsUnitEnemy( u2, GetOwningPlayer( u ) ) or Whirlfury_HitsAllied() ) and not b then
call WhirlfuryInitLoop( u2, u, i, Whirlfury_Duration(i) - Time )
call GroupAddUnit( safety, u )
set maxTargs = maxTargs + 1
endif
set b = false
call GroupRemoveUnit( g, u2 )
endloop
if maxTargs == Whirlfury_MaxTargets(i) or Time == Whirlfury_Duration(i) then
call PauseTimer( t )
call FlushHandleLocals( t )
call DestroyTimer( t )
call DestroyGroup( safety )
else
call SetHandleReal( t, "maxTargs", maxTargs )
call SetHandleReal( t, "timeelapsed", Time )
call SetHandleHandle( t, "safe", safety )
endif
call DestroyGroup( safety2 )
call DestroyGroup( g )
set g = null
set u = null
set safety = null
set safety2 = null
set t = null
endfunction
function Whirlfury takes nothing returns nothing
local timer t = CreateTimer()
local unit u = GetTriggerUnit()
call SetHandleHandle( t, "safe", CreateGroup() )
call SetHandleHandle( t, "u", u )
call SetHandleReal( t, "timeelapsed", 0 )
call SetHandleInt( t, "maxTargs", 0 )
call TimerStart( t, .5, true, function WhirlfuryIniter )
set u = null
set t = null
endfunction
function WhirlfuryConds takes nothing returns boolean
return GetSpellAbilityId() == Whirlfury_Rawcode()
endfunction
function InitTrig_Whirlfury takes nothing returns nothing
set gg_trg_Whirlfury = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_Whirlfury, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Whirlfury, Condition( function WhirlfuryConds ) )
call TriggerAddAction( gg_trg_Whirlfury, function Whirlfury )
endfunction