- Joined
- May 16, 2007
- Messages
- 7,285
A while back XieLong made me a trigger, in JASS, so i just modified the constants and whatever, but ingame after a while, i starts to lag.. Alot. so I dont know whats wrong, but if anyone out there who is good at JASS, could fix the leak?
JASS:
//TESH.scrollpos=0
//TESH.alwaysfold=0
//***************************************************************************\\
// Spell Name: Attack \\
// Spell Author: XieLong \\
// Conforms to the JESP Standard \\
//***************************************************************************\\
//= Needed Object and their ids (Make sure to copy all objects into your map and adjust the rawcodes)
//== Abilities
//=== Attack
constant function Cactus1_SpellId takes nothing returns integer
return 'A008' // The spell's rawcode.
endfunction
//== Units
//=== Missile Dummy
constant function Cactus1_MissileId takes nothing returns integer
return 'n00E'
endfunction
//== Buffs
//=== B000 : Attack
//= End of ObjectIds
//===========================================================================
//= Spell datas and settings
constant function Cactus1_LaunchImprecision takes nothing returns real
return 45.
endfunction
constant function Cactus1_MissileSpeed takes nothing returns integer
return 1000 //covered distance per second
endfunction
constant function Cactus1_Range takes nothing returns integer
return 400
endfunction
constant function Cactus1_MissileCollisonSize takes nothing returns real
return 55.
endfunction
constant function Cactus1_AttackType takes nothing returns attacktype
return ATTACK_TYPE_HERO
endfunction
function Cactus1_Damage takes nothing returns real
return (1. + GetRandomInt(0, 0))
endfunction
//Defines what kind of units can be hit by a missile
//basicly the missile will hit any unit on her path so you have to define the 'not hitable targets'
function Cactus1_HitConditions takes unit attacker, unit target returns boolean
if IsUnitAlly(target, GetOwningPlayer(attacker)) then
return false
endif
// if (IsUnitType(target, UNIT_TYPE_STRUCTURE) == true) then
// return false
// endif
// if (IsUnitType(target, UNIT_TYPE_MECHANICAL) == true) then
// return false
// endif
// if (IsUnitType(target, UNIT_TYPE_ETHEREAL) == true ) then
// return false
// endif
// if (IsUnitType(target, UNIT_TYPE_MAGIC_IMMUNE) == true ) then
// return false
// endif
// if (IsUnitType(target, UNIT_TYPE_GROUND) == true) then
// return false
// endif
if (GetUnitState(target, UNIT_STATE_LIFE) <= 0.405) then
return false
endif
return true
endfunction
//== Any other data/setting have to be changed within the object-editor
//= End of datas/settings
//===========================================================================
// *** Spell Script ***
// Conditions
function Cactus1_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == Cactus1_SpellId() )
endfunction
function Cactus1_Effects takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit c = GetHandleUnit(t, "c")
local unit u = GetHandleUnit(t, "u")
local integer i = GetHandleInt(t, "i")
local integer j = 0
local real x = GetUnitX(u) + 18 * Cos(GetUnitFacing(u) * bj_DEGTORAD)
local real y = GetUnitY(u) + 18 * Sin(GetUnitFacing(u) * bj_DEGTORAD)
local unit v
local group g = CreateGroup()
if (i < R2I((Cactus1_Range() / 14) + .5) ) and ((GetRectMinX(GetWorldBounds()) <= x) and (x <= GetRectMaxX(GetWorldBounds())) and (GetRectMinY(GetWorldBounds()) <= y) and (y <= GetRectMaxY(GetWorldBounds()))) then
call SetUnitX(u, x)
call SetUnitY(u, y)
call GroupEnumUnitsInRange(g, x, y, Cactus1_MissileCollisonSize(), null)
call GroupRemoveUnit(g, u)
loop
set v = FirstOfGroup(g)
exitwhen (v == null)
call GroupRemoveUnit(g, v)
if Cactus1_HitConditions(c, v) then
call UnitDamageTarget(c, v, Cactus1_Damage(), true, false, Cactus1_AttackType(), DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
call KillUnit(u)
call GroupClear(g)
set i = R2I((Cactus1_Range() / 14) + .5)
endif
endloop
else
call KillUnit(u)
call PauseTimer(t)
call FlushHandleLocals(t)
call DestroyTimer(t)
endif
call SetHandleInt(t, "i", i+1)
set c = null
call DestroyGroup(g)
set g = null
set u = null
set v = null
endfunction
function Cactus1_Actions takes nothing returns nothing
local unit c = GetTriggerUnit()
local real f = GetUnitFacing(c)
local integer i = 0
local unit u
local timer t = CreateTimer()
set u = CreateUnit(GetOwningPlayer(c), Cactus1_MissileId(), (GetUnitX(c) + 14 * Cos(f * bj_DEGTORAD)), (GetUnitY(c) + 14 * Sin(f * bj_DEGTORAD)), ModuloReal((f + GetRandomReal(-1*Cactus1_LaunchImprecision(), Cactus1_LaunchImprecision())), 360) )
call SetHandleHandle(t, "c", c)
call SetHandleHandle(t, "u", u)
call TimerStart(t, 0.02, true, function Cactus1_Effects)
set c = null
set u = null
set t = null
endfunction
//===========================================================================
function InitTrig_Cactus1 takes nothing returns nothing
local integer i = 0
set gg_trg_Cactus1 = CreateTrigger( )
loop
call TriggerRegisterPlayerUnitEvent(gg_trg_Cactus1, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, Condition(function ReturnTrue))
set i = i + 1
exitwhen i == 16
endloop
call TriggerAddCondition( gg_trg_Cactus1, Condition( function Cactus1_Conditions ) )
call TriggerAddAction( gg_trg_Cactus1, function Cactus1_Actions )
endfunction