INCINERATE
New Member
- Reaction score
- 12
hey guys , would anyone mind taking a look at this code? this is a spell i found on www.thehiveworkshop.com from XXDINGO93XX.
ever since i put it in, i have notice the frame rate drops, and never recovers .. this only started when i put this in , so does this code leak? and if it does can you guys please post the necessary fixes . thanks
ever since i put it in, i have notice the frame rate drops, and never recovers .. this only started when i put this in , so does this code leak? and if it does can you guys please post the necessary fixes . thanks
JASS:
// ° Mapmaking since 2006...
// °
// °
// °
// °°°ÛÜ
// °°X°ÛÛÛ ÛÛÛÛÛÛÛÛ ÿÜÛÛÛÛÛÛÛÛÜ
// °°XX° ÛÛÛ ßÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛÛ
// °XX ° ÛÛÛÛ ÛÛÛÛÜ ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
// °XX ° ÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛß ßÛÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
// °°XXX°° ÛÛÛÛÛÛÜ ÛÛÛÜ ÛÛÛÛÛ ßÛÛÛÛÛ ßÛÛÛÛ ÛÛÛÛÛÛ
// °°°°°°°° ÛÛÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛ ÛÛÛÛ ÛÛÛÛÜ
// ÛÛÛÛÛÛÛÛ ÛÛÛÛ ÛÛÛÛ ÛÛÛÛÛÛÛ ÛÛÛÛÛÜ ÛÛÛÛ
// °°°°°°°° ÛÛÛÛÛÛÛÛÛ ÛÛÛÛÜ ÛÛÛÛÜ ÛÛÛÛÛÛÛÛ ÛÛÛÛÛÜ ÜÛÛÛÛÛÛ
// °°XXXXX° ÛÛÛÛ ÛÛÛÜ ÛÛÛÛÛ ÛÛÛÛÛÛÜ ßÛÛÛÛÛ ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
// °°XXXXX °° ÛÛÛÛ ÛÛÛÛÜ ÛÛÛÛ °°°ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ°°° ÛÛÛÛÛÛÛÛÛÛÛÛÛß
// ° XXXXX °°ÛÛÛÛÛ°°°°ÛÛÛÛÛÛÛÛ°°XX ÛÛÛÛÛÛÛÛÛÛÛÛÛÛ XXX°°ÛÛÛÛÛÛÛÛÛÛÛ ÛÛÛ
// °° XXXXX ÜÛÛÛÛÛÛ X ÛÛÛÛÛÛÛÛÛ XXX ÛÛÛÛÛÛÛÛÛÛÛ XXXXXX ÛÛÛÛÛÛÛ° ÛÛÛ
// °° XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX °°°°°° °°°°
// °° XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX °°°°°X°°
// °°° XXXXXXXXXX °°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°° XXXXXXXXXXXXXXXXX°°
// °°°°°°°°°°°°°°°° °°°°°°°° XXXXXXX °°°
// °°°°°° XX °°
// ...2009 and still moving on. °°°°°°°
// °°
// Screen Solution: 1280x1024 Visit <a href="http://www.ngo.clan.su" target="_blank" class="link link--external" rel="nofollow ugc noopener">www.ngo.clan.su</a>!
//========================================================================================
scope SpikedImpact initializer Init
//========================================================================================
//====================================SETUP START=========================================
//========================================================================================
globals
//Default: 'SpIm'
private constant integer AID = 039;SpIm039; //the rawcode of the ability "Spike Impact"
//Default: 'eSp1'
private constant integer SPIKED_ONE = 039;eSp1039; //the rawcode of the unit spike 1
//Default: 'eSp2'
private constant integer SPIKED_TWO = 039;eSp2039; //the rawcode of the unit spike 2
//Default: 'eSp3'
private constant integer SPIKED_THREE = 039;eSp3039; //the rawcode of the unit spike 3
//Default: 'eSp4'
private constant integer SPIKED_FOUR = 039;eSp4039; //the rawcode of the unit spike 4
//Default: 8
private constant integer MAX = 8 //the maximal amount of spikes for each heigh
//Default: "Morph"
private constant string START_ANIMATION = "Morph" //the animation the caster will play when he casts the spell
//Default: "Morph Defend"
private constant string END_ANIMATION = "Morph Defend" //the animation the caster will play when the spell ends
//Default: 255
private constant integer RED = 255 //The red RGB color of the affected units from 0 to 255
//Default: 45
private constant integer GREEN = 45 //The green RGB color of the affected units from 0 to 255
//Default: 45
private constant integer BLUE = 45 //The blue RGB color of the affected units from 0 to 255
//Default: "Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl"
private constant string ENEMY_EFFECT = "Objects\\Spawnmodels\\Orc\\Orcblood\\BattrollBlood.mdl" //the that will be created at the enemy when it is affected, in this case is blood.
//Default: 0.3
private constant real SPIKE_GROW = 0.3 //the time the spikes will have to grow before they are paused
//Default: 1.5
private constant real SPIKE_PAUSE = 1.5 //the duration of pausing the spikes
//Default: 1.2
private constant real SPIKE_DEATH = 1.2 //this is how long the death animation of the spikes lasts
endglobals
private constant function Radius takes integer level returns real
//Default: 650. + level * 50.
return 650. + level * 50.
endfunction
private constant function Damage takes integer level returns real
//Default: level * 80. + 25.
return level * 80. + 25.
endfunction
//========================================================================================
//====================================SETUP END===========================================
//========================================================================================
globals
private unit TempCaster = null
endglobals
private function Pick takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(TempCaster)) and (GetWidgetLife(GetFilterUnit()) > 0.405) and not IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE)
endfunction
private function KillEnemies takes unit caster, unit target, integer level returns nothing
local real DamageToDeal = Damage(level)
call PauseUnit(target, false)
call SetUnitTimeScale(target, 100. * 0.01)
if(GetWidgetLife(target) <= DamageToDeal) then
call SetUnitExploded(target, true)
call KillUnit(target)
else
call UnitDamageTarget(caster, target, DamageToDeal, true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNKNOWN, WEAPON_TYPE_WHOKNOWS)
call SetUnitVertexColor(target, 255, 255, 255, 255)
call DestroyEffect(AddSpecialEffectTarget(ENEMY_EFFECT, target, "chest"))
endif
endfunction
private function RecolorEnemies takes nothing returns nothing
local unit Enemy = GetEnumUnit()
call PauseUnit(Enemy, true)
call SetUnitTimeScale(Enemy, 0.00)
call SetUnitVertexColor(Enemy, RED, GREEN, BLUE, 255)
call DestroyEffect(AddSpecialEffectTarget(ENEMY_EFFECT, Enemy, "chest"))
set Enemy = null
endfunction
private struct SIData
unit caster
integer level
unit array spikes [36]
timer t
group g
static method Reset takes nothing returns nothing
local SIData data = SIData(GetTimerData(GetExpiredTimer()))
call data.destroy()
endmethod
static method End takes nothing returns nothing
local SIData data = SIData(GetTimerData(GetExpiredTimer()))
local unit f
local integer i = 0
loop
set f = FirstOfGroup(data.g)
exitwhen f == null
call KillEnemies(data.caster, f, data.level)
call GroupRemoveUnit(data.g, f)
endloop
set i = 0
loop
exitwhen (i == MAX * 4)
call PauseUnit(data.spikes<i>, false)
call UnitApplyTimedLife(data.spikes<i>, 039;BTLF039;, 1.00)
call SetUnitTimeScale(data.spikes<i>, 1)
set i = i + 1
endloop
call SetTimerData(data.t, integer(data))
call SetUnitAnimation(data.caster, END_ANIMATION)
call TimerStart(data.t, 0.5, false, function SIData.Reset)
endmethod
static method Growth takes nothing returns nothing
local SIData data = SIData(GetTimerData(GetExpiredTimer()))
local integer i = 0
loop
exitwhen (i == MAX * 4)
call PauseUnit(data.spikes<i>, true)
call SetUnitTimeScale(data.spikes<i>, 0.)
set i = i + 1
endloop
set TempCaster = data.caster
call GroupEnumUnitsInRange(data.g, GetUnitX(data.caster), GetUnitY(data.caster), Radius(data.level), Condition(function Pick))
call ForGroup(data.g, function RecolorEnemies)
call SetTimerData(data.t, integer(data))
call TimerStart(data.t, SPIKE_DEATH, false, function SIData.End)
endmethod
static method create takes unit aCaster returns SIData
local SIData data = SIData.allocate()
local real x
local real y
local real Degrees
local integer SpikeNumber = 0
local integer i = 0
local player owner = GetOwningPlayer(aCaster)
set data.caster = aCaster
set data.level = GetUnitAbilityLevel(aCaster, AID)
set data.g = CreateGroup()
loop
exitwhen (i == MAX)
set Degrees = (360./MAX * I2R(i))
set x = GetUnitX(data.caster) + 10.0 * Cos(Degrees * bj_DEGTORAD)
set y = GetUnitY(data.caster) + 10.0 * Sin(Degrees * bj_DEGTORAD)
set data.spikes [SpikeNumber] = CreateUnit(owner, SPIKED_ONE, x, y, Degrees)
set data.spikes [SpikeNumber + 1] = CreateUnit(owner, SPIKED_TWO, x, y, Degrees)
set data.spikes [SpikeNumber + 2] = CreateUnit(owner, SPIKED_THREE, x, y, Degrees)
set data.spikes [SpikeNumber + 3] = CreateUnit(owner, SPIKED_FOUR, x, y, Degrees)
set SpikeNumber = SpikeNumber + 4
set i = i + 1
endloop
call PauseUnit(data.caster, true)
call SetUnitAnimation(data.caster, START_ANIMATION)
set data.t = NewTimer()
call SetTimerData(data.t, integer(data))
call TimerStart(data.t, SPIKE_GROW, false, function SIData.Growth)
return data
endmethod
method onDestroy takes nothing returns nothing
local integer Index = 1
loop
exitwhen Index > 36
set this.spikes [Index] = null
set Index = Index + 1
endloop
call ReleaseTimer(this.t)
call IssueImmediateOrder(this.caster, "stop")
call SetUnitAnimation(this.caster, "stand")
call PauseUnit(this.caster, false)
call GroupClear(this.g)
set this.caster = null
set this.g = null
endmethod
endstruct
//====================================================================================
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == AID
endfunction
//====================================================================================
private function Actions takes nothing returns nothing
call SIData.create(GetSpellAbilityUnit())
endfunction
//===========================Creating the trigger=====================================
private function Init takes nothing returns nothing
local trigger Tri = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(Tri, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddAction(Tri, function Actions)
call TriggerAddCondition(Tri, Condition(function Conditions))
// this will remove the first cast lag
call RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), SPIKED_ONE, 0.00, 0.00, 0.00))
call RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), SPIKED_TWO, 0.00, 0.00, 0.00))
call RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), SPIKED_THREE, 0.00, 0.00, 0.00))
call RemoveUnit(CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), SPIKED_FOUR, 0.00, 0.00, 0.00))
call Preload(ENEMY_EFFECT)
endfunction
endscope</i></i></i></i></i>