ZakkWylde-
New Member
- Reaction score
- 14
Is this leaking? if so, where?
If not leaking, is there a way to optimize this (without TOTALLY reworking it)?
(and to whom it may concern, checkTerrain is a trigger array--it is what kills the demon hunter)
EDIT: not sure what i'm using the local real speed for...
JASS:
scope Sliding initializer Init
private function SlidingCond takes nothing returns boolean
return (GetUnitTypeId(GetFilterUnit()) == 039;E000039;)// or GetUnitTypeId(GetFilterUnit()) == 'E001')//the unit rawcode
endfunction
private function Sliding takes nothing returns nothing
local group g = CreateGroup()
local unit u
local real x
local real y
local real uX
local real uY
local real speed = (5.5*correction)
local integer i
local boolean d1
local boolean d2
local boolean d3
local boolean d4
local boolean onDeath
local real tKill
call GroupEnumUnitsInRect(g, GetWorldBounds(), Condition(function SlidingCond))
loop
set u = FirstOfGroup(g)
exitwhen u == null
set i = GetUnitUserData(u)
set tKill = tightness
set uX = GetUnitX(u)
set uY = GetUnitY(u)
set d1 = (GetTerrainType(uX + tKill, uY + tKill) == udg_DeathTerSnow or GetTerrainType(uX + tKill, uY + tKill) == udg_DeathTerLava)
set d2 = (GetTerrainType(uX + tKill, uY - tKill) == udg_DeathTerSnow or GetTerrainType(uX + tKill, uY - tKill) == udg_DeathTerLava)
set d3 = (GetTerrainType(uX - tKill, uY + tKill) == udg_DeathTerSnow or GetTerrainType(uX - tKill, uY + tKill) == udg_DeathTerLava)
set d4 = (GetTerrainType(uX - tKill, uY - tKill) == udg_DeathTerSnow or GetTerrainType(uX - tKill, uY - tKill) == udg_DeathTerLava)
set onDeath = (d1 and d2 and d3 and d4)
if not onDeath then
if (GetTerrainType(uX, uY) == slide1 or GetTerrainType(uX, uY) == slide2) and GetUnitState(u, UNIT_STATE_LIFE) > 0 and IsUnitPaused(u)==false then
set x = uX + slideSpeed<i> * Cos(GetUnitFacing(u) * bj_DEGTORAD) //speed affects sliding speed
set y = uY + slideSpeed<i> * Sin(GetUnitFacing(u) * bj_DEGTORAD)
call SetUnitPosition(u, x, y)
elseif (GetTerrainType(uX, uY) == slide3 or GetTerrainType(uX, uY) == slide4) and GetUnitState(u, UNIT_STATE_LIFE) > 0 and IsUnitPaused(u)==false then
set x = uX + slideSpeed<i> * Cos(GetUnitFacing(u) * bj_DEGTORAD)
set y = uY + slideSpeed<i> * Sin(GetUnitFacing(u) * bj_DEGTORAD)
call SetUnitPosition(u, x, y)
endif
elseif onDeath then
call IssueImmediateOrder(u, "stop")
if (TKInUse<i> == false and GetUnitState(u, UNIT_STATE_LIFE) >= 1) then
call TriggerExecute(udg_checkTerrain<i>)
endif
endif
call GroupRemoveUnit(g, u)
endloop
call DestroyGroup(g)
set g = null
endfunction
private function Init takes nothing returns nothing
local timer p = CreateTimer()
call TimerStart(p, 0.010, true, function Sliding) //frequency of trigger
endfunction
endscope
</i></i></i></i></i></i>
If not leaking, is there a way to optimize this (without TOTALLY reworking it)?
(and to whom it may concern, checkTerrain is a trigger array--it is what kills the demon hunter)
EDIT: not sure what i'm using the local real speed for...