function Trig_MainGameLoop_Actions takes nothing returns nothing
// Movement Functionality
local location point
local integer index = 0
local integer jndex = 0
local real x = 0
local real y = 0
local real angle = 0
local real angle2 = 0
local real speed = 0
local real posX
local real posY
local location pointL
local location pointR
local location pointD
local location pointU
local boolean burning = false
local boolean loopDone = false
local integer iterations = 0
if (udg_mainGameLoop) then //do ALL THAT CODE, I don't feel like indenting it all
loop
exitwhen index >= 12
if ( udg_playerPlaying[index] ) then //don't loop if the player isn't even playing!
set posX = GetUnitX( udg_visibleBastards[index] )
set posY = GetUnitY( udg_visibleBastards[index] )
if ( udg_upArrow[index] ) then
set udg_yVelocity[index] = udg_yVelocity[index] + udg_UPACCEL
endif
set udg_yVelocity[index] = udg_yVelocity[index] - udg_GRAVITY
if ( udg_yVelocity[index] > udg_MAXSPEED ) then
set udg_yVelocity[index] = udg_MAXSPEED
elseif ( udg_yVelocity[index] < ( udg_MAXSPEED * -1 ) ) then
set udg_yVelocity[index] = ( udg_MAXSPEED * -1 )
endif
if ( udg_leftArrow[index] and not( udg_rightArrow[index] ) ) then
set posX = posX - udg_MOVESPEED
elseif ( udg_rightArrow[index] and not( udg_leftArrow[index] ) ) then
set posX = posX + udg_MOVESPEED
endif
set posY = posY + udg_yVelocity[index]
loop
exitwhen (loopDone or iterations > 8)
set point = Location(posX,posY)
if ( GetLocationZ( point ) > udg_zOfGround ) then
set pointL = Location( posX - 1 , posY )
set pointR = Location( posX + 1 , posY )
set pointD = Location( posX , posY - 1 )
set pointU = Location( posX , posY + 1 )
if ( GetLocationZ( pointL ) > GetLocationZ( pointR ) ) then //cliff is to the left
set posX = posX + 2
elseif ( GetLocationZ( pointL ) < GetLocationZ( pointR ) ) then //cliff is to the right
set posX = posX - 2
endif
if ( GetLocationZ( pointD ) > GetLocationZ( pointU ) ) then //cliff is downwards
set posY = posY + 2
if ( udg_yVelocity[index] < 0 ) then
set udg_yVelocity[index] = 0
endif
elseif ( GetLocationZ( pointD ) < GetLocationZ( pointU ) ) then //cliff is upwards
set posY = posY - 2
if ( udg_yVelocity[index] > 0 ) then
set udg_yVelocity[index] = 0
endif
endif
call RemoveLocation(pointL)
call RemoveLocation(pointR)
call RemoveLocation(pointU)
call RemoveLocation(pointD)
else
set loopDone = true
endif
set iterations = iterations + 1
call RemoveLocation(point)
endloop
call SetUnitX( udg_visibleBastards[index] , posX )
call SetUnitY( udg_visibleBastards[index] , posY )
call SetUnitX( udg_healthBar[index] , posX )
call SetUnitY( udg_healthBar[index] , posY + 128.00 )
call SetUnitAnimationByIndex( udg_healthBar[index] , R2I(GetUnitState(udg_controllers[index] , UNIT_STATE_LIFE) / 10.00) )
if (udg_walkAnimating[index] == false) and (udg_rightArrow[index] or udg_leftArrow[index]) and (TimerGetRemaining(udg_fireAnimTimer[index]) == 0) then
set udg_walkAnimating[index] = true
call SetUnitAnimationByIndex(udg_visibleBastards[index] , 6 )
elseif (udg_walkAnimating[index] and (udg_leftArrow[index] == false) and (udg_rightArrow[index] == false)) and (TimerGetRemaining(udg_fireAnimTimer[index]) == 0) then
set udg_walkAnimating[index] = false
call SetUnitAnimation(udg_visibleBastards[index] , "stand" )
endif
if (udg_flameSquirt[index] >= 1) then
set udg_flameSquirt[index] = udg_flameSquirt[index] - 1
set jndex = 0
loop
exitwhen jndex >= udg_flameSize
if (udg_fireball_INPLAY[jndex] == false) then
set x = GetUnitX(udg_visibleBastards[index])
set y = GetUnitY(udg_visibleBastards[index])
set angle = Atan2( udg_flameTargetY[index] - y , udg_flameTargetX[index] - x )
set angle2 = angle + GetRandomReal(-0.087,0.087)
call SetUnitFacing(udg_fireball[index] , angle2)
set udg_fireball_XVEL[jndex] = Cos(angle2) * 50.00
set udg_fireball_YVEL[jndex] = Sin(angle2) * 50.00
set udg_fireball_compressXVEL[jndex] = (Cos(angle) + Cos(angle2))
set udg_fireball_compressYVEL[jndex] = (Sin(angle) + Sin(angle2))
call SetUnitX( udg_fireball[jndex] , GetUnitX(udg_visibleBastards[index]) )
call SetUnitY( udg_fireball[jndex] , GetUnitY(udg_visibleBastards[index]) )
set udg_fireball_INPLAY[jndex] = true
set udg_fireball_LIFE[jndex] = 50
call ShowUnit( udg_fireball[jndex] , true )
set jndex = udg_flameSize
endif
set jndex = jndex + 1
endloop
endif
set burning = false
set jndex = 25 * udg_numPlayers - 1
loop
exitwhen jndex < 0
if (udg_fireball_LIFE[index] <=40) and ( (Pow(GetUnitX(udg_visibleBastards[index]) - GetUnitX(udg_fireball[jndex]),2) + Pow(GetUnitY(udg_visibleBastards[index]) - GetUnitY(udg_fireball[jndex]),2)) <= Pow( 60 - udg_fireball_LIFE[index] , 2 )) then
set burning = true
set jndex = -1
endif
set jndex = jndex - 1
endloop
if (burning) then
call SetUnitState(udg_visibleBastards[index] , UNIT_STATE_LIFE, GetUnitState(udg_visibleBastards[index] , UNIT_STATE_LIFE) - 3 )
call SetUnitState(udg_controllers[index] , UNIT_STATE_LIFE, GetUnitState(udg_visibleBastards[index] , UNIT_STATE_LIFE) )
endif
if ( udg_sniperTrail[index] != null ) and ( udg_sniperTrailVis[index] > 0 ) then
set udg_sniperTrailVis[index] = udg_sniperTrailVis[index] - 1
call SetLightningColor( udg_sniperTrail[index] , 1 , 1 , 1 , I2R(udg_sniperTrailVis[index]) / 25 )
endif
//Setup camera
if ( GetLocalPlayer() == Player(index) ) then
call PanCameraToTimed( posX , posY , 0.05)
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, udg_cameraDistance[index], udg_panSpeed )
call SetCameraField( CAMERA_FIELD_FARZ, 5000.00, 0.05 )
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, 270.00, 0.05 )
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, 120.00, 0.05 )
call SetCameraField( CAMERA_FIELD_ROLL, 0.00, 0.05 )
call SetCameraField( CAMERA_FIELD_ROTATION, 90.00, 0.05 )
endif
endif
set index = index + 1
endloop
endif
endfunction
//===========================================================================
function InitTrig_MainGameLoop_Copy takes nothing returns nothing
set gg_trg_MainGameLoop_Copy = CreateTrigger( )
call TriggerRegisterTimerEvent( gg_trg_MainGameLoop_Copy, 0.02, true )
call TriggerAddAction( gg_trg_MainGameLoop_Copy, function Trig_MainGameLoop_Actions )
endfunction