- Joined
- May 16, 2012
- Messages
- 644
Hello Hive! I created a custom Rain of Fire for one of my Heroes in my map, because i don't want it to be channeled, and i'm in a bit of a dead end now, because i think something is leaking but i cant find out what. There's nothing else being executed in the map, and i pre-placed a couple dozen units to test the ability, and it seems that the more i use it the less fps i got. i start with around 130 fps and after 10 casts or so, my fps is down to 60 or less. I'm using BPower Missile System and the core destructor for it, is returning true in one of the methods, which i am. I also add a couple of debug messages to be sure that the timers i initialize are being stopped and destroyed, and they are. If someone has any idea, plz tell me.
JASS:
scope Monnoroth initializer Init
globals
integer array RoFDot
endglobals
private function DoRoFDot takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit source = LoadUnitHandle(udg_HeroHash, GetHandleId(t), 1)
local unit target = LoadUnitHandle(udg_HeroHash, GetHandleId(t), 2)
local real dot = LoadReal(udg_HeroHash, GetHandleId(t), 3)
local integer index = GetUnitUserData(target)
set RoFDot[index] = RoFDot[index] - 1
call UnitDamageTarget(source, target, dot, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_UNIVERSAL, null)
if RoFDot[index] <= 0 or not UnitAlive(target) then
call DebugMsg("DoRoFDot!")
set RoFDot[index] = 0
call DestroyEffect(LoadEffectHandle(udg_HeroHash, GetHandleId(target), 46))
call RemoveSavedHandle(udg_HeroHash, GetHandleId(target), 46)
call FlushChildHashtable(udg_HeroHash, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
endif
set t = null
set source = null
set target = null
endfunction
private function RainOfFireDot takes unit source, unit target, real dot returns nothing
local timer t
local effect e
local integer index = GetUnitUserData(target)
local integer counter = RoFDot[index]
if counter == 0 then
set t = CreateTimer()
set e = AddSpecialEffectTarget("BurnLarge.mdx", target, "origin")
call SaveEffectHandle(udg_HeroHash, GetHandleId(target), 46, e)
call SaveUnitHandle(udg_HeroHash, GetHandleId(t), 1, source)
call SaveUnitHandle(udg_HeroHash, GetHandleId(t), 2, target)
call SaveReal(udg_HeroHash, GetHandleId(t), 3, dot)
call TimerStart(t, 1, true, function DoRoFDot)
endif
if (counter + 4) > 4 then
set RoFDot[index] = RoFDot[index] + (4 - counter)
else
set RoFDot[index] = RoFDot[index] + 4
endif
set t = null
set e = null
endfunction
private struct FireMeteor extends array
real dot
static method onFinish takes Missile missile returns boolean
local thistype this = thistype(missile)
local group g = CreateGroup()
local unit u
call GroupEnumUnitsInRange(g, missile.x, missile.y, 100, null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if UnitAlive(u) and IsUnitEnemy(u, missile.owner) then
if UnitDamageTarget(missile.source, u, missile.damage, false, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null) then
call RainOfFireDot(missile.source, u, this.dot)
endif
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
set g = null
return true
endmethod
implement MissileStruct
endstruct
private function LaunchMeteor takes Missile meteor, unit caster, integer level, string fx returns nothing
set meteor.scale = 1.5
set meteor.damage = (500*level / (6 - level))
set meteor.model = fx
set meteor.source = caster
set meteor.owner = GetOwningPlayer(caster)
set meteor.acceleration = 0.0
set FireMeteor(meteor).dot = (250*level / (6 - level))
call meteor.flightTime2Speed(1.0)
call FireMeteor.launch(meteor)
endfunction
private function GetRandomRange takes real radius returns real
local real r = GetRandomReal(0, 1) + GetRandomReal(0, 1)
if r > 1 then
return (2 - r)*radius
endif
return r*radius
endfunction
private function RainOfFire takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = LoadUnitHandle(udg_HeroHash, GetHandleId(t), 1)
local integer level = LoadInteger(udg_HeroHash, GetHandleId(t), 2)
local real interval = LoadReal(udg_HeroHash, GetHandleId(t), 3)
local real centerX = LoadReal(udg_HeroHash, GetHandleId(t), 4)
local real centerY = LoadReal(udg_HeroHash, GetHandleId(t), 5)
local real duration = LoadReal(udg_HeroHash, GetHandleId(t), 6)
//parameters
local real maxRange
local real theta
local real radius
local real posX
local real posY
local real angle
local real maxX
local real maxY
local real dX
local real dY
//missile
local Missile meteor
set duration = duration + interval
call SaveReal(udg_HeroHash, GetHandleId(t), 6, duration)
if duration < 10 then
set maxRange = (250 + 25*level)
set theta = 2*bj_PI*GetRandomReal(0, 1)
set radius = GetRandomRange(maxRange)
set posX = centerX + radius*Cos(theta)
set posY = centerY + radius*Sin(theta)
set angle = 2*bj_PI*GetRandomReal(0, 1)
set maxX = centerX + maxRange*Cos(angle)
set maxY = centerY + maxRange*Sin(angle)
set dX = posX - maxX
set dY = posY - maxY
set meteor = Missile.createXYZ(posX, posY, 2000, posX, posY, 0)
call LaunchMeteor(meteor, u, level, "Rain of Fire Vol. II Missile.mdx")
else
call DebugMsg("RainOfFire!")
call FlushChildHashtable(udg_HeroHash, GetHandleId(t))
call PauseTimer(t)
call DestroyTimer(t)
endif
set t = null
set u = null
endfunction
private function DoRainOfFire takes nothing returns nothing
local unit u = GetTriggerUnit()
local integer level = GetUnitAbilityLevel(u, 'A02N')
local real interval = 0.05*(6 - level)
local real centerX = GetSpellTargetX()
local real centerY = GetSpellTargetY()
local timer t = CreateTimer()
call SaveUnitHandle(udg_HeroHash, GetHandleId(t), 1, u)
call SaveInteger(udg_HeroHash, GetHandleId(t), 2, level)
call SaveReal(udg_HeroHash, GetHandleId(t), 3, interval)
call SaveReal(udg_HeroHash, GetHandleId(t), 4, centerX)
call SaveReal(udg_HeroHash, GetHandleId(t), 5, centerY)
call SaveReal(udg_HeroHash, GetHandleId(t), 6, 0)
call TimerStart(t, interval, true, function RainOfFire)
set t = null
set u = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
call RegisterSpellEffectEvent('A02N', function DoRainOfFire)
endfunction
endscope