- Joined
- Jan 6, 2006
- Messages
- 106
Here is the JASS code of a "shockwave" type spell which heals allied units and damages enemy units in a line.
However, every time I cast the spell, it will result it severe framerate drops. And it gets cumulatively worse.
I've followed the JASS guide and closed all leaks as instructed. But it doesn't help. Even increasing the interval between each run of the trigger doesn't. Please help me to find out what is wrong. Thanks.
Oh, and 1 more thing. If I make this spell to be targeted at specific units, this kind of thing does not happen. Can someone please tell me why?
------------------------------------------------------------------------------------
function Trig_Nullifying_Bolt_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A0LL' ) ) then
return false
endif
return true
endfunction
function NullifyingBoltEffect takes nothing returns nothing
local trigger trg = GetTriggeringTrigger()
local group k = GetHandleGroup(trg,"k")
local unit u = GetHandleUnit(trg,"u")
local location p = GetHandleLocation(trg,"p")
local unit h = GetEnumUnit()
local location l = GetUnitLoc(h)
if ( IsUnitType(h, UNIT_TYPE_STRUCTURE) == false ) then
if ( IsUnitType(h, UNIT_TYPE_MECHANICAL) == false ) then
if ( IsUnitAliveBJ(h) == true ) then
if ( GetUnitAbilityLevelSwapped('Avul', h) == 0 ) then
if ( IsUnitInGroup(h, k) == false ) then
if ( IsUnitType(h, UNIT_TYPE_MAGIC_IMMUNE) == false ) then
if ( h != u ) then
call GroupAddUnitSimple( h, k )
if ( IsUnitEnemy(h, GetOwningPlayer(u)) == true ) then
call UnitDamageTargetBJ( u, h, ( 00.00 + ( 65.00 * I2R(GetUnitAbilityLevelSwapped('A0LL', u)) ) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
else
call SetUnitLifeBJ( h, ( GetUnitStateSwap(UNIT_STATE_LIFE, h) + ( 0.00 + ( 50.00 * I2R(GetUnitAbilityLevelSwapped('A0LL', u)) ) ) ) )
endif
call AddSpecialEffectTargetUnitBJ( "overhead", h, "Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCaster.mdl" )
call TriggerExecute( gg_trg_DestroySFX )
endif
endif
endif
endif
endif
endif
endif
call RemoveLocation(l)
set l = null
set u = null
set p = null
set h = null
set k = null
set trg = null
endfunction
function NullifyingBolt takes nothing returns nothing
local trigger trg = GetTriggeringTrigger()
local group k = GetHandleGroup(trg,"k")
local unit u = GetHandleUnit(trg,"u")
local location p = GetHandleLocation(trg,"p")
local unit e = GetHandleUnit(trg,"e")
local location l = GetUnitLoc(e)
local location m = PolarProjectionBJ(l, 20.00, AngleBetweenPoints(l, p))
local group x = GetUnitsInRangeOfLocAll(200.00, l)
local group y = GetUnitsInRangeOfLocAll(18.00, p)
call ForGroupBJ( x, function NullifyingBoltEffect )
if ( RectContainsLoc(udg_EntireMap, p) == false ) then
call KillUnit(e)
call GroupClear(k)
call RemoveUnit(e)
call DestroyGroup(k)
call DestroyGroup(x)
call DestroyGroup(y)
call RemoveLocation(l)
call RemoveLocation(m)
call RemoveLocation(p)
call DisableTrigger(trg)
call FlushHandleLocals(trg)
call DestroyTrigger(trg)
set u = null
set p = null
set e = null
set k = null
set x = null
set y = null
set l = null
set m = null
set trg = null
return
endif
call SetUnitPositionLocFacingBJ( e, m, AngleBetweenPoints(l, p) )
if IsUnitInGroup(e, y) then
call KillUnit(e)
call GroupClear(k)
call RemoveUnit(e)
call DestroyGroup(k)
call DestroyGroup(x)
call DestroyGroup(y)
call RemoveLocation(l)
call RemoveLocation(m)
call RemoveLocation(p)
call DisableTrigger(trg)
call FlushHandleLocals(trg)
call DestroyTrigger(trg)
set u = null
set p = null
set e = null
set k = null
set x = null
set y = null
set l = null
set m = null
set trg = null
endif
call DestroyGroup(x)
call DestroyGroup(y)
call RemoveLocation(l)
call RemoveLocation(m)
set u = null
set p = null
set e = null
set k = null
set x = null
set y = null
set l = null
set m = null
set trg = null
endfunction
function Trig_Nullifying_Bolt_Actions takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local location l = GetUnitLoc(u)
local location m = GetSpellTargetLoc()
local location p = PolarProjectionBJ(l, 800.00, AngleBetweenPoints(l, m))
local unit e = CreateUnit(GetOwningPlayer(u),'h02O',GetLocationX(l),GetLocationY(l),AngleBetweenPoints(l, m))
local trigger trg = CreateTrigger()
local group k = CreateGroup()
call SetHandleHandle(trg,"u",u)
call SetHandleHandle(trg,"p",p)
call SetHandleHandle(trg,"e",e)
call SetHandleHandle(trg,"k",k)
call TriggerRegisterTimerEventPeriodic(trg,0.02)
call TriggerAddAction(trg,function NullifyingBolt)
call RemoveLocation(l)
call RemoveLocation(m)
set u = null
set p = null
set e = null
set k = null
set l = null
set m = null
set trg = null
endfunction
//===========================================================================
function InitTrig_Nullifying_Bolt takes nothing returns nothing
set gg_trg_Nullifying_Bolt = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Nullifying_Bolt, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Nullifying_Bolt, Condition( function Trig_Nullifying_Bolt_Conditions ) )
call TriggerAddAction( gg_trg_Nullifying_Bolt, function Trig_Nullifying_Bolt_Actions )
endfunction
However, every time I cast the spell, it will result it severe framerate drops. And it gets cumulatively worse.
I've followed the JASS guide and closed all leaks as instructed. But it doesn't help. Even increasing the interval between each run of the trigger doesn't. Please help me to find out what is wrong. Thanks.
Oh, and 1 more thing. If I make this spell to be targeted at specific units, this kind of thing does not happen. Can someone please tell me why?
------------------------------------------------------------------------------------
function Trig_Nullifying_Bolt_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A0LL' ) ) then
return false
endif
return true
endfunction
function NullifyingBoltEffect takes nothing returns nothing
local trigger trg = GetTriggeringTrigger()
local group k = GetHandleGroup(trg,"k")
local unit u = GetHandleUnit(trg,"u")
local location p = GetHandleLocation(trg,"p")
local unit h = GetEnumUnit()
local location l = GetUnitLoc(h)
if ( IsUnitType(h, UNIT_TYPE_STRUCTURE) == false ) then
if ( IsUnitType(h, UNIT_TYPE_MECHANICAL) == false ) then
if ( IsUnitAliveBJ(h) == true ) then
if ( GetUnitAbilityLevelSwapped('Avul', h) == 0 ) then
if ( IsUnitInGroup(h, k) == false ) then
if ( IsUnitType(h, UNIT_TYPE_MAGIC_IMMUNE) == false ) then
if ( h != u ) then
call GroupAddUnitSimple( h, k )
if ( IsUnitEnemy(h, GetOwningPlayer(u)) == true ) then
call UnitDamageTargetBJ( u, h, ( 00.00 + ( 65.00 * I2R(GetUnitAbilityLevelSwapped('A0LL', u)) ) ), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE )
else
call SetUnitLifeBJ( h, ( GetUnitStateSwap(UNIT_STATE_LIFE, h) + ( 0.00 + ( 50.00 * I2R(GetUnitAbilityLevelSwapped('A0LL', u)) ) ) ) )
endif
call AddSpecialEffectTargetUnitBJ( "overhead", h, "Abilities\\Spells\\Undead\\ReplenishHealth\\ReplenishHealthCaster.mdl" )
call TriggerExecute( gg_trg_DestroySFX )
endif
endif
endif
endif
endif
endif
endif
call RemoveLocation(l)
set l = null
set u = null
set p = null
set h = null
set k = null
set trg = null
endfunction
function NullifyingBolt takes nothing returns nothing
local trigger trg = GetTriggeringTrigger()
local group k = GetHandleGroup(trg,"k")
local unit u = GetHandleUnit(trg,"u")
local location p = GetHandleLocation(trg,"p")
local unit e = GetHandleUnit(trg,"e")
local location l = GetUnitLoc(e)
local location m = PolarProjectionBJ(l, 20.00, AngleBetweenPoints(l, p))
local group x = GetUnitsInRangeOfLocAll(200.00, l)
local group y = GetUnitsInRangeOfLocAll(18.00, p)
call ForGroupBJ( x, function NullifyingBoltEffect )
if ( RectContainsLoc(udg_EntireMap, p) == false ) then
call KillUnit(e)
call GroupClear(k)
call RemoveUnit(e)
call DestroyGroup(k)
call DestroyGroup(x)
call DestroyGroup(y)
call RemoveLocation(l)
call RemoveLocation(m)
call RemoveLocation(p)
call DisableTrigger(trg)
call FlushHandleLocals(trg)
call DestroyTrigger(trg)
set u = null
set p = null
set e = null
set k = null
set x = null
set y = null
set l = null
set m = null
set trg = null
return
endif
call SetUnitPositionLocFacingBJ( e, m, AngleBetweenPoints(l, p) )
if IsUnitInGroup(e, y) then
call KillUnit(e)
call GroupClear(k)
call RemoveUnit(e)
call DestroyGroup(k)
call DestroyGroup(x)
call DestroyGroup(y)
call RemoveLocation(l)
call RemoveLocation(m)
call RemoveLocation(p)
call DisableTrigger(trg)
call FlushHandleLocals(trg)
call DestroyTrigger(trg)
set u = null
set p = null
set e = null
set k = null
set x = null
set y = null
set l = null
set m = null
set trg = null
endif
call DestroyGroup(x)
call DestroyGroup(y)
call RemoveLocation(l)
call RemoveLocation(m)
set u = null
set p = null
set e = null
set k = null
set x = null
set y = null
set l = null
set m = null
set trg = null
endfunction
function Trig_Nullifying_Bolt_Actions takes nothing returns nothing
local unit u = GetSpellAbilityUnit()
local location l = GetUnitLoc(u)
local location m = GetSpellTargetLoc()
local location p = PolarProjectionBJ(l, 800.00, AngleBetweenPoints(l, m))
local unit e = CreateUnit(GetOwningPlayer(u),'h02O',GetLocationX(l),GetLocationY(l),AngleBetweenPoints(l, m))
local trigger trg = CreateTrigger()
local group k = CreateGroup()
call SetHandleHandle(trg,"u",u)
call SetHandleHandle(trg,"p",p)
call SetHandleHandle(trg,"e",e)
call SetHandleHandle(trg,"k",k)
call TriggerRegisterTimerEventPeriodic(trg,0.02)
call TriggerAddAction(trg,function NullifyingBolt)
call RemoveLocation(l)
call RemoveLocation(m)
set u = null
set p = null
set e = null
set k = null
set l = null
set m = null
set trg = null
endfunction
//===========================================================================
function InitTrig_Nullifying_Bolt takes nothing returns nothing
set gg_trg_Nullifying_Bolt = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Nullifying_Bolt, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Nullifying_Bolt, Condition( function Trig_Nullifying_Bolt_Conditions ) )
call TriggerAddAction( gg_trg_Nullifying_Bolt, function Trig_Nullifying_Bolt_Actions )
endfunction