ZakkWylde-
New Member
- Reaction score
- 14
So it appears that whenever someone dies, there is this annoying map lag from which everyone suffers.
Here is the relevant code:
This is the sliding/Terrain Kill trigger that determines a unit should die:
Regarding [ljass] if (TKInUse == false and alive) then
call TriggerExecute(udg_checkTerrain)
endif [/ljass],
TKInUse will be seen in the following code, and udg_checkTerrain IS the trigger with the following code (there are 12 checkTerrains, one for each hero):
If that weren't enough, this is what runs when the unit actually dies. (REALLY SORRY FOR ALL THIS CODE, but I'D REALLY APPRECIATE finding out what's wrong with it <3)
LASTLY (thank you so much if you've gotten this far):
This is the makecircle function that is called when the unit has died (with Teamwork on):
I know this is a lot of code, but I have gone through it, and I don;t really understand why it would cause map lag...
Appreciate the help (A LOT!),
Zakk
Here is the relevant code:
This is the sliding/Terrain Kill trigger that determines a unit should die:
JASS:
cope Sliding initializer Init
private function SlidingCond takes nothing returns boolean
return (GetUnitTypeId(GetFilterUnit()) == 039;E000039;)
endfunction
private function Sliding takes nothing returns nothing
local unit u
local real x
local real y
local real uX
local real uY
local real facing
local integer terType
local integer t1
local integer t2
local integer t3
local integer t4
local integer i
local boolean d1
local boolean d2
local boolean d3
local boolean d4
local boolean shouldSlide
local boolean properTerrain
local boolean alive
call GroupEnumUnitsInRect(dhGroup, worldBounds, Condition(function SlidingCond))
loop
set u = FirstOfGroup(dhGroup)
exitwhen u == null
set i = GetUnitUserData(u)
set uX = GetUnitX(u)
set uY = GetUnitY(u)
set t1 = GetTerrainType(uX + tightness, uY + tightness)
set t2 = GetTerrainType(uX + tightness, uY - tightness)
set t3 = GetTerrainType(uX - tightness, uY + tightness)
set t4 = GetTerrainType(uX - tightness, uY - tightness)
set d1 = (t1 == udg_DeathTerSnow or t1 == udg_DeathTerLava)
set d2 = (t2 == udg_DeathTerSnow or t2 == udg_DeathTerLava)
set d3 = (t3 == udg_DeathTerSnow or t3 == udg_DeathTerLava)
set d4 = (t4 == udg_DeathTerSnow or t4 == udg_DeathTerLava)
set alive = (GetWidgetLife(u) >= .405)
if not (d1 and d2 and d3 and d4) then
set terType = GetTerrainType(uX, uY)
set properTerrain = (terType == slide1 or terType == slide2 or terType == slide3 or terType == slide4)
set shouldSlide = (alive and IsUnitPaused(u) == false and properTerrain)
if shouldSlide then
set facing = (GetUnitFacing(u) * bj_DEGTORAD)
call SetUnitPosition(u, uX + ((slideSpeed<i> * Cos(facing))* 3.125), uY + ((slideSpeed<i> * Sin(facing))* 3.125))
endif
else
call IssueImmediateOrder(u, "stop")
if (TKInUse<i> == false and alive) then
call TriggerExecute(udg_checkTerrain<i>)
endif
endif
call GroupRemoveUnit(dhGroup, u)
endloop
endfunction
private function Init takes nothing returns nothing
call TimerStart(CreateTimer(), 0.03125, true, function Sliding) //frequency of trigger
endfunction
endscope
</i></i></i></i>
Regarding [ljass] if (TKInUse == false and alive) then
call TriggerExecute(udg_checkTerrain)
endif [/ljass],
TKInUse will be seen in the following code, and udg_checkTerrain IS the trigger with the following code (there are 12 checkTerrains, one for each hero):
JASS:
function RedTerrainKill takes nothing returns nothing
local integer i = 0
local unit u = udg_DemonHunter<i>
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local effect e
local effect e2
if GetTerrainType(x, y) == udg_DeathTerSnow and GetUnitState(u, UNIT_STATE_LIFE) >= 1 then
set TKInUse<i> = true
call PauseUnit(u, true)
set isUnitDying<i> = true
call SetUnitFacing(u, GetUnitFacing(u))
set e = AddSpecialEffect(frost1, x, y)
set e2 = AddSpecialEffect(frost2, x, y)
call DisableTrigger(udg_checkTerrain<i>)
call TriggerSleepAction(2)
call SetUnitExploded(u, false)
if isUnitDying<i> == true then
call KillUnit(u)
endif
call PauseUnit(u, false)
set isUnitDying<i> = false
call DestroyEffect(e)
call DestroyEffect(e2)
set e = null
set e2 = null
set TKInUse<i> = false
call EnableTrigger(udg_checkTerrain<i>)
elseif GetTerrainType(x,y) == udg_DeathTerLava and GetUnitState(u, UNIT_STATE_LIFE) >= 1 then
set TKInUse<i> = true
call PauseUnit(u, true)
set isUnitDying<i> = true
call SetUnitFacing(u, GetUnitFacing(u))
set e = AddSpecialEffect(fire1, x, y)
call DisableTrigger(udg_checkTerrain<i>)
call TriggerSleepAction(1.95)
set e2 = AddSpecialEffect(fire2, x, y)
call TriggerSleepAction(.05)
call SetUnitExploded(u, false)
if isUnitDying<i> == true then
call KillUnit(u)
endif
call PauseUnit(u, false)
set isUnitDying<i> = false
call DestroyEffect(e)
call DestroyEffect(e2)
set e = null
set e2 = null
set TKInUse<i> = false
call EnableTrigger(udg_checkTerrain<i>)
endif
endfunction
//===========================================================================
function InitTrig_RedTerrainKill takes nothing returns nothing
set gg_trg_RedTerrainKill = CreateTrigger( )
call TriggerAddAction( gg_trg_RedTerrainKill, function RedTerrainKill )
endfunction
</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
If that weren't enough, this is what runs when the unit actually dies. (REALLY SORRY FOR ALL THIS CODE, but I'D REALLY APPRECIATE finding out what's wrong with it <3)
JASS:
function Trig_check_if_alive_Conditions takes nothing returns boolean
local integer Id = GetPlayerId( GetOwningPlayer( GetTriggerUnit() ) )
return Id != 12 and Id != 15
endfunction
function Trig_check_if_alive_Actions takes nothing returns nothing
local integer n = GetUnitUserData( GetTriggerUnit() )
local integer i = 0
local item it=UnitItemInSlot(udg_DemonHunter[n],0)
local integer d=GetItemUserData(it)
call SetItemPosition(it, GetRectCenterX(itemsloc[d]), GetRectCenterY(itemsloc[d]))
set udg_CircleOn[n] = false
if udg_Teamwork then
loop
exitwhen i>11 or GetUnitState(udg_DemonHunter<i>, UNIT_STATE_LIFE) > 0
set i = i + 1
endloop
else
loop
exitwhen i>11 or GetUnitState(udg_DemonHunter<i>, UNIT_STATE_LIFE) > 0 or GetUnitState(reviveCircle<i>, UNIT_STATE_LIFE) > 0
set i = i + 1
endloop
endif
if (i <= 11) then
if udg_Teamwork then
call TriggerExecute(makecircle[n])
else
if GetUnitState(reviveCircle[n], UNIT_STATE_LIFE) > 0 then
call circlerevive(n)
endif
endif
endif
if ( i>11 ) and IsTriggerEnabled(gg_trg_DeathRez) then
call ForGroup(reviveCircles, function RemoveCircles)
if not udg_Teamwork then
set i = 0
loop
exitwhen i > 11
set madecircle<i> = false
set i = i+1
endloop
endif
call TriggerExecute( gg_trg_DeathRez )
endif
endfunction
//===========================================================================
function InitTrig_CheckIfAlive takes nothing returns nothing
set gg_trg_CheckIfAlive = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CheckIfAlive, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddCondition( gg_trg_CheckIfAlive, Condition( function Trig_check_if_alive_Conditions ) )
call TriggerAddAction( gg_trg_CheckIfAlive, function Trig_check_if_alive_Actions )
endfunction
</i></i></i></i>
LASTLY (thank you so much if you've gotten this far):
This is the makecircle function that is called when the unit has died (with Teamwork on):
JASS:
function MakeCircle takes integer n returns nothing
local real offset=127-(2*tightness) //90
local real checkoffset=20
local real x=GetUnitX(udg_DemonHunter[n])
local real y=GetUnitY(udg_DemonHunter[n])
local real rx=x
local real ry=y
local boolean check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
if not(check)then
set rx=x-offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x+offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x
set ry=y-offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x
set ry=y+offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x-offset
set ry=y-offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x-offset
set ry=y+offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x+offset
set ry=y-offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x+offset
set ry=y+offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
//in case everything goes WRONGGGGgggggggg I dont think the trigger ever goes past this part--it goes straight to call RemoveUnit(...)...
if not (check) then
set checkoffset = 0
if not(check)then
set rx=x-offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x+offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x
set ry=y-offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x
set ry=y+offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x-offset
set ry=y-offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x-offset
set ry=y+offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x+offset
set ry=y-offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not(check)then
set rx=x+offset
set ry=y+offset
set check=GetTerrainType(rx+checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry+checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx-checkoffset,ry-checkoffset)!=deathTerrain and GetTerrainType(rx+checkoffset,ry)!=deathTerrain and GetTerrainType(rx-checkoffset,ry)!=deathTerrain and GetTerrainType(rx,ry-checkoffset)!=deathTerrain and GetTerrainType(rx,ry+checkoffset)!=deathTerrain
endif
if not (check) then
endif
endif
call RemoveUnit(reviveCircle[n])
set reviveCircle[n]=CreateUnit(Player(n),039;h005039;,rx,ry,90)
call TriggerRegisterUnitInRange(revivetrig[n],reviveCircle[n],80.00, null)
call GroupAddUnit(reviveCircles,reviveCircle[n])
call SetUnitPosition(udg_DemonHunter[n],rx,ry)
call SetUnitAnimationByIndex(udg_DemonHunter[n],0)
//call TriggerSleepAction(0.2)
call TriggerSleepAction(0.001) //?
endfunction
I know this is a lot of code, but I have gone through it, and I don;t really understand why it would cause map lag...
Appreciate the help (A LOT!),
Zakk