function IsPlayerEnemyCR takes player pPlayer1, player pPlayer2 returns boolean
return pPlayer1 != pPlayer2
endfunction
function PlaySoundPlayer takes player pPlayer, sound soundHandle returns nothing
if ( GetLocalPlayer() == pPlayer ) then
call PlaySoundBJ(soundHandle)
endif
endfunction
function StopSoundPlayer takes player pPlayer, sound soundHandle, boolean bFadeOut returns nothing
if ( GetLocalPlayer() == pPlayer ) then
call StopSound(soundHandle, false, bFadeOut)
endif
endfunction
function StandardAngle takes real rAngle returns real
loop
if ( rAngle < -180 ) then
set rAngle = rAngle + 360
elseif ( rAngle > 180 ) then
set rAngle = rAngle - 360
else
exitwhen true
endif
endloop
return rAngle
endfunction
function ShowDebugMsg takes string fp_strMsg returns nothing
if (udg_ItsForDebug) then
call DisplayTextToForce( GetPlayersAll(), fp_strMsg )
endif
endfunction
function ShowDisplayOrderID takes nothing returns nothing
call ShowDebugMsg( I2S(GetIssuedOrderIdBJ()) )
endfunction
function ShowQuestMsg takes string fp_strTitle, string fp_strMsg returns nothing
call QuestMessageBJ( GetPlayersAll(), bj_QUESTMESSAGE_ALWAYSHINT, "\r|cffffcc00REQUIRED QUEST|r\n" + StringCase(fp_strTitle, true) + "\n" + fp_strMsg )
endfunction
function ShowQuestHintMsg takes string fp_strMsg returns nothing
call PlaySoundBJ( gg_snd_Hint )
call QuestMessageBJ( GetPlayersAll(), bj_QUESTMESSAGE_ALWAYSHINT, "\r|cffffcc00HINT|r - " + fp_strMsg )
endfunction
function ShowTipMsg takes string fp_strMsg returns nothing
call PlaySoundBJ( gg_snd_Hint )
call QuestMessageBJ( GetPlayersAll(), bj_QUESTMESSAGE_ALWAYSHINT, "\r|cff00ff00TIP|r - " + fp_strMsg )
endfunction
function ShowTipMsgPlayer takes player fp_Player, string fp_strMsg returns nothing
call DisplayTextToPlayer( fp_Player, 0, 0, "\r|cff00ff00TIP|r - " + fp_strMsg )
endfunction
function ShowWarningMsg takes player fp_Player, string fp_strMsg returns nothing
call DisplayTextToPlayer ( fp_Player, 0, 0, "\r|cffff0000WARNING|r - " + fp_strMsg )
endfunction
function ShowGeneralMsg takes string fp_strMsg, boolean fp_snd returns nothing
if (fp_snd) then
call PlaySoundBJ( gg_snd_Hint )
endif
call QuestMessageBJ( GetPlayersAll(), bj_QUESTMESSAGE_ALWAYSHINT, "\r|cffffcc00" + StringCase(fp_strMsg, true) + "|r")
endfunction
function ShowDrivingMsgPlayer takes player plPlayer, string strMsg returns nothing
call DisplayTextToPlayer ( plPlayer, 0, 0, "\r|cffffcc00" + strMsg + "|r" )
endfunction
function ShowPowerUpMsgPlayer takes player plPlayer, string strMsg returns nothing
call DisplayTextToPlayer ( plPlayer, 0, 0, "\r|cccffff00" + strMsg + "|r" )
endfunction
function GetPlayerNameWithColor takes integer nPlayerIndex returns string
return udg_PlayerColor[nPlayerIndex] + GetPlayerName(Player(nPlayerIndex)) + "|r"
endfunction
function ShowHitMsg takes player fp_PlayerHit, integer nPlayerIndexHitter, string fp_strMsg returns nothing
call PlaySoundPlayer( fp_PlayerHit, gg_snd_QuestLog )
call ShowWarningMsg( fp_PlayerHit, "You got hit by " + GetPlayerNameWithColor( nPlayerIndexHitter ) + "'s " + fp_strMsg + "!" )
endfunction
function GetPlayerIndex takes player plPlayer returns integer
local integer nIndex = 0
loop
exitwhen nIndex > udg_PLAYER_MAXNUM
if ( plPlayer == Player(nIndex) ) then
return nIndex
endif
set nIndex = nIndex + 1
endloop
return -1
endfunction
function GetModelAddress takes integer nModel returns integer
return nModel * 12
endfunction
function GetModelUnitType takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 0]
endfunction
function GetModelIndex takes integer nUnitType returns integer
local integer nIndex = 0
loop
exitwhen nIndex >= udg_MODEL_NUM
if ( nUnitType == GetModelUnitType(nIndex) ) then
return nIndex
endif
set nIndex = nIndex + 1
endloop
return -1
endfunction
function GetModelPickUnitType takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 1]
endfunction
function GetModelFlyUnitType takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 2]
endfunction
function GetModelHonk takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 3]
endfunction
function GetModelAnimStandID takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 4]
endfunction
function GetModelAnimWalkID takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 5]
endfunction
function GetModelAnimStandAttackID takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 6]
endfunction
function GetModelAnimWalkAttackID takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 7]
endfunction
function GetModelAnimVictoryID takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 8]
endfunction
function GetModelDriverUnitType takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 9]
endfunction
function GetModelDriverAnimID takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 10]
endfunction
function GetModelDriverSound takes integer nModel returns integer
return udg_Models[GetModelAddress(nModel) + 11]
endfunction
function GetModelAttributesAddress takes integer nModel returns integer
return nModel * 4
endfunction
function GetModelMaxSpeed takes integer nModel returns real
return udg_ModelAttributes[GetModelAttributesAddress(nModel) + 0]
endfunction
function GetModelTurnRate takes integer nModel returns real
return udg_ModelAttributes[GetModelAttributesAddress(nModel) + 1]
endfunction
function GetModelAcceRate takes integer nModel returns real
return udg_ModelAttributes[GetModelAttributesAddress(nModel) + 2]
endfunction
function GetModelMassDrag takes integer nModel returns real
return udg_ModelAttributes[GetModelAttributesAddress(nModel) + 3]
endfunction
function GetPowerUpTypeAddress takes integer nIndex returns integer
return nIndex * 4
endfunction
function GetPowerUpType takes integer nIndex, integer nSlot returns integer
return udg_PowerUpTypes[GetPowerUpTypeAddress(nIndex) + nSlot]
endfunction
function GetPowerUpTypeIndex takes integer nType returns integer
local integer nIndex = 0
local integer nSlot = 0
loop
exitwhen nIndex >= udg_PowerUpTypeNum
set nSlot = 0
loop
exitwhen nSlot >= 4
if ( GetPowerUpType( nIndex, nSlot ) == nType ) then
return nIndex
endif
set nSlot = nSlot + 1
endloop
set nIndex = nIndex + 1
endloop
return -1
endfunction
function GetPowerUpTypeSlot takes integer nType returns integer
local integer nIndex = 0
local integer nSlot = 0
loop
exitwhen nIndex >= udg_PowerUpTypeNum
set nSlot = 0
loop
exitwhen nSlot >= 4
if ( GetPowerUpType( nIndex, nSlot ) == nType ) then
return nSlot
endif
set nSlot = nSlot + 1
endloop
set nIndex = nIndex + 1
endloop
return -1
endfunction
function IsItACart takes integer nUnitId returns boolean
local integer nLoopId = 0
loop
exitwhen nLoopId >= udg_MODEL_NUM
if ( GetModelUnitType( nLoopId ) == nUnitId ) then
return true
endif
set nLoopId = nLoopId + 1
endloop
return false
endfunction
function GetPickModelIndex takes integer nUnitType returns integer
local integer nIndex = 0
loop
exitwhen nIndex >= udg_MODEL_NUM
if ( nUnitType == GetModelPickUnitType(nIndex) ) then
return nIndex
endif
set nIndex = nIndex + 1
endloop
return -1
endfunction
function GetCurrentPlayerNum takes nothing returns integer
local integer nPlayerIndex = 0
local integer nNum = 0
loop
exitwhen nPlayerIndex >= 8
if ( GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
set nNum = nNum + 1
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
return nNum
endfunction
function RealSpeed takes real rSpeed returns real
return rSpeed / 3
endfunction
function FakeSpeed takes real rSpeed returns real
return rSpeed * 3
endfunction
function IsCartVisible takes unit uCart returns boolean
return not UnitHasBuffBJ( uCart, 'Binv' ) and not UnitHasBuffBJ( uCart, 'B003' )
endfunction
function IsCartSpinning takes unit uCart returns boolean
return UnitHasBuffBJ( uCart, 'B000' )
endfunction
function IsCartTrapped takes unit uCart returns boolean
return UnitHasBuffBJ( uCart, 'Beng' )
endfunction
function IsCartStunned takes unit uCart returns boolean
return UnitHasBuffBJ( uCart, 'BPSE' )
endfunction
function IsCartLightened takes unit uCart returns boolean
return UnitHasBuffBJ( uCart, 'B004' )
endfunction
function SetCartInvulnerable takes unit uCart, boolean b returns nothing
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
if ( nPlayerIndex < 0 ) then
return
endif
call SetUnitInvulnerable( uCart, b )
call SetItemInvulnerable( udg_VulnerableSignal[nPlayerIndex], b )
endfunction
function IsCartVulnerable takes unit uCart returns boolean
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
local boolean b = false
if ( nPlayerIndex < 0 ) then
return false
endif
set b = not UnitHasBuffBJ( uCart, 'Bvul' ) and not UnitHasBuffBJ( uCart, 'B005' )
set b = b and not UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'Btsp' ) //Tonado
set b = b and not UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'B007' ) //Frozen
return b and not IsItemInvulnerable( udg_VulnerableSignal[nPlayerIndex] )
endfunction
function Integer2String2 takes integer n returns string
local integer n1 = 0
local integer n2 = 0
if ( n > 99 ) then
set n = ModuloInteger( n, 100 )
endif
set n1 = n / 10
set n2 = n - n1 * 10
return I2S(n1) + I2S(n2)
endfunction
function Second2String takes integer nSeconds, boolean bHour returns string
local string str = null
if ( bHour ) then
set str = Integer2String2( nSeconds / 3600 ) + ":"
else
set str = ""
endif
set nSeconds = ModuloInteger( nSeconds, 3600 )
set str = str + Integer2String2( nSeconds / 60 )
set nSeconds = ModuloInteger( nSeconds, 60 )
set str = str + ":" + Integer2String2( nSeconds )
return str
endfunction
Name | Type | is_array | initial_value |
ACCELERATE_BACKWARD | integer | No | -1 |
ACCELERATE_COAST | integer | No | 0 |
ACCELERATE_FORWARD | integer | No | 1 |
Accelerating | integer | Yes | |
AllPowerUpNames | string | Yes | |
AMMO_MAX | integer | No | 50 |
AmmoWarning | boolean | Yes | |
Angle | real | Yes | |
ANIM_NONE | integer | No | -1 |
ANIM_STAND | integer | No | |
ANIM_STANDATTACK | integer | No | 2 |
ANIM_VICTORY | integer | No | 4 |
ANIM_WALK | integer | No | 1 |
ANIM_WALKATTACK | integer | No | 3 |
BigGunLoadTimer | timer | No | |
BigGunSound | sound | Yes | |
BlizzardingFlag | integer | Yes | -1 |
BlizzardSound | sound | Yes | |
BlizzardSoundIsPlaying | boolean | Yes | |
BoardPlayerIndexes | integer | Yes | |
BoardTimer | timer | No | |
CartAnimIndex | integer | Yes | -1 |
CartGun | unit | Yes | |
CartItemNum | integer | Yes | |
CartPowerUps | integer | Yes | |
CartPrePos | location | Yes | |
Carts | unit | Yes | |
CartSndPlaying | integer | Yes | -1 |
CartSounds | sound | Yes | |
CaughtInTornado | boolean | Yes | |
ChampionDriver | unit | No | |
ChampionDriverAnim | string | No | |
ChampionDriverSound | sound | No | |
CheckPointsNum | integer | No | 3 |
CheckPointStatus | integer | Yes | |
CinematicUnitGrp | group | No | |
DlgBtnLaps | button | Yes | |
DlgLapNumber | dialog | No | |
DriverAnimName | string | Yes | |
DriverSound | sound | Yes | |
DrivingTimer | timer | No | |
EffectInjured | effect | Yes | |
EffectWrongDir | effect | Yes | |
FadeMask321 | integer | No | 5 |
FakePackage | unit | Yes | |
FlareGunA | unit | No | |
FlareGunB | unit | No | |
FlareSound | sound | Yes | |
Frozen | boolean | Yes | |
FrozenEffect | effect | Yes | |
GAME_DRIVING | integer | No | 2 |
GAME_FINISHING | integer | No | 4 |
GAME_LEFT | integer | No | 6 |
GAME_OVER | integer | No | 5 |
GAME_PICKING | integer | No | |
GAME_PREPARING | integer | No | 1 |
GAME_REPAIRING | integer | No | 3 |
GameGoingStatus | integer | Yes | -1 |
GameOver | boolean | No | |
GameStartTimer | timer | No | |
GameTimer | timer | No | |
GameTipTextTag | texttag | Yes | |
GARAGE_NUM | integer | No | 4 |
GunAmmo | integer | Yes | |
GunAttackTick | integer | Yes | -1 |
HOSTILE | player | No | PlayerNA |
HowManyPicked | integer | No | |
IceTrunkCooldown | integer | Yes | -1 |
IceTrunkTrigger | trigger | Yes | |
IceTrunkTriggerNum | integer | No | |
ItsForDebug | boolean | No | false |
LapNumber | integer | No | 1 |
LightningResize | integer | Yes | |
LIGHTNINGRESIZE_MAX | integer | No | 7 |
LostControl | boolean | Yes | |
LostControlTickle | integer | Yes | |
mb | multiboard | Yes | |
MineCartTimer | timer | No | |
MineCartTimerCount | integer | No | |
MODEL_NUM | integer | No | 0 |
ModelAttributes | real | Yes | |
ModelDescription | string | Yes | |
ModelHonkDur | integer | Yes | |
ModelHonkPath | string | Yes | |
ModelIcons | string | Yes | |
Models | integer | Yes | |
nIndex | integer | No | |
nIndexChance | integer | No | |
NormalCamera | boolean | Yes | |
NPC | player | No | PlayerNP |
PickCartCamera | camerasetup | Yes | |
PickCartCameraUnits | unit | Yes | |
PickCartPlayerTimer | timer | Yes | |
PickCartPos | location | Yes | |
PickCarts | unit | Yes | |
PickCartTextTag | texttag | Yes | |
PickCartTimer | timer | No | |
PickCartTimerWnd | timerdialog | No | |
PickCartVisibility | fogmodifier | Yes | |
PitCrews | unit | Yes | |
PITGARAGE_NUM | integer | No | 4 |
PitGarageOccupied | boolean | Yes | |
PitGarages | unit | Yes | |
PlaceCheckPt | unit | Yes | |
PlaceCheckPtDir | real | Yes | |
PlaceCheckPtNum | integer | No | |
PlaceCheckPtPos | location | Yes | |
PlaceChkPtCross1 | integer | No | -1 |
PlaceChkPtCross2 | integer | No | -1 |
PlaceChkPtCur | integer | Yes | -1 |
PlaceChkPtCurBak | integer | Yes | -1 |
PlaceChkPtHowFar | real | Yes | |
PlaceChkPtHowFarBak | real | Yes | |
PlaceChkPtLap | integer | Yes | -1 |
PlaceChkPtLapBak | integer | Yes | -1 |
PlaceNum | integer | No | |
Places | integer | Yes | -1 |
PLAYER_MAXNUM | integer | No | 8 |
PlayerBlazeFlag | integer | Yes | |
PlayerCameraIndex | integer | Yes | 2 |
PlayerCameraTarget | unit | Yes | |
PlayerColor | string | Yes | |
PlayerColorBlue | integer | Yes | |
PlayerColorGreen | integer | Yes | |
PlayerColorRed | integer | Yes | |
PlayerModels | integer | Yes | -1 |
PowerUpNames | string | Yes | |
PowerUpPickChance | integer | Yes | |
PowerUpTypeNum | integer | No | |
PowerUpTypes | abilcode | Yes | |
PowerUpUnitTypeNum | integer | No | |
PowerUpUnitTypes | unitcode | Yes | |
ProhibitAreaNum | integer | No | |
ProhibitAreas | rect | Yes | |
SheepFled | boolean | No | |
SheepTimer | timer | No | |
ShipAttackTimer | timer | No | |
Ships | unit | Yes | |
ShipTargetPoint | location | Yes | |
SNDINDEX_BRAKE | integer | No | 4 |
SNDINDEX_COAST | integer | No | 0 |
SNDINDEX_GOING1 | integer | No | 1 |
SNDINDEX_GOING2 | integer | No | 2 |
SNDINDEX_GOING3 | integer | No | 3 |
SNDINDEX_NONE | integer | No | -1 |
Speed | real | Yes | |
START_ANGLE | real | No | 90.00 |
StartPoints | location | Yes | |
StopFlares | boolean | No | |
TempFlarePoint | location | No | |
TempVolcanoPoint | location | No | |
ThrowTurtleAngle | real | Yes | |
ThrowTurtleTimer | timer | Yes | |
TickMedium | integer | No | |
TickSlow | integer | No | |
TimeUsed | real | Yes | |
TrapMax | integer | No | |
Traps | unit | Yes | |
TrapTriggers | trigger | Yes | |
Turning | integer | Yes | |
TURNING_LEFT | integer | No | -1 |
TURNING_NOTURN | integer | No | 0 |
TURNING_RIGHT | integer | No | 1 |
TurnSpeed | real | Yes | |
TurtleThrown | unit | Yes | |
TurtleThrowTickle | integer | Yes | |
UseInvulnerableIndex | integer | Yes | |
VictoryString | string | No | |
VolcanoRegion | rect | Yes | |
VolcanoUnit | unit | No | |
VulnerableSignal | item | Yes | |
WarningWrongDir | boolean | Yes |
function CreateHonkSound takes integer nIndex returns sound
local string strPath = udg_ModelHonkPath[nIndex]
local sound snd = CreateSound( strPath, false, true, false, 10, 10, "DefaultEAXON" )
call SetSoundDuration( snd, udg_ModelHonkDur[nIndex] )
call SetSoundChannel( snd, 0 )
call SetSoundVolume( snd, 127 )
call SetSoundPitch( snd, 1.0 )
call SetSoundDistances( snd, 1000.0, 10000.0 )
call SetSoundDistanceCutoff( snd, 3000.0 )
call SetSoundConeAngles( snd, 0.0, 0.0, 127 )
call SetSoundConeOrientation( snd, 0.0, 0.0, 0.0 )
return snd
endfunction
function GetCartSoundIndex takes integer nPlayerIndex, integer nSound returns integer
return nSound * udg_PLAYER_MAXNUM + nPlayerIndex
endfunction
function GetCartSound takes integer nPlayerIndex, integer nSound returns sound
return udg_CartSounds[GetCartSoundIndex(nPlayerIndex, nSound)]
endfunction
function SetCartSound takes integer nPlayerIndex, integer nSound, sound sndCart returns nothing
set udg_CartSounds[GetCartSoundIndex(nPlayerIndex, nSound)] = sndCart
endfunction
function ChangeCartSound takes integer nPlayerIndex, integer nSound returns nothing
if ( udg_CartSndPlaying[nPlayerIndex] == nSound ) then
return
endif
if ( udg_CartSndPlaying[nPlayerIndex] != udg_SNDINDEX_NONE ) then
call StopSoundBJ( GetCartSound( nPlayerIndex, udg_CartSndPlaying[nPlayerIndex] ), true )
endif
set udg_CartSndPlaying[nPlayerIndex] = nSound
if ( nSound != udg_SNDINDEX_NONE ) then
call PlaySoundOnUnitBJ( GetCartSound( nPlayerIndex, udg_CartSndPlaying[nPlayerIndex] ), 100, udg_Carts[nPlayerIndex] )
endif
endfunction
//===========================================================================
function InitTrig_Sound_Functions takes nothing returns nothing
endfunction
function InitializePlayer takes nothing returns nothing
local integer nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= 8
call SetPlayerAbilityAvailable( Player(nPlayerIndex), 'A01V', false )
set nPlayerIndex = nPlayerIndex + 1
endloop
set nPlayerIndex = 0
set udg_PlaceNum = 0
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
if ( GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
set udg_Places[udg_PlaceNum] = nPlayerIndex
set udg_PlaceNum = udg_PlaceNum + 1
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
set nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
set udg_VulnerableSignal[nPlayerIndex] = CreateItem( 'I000', GetRectCenterX(gg_rct_VulnerableArea), GetRectCenterY(gg_rct_VulnerableArea) )
set nPlayerIndex = nPlayerIndex + 1
endloop
endfunction
function InitializeModelArray takes nothing returns nothing
local integer nIndex = 0
local integer nIndex1 = 0
set udg_MODEL_NUM = 0
set udg_DriverAnimName[0] = "Spell Slam"
set udg_DriverAnimName[1] = "Stand - 3"
set udg_DriverAnimName[2] = "Stand Victory"
set udg_DriverAnimName[3] = "Spell"
set udg_DriverAnimName[4] = "Stand Alternate"
set udg_DriverSound[0] = gg_snd_VictoryDiablo
set udg_DriverSound[1] = gg_snd_VictoryGrunt
set udg_DriverSound[2] = gg_snd_VictoryLich
set udg_DriverSound[3] = gg_snd_VictoryDwarf
//Diablo
set udg_Models[nIndex1] = 'h000'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00B'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00H'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 3
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 1
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 0
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 2
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 3
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 5
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00P'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 4
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 0
set nIndex1 = nIndex1 + 1
set udg_ModelIcons[udg_MODEL_NUM] = "ReplaceableTextures\\CommandButtons\\BTNDiabloCar.blp"
set udg_ModelDescription[udg_MODEL_NUM] = "Moderate Acceleration, Good Top Speed, Moderate HP\r\rDiablo, Lord of Terror, was excited upon hearing about the Azeroth Grand Prix and wanted something fast and durable. Void dragons were too annoying to deal with, so he turned his attention to the sentinel infernal contraptions."
set udg_ModelAttributes[nIndex] = 205.00
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 1.
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 6.8
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 0.006
set nIndex = nIndex + 1
set udg_MODEL_NUM = udg_MODEL_NUM + 1
//Orc
set udg_Models[nIndex1] = 'h002'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h001'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00C'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 0
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 2
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 0
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 3
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 1
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 5
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00O'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 4
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 1
set nIndex1 = nIndex1 + 1
set udg_ModelIcons[udg_MODEL_NUM] = "ReplaceableTextures\\CommandButtons\\BTNOrcCar.blp"
set udg_ModelDescription[udg_MODEL_NUM] = "Good Acceleration, Moderate Top Speed, Good HP\r\rThe Horde possess brutish endurance on the battlefield as well as on the racing track. Chief Engineer Gazlowe stuck the engine of a goblin shredder into a motorcycle molded from pillaged dwarven steel to create this well balanced machine."
set udg_ModelAttributes[nIndex] = 200.00
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 1.
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 7.2
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 0.006
set nIndex = nIndex + 1
set udg_MODEL_NUM = udg_MODEL_NUM + 1
//Undead
set udg_Models[nIndex1] = 'h004'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h007'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00F'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 1
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 0
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 3
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 2
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 5
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 1
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00N'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 4
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 2
set nIndex1 = nIndex1 + 1
set udg_ModelIcons[udg_MODEL_NUM] = "ReplaceableTextures\\CommandButtons\\BTNUndeadCar.blp"
set udg_ModelDescription[udg_MODEL_NUM] = "Poor Acceleration, Excellent Top Speed, Poor HP\r\rHailing from the icy realms of Northend, Ner’zhul’s champion biker “Swifticle” commands both acceleration and top speed. Racers that underestimate its frail-looking chasis are left in the chilly dust."
set udg_ModelAttributes[nIndex] = 210.00
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 1.
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 6.5
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 0.006
set nIndex = nIndex + 1
set udg_MODEL_NUM = udg_MODEL_NUM + 1
//Dwarf
set udg_Models[nIndex1] = 'h008'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h009'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00G'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 2
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 0
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 2
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 3
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 4
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 1
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00M'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 4
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 3
set nIndex1 = nIndex1 + 1
set udg_ModelIcons[udg_MODEL_NUM] = "ReplaceableTextures\\CommandButtons\\BTNDwarfCar.blp"
set udg_ModelDescription[udg_MODEL_NUM] = "Excellent Acceleration, Poor Top Speed, Excellent HP\r\rDwarven know-how and gnome expertise combined to produce this powerful mobile racing tank which can withstand the most extreme temperatures. Unfortunately, the weight of its thick mithril layers left it a little lacking in the top speed category. Gnomish engineering at its finest."
set udg_ModelAttributes[nIndex] = 195.00
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 1.
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 7.5
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 0.006
set nIndex = nIndex + 1
set udg_MODEL_NUM = udg_MODEL_NUM + 1
return
//Night Elf
set udg_Models[nIndex1] = 'h006'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h003'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00D'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 1
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 0
set nIndex1 = nIndex1 + 1
set udg_ModelIcons[udg_MODEL_NUM] = "ReplaceableTextures\\CommandButtons\\BTNGlaiveThrower.blp"
set udg_ModelAttributes[nIndex] = 220.00
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 1.
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 8.
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 0.006
set nIndex = nIndex + 1
set udg_MODEL_NUM = udg_MODEL_NUM + 1
//Judge
set udg_Models[nIndex1] = 'h00A'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h005'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 'h00E'
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 2
set nIndex1 = nIndex1 + 1
set udg_Models[nIndex1] = 3
set nIndex1 = nIndex1 + 1
set udg_ModelIcons[udg_MODEL_NUM] = "ReplaceableTextures\\CommandButtons\\BTNInfernalFlameCannon.blp"
set udg_ModelAttributes[nIndex] = 200.00
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 1.
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 7.
set nIndex = nIndex + 1
set udg_ModelAttributes[nIndex] = 0.006
set nIndex = nIndex + 1
set udg_MODEL_NUM = udg_MODEL_NUM + 1
endfunction
function InitializePlayerColor takes nothing returns nothing
set udg_PlayerColorRed[0] = 255
set udg_PlayerColorGreen[0] = 0
set udg_PlayerColorBlue[0] = 0
set udg_PlayerColor[0] = "|cffff0000"
// ----------------------------------------------------------------------------------------------------------------------------------------
set udg_PlayerColorRed[1] = 0
set udg_PlayerColorGreen[1] = 0
set udg_PlayerColorBlue[1] = 255
set udg_PlayerColor[1] = "|cff0000ff"
// ----------------------------------------------------------------------------------------------------------------------------------------
set udg_PlayerColorRed[2] = 0
set udg_PlayerColorGreen[2] = 255
set udg_PlayerColorBlue[2] = 255
set udg_PlayerColor[2] = "|cff00ffff"
// ----------------------------------------------------------------------------------------------------------------------------------------
set udg_PlayerColorRed[3] = 128
set udg_PlayerColorGreen[3] = 0
set udg_PlayerColorBlue[3] = 128
set udg_PlayerColor[3] = "|cff800080"
// ----------------------------------------------------------------------------------------------------------------------------------------
set udg_PlayerColorRed[4] = 255
set udg_PlayerColorGreen[4] = 255
set udg_PlayerColorBlue[4] = 0
set udg_PlayerColor[4] = "|cffffff00"
// ----------------------------------------------------------------------------------------------------------------------------------------
set udg_PlayerColorRed[5] = 255
set udg_PlayerColorGreen[5] = 128
set udg_PlayerColorBlue[5] = 0
set udg_PlayerColor[5] = "|cffff8000"
// ----------------------------------------------------------------------------------------------------------------------------------------
set udg_PlayerColorRed[6] = 0
set udg_PlayerColorGreen[6] = 255
set udg_PlayerColorBlue[6] = 0
set udg_PlayerColor[6] = "|cff00ff00"
// ----------------------------------------------------------------------------------------------------------------------------------------
set udg_PlayerColorRed[7] = 255
set udg_PlayerColorGreen[7] = 0
set udg_PlayerColorBlue[7] = 255
set udg_PlayerColor[7] = "|cffff00ff"
endfunction
function InitializePitCrews takes real rFace returns nothing
local integer nIndex = 0
loop
exitwhen nIndex >= udg_PITGARAGE_NUM
call SetUnitFacing( udg_PitCrews[nIndex], rFace )
set nIndex = nIndex + 1
endloop
endfunction
function InitializeCartPowerUps takes nothing returns nothing
local integer nPlayerIndex = 0
local integer nSlot = 0
local integer nIndex = 0
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
set nSlot = 0
loop
exitwhen nSlot >= 4
set udg_CartPowerUps[nIndex] = 0
set nIndex = nIndex + 1
set nSlot = nSlot + 1
endloop
set nPlayerIndex = nPlayerIndex + 1
endloop
endfunction
function InitializeSound takes nothing returns nothing
set udg_BigGunSound[0] = gg_snd_GyrocopterImpactHit100
set udg_BigGunSound[1] = gg_snd_GyrocopterImpactHit101
set udg_BigGunSound[2] = gg_snd_GyrocopterImpactHit102
set udg_BigGunSound[3] = gg_snd_GyrocopterImpactHit103
set udg_BigGunSound[4] = gg_snd_GyrocopterImpactHit104
set udg_BigGunSound[5] = gg_snd_GyrocopterImpactHit105
set udg_BigGunSound[6] = gg_snd_GyrocopterImpactHit106
set udg_BigGunSound[7] = gg_snd_GyrocopterImpactHit107
set udg_BlizzardSound[0] = gg_snd_BlizzardLoop100
set udg_BlizzardSound[1] = gg_snd_BlizzardLoop101
set udg_BlizzardSound[2] = gg_snd_BlizzardLoop102
set udg_BlizzardSound[3] = gg_snd_BlizzardLoop103
set udg_BlizzardSound[4] = gg_snd_BlizzardLoop104
set udg_BlizzardSound[5] = gg_snd_BlizzardLoop105
set udg_BlizzardSound[6] = gg_snd_BlizzardLoop106
set udg_BlizzardSound[7] = gg_snd_BlizzardLoop107
call SetCartSound( 0, udg_SNDINDEX_COAST, gg_snd_W3RaceCarLoop0 )
call SetCartSound( 1, udg_SNDINDEX_COAST, gg_snd_W3RaceCarLoop1 )
call SetCartSound( 2, udg_SNDINDEX_COAST, gg_snd_W3RaceCarLoop2 )
call SetCartSound( 3, udg_SNDINDEX_COAST, gg_snd_W3RaceCarLoop3 )
call SetCartSound( 4, udg_SNDINDEX_COAST, gg_snd_W3RaceCarLoop4 )
call SetCartSound( 5, udg_SNDINDEX_COAST, gg_snd_W3RaceCarLoop5 )
call SetCartSound( 6, udg_SNDINDEX_COAST, gg_snd_W3RaceCarLoop6 )
call SetCartSound( 7, udg_SNDINDEX_COAST, gg_snd_W3RaceCarLoop7 )
call SetCartSound( 0, udg_SNDINDEX_GOING1, gg_snd_W3RaceCarGoing1_0 )
call SetCartSound( 1, udg_SNDINDEX_GOING1, gg_snd_W3RaceCarGoing1_1 )
call SetCartSound( 2, udg_SNDINDEX_GOING1, gg_snd_W3RaceCarGoing1_2 )
call SetCartSound( 3, udg_SNDINDEX_GOING1, gg_snd_W3RaceCarGoing1_3 )
call SetCartSound( 4, udg_SNDINDEX_GOING1, gg_snd_W3RaceCarGoing1_4 )
call SetCartSound( 5, udg_SNDINDEX_GOING1, gg_snd_W3RaceCarGoing1_5 )
call SetCartSound( 6, udg_SNDINDEX_GOING1, gg_snd_W3RaceCarGoing1_6 )
call SetCartSound( 7, udg_SNDINDEX_GOING1, gg_snd_W3RaceCarGoing1_7 )
call SetCartSound( 0, udg_SNDINDEX_GOING2, gg_snd_W3RaceCarGoing2_0 )
call SetCartSound( 1, udg_SNDINDEX_GOING2, gg_snd_W3RaceCarGoing2_1 )
call SetCartSound( 2, udg_SNDINDEX_GOING2, gg_snd_W3RaceCarGoing2_2 )
call SetCartSound( 3, udg_SNDINDEX_GOING2, gg_snd_W3RaceCarGoing2_3 )
call SetCartSound( 4, udg_SNDINDEX_GOING2, gg_snd_W3RaceCarGoing2_4 )
call SetCartSound( 5, udg_SNDINDEX_GOING2, gg_snd_W3RaceCarGoing2_5 )
call SetCartSound( 6, udg_SNDINDEX_GOING2, gg_snd_W3RaceCarGoing2_6 )
call SetCartSound( 7, udg_SNDINDEX_GOING2, gg_snd_W3RaceCarGoing2_7 )
call SetCartSound( 0, udg_SNDINDEX_GOING3, gg_snd_W3RaceCarGoing3_0 )
call SetCartSound( 1, udg_SNDINDEX_GOING3, gg_snd_W3RaceCarGoing3_1 )
call SetCartSound( 2, udg_SNDINDEX_GOING3, gg_snd_W3RaceCarGoing3_2 )
call SetCartSound( 3, udg_SNDINDEX_GOING3, gg_snd_W3RaceCarGoing3_3 )
call SetCartSound( 4, udg_SNDINDEX_GOING3, gg_snd_W3RaceCarGoing3_4 )
call SetCartSound( 5, udg_SNDINDEX_GOING3, gg_snd_W3RaceCarGoing3_5 )
call SetCartSound( 6, udg_SNDINDEX_GOING3, gg_snd_W3RaceCarGoing3_6 )
call SetCartSound( 7, udg_SNDINDEX_GOING3, gg_snd_W3RaceCarGoing3_7 )
set udg_ModelHonkPath[0] = "war3mapImported\\War3CarHonk02.wav"
set udg_ModelHonkDur[0] = 784
set udg_ModelHonkPath[1] = "war3mapImported\\War3CarHonk03.wav"
set udg_ModelHonkDur[1] = 678
set udg_ModelHonkPath[2] = "war3mapImported\\War3CarHonk05.wav"
set udg_ModelHonkDur[2] = 1401
set udg_ModelHonkPath[3] = "war3mapImported\\War3CarHonk08.wav"
set udg_ModelHonkDur[3] = 1324
endfunction
function IceTrunkFilter takes nothing returns boolean
return GetUnitTypeId( GetFilterUnit() ) == 'n00M' and IsUnitAliveBJ( GetFilterUnit() )
endfunction
function Trig_IceTrunk_Conditions takes nothing returns boolean
if ( not IsItACart( GetUnitTypeId( GetTriggerUnit() ) ) ) then
return false
elseif ( not IsUnitAliveBJ( GetTriggerUnit() ) ) then
return false
elseif ( not IsCartVisible( GetTriggerUnit() ) ) then
return false
elseif ( not IsCartVulnerable( GetTriggerUnit() ) ) then
return false
endif
return true
endfunction
function Trig_IceTrunk_Actions takes nothing returns nothing
local unit uAttacker
local unit uCart
local location loc
local group g
local unit uIceTrunk
local integer nIndex
local integer nPlayerIndex
local effect eff
call ShowDebugMsg( "Trig_IceTrunk_Actions" )
set uCart = GetTriggerUnit()
set nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
if ( nPlayerIndex < 0 ) then
return
endif
if ( udg_IceTrunkCooldown[nPlayerIndex] >= 0 ) then
return
endif
set loc = GetUnitLoc( uCart )
set udg_Frozen[nPlayerIndex] = true
set udg_Speed[nPlayerIndex] = 0
call SetUnitTimeScale( udg_Carts[nPlayerIndex], 1 )
call SetCartInvulnerable( udg_Carts[nPlayerIndex], true )
set uAttacker = CreateUnit( udg_HOSTILE, 'n00N', GetUnitX(uCart), GetUnitY(uCart), 0 )
call IssueTargetOrder( uAttacker, "attack", uCart )
call UnitApplyTimedLife( uAttacker, 'BTLF', 2 )
set eff = AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathMissile.mdl", udg_Carts[nPlayerIndex], "origin" )
call DestroyEffect( eff )
set g = GetUnitsInRangeOfLocMatching( 400, loc, Condition(function IceTrunkFilter) )
call RemoveLocation( loc )
loop
set uIceTrunk = FirstOfGroup( g )
exitwhen uIceTrunk == null
set nIndex = GetUnitUserData( uIceTrunk)
if ( udg_IceTrunkTrigger[nIndex] == GetTriggeringTrigger() ) then
call DestroyTrigger( udg_IceTrunkTrigger[nIndex] )
set udg_IceTrunkTrigger[nIndex] = null
call KillUnit( uIceTrunk )
exitwhen true
endif
call GroupRemoveUnit( g, uIceTrunk )
endloop
call DestroyGroup( g )
endfunction
function CreateIceTrunk takes location loc returns nothing
local integer nIndex
local trigger t
local unit u = CreateUnitAtLoc( udg_NPC, 'n00M', loc, I2R(GetRandomInt(0, 359)) )
set t = CreateTrigger( )
call TriggerRegisterUnitInRangeSimple( t, 60, u )
call TriggerAddCondition( t, Condition( function Trig_IceTrunk_Conditions ) )
call TriggerAddAction( t, function Trig_IceTrunk_Actions )
set nIndex = 0
loop
exitwhen nIndex >= udg_IceTrunkTriggerNum
exitwhen udg_IceTrunkTrigger[nIndex] == null
set nIndex = nIndex + 1
endloop
set udg_IceTrunkTrigger[nIndex] = t
call SetUnitUserData( u, nIndex )
if ( nIndex >= udg_IceTrunkTriggerNum ) then
set udg_IceTrunkTriggerNum = udg_IceTrunkTriggerNum + 1
endif
endfunction
function InitIceTrunk takes nothing returns nothing
local group g = null
local unit u
local location loc
set g = GetUnitsInRectMatching( gg_rct_IceTrunkArea, Condition(function IceTrunkFilter) )
loop
set u = FirstOfGroup( g )
exitwhen u == null
set loc = GetUnitLoc( u )
call RemoveUnit( u )
call CreateIceTrunk( loc )
call RemoveLocation( loc )
call GroupRemoveUnit( g, u )
endloop
call DestroyGroup( g )
endfunction
function FakeSheepFilter takes nothing returns boolean
return GetUnitTypeId( GetFilterUnit() ) == 'n00H' and IsUnitAliveBJ( GetFilterUnit() )
endfunction
function InitSheep takes nothing returns nothing
local group g = null
local unit u
set g = GetUnitsInRectMatching( gg_rct_SheepAreaFake, Condition(function FakeSheepFilter) )
loop
set u = FirstOfGroup( g )
exitwhen u == null
call SetUnitPathing( u, false )
call SetUnitFacing( u, GetRandomReal(0., 359.) )
call GroupRemoveUnit( g, u )
endloop
call DestroyGroup( g )
endfunction
//===========================================================================
function InitTrig_Initialization_Functions takes nothing returns nothing
endfunction
function ResetCameraForPick takes integer nPlayerIndex returns nothing
call SetCameraTargetControllerNoZForPlayer( Player(nPlayerIndex), udg_PickCartCameraUnits[nPlayerIndex], 0, 0, true )
call SetCameraFieldForPlayer( Player(nPlayerIndex), CAMERA_FIELD_TARGET_DISTANCE, 800, 0 )
call SetCameraFieldForPlayer( Player(nPlayerIndex), CAMERA_FIELD_FIELD_OF_VIEW, 70, 0 )
call SetCameraFieldForPlayer( Player(nPlayerIndex), CAMERA_FIELD_ROTATION, 270, 0 )
call SetCameraFieldForPlayer( Player(nPlayerIndex), CAMERA_FIELD_ZOFFSET, 0, 0 )
call SetCameraFieldForPlayer( Player(nPlayerIndex), CAMERA_FIELD_ANGLE_OF_ATTACK, 350.00, 0 )
call SetCameraFieldForPlayer( Player(nPlayerIndex), CAMERA_FIELD_FARZ, 1000.00, 0 )
endfunction
function GetGameTip takes nothing returns string
local string str = "|cff00ff00[IN GAME TIPS]|r|n"
set str = str + "|n|cffffcc00Arrow keys|r - Drive your cart"
set str = str + "|n|cffffcc00'A' 'S' 'D' 'F'|r - Use items"
set str = str + "|n|cffffcc00'W'|r - Fire machine gun"
set str = str + "|n|cffffcc00'Q'|r - Honk"
return str
endfunction
function GetCartDescription takes unit uCart returns string
local integer nModelId = GetPickModelIndex( GetUnitTypeId( uCart ) )
//local string str = StringCase( GetUnitName( uCart ), true )
//set str = str + "|n|nMax Speed : " + R2SW( GetModelMaxSpeed( nModelId ), 1, 1 )
//set str = str + "|nAcceleration : " + R2SW( GetModelAcceRate( nModelId ), 1, 1 )
//set str = str + "|nTurn Speed : " + R2SW( GetModelTurnRate( nModelId ), 1, 1 )
return udg_ModelDescription[nModelId]
endfunction
function CreateGameTipTag takes integer nPlayerIndex returns nothing
set udg_GameTipTextTag[nPlayerIndex] = CreateTextTag()
call SetTextTagText( udg_GameTipTextTag[nPlayerIndex], GetGameTip(), 0.023 )
call SetTextTagColor( udg_GameTipTextTag[nPlayerIndex], 255, 255, 255, 255 )
call SetTextTagVelocity( udg_GameTipTextTag[nPlayerIndex], 0, 0 )
call ShowTextTagForceBJ( true, udg_GameTipTextTag[nPlayerIndex], GetForceOfPlayer(Player(nPlayerIndex)) )
call SetTextTagPos( udg_GameTipTextTag[nPlayerIndex], GetLocationX(udg_PickCartPos[nPlayerIndex]) + 300, GetLocationY(udg_PickCartPos[nPlayerIndex]) + 200, 70)
endfunction
function DestroyGameTipTag takes integer nPlayerIndex returns nothing
if ( udg_PickCartTextTag[nPlayerIndex] == null ) then
return
endif
call DestroyTextTag( udg_GameTipTextTag[nPlayerIndex] )
set udg_GameTipTextTag[nPlayerIndex] = null
endfunction
function ResetPickCartTextTag takes integer nPlayerIndex returns nothing
if ( udg_PickCarts[nPlayerIndex] != null ) then
if ( udg_PickCartTextTag[nPlayerIndex] != null ) then
call DestroyTextTag( udg_PickCartTextTag[nPlayerIndex] )
endif
set udg_PickCartTextTag[nPlayerIndex] = CreateTextTag()
call SetTextTagText( udg_PickCartTextTag[nPlayerIndex], GetCartDescription(udg_PickCarts[nPlayerIndex]), 0.023 )
call SetTextTagColor( udg_PickCartTextTag[nPlayerIndex], 200, 255, 0, 255 )
call SetTextTagVelocity( udg_PickCartTextTag[nPlayerIndex], 0, 0.020 )
call ShowTextTagForceBJ( true, udg_PickCartTextTag[nPlayerIndex], GetForceOfPlayer(Player(nPlayerIndex)) )
call SetTextTagPos( udg_PickCartTextTag[nPlayerIndex], GetLocationX(udg_PickCartPos[nPlayerIndex]) - 150, GetLocationY(udg_PickCartPos[nPlayerIndex]) + 200, -90)
else
if ( udg_PickCartTextTag[nPlayerIndex] != null ) then
call DestroyTextTag( udg_PickCartTextTag[nPlayerIndex] )
set udg_PickCartTextTag[nPlayerIndex] = null
endif
endif
endfunction
function PreparePickingCartPlayer takes integer nPlayerIndex returns nothing
local unit uCamera = null
local unit uCart = null
local location loc = null
local rect rc = null
set udg_GameGoingStatus[nPlayerIndex] = udg_GAME_PICKING
set udg_PickCartCameraUnits[nPlayerIndex] = CreateUnitAtLoc( Player(nPlayerIndex), 'n00K', udg_PickCartPos[nPlayerIndex], 0 )
set loc = PolarProjectionBJ( udg_PickCartPos[nPlayerIndex], 80, 0 )
set udg_PickCarts[nPlayerIndex] = CreateUnitAtLoc( Player(nPlayerIndex), GetModelPickUnitType(0), loc, 90 )
call RemoveLocation( loc )
call ClearSelectionForPlayer( Player(nPlayerIndex) )
call SelectUnitForPlayerSingle( udg_PickCarts[nPlayerIndex], Player(nPlayerIndex) )
set rc = Rect( GetLocationX(udg_PickCartPos[nPlayerIndex]) - 250, GetLocationY(udg_PickCartPos[nPlayerIndex]) - 250, GetLocationX(udg_PickCartPos[nPlayerIndex]) + 250, GetLocationY(udg_PickCartPos[nPlayerIndex]) + 250 )
set udg_PickCartVisibility[nPlayerIndex] = CreateFogModifierRectBJ( true, Player(nPlayerIndex), FOG_OF_WAR_VISIBLE, rc )
call RemoveRect( rc )
call TimerStart( udg_PickCartPlayerTimer[nPlayerIndex], 0.05, true, null )
call CreateGameTipTag( nPlayerIndex )
call ResetPickCartTextTag( nPlayerIndex )
call ResetCameraForPick( nPlayerIndex )
endfunction
function RotatePickCart takes integer nPlayerIndex returns nothing
local location loc = null
local real rAngle = 0
if ( udg_PickCarts[nPlayerIndex] == null ) then
return
endif
set loc = GetUnitLoc( udg_PickCarts[nPlayerIndex] )
set rAngle = GetUnitFacing( udg_PickCarts[nPlayerIndex] ) + 5
call SetUnitFacing( udg_PickCarts[nPlayerIndex], rAngle )
call SetUnitPositionLoc( udg_PickCarts[nPlayerIndex], loc )
call RemoveLocation( loc )
endfunction
function StartPickingCart takes nothing returns nothing
local boolean bContinue = false
local integer nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= 8
if ( GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
call PreparePickingCartPlayer(nPlayerIndex)
else
call DestroyTimer( udg_PickCartPlayerTimer[nPlayerIndex] )
call DestroyTextTag( udg_PickCartTextTag[nPlayerIndex] )
set udg_PickCartTextTag[nPlayerIndex] = null
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
endfunction
function ResetCameraTarget takes integer nPlayerIndex, unit uTarget returns nothing
if ( uTarget != null and uTarget != udg_PlayerCameraTarget[nPlayerIndex] ) then
set udg_PlayerCameraTarget[nPlayerIndex] = uTarget
if ( IsUnitAliveBJ( udg_PlayerCameraTarget[nPlayerIndex] ) ) then
call SetCameraTargetControllerNoZForPlayer( Player(nPlayerIndex), udg_PlayerCameraTarget[nPlayerIndex], 0, 0, true )
endif
endif
if (GetLocalPlayer() == Player(nPlayerIndex) ) then
if ( GetCameraField(CAMERA_FIELD_TARGET_DISTANCE) != 500 + udg_PlayerCameraIndex[nPlayerIndex] * 225 ) then
call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, 500 + udg_PlayerCameraIndex[nPlayerIndex] * 225, 0 )
endif
if ( GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW) != 70 ) then
call SetCameraField( CAMERA_FIELD_FIELD_OF_VIEW, 70, 0 )
endif
if ( GetCameraField(CAMERA_FIELD_ROTATION) != udg_Angle[nPlayerIndex] ) then
call SetCameraField( CAMERA_FIELD_ROTATION, udg_Angle[nPlayerIndex], 0 )
endif
if ( GetCameraField(CAMERA_FIELD_ZOFFSET) != 200 ) then
call SetCameraField( CAMERA_FIELD_ZOFFSET, 200.00, 0 )
endif
if ( GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK) != 340 ) then
call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, 340.00, 0 )
endif
if ( GetCameraField(CAMERA_FIELD_FARZ) != 5500 ) then
call SetCameraField( CAMERA_FIELD_FARZ, 5500.00, 0 )
endif
endif
endfunction
function ResetCamera takes integer nPlayerIndex returns nothing
if ( udg_NormalCamera[nPlayerIndex] ) then
return
endif
if ( GetPlayerController(Player(nPlayerIndex)) != MAP_CONTROL_USER or GetPlayerSlotState(Player(nPlayerIndex)) != PLAYER_SLOT_STATE_PLAYING ) then
return
endif
call ResetCameraTarget( nPlayerIndex, null )
endfunction
function PickCartNavigate takes unit uCartPick, boolean bForward returns nothing
local location loc = null
local real rAngle = 0
local integer nModelIndex = GetPickModelIndex( GetUnitTypeId( uCartPick ) )
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer(uCartPick) )
if ( nModelIndex < 0 or nPlayerIndex < 0 ) then
return
endif
if ( uCartPick != udg_PickCarts[nPlayerIndex] ) then
return
endif
if ( bForward ) then
set nModelIndex = nModelIndex + 1
if ( nModelIndex >= udg_MODEL_NUM ) then
set nModelIndex = 0
endif
else
set nModelIndex = nModelIndex - 1
if ( nModelIndex < 0 ) then
set nModelIndex = udg_MODEL_NUM - 1
endif
endif
set loc = GetUnitLoc( udg_PickCarts[nPlayerIndex] )
set rAngle = GetUnitFacing( udg_PickCarts[nPlayerIndex] )
call RemoveUnit( udg_PickCarts[nPlayerIndex] )
set udg_PickCarts[nPlayerIndex] = CreateUnitAtLoc( Player(nPlayerIndex), GetModelPickUnitType( nModelIndex ), loc, rAngle )
call RemoveLocation( loc )
call ClearSelectionForPlayer( Player(nPlayerIndex) )
call SelectUnitForPlayerSingle( udg_PickCarts[nPlayerIndex], Player(nPlayerIndex) )
call ResetPickCartTextTag( nPlayerIndex )
endfunction
function PickCartSimple takes player plPlayer, integer nModelIndex returns nothing
local integer nPlayerIndex = -1
local rect rc = null
set nPlayerIndex = GetPlayerIndex( plPlayer )
if ( nPlayerIndex < 0 ) then
return
endif
if ( udg_GameGoingStatus[nPlayerIndex] != udg_GAME_PICKING ) then
return
endif
call DestroyTimer( udg_PickCartPlayerTimer[nPlayerIndex] )
call RemoveUnit( udg_PickCarts[nPlayerIndex] )
set udg_PickCarts[nPlayerIndex] = null
call RemoveUnit( udg_PickCartCameraUnits[nPlayerIndex] )
set udg_PickCartCameraUnits[nPlayerIndex] = null
call DestroyGameTipTag( nPlayerIndex )
call ResetPickCartTextTag( nPlayerIndex )
set udg_PlayerModels[nPlayerIndex] = nModelIndex
set udg_Carts[nPlayerIndex] = CreateUnitAtLoc( Player(nPlayerIndex), GetModelUnitType( udg_PlayerModels[nPlayerIndex] ), udg_StartPoints[udg_HowManyPicked], udg_START_ANGLE )
set udg_CartPrePos[nPlayerIndex] = udg_StartPoints[udg_HowManyPicked]
call ClearSelectionForPlayer( Player(nPlayerIndex) )
call SelectUnitForPlayerSingle( udg_Carts[nPlayerIndex], Player(nPlayerIndex) )
set udg_Angle[nPlayerIndex] = udg_START_ANGLE
call ResetCameraTarget( nPlayerIndex, udg_Carts[nPlayerIndex] )
call ChangeCartSound( nPlayerIndex, udg_SNDINDEX_COAST )
set udg_HowManyPicked = udg_HowManyPicked + 1
call DestroyFogModifier( udg_PickCartVisibility[nPlayerIndex] )
set rc = Rect( GetLocationX(udg_PickCartPos[nPlayerIndex]) - 200, GetLocationY(udg_PickCartPos[nPlayerIndex]) - 200, GetLocationX(udg_PickCartPos[nPlayerIndex]) + 200, GetLocationY(udg_PickCartPos[nPlayerIndex]) + 200 )
set udg_PickCartVisibility[nPlayerIndex] = CreateFogModifierRectBJ( true, Player(nPlayerIndex), FOG_OF_WAR_MASKED, rc )
call RemoveRect( rc )
call CreateFogModifierRectBJ( true, Player(nPlayerIndex), FOG_OF_WAR_VISIBLE, gg_rct_VisibleRgn )
endfunction
function PickingEnded takes nothing returns nothing
local integer nPlayerIndex = 0
if ( udg_PickCartTimer == null ) then
return
endif
call DestroyTrigger( gg_trg_Picking_Cart_Timer )
call DestroyTimerDialogBJ( udg_PickCartTimerWnd )
call DestroyTimer( udg_PickCartTimer )
set udg_PickCartTimer = null
set nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= 8
if ( udg_PickCarts[nPlayerIndex] != null ) then
call PickCartSimple( Player(nPlayerIndex), GetPickModelIndex( GetUnitTypeId( udg_PickCarts[nPlayerIndex] ) ) )
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
// --------------------------------------------------
call DestroyTrigger( gg_trg_Pick_Cart_Functions )
call DestroyTrigger( gg_trg_Start_Picking_Cart )
call DestroyTrigger( gg_trg_Picking_Cart_Player_Timer )
call DestroyTrigger( gg_trg_Select_Other_Unit_Than_Picking_Cart )
call DestroyTrigger( gg_trg_Deselect_Picking_Cart )
call DestroyTrigger( gg_trg_View_Previous_Cart )
call DestroyTrigger( gg_trg_View_Next_Cart )
call DestroyTrigger( gg_trg_Pick_Cart )
// --------------------------------------------------
call TimerStart( udg_GameStartTimer, 1.00, true, null )
// --------------------------------------------------
call TimerStart( udg_DrivingTimer, 0.05, true, null )
// --------------------------------------------------
set nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= 8
if ( udg_Carts[nPlayerIndex] != null ) then
call SetPlayerAbilityAvailable( Player(nPlayerIndex), 'A01V', true )
call IssueImmediateOrder( udg_Carts[nPlayerIndex], "cannibalize" )
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
call TimerStart( udg_BigGunLoadTimer, 15, false, null )
// --------------------------------------------------
call ClearMapMusic()
call StopMusic( true )
call SetMapMusic( gg_snd_Credits + ";" + gg_snd_PH1, false, 0 )
//call SetMapMusic( gg_snd_carracingxmas, false, 0 )
call PlayMusic( gg_snd_PH1 )
set nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= 8
set udg_GameGoingStatus[nPlayerIndex] = udg_GAME_PREPARING
set nPlayerIndex = nPlayerIndex + 1
endloop
//call ShowTipMsg( "Arrow keys - Drive your cart" )
//call PolledWait( 10 )
//call ShowTipMsg( "'A' 'S' 'D' 'F' - Use items" )
//call PolledWait( 10 )
//call ShowTipMsg( "'W' - Fire machine gun" )
//call PolledWait( 10 )
//call ShowTipMsg( "'Q' - Honk" )
endfunction
function PickCart takes player plPlayer, integer nModelIndex returns nothing
local integer nPlayerIndex = 0
call PickCartSimple( plPlayer, nModelIndex )
set nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= 8
if ( udg_PickCarts[nPlayerIndex] != null ) then
return
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
//All picked? Time for fun
call PickingEnded()
return
endfunction
//===========================================================================
function InitTrig_Pick_Cart_Functions takes nothing returns nothing
endfunction
function GameStartTimer takes nothing returns nothing
local integer nIndex = 0
if ( udg_FadeMask321 == 3 ) then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 0.6, "war3mapImported\\Special3Mask.blp", 90.00, 0, 0, 15.00 )
call PlaySoundBJ( gg_snd_AnnouncerThreeProcessed )
elseif ( udg_FadeMask321 == 2 ) then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 0.6, "war3mapImported\\Special2Mask.blp", 90.00, 0, 0, 15.00 )
call PlaySoundBJ( gg_snd_AnnouncerTwoProcessed )
elseif ( udg_FadeMask321 == 1 ) then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 0.6, "war3mapImported\\Special1Mask.blp", 90.00, 0, 0, 15.00 )
call PlaySoundBJ( gg_snd_AnnouncerOneProcessed )
elseif ( udg_FadeMask321 == 0 ) then
call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 3, "war3mapImported\\SpecialGoMask.blp", 90.00, 0, 0, 15.00 )
call PlaySoundBJ( gg_snd_AnnouncerGoProcessed )
call DestroyTimer( udg_GameStartTimer )
// --------------------------------------------------
call TriggerExecute( gg_trg_Create_Board )
// --------------------------------------------------
call TimerStart( udg_GameTimer, 1000000000.00, false, null )
call TimerStart( udg_MineCartTimer, 0.75, true, null )
call TimerStart( udg_SheepTimer, 80.00, false, null )
loop
exitwhen nIndex >= 8
set udg_GameGoingStatus[nIndex] = udg_GAME_DRIVING
set nIndex = nIndex + 1
endloop
return
endif
set udg_FadeMask321 = udg_FadeMask321 - 1
endfunction
function ChargeBigGunSingle takes integer nPlayerIndex returns nothing
if ( udg_Carts[nPlayerIndex] != null ) then
call UnitRemoveAbility( udg_Carts[nPlayerIndex], 'A01V' )
call UnitAddAbility( udg_Carts[nPlayerIndex], 'A01U' )
set udg_GunAmmo[nPlayerIndex] = udg_AMMO_MAX
endif
endfunction
function ChargeBigGun takes nothing returns nothing
local integer nPlayerIndex = 0
call DestroyTimer( udg_BigGunLoadTimer )
loop
exitwhen nPlayerIndex >= 8
call ChargeBigGunSingle( nPlayerIndex )
set nPlayerIndex = nPlayerIndex + 1
endloop
endfunction
//===========================================================================
function InitTrig_Game_Start_Functions takes nothing returns nothing
endfunction
function GetLeadingCart takes nothing returns integer
local integer nPlace = 0
loop
exitwhen nPlace >= udg_PlaceNum
if ( udg_GameGoingStatus[udg_Places[nPlace]] == udg_GAME_DRIVING or udg_GameGoingStatus[udg_Places[nPlace]] == udg_GAME_REPAIRING ) then
return udg_Places[nPlace]
endif
set nPlace = nPlace + 1
endloop
return -1
endfunction
function GetPlayerPlace takes integer nPlayerIndex returns integer
local integer nIndex = 0
loop
exitwhen nIndex >= udg_PlaceNum
if ( udg_Places[nIndex] == nPlayerIndex ) then
return nIndex
endif
set nIndex = nIndex + 1
endloop
return -1
endfunction
function GameOverPlayer takes integer nPlayerIndex returns nothing
local location loc = null
local effect eff = null
set udg_GameGoingStatus[nPlayerIndex] = udg_GAME_OVER
if ( udg_Carts[nPlayerIndex] == null ) then
return
endif
set loc = GetUnitLoc( udg_Carts[nPlayerIndex] )
set eff = AddSpecialEffectLoc( "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", loc)
call RemoveLocation( loc )
call RemoveUnit( udg_Carts[nPlayerIndex] )
set udg_Carts[nPlayerIndex] = null
call DestroyEffect( eff )
endfunction
function GameOver takes nothing returns nothing
local integer nPlayerIndex = 0
call PolledWait( 2 )
if ( udg_GameOver ) then
return
endif
set udg_GameOver = true
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
set udg_GameGoingStatus[nPlayerIndex] = udg_GAME_OVER
set nPlayerIndex = nPlayerIndex + 1
endloop
call ConditionalTriggerExecute( gg_trg_Ending )
call ConditionalTriggerExecute( gg_trg_Ending_Flares )
endfunction
function EnterNextLap takes integer nPlayerIndex returns nothing
if ( udg_PlaceChkPtLap[nPlayerIndex] == udg_LapNumber - 1 ) then
call ShowDrivingMsgPlayer( Player(nPlayerIndex), "Last lap" )
call PlaySoundPlayer( Player(nPlayerIndex), gg_snd_AnnouncerFinalLap01 )
else
call ShowDrivingMsgPlayer( Player(nPlayerIndex), "Lap " + I2S(udg_PlaceChkPtLap[nPlayerIndex] + 1) )
endif
endfunction
function CompletedAllLaps takes integer nPlayerIndex returns nothing
local string str
local string str1 = "|cff00ff00 Please wait for the race to end and the award ceremony.|r"
local integer nPlace
local string array strNum
set strNum[0] = "FIRST"
set strNum[1] = "SECOND"
set strNum[2] = "THIRD"
set strNum[3] = "FOURTH"
set strNum[4] = "FIFTH"
set strNum[5] = "SIXTH"
set strNum[6] = "SEVENTH"
set strNum[7] = "EIGHTH"
call SetCartInvulnerable( udg_Carts[nPlayerIndex], true )
call SetUnitOwner( udg_Carts[nPlayerIndex], udg_NPC, false )
set udg_GameGoingStatus[ nPlayerIndex ] = udg_GAME_FINISHING
set udg_TimeUsed[ nPlayerIndex ] = TimerGetElapsed( udg_GameTimer )
set udg_NormalCamera[nPlayerIndex] = true
call SetUnitAnimationByIndex( udg_Carts[nPlayerIndex], GetModelAnimVictoryID( udg_PlayerModels[nPlayerIndex] ) )
call CameraSetupApplyForPlayer( true, gg_cam_GameEndCamera, Player(nPlayerIndex), 5.00 )
call ResetToGameCameraForPlayer( Player(nPlayerIndex), 2.00 )
set nPlace = GetPlayerPlace( nPlayerIndex )
if ( nPlace == 0 ) then
set str = "\r|cff00ff00Congratulations for finishing in |r|cffff0000" + strNum[nPlace] + "|r|cff00ff00 place.|r" + str1
elseif ( nPlace > 0 ) then
set str = "\r|cff00ff00You finish in |r|cffff0000" + strNum[nPlace] + "|r|cff00ff00 place.|r" + str1
else
return
endif
set str = str + "\r|cff00ff00Your total racing time is |r|cffffcc00" + Second2String( R2I(udg_TimeUsed[nPlayerIndex]), false ) + "|r|cff00ff00.|r"
if ( GetLocalPlayer() == Player(nPlayerIndex) ) then
call ClearTextMessages()
call PlaySoundBJ( gg_snd_Hint )
call DisplayTimedTextToPlayer( Player(nPlayerIndex), 0, 0, 10, str )
endif
endfunction
function ReachedCheckPoint takes location locCart, integer nChkPtIndex returns boolean
local real rDir = AngleBetweenPoints( udg_PlaceCheckPtPos[nChkPtIndex], locCart )
return CosBJ( rDir - udg_PlaceCheckPtDir[nChkPtIndex] ) >= 0
endfunction
function DistanceFromCheckPoint takes location locCart, integer nChkPtIndex returns real
local real rDir = AngleBetweenPoints( udg_PlaceCheckPtPos[nChkPtIndex], locCart )
local real rDis = DistanceBetweenPoints( locCart, udg_PlaceCheckPtPos[nChkPtIndex] )
return rDis * CosBJ( rDir - udg_PlaceCheckPtDir[nChkPtIndex] )
endfunction
function RefreshPlayerCheckPoint takes integer nPlayerIndex returns nothing
local location loc = null
local integer nLapPre
local integer nChkPre
local integer nLapNext
local integer nChkNext
local real rDis
if ( udg_Carts[nPlayerIndex] == null ) then
return
endif
set loc = GetUnitLoc( udg_Carts[nPlayerIndex] )
if ( RectContainsLoc( gg_rct_CrossArea1, loc ) ) then
set udg_PlaceChkPtCur[nPlayerIndex] = udg_PlaceChkPtCross1
set udg_PlaceChkPtHowFar[nPlayerIndex] = 900
call RemoveLocation( loc )
return
elseif ( RectContainsLoc( gg_rct_CrossArea2, loc ) ) then
set udg_PlaceChkPtCur[nPlayerIndex] = udg_PlaceChkPtCross2
set udg_PlaceChkPtHowFar[nPlayerIndex] = 0
call RemoveLocation( loc )
return
endif
//First check whether cart reaches next point
if ( udg_PlaceChkPtLap[nPlayerIndex] < 0 ) then
set nChkNext = 0
set nLapNext = 0
elseif ( udg_PlaceChkPtCur[nPlayerIndex] == udg_PlaceCheckPtNum - 1 ) then
set nChkNext = 0
set nLapNext = udg_PlaceChkPtLap[nPlayerIndex] + 1
else
set nChkNext = udg_PlaceChkPtCur[nPlayerIndex] + 1
set nLapNext = udg_PlaceChkPtLap[nPlayerIndex]
endif
//If reached next check point
if ( nChkNext >= 0 ) then
if ( ReachedCheckPoint( loc, nChkNext ) ) then
set udg_PlaceChkPtLap[nPlayerIndex] = nLapNext
set udg_PlaceChkPtCur[nPlayerIndex] = nChkNext
set udg_PlaceChkPtHowFar[nPlayerIndex] = DistanceFromCheckPoint(loc, udg_PlaceChkPtCur[nPlayerIndex] )
call RemoveLocation( loc )
//If this is the start point
if ( udg_PlaceChkPtCur[nPlayerIndex] == 0 ) then
if ( udg_PlaceChkPtLap[nPlayerIndex] >= udg_LapNumber ) then
call CompletedAllLaps( nPlayerIndex )
else
call EnterNextLap( nPlayerIndex )
endif
endif
return
endif
endif
//If player is moving forward
if ( udg_PlaceChkPtCur[nPlayerIndex] >= 0 ) then
if ( ReachedCheckPoint( loc, udg_PlaceChkPtCur[nPlayerIndex] ) ) then
set udg_PlaceChkPtHowFar[nPlayerIndex] = DistanceFromCheckPoint(loc, udg_PlaceChkPtCur[nPlayerIndex] )
call RemoveLocation( loc )
return
endif
endif
//Player move backward
if ( udg_PlaceChkPtLap[nPlayerIndex] < 0 ) then
set nChkPre = -1
set nLapPre = -1
elseif ( udg_PlaceChkPtCur[nPlayerIndex] == 0 ) then
if ( udg_PlaceChkPtLap[nPlayerIndex] == 0 ) then
set nChkPre = -1
set nLapPre = -1
else
set nChkPre = udg_PlaceCheckPtNum - 1
set nLapPre = udg_PlaceChkPtLap[nPlayerIndex] - 1
endif
else
set nChkPre = udg_PlaceChkPtCur[nPlayerIndex] - 1
set nLapPre = udg_PlaceChkPtLap[nPlayerIndex]
endif
if ( nChkPre >= 0 ) then
set udg_PlaceChkPtLap[nPlayerIndex] = nLapPre
set udg_PlaceChkPtCur[nPlayerIndex] = nChkPre
set udg_PlaceChkPtHowFar[nPlayerIndex] = DistanceFromCheckPoint(loc, udg_PlaceChkPtCur[nPlayerIndex] )
call RemoveLocation( loc )
return
endif
set udg_PlaceChkPtLap[nPlayerIndex] = -1
set udg_PlaceChkPtCur[nPlayerIndex] = -1
set udg_PlaceChkPtHowFar[nPlayerIndex] = 0
call RemoveLocation( loc )
endfunction
function ComparePlace takes integer nLap1, integer nPos1, real rHowFar1, integer nLap2, integer nPos2, real rHowFar2 returns integer
if ( nLap1 > nLap2 ) then
return 1
elseif ( nLap1 < nLap2 ) then
return -1
endif
if ( nPos1 > nPos2 ) then
return 1
elseif ( nPos1 < nPos2 ) then
return -1
endif
if ( rHowFar1 > rHowFar2 ) then
return 1
elseif ( rHowFar1 < rHowFar2 ) then
return -1
endif
return 0
endfunction
function ComparePlaceIndex takes integer nPlayerIndex1, integer nPlayerIndex2 returns integer
local integer n
local boolean b1 = udg_GameGoingStatus[ nPlayerIndex1 ] == udg_GAME_FINISHING or udg_GameGoingStatus[ nPlayerIndex1 ] == udg_GAME_OVER
local boolean b2 = udg_GameGoingStatus[ nPlayerIndex2 ] == udg_GAME_FINISHING or udg_GameGoingStatus[ nPlayerIndex2 ] == udg_GAME_OVER
if ( b1 and b2 ) then
if ( udg_TimeUsed[nPlayerIndex1] < udg_TimeUsed[nPlayerIndex2] ) then
return 1
elseif ( udg_TimeUsed[nPlayerIndex1] > udg_TimeUsed[nPlayerIndex2] ) then
return -1
endif
elseif ( b1 ) then
return 1
elseif ( b2 ) then
return -1
else
set n = ComparePlace( udg_PlaceChkPtLap[nPlayerIndex1], udg_PlaceChkPtCur[nPlayerIndex1], udg_PlaceChkPtHowFar[nPlayerIndex1], udg_PlaceChkPtLap[nPlayerIndex2], udg_PlaceChkPtCur[nPlayerIndex2], udg_PlaceChkPtHowFar[nPlayerIndex2] )
if ( n != 0 ) then
return n
endif
endif
if ( nPlayerIndex1 < nPlayerIndex2 ) then
return 1
elseif ( nPlayerIndex1 > nPlayerIndex2 ) then
return -1
endif
return 0
endfunction
function SortPlace takes nothing returns nothing
local integer nPlayerIndex
local integer nIndex
local integer nTemp
set nPlayerIndex = 0
set udg_PlaceNum = 0
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
if ( GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
set udg_Places[udg_PlaceNum] = nPlayerIndex
set udg_PlaceNum = udg_PlaceNum + 1
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
set nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= udg_PlaceNum - 1
set nIndex = 0
loop
exitwhen nIndex >= udg_PlaceNum - 1 - nPlayerIndex
if ( ComparePlaceIndex( udg_Places[nIndex], udg_Places[nIndex + 1] ) < 0 ) then
set nTemp = udg_Places[nIndex]
set udg_Places[nIndex] = udg_Places[nIndex + 1]
set udg_Places[nIndex + 1] = nTemp
endif
set nIndex = nIndex + 1
endloop
set nPlayerIndex = nPlayerIndex + 1
endloop
endfunction
function CheckWrongDirection takes integer nPlayerIndex returns nothing
local boolean bWrong = true
if ( udg_Speed[nPlayerIndex] <= 20 ) then
set bWrong = false
elseif ( ComparePlace( udg_PlaceChkPtLapBak[nPlayerIndex], udg_PlaceChkPtCurBak[nPlayerIndex], udg_PlaceChkPtHowFarBak[nPlayerIndex], udg_PlaceChkPtLap[nPlayerIndex], udg_PlaceChkPtCur[nPlayerIndex], udg_PlaceChkPtHowFar[nPlayerIndex] ) <= 0 ) then
set bWrong = false
endif
if ( not bWrong ) then
if ( udg_EffectWrongDir[nPlayerIndex] != null ) then
call DestroyEffect( udg_EffectWrongDir[nPlayerIndex] )
set udg_EffectWrongDir[nPlayerIndex] = null
endif
return
endif
if ( udg_EffectWrongDir[nPlayerIndex] == null ) then
set udg_EffectWrongDir[nPlayerIndex] = AddSpecialEffectTarget( "Abilities\\Spells\\Other\\TalkToMe\\TalkToMe.mdl", udg_Carts[nPlayerIndex], "overhead" )
endif
if ( udg_WarningWrongDir[nPlayerIndex] ) then
return
endif
set udg_WarningWrongDir[nPlayerIndex] = true
call ShowWarningMsg( Player(nPlayerIndex), "You are going wrong direction." )
call PolledWait(15)
set udg_WarningWrongDir[nPlayerIndex] = false
endfunction
function RefreshPlayerCheckPoints takes nothing returns nothing
local integer nPlayerIndex
local integer nNum = 0
local integer nIndex
set nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
if ( GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
if ( udg_GameGoingStatus[nPlayerIndex] == udg_GAME_DRIVING ) then
//Save backup to check whether player is going wrong direction
set udg_PlaceChkPtLapBak[nPlayerIndex] = udg_PlaceChkPtLap[nPlayerIndex]
set udg_PlaceChkPtCurBak[nPlayerIndex] = udg_PlaceChkPtCur[nPlayerIndex]
set udg_PlaceChkPtHowFarBak[nPlayerIndex] = udg_PlaceChkPtHowFar[nPlayerIndex]
call RefreshPlayerCheckPoint( nPlayerIndex )
endif
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
set nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
if ( GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
if ( udg_GameGoingStatus[nPlayerIndex] == udg_GAME_DRIVING ) then
call CheckWrongDirection( nPlayerIndex )
endif
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
call SortPlace()
set nNum = udg_PlaceNum
if ( nNum > udg_PlaceNum ) then
set nNum = udg_PlaceNum
endif
set nIndex = 0
loop
exitwhen nIndex >= nNum
set nPlayerIndex = udg_Places[nIndex]
if ( udg_GameGoingStatus[nPlayerIndex] != udg_GAME_OVER and udg_GameGoingStatus[nPlayerIndex] != udg_GAME_FINISHING ) then
return
endif
set nIndex = nIndex + 1
endloop
call GameOver()
endfunction
//===========================================================================
function InitTrig_Place_Functions takes nothing returns nothing
endfunction
function StopCart takes integer nPlayerIndex returns nothing
set udg_Speed[nPlayerIndex] = 0
set udg_TurnSpeed[nPlayerIndex] = 0
if ( udg_CartPrePos[nPlayerIndex] != null ) then
call RemoveLocation( udg_CartPrePos[nPlayerIndex] )
endif
set udg_CartPrePos[nPlayerIndex] = GetUnitLoc( udg_Carts[nPlayerIndex] )
endfunction
function GetCartPowerUpAddress takes integer nPlayerIndex returns integer
return nPlayerIndex * 4
endfunction
function GetCartSlotPowerUp takes integer nPlayerIndex, integer nSlot returns integer
return udg_CartPowerUps[ GetCartPowerUpAddress(nPlayerIndex) + nSlot ]
endfunction
function IsCartSlotEmpty takes integer nPlayerIndex, integer nSlot returns boolean
return GetCartSlotPowerUp(nPlayerIndex, nSlot) == 0
endfunction
function SetCartSlotPowerUp takes integer nPlayerIndex, integer nSlot, integer nType returns nothing
set udg_CartPowerUps[ GetCartPowerUpAddress(nPlayerIndex) + nSlot ] = nType
endfunction
function AddCartSlotPowerUp takes integer nPlayerIndex, integer nSlot, integer nType returns nothing
if ( not IsCartSlotEmpty(nPlayerIndex, nSlot) ) then
return
endif
call SetCartSlotPowerUp(nPlayerIndex, nSlot, nType )
set udg_CartItemNum[nPlayerIndex] = udg_CartItemNum[nPlayerIndex] + 1
endfunction
function RemoveCartSlotPowerUp takes integer nPlayerIndex, integer nSlot returns nothing
if ( IsCartSlotEmpty(nPlayerIndex, nSlot) ) then
return
endif
call SetCartSlotPowerUp(nPlayerIndex, nSlot, 0 )
set udg_CartItemNum[nPlayerIndex] = udg_CartItemNum[nPlayerIndex] - 1
endfunction
function CheckItemPickFilter takes nothing returns boolean
local integer nType = 0
local integer nIndex = 0
if ( IsUnitDeadBJ(GetFilterUnit()) ) then
return false
endif
set nType = GetUnitTypeId( GetFilterUnit() )
loop
exitwhen nIndex >= udg_PowerUpUnitTypeNum
if ( nType == udg_PowerUpUnitTypes[nIndex] ) then
return true
endif
if ( nType == 'nshe' or nType == 'n00L' ) then
return true
endif
set nIndex = nIndex + 1
endloop
return false
endfunction
function PowerUpDice takes integer nDiceType returns integer
local integer nIndex = 0
local integer nIndex1 = 0
local integer nTotal = 0
local integer nDice = 0
set nIndex = 0
set nIndex1 = nDiceType - 1
set nTotal = 0
loop
exitwhen nIndex >= udg_PowerUpTypeNum
set nTotal = nTotal + udg_PowerUpPickChance[nIndex1]
set nIndex = nIndex + 1
set nIndex1 = nIndex1 + 3
endloop
set nDice = GetRandomInt( 1, nTotal )
set nIndex = 0
set nIndex1 = nDiceType - 1
set nTotal = 0
loop
exitwhen nIndex > udg_PowerUpTypeNum
set nTotal = nTotal + udg_PowerUpPickChance[nIndex1]
if ( udg_PowerUpPickChance[nIndex1] > 0 and nDice <= nTotal ) then
return nIndex
endif
set nIndex = nIndex + 1
set nIndex1 = nIndex1 + 3
endloop
return -1
endfunction
function PickItem takes integer nPlayerIndex, unit uItem returns boolean
local integer n = 0
local integer nIndex = 0
local effect effPicking = null
local location loc = null
local integer nPlace
local integer nDiceType = 0
if ( udg_CartItemNum[nPlayerIndex] >= 4 ) then
return false
endif
if ( udg_ItsForDebug ) then
set n = 10
else
set nPlace = GetPlayerPlace( nPlayerIndex )
if ( udg_PlaceNum <= 4 ) then
if ( nPlace == 0 ) then
set nDiceType = 1
elseif ( nPlace == udg_PlaceNum - 1 ) then
set nDiceType = 3
else
set nDiceType = 2
endif
else
if ( nPlace <= 1 ) then
set nDiceType = 1
elseif ( nPlace >= udg_PlaceNum - 2 ) then
set nDiceType = 3
else
set nDiceType = 2
endif
endif
set n = PowerUpDice( nDiceType )
if ( n < 0 ) then
return false
endif
endif
set nIndex = 0
loop
exitwhen nIndex >= 4
if ( IsCartSlotEmpty( nPlayerIndex, nIndex ) ) then
exitwhen true
endif
set nIndex = nIndex + 1
endloop
if ( nIndex >= 4 ) then
return false
endif
call AddCartSlotPowerUp( nPlayerIndex, nIndex, GetPowerUpType( n, nIndex ) )
call UnitAddAbility( udg_Carts[nPlayerIndex], GetPowerUpType( n, nIndex ) )
call ShowPowerUpMsgPlayer( Player(nPlayerIndex), "You picked up " + udg_PowerUpNames[n] + "." )
set loc = GetUnitLoc( uItem )
set effPicking = AddSpecialEffectLoc( "Objects\\Spawnmodels\\Other\\ToonBoom\\ToonBoom.mdl", loc)
call RemoveLocation( loc )
call DestroyEffect( effPicking )
set effPicking = AddSpecialEffectTarget( "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdl", udg_Carts[nPlayerIndex], "origin" )
call DestroyEffect( effPicking )
return true
endfunction
function CreateAssistant takes integer nPlayerIndex, real rLifeLength returns unit
local location loc = GetRectCenter( gg_rct_AssistantArea )
local unit uAssistant = CreateUnitAtLoc( Player(nPlayerIndex), 'n005', loc, 0 )
call SetUnitPathing( uAssistant, false )
call UnitApplyTimedLife( uAssistant, 'BTLF', rLifeLength )
call RemoveLocation( loc )
return uAssistant
endfunction
function CreateAssistant1 takes integer nPlayerIndex, real rLifeLength returns unit
local location loc = GetRectCenter( gg_rct_AssistantArea )
local unit uAssistant = CreateUnitAtLoc( Player(nPlayerIndex), 'n00I', loc, 0 )
call SetUnitPathing( uAssistant, false )
call UnitApplyTimedLife( uAssistant, 'BTLF', rLifeLength )
call RemoveLocation( loc )
return uAssistant
endfunction
function ItemPicked takes integer nPlayerIndex, unit uItem returns nothing
local integer nType = GetUnitTypeId( uItem )
local unit uAssistant = null
local boolean bInside = false
local boolean bPicked = false
local boolean bUsed = false
local location loc = null
local location locCart = null
local real rAngle = 0
local real rDistance = 0
local unit uDumy = null
local effect effSnowManDeath = null
set loc = GetUnitLoc( uItem )
set locCart = GetUnitLoc( udg_Carts[nPlayerIndex] )
set rDistance = DistanceBetweenPoints( loc, locCart )
set rAngle = RAbsBJ( StandardAngle( AngleBetweenPoints( locCart, loc ) - udg_Angle[nPlayerIndex] ) )
call RemoveLocation( loc )
call RemoveLocation( locCart )
call ShowDebugMsg( "Distance = " + R2SW(rDistance, 1, 1) )
call ShowDebugMsg( "Angle = " + R2SW(rAngle, 1, 1) )
call ShowDebugMsg( "DisH = " + R2SW(rDistance * SinBJ( rAngle ), 1, 1) )
call ShowDebugMsg( "DisV = " + R2SW(rDistance * CosBJ( rAngle ), 1, 1) )
if ( rDistance * SinBJ( rAngle ) >= 100 ) then
return
endif
if ( rAngle < 90 ) then
if ( rDistance * CosBJ( rAngle ) >= 175 ) then
return
endif
endif
if ( nType == 'n003' ) then //mushroom
if ( not UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'Buhf' ) ) then
set uAssistant = CreateAssistant( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "unholyfrenzy", udg_Carts[nPlayerIndex] )
set bUsed = true
endif
elseif ( nType == 'n002' ) then //poison smoke
if ( not UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'Bslo' ) and IsCartVulnerable(udg_Carts[nPlayerIndex]) ) then
set uAssistant = CreateAssistant( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "slow", udg_Carts[nPlayerIndex] )
set bUsed = true
endif
elseif ( nType == 'nshe' and udg_SheepFled ) then //Sheep
call KillUnit( uItem )
if ( IsCartVulnerable(udg_Carts[nPlayerIndex]) ) then
set uAssistant = CreateAssistant( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "slow", udg_Carts[nPlayerIndex] )
endif
elseif ( nType == 'n00L' ) then //Snowman
set loc = GetUnitLoc( uItem )
call KillUnit( uItem )
set effSnowManDeath = AddSpecialEffectLoc( "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", loc)
call RemoveLocation( loc )
call DestroyEffect( effSnowManDeath )
call StopCart( nPlayerIndex )
if ( IsCartVulnerable(udg_Carts[nPlayerIndex]) ) then
set uAssistant = CreateAssistant( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "slow", udg_Carts[nPlayerIndex] )
endif
elseif ( nType == 'n00C' ) then //random power up
set bPicked = PickItem( nPlayerIndex, uItem )
endif
//Used to create a respawn event
if ( bUsed or bPicked ) then
set loc = GetUnitLoc( uItem )
call RemoveUnit( uItem )
set uDumy = CreateUnitAtLoc( udg_NPC, 'n00K', loc, 0 )
call RemoveLocation( loc )
call SetUnitUserData( uDumy, nType )
call KillUnit( uDumy )
endif
endfunction
function CheckItemPick takes integer nPlayerIndex returns nothing
local location loc = null
local group g = null
local unit uItem = null
local real rSpeed
local real rRange
if ( nPlayerIndex < 0 ) then
return
endif
if ( udg_Carts[nPlayerIndex] == null or IsUnitDeadBJ( udg_Carts[nPlayerIndex] ) ) then
return
endif
set loc = GetUnitLoc( udg_Carts[nPlayerIndex] )
set rSpeed = RealSpeed( udg_Speed[nPlayerIndex] )
set rRange = SquareRoot( rSpeed * rSpeed + 90 * 90 )
set g = GetUnitsInRangeOfLocMatching( 200, loc, Condition(function CheckItemPickFilter) )
call RemoveLocation( loc )
loop
set uItem = FirstOfGroup( g )
exitwhen uItem == null
call ItemPicked( nPlayerIndex, uItem )
call GroupRemoveUnit( g, uItem )
endloop
call DestroyGroup( g )
endfunction
function SpinVehicle takes integer nPlayerIndex returns nothing
local unit uAssistant = null
set uAssistant = CreateAssistant1( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "bloodlust", udg_Carts[nPlayerIndex] )
endfunction
function DoLightningHit takes integer nPlayerIndex returns nothing
local location loc = null
local group grp = null
local unit uCart = null
local boolean bHit = false
if ( not IsCartLightened( udg_Carts[nPlayerIndex] ) or not IsCartVulnerable( udg_Carts[nPlayerIndex] ) ) then
return
endif
if ( IsCartTrapped( udg_Carts[nPlayerIndex] ) or IsCartSpinning( udg_Carts[nPlayerIndex] ) or IsCartStunned( udg_Carts[nPlayerIndex] ) ) then
return
endif
set loc = GetUnitLoc( udg_Carts[nPlayerIndex] )
set grp = GetUnitsInRangeOfLocAll( 200, loc )
call RemoveLocation( loc )
loop
set uCart = FirstOfGroup( grp )
exitwhen uCart == null
if ( IsItACart( GetUnitTypeId( uCart ) ) and IsUnitAliveBJ( uCart ) and IsPlayerEnemyCR( Player(nPlayerIndex), GetOwningPlayer( uCart ) ) ) then
if ( not IsCartLightened( uCart ) and not UnitHasBuffBJ( uCart, 'Btsp' ) and not IsCartSpinning( uCart ) ) then
set bHit = true
exitwhen true
endif
endif
call GroupRemoveUnit( grp, uCart )
endloop
call DestroyGroup( grp )
if ( bHit ) then
call SpinVehicle( nPlayerIndex )
endif
endfunction
function DoLightningResize takes integer nPlayerIndex returns nothing
local unit uCart = udg_Carts[nPlayerIndex]
local real rResize = 0
if ( not IsCartLightened( uCart ) ) then
call SetUnitScale( uCart, 1, 1, 1 )
if ( udg_LightningResize[nPlayerIndex] > 0 ) then
set udg_LightningResize[nPlayerIndex] = 0
endif
return
endif
if ( udg_LightningResize[nPlayerIndex] < udg_LIGHTNINGRESIZE_MAX ) then
set udg_LightningResize[nPlayerIndex] = udg_LightningResize[nPlayerIndex] + 1
endif
set rResize = ( 10. - udg_LightningResize[nPlayerIndex] ) / 10.
call SetUnitScale( uCart, rResize, rResize, rResize )
endfunction
function DoLightningSingle takes integer nAttackerIndex, integer nPlayerIndex returns nothing
local unit uAssistant = null
local unit uCart = udg_Carts[nPlayerIndex]
local location loc = GetUnitLoc( uCart )
local unit uLightning = CreateUnitAtLoc( Player(nAttackerIndex), 'n000', loc, 0 )
call RemoveLocation( loc )
call SetUnitPathing( uLightning, false )
call UnitApplyTimedLife( uLightning, 'BTLF', 2 )
call IssueTargetOrder( uLightning, "attack", uCart )
set uAssistant = CreateAssistant( nAttackerIndex, 2 )
call IssueTargetOrder( uAssistant, "purge", uCart )
call ShowHitMsg( Player(nPlayerIndex), nAttackerIndex, "Lightning" )
endfunction
function Lightning takes unit uCart returns nothing
local integer nPlayerIndexUse = GetPlayerIndex( GetOwningPlayer( uCart ) )
local integer nPlayerIndex = 0
if (nPlayerIndexUse < 0 ) then
return
endif
call StartSound( gg_snd_MonsoonLightningHit )
loop
exitwhen nPlayerIndex >= 8
if ( nPlayerIndex != nPlayerIndexUse and GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
if ( udg_Carts[nPlayerIndex] != null and IsUnitAliveBJ(udg_Carts[nPlayerIndex]) and IsCartVulnerable(udg_Carts[nPlayerIndex]) and IsCartVisible(udg_Carts[nPlayerIndex]) ) then
call DoLightningSingle( nPlayerIndexUse, nPlayerIndex )
endif
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
endfunction
function DoStarHit takes integer nPlayerIndex returns nothing
local location loc = null
local group grp = null
local unit uCart = null
local integer nIndexHit
if ( not UnitHasBuffBJ( udg_Carts[nPlayerIndex], 'B005' ) ) then
return
endif
set loc = GetUnitLoc( udg_Carts[nPlayerIndex] )
set grp = GetUnitsInRangeOfLocAll( 200, loc )
call RemoveLocation( loc )
loop
set uCart = FirstOfGroup( grp )
exitwhen uCart == null
if ( IsItACart( GetUnitTypeId( uCart ) ) and IsUnitAliveBJ( uCart ) and IsPlayerEnemyCR( Player(nPlayerIndex), GetOwningPlayer( uCart ) ) ) then
if ( IsCartVulnerable( uCart ) ) then
set nIndexHit = GetPlayerIndex( GetOwningPlayer( uCart ) )
call ShowHitMsg( Player(nIndexHit), nPlayerIndex, "Cart" )
call SpinVehicle( nIndexHit )
endif
endif
call GroupRemoveUnit( grp, uCart )
endloop
call DestroyGroup( grp )
endfunction
function UseStar takes unit uCart returns nothing
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
local unit uAssistant = null
local integer nUseIndex = 0
if (nPlayerIndex < 0 ) then
return
endif
set udg_UseInvulnerableIndex[nPlayerIndex] = udg_UseInvulnerableIndex[nPlayerIndex] + 1
set nUseIndex = udg_UseInvulnerableIndex[nPlayerIndex]
set uAssistant = CreateAssistant1( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "innerfire", uCart )
call SetCartInvulnerable( uCart, true )
call PolledWait( 6. )
if ( nUseIndex == udg_UseInvulnerableIndex[nPlayerIndex] ) then
call SetCartInvulnerable( uCart, false )
endif
endfunction
function EatMushroom takes unit uCart returns nothing
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
local unit uAssistant = null
if (nPlayerIndex < 0 ) then
return
endif
set uAssistant = CreateAssistant( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "unholyfrenzy", uCart )
endfunction
function IHateTheLeadingCart takes unit uCart returns nothing
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
local integer nIndex = 0
local unit uLauncher = null
local unit uDummyTarget = null
local real rAngle = 0
local location locSrc = null
local location locTarget = null
local location locTemp = null
if (nPlayerIndex < 0 ) then
return
endif
set nIndex = GetLeadingCart()
if ( nIndex >= 0 ) then
if ( udg_Carts[nIndex] == null or IsUnitDeadBJ(udg_Carts[nIndex] ) ) then
set nIndex = -1
elseif ( not IsCartVulnerable(udg_Carts[nIndex]) or udg_GameGoingStatus[nIndex] != udg_GAME_DRIVING ) then
set nIndex = -1
endif
endif
if ( nIndex >= 0 ) then
call ShowWarningMsg( Player(nIndex), udg_PlayerColor[nPlayerIndex] + GetPlayerName(Player(nPlayerIndex)) + "|r is launching missile at you!" )
endif
set locSrc = GetUnitLoc( uCart )
if ( nIndex < 0 ) then
set locTarget = Location( 0, 0 )
else
set locTarget = GetUnitLoc( udg_Carts[nIndex] )
endif
set rAngle = AngleBetweenPoints( locSrc, locTarget )
call RemoveLocation( locTarget )
set locTemp = PolarProjectionBJ( locSrc, 600, rAngle )
set uLauncher = CreateUnitAtLoc( Player(nPlayerIndex), 'n007', locSrc, 0 )
call RemoveLocation( locSrc )
call SetUnitPathing( uLauncher, false )
call SetUnitVertexColor( uLauncher, 0, 0, 0, 0 )
set uDummyTarget = CreateUnitAtLoc( Player(nPlayerIndex), 'n006', locTemp, 0 )
call RemoveLocation( locTemp )
call SetUnitPathing( uDummyTarget, false )
call SetUnitVertexColor( uDummyTarget, 0, 0, 0, 0 )
call IssueTargetOrder( uLauncher, "attack", uDummyTarget )
call UnitApplyTimedLife( uLauncher, 'BTLF', 2 )
call UnitApplyTimedLife( uDummyTarget, 'BTLF', 2 )
if ( nIndex < 0 ) then
return
endif
call StartSound( gg_snd_PError )
call PolledWait( 4.5 )
call StopSound( gg_snd_PError, false, true )
if ( udg_GameGoingStatus[nIndex] != udg_GAME_DRIVING or udg_Carts[nIndex] == null or IsUnitDeadBJ(udg_Carts[nIndex]) or not IsCartVulnerable( udg_Carts[nIndex] ) or not IsCartVisible( udg_Carts[nIndex] ) ) then
return
endif
set locTarget = GetUnitLoc( udg_Carts[nIndex] )
set locTemp = PolarProjectionBJ( locTarget, 300, rAngle + 180 )
call RemoveLocation( locTarget )
set uLauncher = CreateUnitAtLoc( Player(nPlayerIndex), 'n004', locTemp, 0 )
call RemoveLocation( locTemp )
call SetUnitPathing( uLauncher, false )
call SetUnitVertexColor( uLauncher, 0, 0, 0, 0 )
call IssueTargetOrder( uLauncher, "thunderbolt", udg_Carts[nIndex] )
call UnitApplyTimedLife( uLauncher, 'BTLF', 2 )
call PolledWait( 0.2 )
if ( udg_GameGoingStatus[nIndex] != udg_GAME_DRIVING or udg_Carts[nIndex] == null or IsUnitDeadBJ(udg_Carts[nIndex]) or not IsCartVulnerable( udg_Carts[nIndex] ) or not IsCartVisible( udg_Carts[nIndex] ) ) then
return
endif
set locTarget = GetUnitLoc( udg_Carts[nIndex] )
call PlaySoundAtPointBJ( gg_snd_BuildingDeathLargeHuman, 100, locTarget, 0 )
call RemoveLocation( locTarget )
call ShowHitMsg( Player(nIndex), nPlayerIndex, "Rocket" )
endfunction
function LayMine takes unit uCart returns nothing
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
local location loc = null
local location loc1 = null
local unit uMine = null
local unit uFake = null
local integer nIndex
if (nPlayerIndex < 0 ) then
return
endif
set loc = GetUnitLoc( uCart )
set loc1 = PolarProjectionBJ( loc, 100, udg_Angle[nPlayerIndex] + 180 )
call RemoveLocation( loc )
set uMine = CreateUnitAtLoc( Player(nPlayerIndex), 'n00G', loc1, 0 )
set uFake = CreateUnitAtLoc( Player(nPlayerIndex), 'n001', loc1, 0 )
call RemoveLocation( loc1 )
set nIndex = 0
loop
exitwhen udg_FakePackage[nIndex] == null
set nIndex = nIndex + 1
endloop
set udg_FakePackage[nIndex] = uFake
call SetUnitUserData( uMine, nIndex )
call SetUnitAnimation( uFake, "birth" )
endfunction
function MineExplorded takes unit uMine returns nothing
local location loc = null
local group grp = null
local unit uCart = null
local player plPlayer = GetOwningPlayer( uMine )
local integer nPlayerIndex = GetPlayerIndex( plPlayer )
local integer nPlayerHit
local integer nFake = -1
if ( nPlayerIndex < 0 ) then
return
endif
set nFake = GetUnitUserData( uMine )
if ( udg_FakePackage[nFake] != null ) then
call KillUnit( udg_FakePackage[nFake] )
set udg_FakePackage[nFake] = null
endif
set loc = GetUnitLoc( uMine )
set grp = GetUnitsInRangeOfLocAll( 300, loc )
call RemoveLocation( loc )
loop
set uCart = FirstOfGroup( grp )
exitwhen uCart == null
if ( IsItACart( GetUnitTypeId( uCart ) ) and IsUnitAliveBJ( uCart ) and IsPlayerEnemyCR(plPlayer, GetOwningPlayer( uCart ) ) ) then
set nPlayerHit = GetPlayerIndex( GetOwningPlayer( uCart ) )
call ShowHitMsg( Player(nPlayerHit), nPlayerIndex, "Mine" )
call SpinVehicle( nPlayerHit )
endif
call GroupRemoveUnit( grp, uCart )
endloop
call DestroyGroup( grp )
endfunction
function DoBlaze takes integer nPlayerIndex returns nothing
local unit uBlaze = null
local location loc = null
local location loc1 = null
local location loc2 = null
local real rAngle = 0
if ( udg_Carts[nPlayerIndex] == null or IsUnitDeadBJ(udg_Carts[nPlayerIndex]) ) then
return
endif
set rAngle = udg_Angle[nPlayerIndex]
if ( udg_Speed[nPlayerIndex] >= 0 ) then
set rAngle = rAngle + 180
endif
set loc = GetUnitLoc( udg_Carts[nPlayerIndex] )
set loc1 = PolarProjectionBJ( loc, 100, rAngle )
call RemoveLocation( loc )
set uBlaze = CreateUnitAtLoc( Player(nPlayerIndex), 'n009', loc1, 0 )
call SetUnitPathing( uBlaze, false )
call UnitApplyTimedLife( uBlaze, 'BTLF', 4 )
set loc2 = PolarProjectionBJ( loc1, 50, rAngle )
call RemoveLocation( loc1 )
set uBlaze = CreateUnitAtLoc( Player(nPlayerIndex), 'n009', loc2, 0 )
call RemoveLocation( loc2 )
call SetUnitPathing( uBlaze, false )
call UnitApplyTimedLife( uBlaze, 'BTLF', 4 )
endfunction
function UseBlaze takes unit uCart returns nothing
local integer nBlazeFlag = 0
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
if (nPlayerIndex < 0 ) then
return
endif
set udg_PlayerBlazeFlag[nPlayerIndex] = udg_PlayerBlazeFlag[nPlayerIndex] + 1
set nBlazeFlag = udg_PlayerBlazeFlag[nPlayerIndex]
call PolledWait( 4 )
if ( udg_PlayerBlazeFlag[nPlayerIndex] == nBlazeFlag ) then
set udg_PlayerBlazeFlag[nPlayerIndex] = 0
endif
endfunction
function DoFireCoatSlow takes integer nPlayerIndex returns nothing
local location loc = null
local group grp = null
local unit uCart = null
local unit uAssistant = null
if ( not UnitHasBuffBJ( udg_Carts[nPlayerIndex], 'B001' ) ) then
return
endif
set loc = GetUnitLoc( udg_Carts[nPlayerIndex] )
set grp = GetUnitsInRangeOfLocAll( 300, loc )
call RemoveLocation( loc )
loop
set uCart = FirstOfGroup( grp )
exitwhen uCart == null
if ( IsItACart( GetUnitTypeId( uCart ) ) and IsUnitAliveBJ( uCart ) and IsPlayerEnemy( Player(nPlayerIndex), GetOwningPlayer( uCart ) ) ) then
if ( IsCartVulnerable( uCart) and not UnitHasBuffBJ( uCart, 'B002' ) ) then
set uAssistant = CreateAssistant1( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "faeriefire", uCart )
endif
endif
call GroupRemoveUnit( grp, uCart )
endloop
call DestroyGroup( grp )
endfunction
function Trig_Trap_Actions takes nothing returns nothing
local integer nLoopIndex = 0
local trigger trgTrap = GetTriggeringTrigger()
local unit uCart = GetTriggerUnit()
set nLoopIndex = 0
loop
exitwhen nLoopIndex >= udg_TrapMax
exitwhen udg_TrapTriggers[nLoopIndex] == trgTrap
set nLoopIndex = nLoopIndex + 1
endloop
if ( nLoopIndex >= udg_TrapMax ) then
return
endif
if ( udg_Traps[nLoopIndex] == null or IsUnitDeadBJ( udg_Traps[nLoopIndex] ) ) then
return
endif
if ( not IsItACart( GetUnitTypeId(uCart) ) or IsUnitDeadBJ( uCart ) ) then
return
endif
if ( not IsPlayerEnemyCR( GetOwningPlayer(udg_Traps[nLoopIndex]), GetOwningPlayer( uCart ) ) ) then
return
endif
call DestroyTrigger( trgTrap )
set udg_TrapTriggers[nLoopIndex] = null
call UnitAddAbility( udg_Traps[nLoopIndex], 'Aloc' )
call UnitAddAbility( udg_Traps[nLoopIndex], 'A000' )
call IssueTargetOrder( udg_Traps[nLoopIndex], "cripple", uCart )
call UnitApplyTimedLife( udg_Traps[nLoopIndex], 'BTLF', 2 )
call ShowHitMsg( GetOwningPlayer(uCart), GetPlayerIndex(GetOwningPlayer(udg_Traps[nLoopIndex])), "Trap" )
endfunction
function SetupTrap takes unit uCart returns nothing
local trigger trgTrap = null
local unit uTrap = null
local integer nLoopIndex = 0
local location loc = null
local location loc1 = null
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
if (nPlayerIndex < 0 ) then
return
endif
set loc = GetUnitLoc( uCart )
set loc1 = PolarProjectionBJ( loc, 100, udg_Angle[nPlayerIndex] + 180 )
call RemoveLocation( loc )
set uTrap = CreateUnitAtLoc( Player(nPlayerIndex), 'n00A', loc1, 0 )
call UnitApplyTimedLife( uTrap, 'BTLF', 120 )
call RemoveLocation( loc1 )
set trgTrap = CreateTrigger()
set nLoopIndex = 0
loop
exitwhen nLoopIndex >= udg_TrapMax
exitwhen udg_Traps[nLoopIndex] == null
set nLoopIndex = nLoopIndex + 1
endloop
set udg_Traps[nLoopIndex] = uTrap
set udg_TrapTriggers[nLoopIndex] = trgTrap
if ( nLoopIndex == udg_TrapMax ) then
set udg_TrapMax = udg_TrapMax + 1
endif
call TriggerRegisterUnitInRangeSimple( trgTrap, 80.00, uTrap )
call TriggerAddAction( trgTrap, function Trig_Trap_Actions )
endfunction
function TrapExpired takes unit uWeb returns nothing
local integer nLoopIndex = 0
set nLoopIndex = 0
loop
exitwhen nLoopIndex >= udg_TrapMax
if ( udg_Traps[nLoopIndex] == uWeb ) then
if ( udg_TrapTriggers[nLoopIndex] != null ) then
call DestroyTrigger( udg_TrapTriggers[nLoopIndex] )
set udg_TrapTriggers[nLoopIndex] = null
endif
set udg_Traps[nLoopIndex] = null
return
endif
set nLoopIndex = nLoopIndex + 1
endloop
endfunction
function ThrowTurtle takes unit uCart returns nothing
local location loc = null
local location locNext = null
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
if (nPlayerIndex < 0 ) then
return
endif
if ( udg_TurtleThrown[nPlayerIndex] != null ) then
call PauseTimer( udg_ThrowTurtleTimer[nPlayerIndex] )
call RemoveUnit( udg_TurtleThrown[nPlayerIndex] )
set udg_TurtleThrown[nPlayerIndex] = null
endif
set udg_ThrowTurtleAngle[nPlayerIndex] = StandardAngle( GetUnitFacing(uCart) )
set loc = GetUnitLoc( uCart )
set locNext = PolarProjectionBJ( loc, 200, udg_ThrowTurtleAngle[nPlayerIndex] )
call RemoveLocation( loc )
set udg_TurtleThrown[nPlayerIndex] = CreateUnitAtLoc( Player(nPlayerIndex), 'n00J', locNext, udg_ThrowTurtleAngle[nPlayerIndex] )
call RemoveLocation( locNext)
call SetUnitPathing( udg_TurtleThrown[nPlayerIndex], false )
call UnitApplyTimedLife( udg_TurtleThrown[nPlayerIndex], 'BTLF', 2 )
call SetUnitAnimationByIndex( udg_TurtleThrown[nPlayerIndex], 8 )
call SetUnitTimeScale( udg_TurtleThrown[nPlayerIndex], 2 )
set udg_TurtleThrowTickle[nPlayerIndex] = 0
call TimerStart( udg_ThrowTurtleTimer[nPlayerIndex], 0.05, true, null )
endfunction
function TurtleBump takes integer nPlayerIndex, unit uCart returns nothing
local integer nPlayerIndexCart = 0
local location locTurtle = null
local location locCart = null
local location loc = null
local real rAngle = 0
local real rDistance = 0
local real rTemp = 0
local real rHP = 0
local effect effBite = null
if ( not IsCartVulnerable( uCart ) or not IsCartVisible( uCart ) ) then
return
endif
//If the vehicle is already spinning
if ( IsCartSpinning( uCart ) ) then
return
endif
set locTurtle = GetUnitLoc( udg_TurtleThrown[nPlayerIndex] )
set locCart = GetUnitLoc( uCart )
set rAngle = AngleBetweenPoints( locTurtle, locCart )
set rDistance = DistanceBetweenPoints( locTurtle, locCart )
call RemoveLocation( locTurtle )
call ShowDebugMsg( "Throw Angle = " + R2S(udg_ThrowTurtleAngle[nPlayerIndex]) )
call ShowDebugMsg( "Relat Angle = " + R2S(rAngle) )
set rTemp = StandardAngle( rAngle - udg_ThrowTurtleAngle[nPlayerIndex] )
if ( rTemp > 90 or rTemp < -90 ) then
call RemoveLocation( locCart )
return
endif
set rDistance = RAbsBJ( rDistance * SinBJ(rTemp) )
if ( rDistance > 100 ) then
call RemoveLocation( locCart )
return
endif
call KillUnit( udg_TurtleThrown[nPlayerIndex] )
set rHP = GetUnitState( uCart, UNIT_STATE_LIFE )
if ( rHP <= 150 ) then
call KillUnit( uCart )
call RemoveLocation( locCart )
return
endif
set rHP = rHP - 150
call SetUnitState( uCart, UNIT_STATE_LIFE, rHP )
set effBite = AddSpecialEffectTarget( "Environment\\LargeBuildingFire\\LargeBuildingFire1.mdl", uCart, "chest" )
call DestroyEffect( effBite )
//if ( rTemp < 0 ) then
// set rAngle = udg_ThrowTurtleAngle[nPlayerIndex] - 60
//elseif ( rTemp > 0 ) then
// set rAngle = udg_ThrowTurtleAngle[nPlayerIndex] + 60
//endif
set nPlayerIndexCart = GetPlayerIndex( GetOwningPlayer( uCart ) )
//set udg_Angle[nPlayerIndexCart] = rAngle
//set loc = PolarProjectionBJ( locCart, 50, rAngle)
//call RemoveLocation( locCart )
//call SetUnitFacing( uCart, udg_Angle[nPlayerIndexCart] )
//call SetUnitPositionLoc( uCart, loc )
//call RemoveLocation( loc )
call RemoveLocation( locCart )
call ShowHitMsg( Player(nPlayerIndexCart), nPlayerIndex, "Sheepedo" )
call SpinVehicle( nPlayerIndexCart )
endfunction
function LocateTurtleTarget takes location loc, real rAngle, integer nPlayerIndex returns integer
local integer nIndex = 0
local integer nIndexPick = -1
local location loc1 = null
local real rAngle1
local boolean bContinue
local real rDisMin = 0
local real rDis
loop
exitwhen nIndex >= udg_PLAYER_MAXNUM
set bContinue = nIndex != nPlayerIndex and udg_Carts[nIndex] != null
if ( bContinue ) then
if ( IsUnitDeadBJ( udg_Carts[nIndex] ) or not IsCartVulnerable( udg_Carts[nIndex] ) ) then
set bContinue = false
endif
endif
call ShowDebugMsg( "Locate Target 1" )
if ( bContinue ) then
set loc1 = GetUnitLoc( udg_Carts[nIndex] )
set rAngle1 = StandardAngle( AngleBetweenPoints( loc, loc1 ) - rAngle )
call ShowDebugMsg( "Angle = " + R2S(rAngle1) )
if ( rAngle1 > 90 or rAngle1 < -90 ) then
set bContinue = false
endif
endif
call ShowDebugMsg( "Locate Target 2" )
if ( bContinue ) then
set rDis = DistanceBetweenPoints( loc, loc1 )
if ( rDis > 6000 or rDis <= 0 ) then
set bContinue = false
endif
call ShowDebugMsg( "Locate Target 3" )
if ( bContinue ) then
if ( nIndexPick >= 0 ) then
if ( rDis >= rDisMin ) then
set bContinue = false
endif
endif
endif
call ShowDebugMsg( "Locate Target 4" )
if ( bContinue ) then
set nIndexPick = nIndex
set rDisMin = rDis
endif
endif
if ( loc1 != null ) then
call RemoveLocation( loc1 )
endif
set nIndex = nIndex + 1
endloop
return nIndexPick
endfunction
function ThrowTurtleGoGoGo takes integer nPlayerIndex returns nothing
local location loc = null
local location locNext = null
local group grp = null
local unit uCart = null
local integer nTarget
local real rAngle
local real rChange = 4.8
local real rTemp
if ( udg_TurtleThrown[nPlayerIndex] == null or IsUnitDeadBJ( udg_TurtleThrown[nPlayerIndex] ) ) then
call PauseTimer( udg_ThrowTurtleTimer[nPlayerIndex] )
set udg_TurtleThrown[nPlayerIndex] = null
return
endif
set loc = GetUnitLoc( udg_TurtleThrown[nPlayerIndex] )
set nTarget = LocateTurtleTarget( loc, udg_ThrowTurtleAngle[nPlayerIndex], nPlayerIndex )
call ShowDebugMsg( "Target = " + I2S(nTarget) )
if ( udg_TurtleThrowTickle[nPlayerIndex] < 6 ) then
set rChange = udg_TurtleThrowTickle[nPlayerIndex] * 0.8
endif
if ( nTarget >= 0 ) then
set locNext = GetUnitLoc( udg_Carts[nTarget] )
set rAngle = StandardAngle( AngleBetweenPoints( loc, locNext ) )
set rTemp = StandardAngle( rAngle - udg_ThrowTurtleAngle[nPlayerIndex] )
if ( rTemp < 0 ) then
if ( rTemp > -3 ) then
set udg_ThrowTurtleAngle[nPlayerIndex] = rAngle
else
set udg_ThrowTurtleAngle[nPlayerIndex] = StandardAngle( udg_ThrowTurtleAngle[nPlayerIndex] - rChange )
endif
elseif ( rTemp > 0 ) then
if ( rTemp < 3 ) then
set udg_ThrowTurtleAngle[nPlayerIndex] = rAngle
else
set udg_ThrowTurtleAngle[nPlayerIndex] = StandardAngle( udg_ThrowTurtleAngle[nPlayerIndex] + rChange )
endif
endif
call RemoveLocation( locNext )
endif
set locNext = PolarProjectionBJ( loc, 150, udg_ThrowTurtleAngle[nPlayerIndex] )
call RemoveLocation( loc )
call SetUnitPositionLoc( udg_TurtleThrown[nPlayerIndex], locNext )
set grp = GetUnitsInRangeOfLocAll( 200, locNext )
call RemoveLocation( locNext )
loop
set uCart = FirstOfGroup( grp )
exitwhen uCart == null
if ( IsItACart( GetUnitTypeId( uCart ) ) and IsUnitAliveBJ( uCart ) and IsPlayerEnemyCR( Player(nPlayerIndex), GetOwningPlayer( uCart ) ) ) then
call TurtleBump( nPlayerIndex, uCart )
endif
call GroupRemoveUnit( grp, uCart )
endloop
call DestroyGroup( grp )
set udg_TurtleThrowTickle[nPlayerIndex] = udg_TurtleThrowTickle[nPlayerIndex] + 1
endfunction
function SummonGhost takes unit uCart returns nothing
local unit uAssistant = null
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
if (nPlayerIndex < 0 ) then
return
endif
set uAssistant = CreateAssistant1( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "invisibility", uCart )
endfunction
function UseRepairKit takes unit uCart returns nothing
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
local real rHP = GetUnitState( uCart, UNIT_STATE_LIFE )
local real rHPMax = GetUnitState( uCart, UNIT_STATE_MAX_LIFE )
local effect effHeal = null
if (nPlayerIndex < 0 ) then
return
endif
set udg_GunAmmo[nPlayerIndex] = udg_GunAmmo[nPlayerIndex] + 25
if ( udg_GunAmmo[nPlayerIndex] > udg_AMMO_MAX ) then
set udg_GunAmmo[nPlayerIndex] = udg_AMMO_MAX
endif
set rHP = rHP + 150
if ( rHP > rHPMax ) then
set rHP = rHPMax
endif
call SetUnitState( uCart, UNIT_STATE_LIFE, rHP )
set effHeal = AddSpecialEffectTarget( "Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl", uCart, "origin" )
call PolledWait( 0.1 )
call DestroyEffect( effHeal )
endfunction
function BlizzardCartFilter takes nothing returns boolean
local unit u = GetFilterUnit()
return IsItACart( GetUnitTypeId(u) ) and IsUnitAliveBJ( u ) and IsCartVulnerable( u )
endfunction
function DoBlizzard takes integer nPlayerIndex returns nothing
local real rRadius
local real rAngle
local location locCart
local location locCenter
local location loc
local effect eff
local group g
local unit uCart
local integer nPlayerIndexTarget
local real rHP
if ( udg_BlizzardingFlag[nPlayerIndex] < 0 ) then
return
endif
if ( udg_Carts[nPlayerIndex] == null or IsUnitDeadBJ( udg_Carts[nPlayerIndex] ) or udg_GameGoingStatus[nPlayerIndex] != udg_GAME_DRIVING ) then
set udg_BlizzardingFlag[nPlayerIndex] = -1
if ( udg_BlizzardSoundIsPlaying[nPlayerIndex] ) then
set udg_BlizzardSoundIsPlaying[nPlayerIndex] = false
call StopSound( udg_BlizzardSound[nPlayerIndex], false, true )
endif
return
endif
if ( not udg_BlizzardSoundIsPlaying[nPlayerIndex] ) then
set udg_BlizzardSoundIsPlaying[nPlayerIndex] = true
call PlaySoundOnUnitBJ( udg_BlizzardSound[nPlayerIndex], 100, udg_Carts[nPlayerIndex] )
endif
set locCart = GetUnitLoc( udg_Carts[nPlayerIndex] )
set rRadius = udg_Speed[nPlayerIndex] * 5
set rAngle = GetUnitFacing( udg_Carts[nPlayerIndex] )
if ( rRadius < 0 ) then
set rRadius = -rRadius
set rAngle = rAngle + 180
endif
set locCenter = PolarProjectionBJ( locCart, rRadius, rAngle )
call RemoveLocation( locCart )
set rRadius = GetRandomReal( 50., 500. )
set rAngle = GetRandomReal( 0., 359. )
set loc = PolarProjectionBJ( locCenter, rRadius, rAngle )
set eff = AddSpecialEffectLoc( "Abilities\\Spells\\Human\\Blizzard\\BlizzardTarget.mdl", loc )
call DestroyEffect( eff )
set g = GetUnitsInRangeOfLocMatching( 500, locCenter, Condition(function BlizzardCartFilter) )
call RemoveLocation( loc )
loop
set uCart = FirstOfGroup( g )
exitwhen uCart == null
set nPlayerIndexTarget = GetPlayerIndex( GetOwningPlayer(uCart) )
if ( nPlayerIndexTarget != nPlayerIndex ) then
set rHP = GetUnitState( udg_Carts[nPlayerIndexTarget], UNIT_STATE_LIFE )
if ( rHP <= 2 ) then
call KillUnit( udg_Carts[nPlayerIndexTarget] )
else
call SetUnitState( udg_Carts[nPlayerIndexTarget], UNIT_STATE_LIFE, rHP - 2 )
endif
endif
call GroupRemoveUnit( g, uCart )
endloop
call DestroyGroup( g )
call RemoveLocation( locCenter )
endfunction
function Blizzard takes unit uCart returns nothing
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
local integer nBlizzardingFlag
if (nPlayerIndex < 0 ) then
return
endif
set udg_BlizzardingFlag[nPlayerIndex] = udg_BlizzardingFlag[nPlayerIndex] + 1
set nBlizzardingFlag = udg_BlizzardingFlag[nPlayerIndex]
call PolledWait( 8 )
if ( nBlizzardingFlag == udg_BlizzardingFlag[nPlayerIndex] ) then
set udg_BlizzardingFlag[nPlayerIndex] = -1
if ( udg_BlizzardSoundIsPlaying[nPlayerIndex] ) then
set udg_BlizzardSoundIsPlaying[nPlayerIndex] = false
call StopSound( udg_BlizzardSound[nPlayerIndex], false, true )
endif
endif
endfunction
function CarrionSwarm takes unit uCart returns nothing
local integer nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
local location loc = null
local location locSource = null
local location locTarget = null
local unit uCaster = null
local real rAngle = 0
local real rSpeed
if (nPlayerIndex < 0 ) then
return
endif
set loc = GetUnitLoc( uCart )
set rAngle = GetUnitFacing( uCart )
set locSource = PolarProjectionBJ( loc, 20, rAngle + 180 )
call RemoveLocation( loc )
set uCaster = CreateUnit( Player(nPlayerIndex), 'n00O', GetLocationX(locSource), GetLocationY(locSource), rAngle )
call SetUnitPathing( uCaster, false )
set locTarget = PolarProjectionBJ( locSource, 50, rAngle )
call RemoveLocation( locSource )
call IssuePointOrder( uCaster, "carrionswarm", GetLocationX(locTarget), GetLocationY(locTarget) )
call RemoveLocation( locTarget )
call PolledWait(3)
call RemoveUnit( uCaster )
endfunction
function UnitCatchGunFire takes location locGun, real rAngleGun, location locTarget, location locVH returns boolean
local boolean bContinue = false
local real rAngle = AngleBetweenPoints( locGun, locTarget )
local real rAngleDif = RAbsBJ( StandardAngle( rAngle - rAngleGun ) )
local real rDis
local real rDisH
local real rDisV
if ( rAngleDif > -90 and rAngleDif < 90 ) then
set rDis = DistanceBetweenPoints( locGun, locTarget )
set rDisH = rDis * Sin(rAngleDif * bj_DEGTORAD)
if ( rDisH < 100 ) then
set rDisV = rDis * Cos(rAngleDif * bj_DEGTORAD)
if ( rDisV <= 1500 ) then
set bContinue = true
endif
endif
endif
if ( bContinue ) then
set bContinue = false
if ( GetLocationY( locVH ) < 0 or rDisV < GetLocationY( locVH ) ) then //First one
set bContinue = true
elseif ( rDisV == GetLocationY( locVH ) and ( GetLocationX( locVH ) < 0 or rDisH < GetLocationX( locVH ) ) ) then
set bContinue = true
endif
endif
if ( bContinue ) then
call MoveLocation( locVH, rDisH, rDisV )
endif
return bContinue
endfunction
function CheckSheepFilter takes nothing returns boolean
return ( GetUnitTypeId( GetFilterUnit() ) == 'nshe' or GetUnitTypeId( GetFilterUnit() ) == 'n00H' ) and IsUnitAliveBJ( GetFilterUnit() )
endfunction
function CheckWagonFilter takes nothing returns boolean
return ( GetUnitTypeId( GetFilterUnit() ) == 'h00K' or GetUnitTypeId( GetFilterUnit() ) == 'h003' or GetUnitTypeId( GetFilterUnit() ) == 'h005' or GetUnitTypeId( GetFilterUnit() ) == 'h006' ) and IsUnitAliveBJ( GetFilterUnit() )
endfunction
function BigGun takes unit uCart returns nothing
local integer nPlayerIndex = 0
local integer nPlayerSelf = -1
local integer nPlayerTarget = -1
local real rAngle = 0
local boolean bContinue = false
local location loc = null
local location loc1 = null
local location locVH = Location( -1, -1 )
local group g = null
local unit uSheep
local unit uSheepTarget
local unit uWagon
local effect effShoot = null
local real rHP = 0
local integer nLoopIndex = 0
set nPlayerSelf = GetPlayerIndex( GetOwningPlayer(uCart) )
if ( nPlayerSelf < 0 ) then
return
endif
if ( udg_GunAmmo[nPlayerSelf] <= 0 ) then
if ( not udg_AmmoWarning[nPlayerSelf] ) then
set udg_AmmoWarning[nPlayerSelf] = true
call ShowWarningMsg( Player(nPlayerSelf), "Out of Ammo!!! Reload ammo at pit stop." )
call PolledWait( 5 )
set udg_AmmoWarning[nPlayerSelf] = false
endif
return
endif
set udg_GunAmmo[nPlayerSelf] = udg_GunAmmo[nPlayerSelf] - 1
set udg_GunAttackTick[nPlayerSelf] = 0
set loc = GetUnitLoc( uCart )
set rAngle = GetUnitFacing( uCart )
set nLoopIndex = 0
call StopSound( udg_BigGunSound[nPlayerSelf], false, false )
call PlaySoundOnUnitBJ( udg_BigGunSound[nPlayerSelf], 100, uCart )
// loop
// exitwhen nLoopIndex >= 4
// set loc1 = PolarProjectionBJ( loc, 350 + RealSpeed(udg_Speed[nPlayerSelf]) * 5 + nLoopIndex * 50, rAngle )
// set effShoot = AddSpecialEffectLoc( "Abilities\\Weapons\\GyroCopter\\GyroCopterImpact.mdl", loc1 )
// call RemoveLocation( loc1 )
// call DestroyEffect( effShoot )
// set nLoopIndex = nLoopIndex + 1
// endloop
//Killing Sheep
set g = GetUnitsInRangeOfLocMatching( 1500, loc, Condition(function CheckSheepFilter) )
loop
set uSheep = FirstOfGroup( g )
exitwhen uSheep == null
set loc1 = GetUnitLoc( uSheep )
if ( UnitCatchGunFire( loc, rAngle, loc1, locVH ) ) then
call KillUnit( uSheep )
endif
call RemoveLocation( loc1 )
call GroupRemoveUnit( g, uSheep )
endloop
call DestroyGroup( g )
//Killing Wagon
set g = GetUnitsInRangeOfLocMatching( 1520, loc, Condition(function CheckWagonFilter) )
loop
set uWagon = FirstOfGroup( g )
exitwhen uWagon == null
set loc1 = GetUnitLoc( uWagon )
if ( UnitCatchGunFire( loc, rAngle, loc1, locVH ) ) then
set rHP = GetUnitState( uWagon, UNIT_STATE_LIFE )
if ( rHP <= 25 ) then
call KillUnit( uWagon )
else
call SetUnitState( uWagon, UNIT_STATE_LIFE, rHP - 25 )
set effShoot = AddSpecialEffectTarget( "Abilities\\Weapons\\GyroCopter\\GyroCopterImpact.mdl", uWagon, "chest" )
call DestroyEffect( effShoot )
set effShoot = AddSpecialEffectTarget( "Environment\\LargeBuildingFire\\LargeBuildingFire1.mdl", uWagon, "chest" )
call DestroyEffect( effShoot )
endif
endif
call RemoveLocation( loc1 )
call GroupRemoveUnit( g, uWagon )
endloop
call DestroyGroup( g )
call MoveLocation( locVH, -1, -1 )
loop
exitwhen nPlayerIndex >= 8
set bContinue = false
if ( nPlayerIndex != nPlayerSelf and udg_Carts[nPlayerIndex] != null and IsUnitAliveBJ( udg_Carts[nPlayerIndex] ) ) then
set bContinue = true
endif
if ( bContinue and IsCartVulnerable( udg_Carts[nPlayerIndex] ) ) then
set bContinue = false
set loc1 = GetUnitLoc( udg_Carts[nPlayerIndex] )
set bContinue = UnitCatchGunFire( loc, rAngle, loc1, locVH )
call RemoveLocation( loc1 )
if ( bContinue ) then
set nPlayerTarget = nPlayerIndex
endif
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
if ( nPlayerTarget >= 0 ) then
set rHP = GetUnitState( udg_Carts[nPlayerTarget], UNIT_STATE_LIFE )
if ( rHP <= 25 ) then
call KillUnit( udg_Carts[nPlayerTarget] )
else
call SetUnitState( udg_Carts[nPlayerTarget], UNIT_STATE_LIFE, rHP - 25 )
set effShoot = AddSpecialEffectTarget( "Abilities\\Weapons\\GyroCopter\\GyroCopterImpact.mdl", udg_Carts[nPlayerTarget], "chest" )
call DestroyEffect( effShoot )
set effShoot = AddSpecialEffectTarget( "Environment\\LargeBuildingFire\\LargeBuildingFire1.mdl", udg_Carts[nPlayerTarget], "chest" )
call DestroyEffect( effShoot )
endif
else
set loc1 = PolarProjectionBJ( loc, 1450, rAngle )
set effShoot = AddSpecialEffectLoc( "Abilities\\Weapons\\GyroCopter\\GyroCopterImpact.mdl", loc1 )
call RemoveLocation( loc1 )
call DestroyEffect( effShoot )
endif
call RemoveLocation( loc )
call RemoveLocation( locVH )
endfunction
function CartUseSpell takes unit uCart, integer nSpellId returns nothing
local integer nPlayerIndex = 0
local integer nIndex = 0
local integer nSlot = 0
local sound sndHonk = null
local integer nHonkIndex
set nPlayerIndex = GetPlayerIndex( GetOwningPlayer( uCart ) )
if ( nPlayerIndex < 0 ) then
return
endif
if ( nSpellId == 'A01X' ) then //honk
set nHonkIndex = GetModelHonk( udg_PlayerModels[nPlayerIndex] )
set sndHonk = CreateHonkSound( nHonkIndex )
call PlaySoundOnUnitBJ( sndHonk, 100, udg_Carts[nPlayerIndex] )
call KillSoundWhenDone(sndHonk)
call PolledWait( 0.1 )
set udg_CartAnimIndex[nPlayerIndex] = udg_ANIM_NONE
return
endif
if ( udg_GameGoingStatus[nPlayerIndex] != udg_GAME_DRIVING ) then
return
endif
set nIndex = GetPowerUpTypeIndex( nSpellId )
if ( nIndex < 0 ) then
if ( nSpellId == 'A003' ) then
if ( udg_PlayerCameraIndex[nPlayerIndex] == 4 ) then
set udg_PlayerCameraIndex[nPlayerIndex] = 0
else
set udg_PlayerCameraIndex[nPlayerIndex] = udg_PlayerCameraIndex[nPlayerIndex] + 1
endif
elseif ( nSpellId == 'A01U' ) then //OKay, machine gun then
call BigGun( uCart )
endif
endif
call PolledWait( 0.1 )
set udg_CartAnimIndex[nPlayerIndex] = udg_ANIM_NONE
if ( nIndex < 0 ) then
return
endif
if ( GetUnitAbilityLevel( uCart, nSpellId ) <= 0 ) then
return
endif
set nSlot = GetPowerUpTypeSlot( nSpellId )
call UnitRemoveAbility( uCart, nSpellId )
call RemoveCartSlotPowerUp( nPlayerIndex, nSlot )
call ShowDebugMsg( "how many left? " + I2S(udg_CartItemNum[nPlayerIndex]) )
if ( udg_PowerUpNames[nIndex] == "|cff80ff80Engine Boost|r" ) then
call EatMushroom( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Repair Kit|r" ) then
call UseRepairKit( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Blaze|r" ) then
call UseBlaze( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Ethereal Cloak|r" ) then
call SummonGhost( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Mine|r" ) then
call LayMine( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Sheepedo|r" ) then
call ThrowTurtle( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Web Trap|r" ) then
call SetupTrap( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Specklefrogg's Rocket|r" ) then
call IHateTheLeadingCart( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Uther's Blessing|r" ) then
call UseStar( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Electric Justice|r" ) then
call Lightning( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Blizzard|r" ) then
call Blizzard( uCart )
elseif ( udg_PowerUpNames[nIndex] == "|cff80ff80Carrion Swarm|r" ) then
call CarrionSwarm( uCart )
endif
endfunction
//===========================================================================
function InitTrig_Abilities_Functions takes nothing returns nothing
endfunction
function CalcTurnSpeed takes integer nModel, real nCurTurnSpeed, integer nTurning, real rSpeed, integer nAcceleration returns real
if ( rSpeed == 0 ) then
return 0.
endif
if ( nTurning == udg_TURNING_LEFT ) then
if ( rSpeed >= 0 ) then
return GetModelTurnRate( nModel )
else
return -GetModelTurnRate( nModel )
endif
elseif ( nTurning == udg_TURNING_RIGHT ) then
if ( rSpeed >= 0 ) then
return -GetModelTurnRate( nModel )
else
return GetModelTurnRate( nModel )
endif
endif
return 0.
endfunction
function CalcDirection takes real rCurAngle, real rCurTurnSpeed returns real
return rCurAngle + rCurTurnSpeed * 3
endfunction
function CalcDrag takes integer nModel, real rSpeed, real rTurnSpeed returns real
if ( rSpeed == 0 ) then
return 0.0
endif
if ( rTurnSpeed < 0 ) then
set rTurnSpeed = -rTurnSpeed
endif
if ( rSpeed < 0 ) then
return -0.5 + rSpeed * ( GetModelMassDrag(nModel) - rTurnSpeed * 0.003 )
else
return 0.5 + rSpeed * ( GetModelMassDrag(nModel) + rTurnSpeed * 0.003 )
endif
endfunction
function GetModelMaxSpeedAfterBuff takes integer nPlayerIndex, location locMax returns boolean
local boolean bInjured = false
local real rMaxSpeed = GetModelMaxSpeed( udg_PlayerModels[nPlayerIndex] )
if ( UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'Bspe' ) ) then //Speed Bonus
set rMaxSpeed = rMaxSpeed * 1.5
endif
if ( UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'B008' ) ) then //Pit Stop
set rMaxSpeed = rMaxSpeed * 1.2
endif
if ( UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'B005' ) ) then //Invulnerable
set rMaxSpeed = rMaxSpeed * 1.3
endif
if ( UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'Bslo' ) or UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'Basl' ) or UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'B004' ) ) then
set rMaxSpeed = rMaxSpeed / 2
endif
if ( GetUnitLifePercent( udg_Carts[nPlayerIndex] ) <= 33 ) then
set rMaxSpeed = rMaxSpeed * 3 / 4
set bInjured = true
endif
call MoveLocation( locMax, rMaxSpeed, -rMaxSpeed / 3 )
return bInjured
endfunction
function CalcCurSpeed takes integer nPlayerIndex returns real
local location loc = null
local real rSpeed = 0
local real rAngle = 0
local real rAngle1 = 0
local real r
local location locMax
local boolean bSlide = false
if ( udg_GameGoingStatus[nPlayerIndex] != udg_GAME_DRIVING ) then
set rSpeed = udg_Speed[nPlayerIndex]
else
set loc = GetUnitLoc( udg_Carts[nPlayerIndex] )
set rSpeed = FakeSpeed( DistanceBetweenPoints( loc, udg_CartPrePos[nPlayerIndex] ) )
if ( rSpeed != 0 ) then
set rAngle = AngleBetweenPoints( udg_CartPrePos[nPlayerIndex], loc )
set rAngle1 = udg_Angle[nPlayerIndex]
if ( udg_Speed[nPlayerIndex] < 0 ) then
set rAngle1 = rAngle1 + 180
endif
set r = StandardAngle( rAngle1 - rAngle )
if ( r > 2 or r < -2 ) then
set bSlide = true
endif
if ( CosBJ( rAngle - udg_Angle[nPlayerIndex] ) < 0 ) then
set rSpeed = -rSpeed
endif
endif
call RemoveLocation( loc )
set locMax = Location( 0, 0 )
call GetModelMaxSpeedAfterBuff( nPlayerIndex, locMax )
if ( bSlide ) then
call MoveLocation( locMax, GetLocationX(locMax) / 3, GetLocationY(locMax) / 3 )
endif
if ( rSpeed > GetLocationX(locMax) ) then
set rSpeed = GetLocationX(locMax)
elseif ( rSpeed < GetLocationY(locMax) ) then
set rSpeed = GetLocationY(locMax)
endif
call RemoveLocation( locMax )
endif
return rSpeed
endfunction
function CalcSpeed takes integer nPlayerIndex, real rCurSpeed, integer nAcceleration, real rCurTurnSpeed returns real
local real rSpeed = rCurSpeed
local integer nModel = udg_PlayerModels[nPlayerIndex]
local location locMax
if ( ( rSpeed < 0 and nAcceleration > 0 ) or ( rSpeed > 0 and nAcceleration < 0 ) ) then
set nAcceleration = nAcceleration * 2
endif
set rSpeed = rSpeed + nAcceleration * GetModelAcceRate(nModel)
if ( rSpeed < 0 ) then
set rSpeed = rSpeed - CalcDrag( nModel, rCurSpeed, rCurTurnSpeed )
if ( rSpeed > 0 ) then
set rSpeed = 0
endif
elseif ( rSpeed > 0 ) then
set rSpeed = rSpeed - CalcDrag( nModel, rCurSpeed, rCurTurnSpeed )
if ( rSpeed < 0 ) then
set rSpeed = 0
endif
endif
set locMax = Location( 0, 0 )
call GetModelMaxSpeedAfterBuff( nPlayerIndex, locMax )
if ( rSpeed > GetLocationX(locMax) ) then
set rSpeed = GetLocationX(locMax)
elseif ( rSpeed < GetLocationY(locMax) ) then
set rSpeed = GetLocationY(locMax)
endif
call RemoveLocation( locMax )
return rSpeed
endfunction
function CalcFinishingSpeed takes integer nModel, real rCurSpeed returns real
if ( rCurSpeed < 10 ) then
return 0
else
return rCurSpeed * 19 / 20
endif
endfunction
function IsValidLocForVehicle takes location loc returns boolean
local boolean bValid = true
local integer nIndex = 0
if ( GetTerrainCliffLevel( GetLocationX( loc ), GetLocationY( loc ) ) != 4 ) then
set bValid = false
else
set nIndex = 0
loop
exitwhen nIndex >= udg_ProhibitAreaNum
if ( RectContainsLoc( udg_ProhibitAreas[nIndex], loc ) ) then
set bValid = false
exitwhen true
endif
set nIndex = nIndex + 1
endloop
endif
return bValid
endfunction
function CaughtInTornado takes integer nPlayerIndex returns boolean
if ( not UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'Btsp' ) ) then
if ( udg_CaughtInTornado[nPlayerIndex] ) then
set udg_CaughtInTornado[nPlayerIndex] = false
set udg_Angle[nPlayerIndex] = udg_PlaceCheckPtDir[udg_PlaceChkPtCur[nPlayerIndex]]
call SetUnitFacing( udg_Carts[nPlayerIndex], udg_Angle[nPlayerIndex] )
call SetUnitPosition( udg_Carts[nPlayerIndex], GetUnitX(udg_Carts[nPlayerIndex]), GetUnitY(udg_Carts[nPlayerIndex]))
endif
return false
endif
// Haha, caught in tornado
set udg_CaughtInTornado[nPlayerIndex] = true
set udg_Speed[nPlayerIndex] = 0
call SetUnitTimeScale( udg_Carts[nPlayerIndex], 1 )
set udg_Angle[nPlayerIndex] = udg_Angle[nPlayerIndex] + 28
return true
endfunction
function FrozenByIce takes integer nPlayerIndex returns boolean
if ( not UnitHasBuffBJ(udg_Carts[nPlayerIndex], 'B007' ) ) then
if ( udg_Frozen[nPlayerIndex] ) then
if ( udg_FrozenEffect[nPlayerIndex] != null ) then
call DestroyEffect( udg_FrozenEffect[nPlayerIndex] )
set udg_FrozenEffect[nPlayerIndex] = null
endif
set udg_Frozen[nPlayerIndex] = false
call SetCartInvulnerable( udg_Carts[nPlayerIndex], false )
set udg_IceTrunkCooldown[nPlayerIndex] = 0
endif
return false
endif
// Haha, Frozen
set udg_Frozen[nPlayerIndex] = true
set udg_Speed[nPlayerIndex] = 0
call SetUnitTimeScale( udg_Carts[nPlayerIndex], 1 )
call SetCartInvulnerable( udg_Carts[nPlayerIndex], true )
if ( udg_FrozenEffect[nPlayerIndex] == null ) then
call PlaySoundOnUnitBJ( gg_snd_FreezingBreathTarget1, 100, udg_Carts[nPlayerIndex] )
set udg_FrozenEffect[nPlayerIndex] = AddSpecialEffectTarget( "Abilities\\Spells\\Undead\\FreezingBreath\\FreezingBreathTargetArt.mdl", udg_Carts[nPlayerIndex], "origin" )
endif
return true
endfunction
function LostControl takes integer nPlayerIndex returns boolean
local real rAngle = 0
local location loc = null
local location locPre = null
local real rSpeed = 0
local real scale = 0
if ( not IsCartSpinning(udg_Carts[nPlayerIndex] ) ) then
if ( udg_LostControl[nPlayerIndex] ) then
if ( udg_LostControlTickle[nPlayerIndex] < 20 ) then
set udg_Angle[nPlayerIndex] = udg_PlaceCheckPtDir[udg_PlaceChkPtCur[nPlayerIndex]]
call SetUnitPosition( udg_Carts[nPlayerIndex], GetUnitX(udg_Carts[nPlayerIndex]), GetUnitY(udg_Carts[nPlayerIndex]) )
call SetUnitFacingTimed( udg_Carts[nPlayerIndex], udg_Angle[nPlayerIndex], 0 )
set udg_LostControlTickle[nPlayerIndex] = udg_LostControlTickle[nPlayerIndex] + 1
return true
endif
set udg_LostControl[nPlayerIndex] = false
endif
return false
endif
set udg_LostControl[nPlayerIndex] = true
set udg_LostControlTickle[nPlayerIndex] = 0
set locPre = GetUnitLoc(udg_Carts[nPlayerIndex])
set udg_Speed[nPlayerIndex] = udg_Speed[nPlayerIndex] * 39 / 40
set rSpeed = udg_Speed[nPlayerIndex] / 3
set loc = PolarProjectionBJ( locPre, rSpeed, udg_Angle[nPlayerIndex])
call RemoveLocation( locPre )
if ( IsValidLocForVehicle( loc ) ) then
call SetUnitPositionLoc( udg_Carts[nPlayerIndex], loc )
endif
call RemoveLocation( loc )
set rAngle = GetUnitFacing( udg_Carts[nPlayerIndex] ) + 60
call SetUnitFacingTimed( udg_Carts[nPlayerIndex], rAngle, 0 )
call ShowDebugMsg( R2S(rAngle) )
return true
endfunction
function Move takes integer nPlayerIndex returns nothing
local location loc = null
local real rSpeed = 0
local real scale = 0
if ( nPlayerIndex < 0 ) then
return
endif
set rSpeed = RealSpeed( udg_Speed[nPlayerIndex] )
set loc = PolarProjectionBJ( udg_CartPrePos[nPlayerIndex], rSpeed, udg_Angle[nPlayerIndex])
if ( IsValidLocForVehicle( loc ) ) then
call SetUnitPositionLoc( udg_Carts[nPlayerIndex], loc )
else
call StopCart( nPlayerIndex )
endif
call RemoveLocation( loc )
call SetUnitFacingTimed( udg_Carts[nPlayerIndex], udg_Angle[nPlayerIndex], 0.05 )
//Check whether the cart are near enough to an item
if ( udg_TickSlow == 0 ) then
call CheckItemPick( nPlayerIndex )
endif
if ( rSpeed > 0 ) then
if ( udg_PlayerBlazeFlag[nPlayerIndex] > 0 ) then
call DoBlaze( nPlayerIndex )
endif
endif
endfunction
function DoInjureEffect takes integer nPlayerIndex returns nothing
if ( udg_Carts[nPlayerIndex] != null and IsUnitAliveBJ( udg_Carts[nPlayerIndex] ) and GetUnitLifePercent( udg_Carts[nPlayerIndex] ) <= 33 ) then
if ( udg_EffectInjured[nPlayerIndex] == null ) then
set udg_EffectInjured[nPlayerIndex] = AddSpecialEffectTarget( "Environment\\LargeBuildingFire\\LargeBuildingFire1.mdl", udg_Carts[nPlayerIndex], "chest" )
call ShowWarningMsg( Player(nPlayerIndex), "Your cart loses speed due to damage!" )
endif
else
if ( udg_EffectInjured[nPlayerIndex] != null ) then
call DestroyEffect( udg_EffectInjured[nPlayerIndex] )
set udg_EffectInjured[nPlayerIndex] = null
endif
endif
endfunction
function DoBrakeLight takes integer nPlayerIndex returns nothing
local boolean bBrake = false
local boolean bOn = false
local integer nBrakeLight = 'A01Y'
if ( udg_GameGoingStatus[nPlayerIndex] == udg_GAME_PREPARING or udg_GameGoingStatus[nPlayerIndex] == udg_GAME_FINISHING ) then
set bBrake = true
elseif ( udg_GameGoingStatus[nPlayerIndex] == udg_GAME_DRIVING ) then
if ( udg_Accelerating[nPlayerIndex] < 0 ) then
set bBrake = true
endif
endif
set bOn = GetUnitAbilityLevel( udg_Carts[nPlayerIndex], nBrakeLight ) > 0
if ( bBrake ) then
if ( bOn ) then
return
else
call UnitAddAbility( udg_Carts[nPlayerIndex], nBrakeLight )
endif
else
if ( bOn ) then
call UnitRemoveAbility( udg_Carts[nPlayerIndex], nBrakeLight )
else
return
endif
endif
endfunction
function RefreshCartAnim takes integer nPlayerIndex returns nothing
local real rSpeed
local real rScale
local integer nAnim
if ( udg_GameOver ) then
return
endif
if ( udg_Carts[nPlayerIndex] == null or IsUnitDeadBJ( udg_Carts[nPlayerIndex] ) ) then
set udg_CartAnimIndex[nPlayerIndex] = udg_ANIM_NONE
return
endif
if ( udg_GameGoingStatus[nPlayerIndex] == udg_GAME_FINISHING or udg_GameGoingStatus[nPlayerIndex] == udg_GAME_OVER ) then
if ( udg_CartAnimIndex[nPlayerIndex] != udg_ANIM_VICTORY ) then
call SetUnitAnimationByIndex( udg_Carts[nPlayerIndex], GetModelAnimVictoryID( udg_PlayerModels[nPlayerIndex] ) )
call SetUnitTimeScale( udg_Carts[nPlayerIndex], 1 )
set udg_CartAnimIndex[nPlayerIndex] = udg_ANIM_VICTORY
endif
return
endif
if ( udg_GunAttackTick[nPlayerIndex] >= 0 ) then
set udg_GunAttackTick[nPlayerIndex] = udg_GunAttackTick[nPlayerIndex] + 1
if ( udg_GunAttackTick[nPlayerIndex] > 5 ) then
set udg_GunAttackTick[nPlayerIndex] = -1
endif
endif
if ( udg_Speed[nPlayerIndex] == 0) then
if ( udg_GunAttackTick[nPlayerIndex] < 0 ) then
set nAnim = udg_ANIM_STAND
else
set nAnim = udg_ANIM_STANDATTACK
endif
if ( udg_CartAnimIndex[nPlayerIndex] == nAnim ) then
return
endif
set udg_CartAnimIndex[nPlayerIndex] = nAnim
if ( udg_CartAnimIndex[nPlayerIndex] == udg_ANIM_STAND ) then
call SetUnitAnimationByIndex( udg_Carts[nPlayerIndex], GetModelAnimStandID( udg_PlayerModels[nPlayerIndex] ) )
else
call SetUnitAnimationByIndex( udg_Carts[nPlayerIndex], GetModelAnimStandAttackID( udg_PlayerModels[nPlayerIndex] ) )
endif
if ( udg_GunAttackTick[nPlayerIndex] < 0 ) then
call SetUnitTimeScale( udg_Carts[nPlayerIndex], 1 )
else
call SetUnitTimeScale( udg_Carts[nPlayerIndex], 5 )
endif
else
if ( udg_GunAttackTick[nPlayerIndex] < 0 ) then
set nAnim = udg_ANIM_WALK
else
set nAnim = udg_ANIM_WALKATTACK
endif
if ( udg_CartAnimIndex[nPlayerIndex] != nAnim ) then
set udg_CartAnimIndex[nPlayerIndex] = nAnim
if ( udg_CartAnimIndex[nPlayerIndex] == udg_ANIM_WALK ) then
call SetUnitAnimationByIndex( udg_Carts[nPlayerIndex], GetModelAnimWalkID( udg_PlayerModels[nPlayerIndex] ) )
else
call SetUnitAnimationByIndex( udg_Carts[nPlayerIndex], GetModelAnimWalkAttackID( udg_PlayerModels[nPlayerIndex] ) )
endif
endif
if ( udg_GunAttackTick[nPlayerIndex] < 0 ) then
set rSpeed = udg_Speed[nPlayerIndex]
if ( rSpeed < 0 ) then
set rSpeed = -rSpeed
endif
set rScale = rSpeed * 6 / GetModelMaxSpeed(udg_PlayerModels[nPlayerIndex])
call SetUnitTimeScale( udg_Carts[nPlayerIndex], rScale )
else
call SetUnitTimeScale( udg_Carts[nPlayerIndex], 5 )
endif
endif
endfunction
function RefreshCartSound takes integer nPlayerIndex returns nothing
local real rSpeedMax = 0
local real rSpeedAbs = 0
if ( udg_Carts[nPlayerIndex] == null or IsUnitDeadBJ(udg_Carts[nPlayerIndex]) ) then
call ChangeCartSound( nPlayerIndex, udg_SNDINDEX_NONE )
return
endif
set rSpeedAbs = RAbsBJ( udg_Speed[nPlayerIndex] )
set rSpeedMax = GetModelMaxSpeed( udg_PlayerModels[nPlayerIndex] ) * 4 / 3
if ( rSpeedAbs < rSpeedMax / 15 ) then
call ChangeCartSound( nPlayerIndex, udg_SNDINDEX_COAST )
elseif ( rSpeedAbs <= rSpeedMax / 3 ) then
call ChangeCartSound( nPlayerIndex, udg_SNDINDEX_GOING1 )
elseif ( rSpeedAbs <= rSpeedMax * 2 / 3 ) then
call ChangeCartSound( nPlayerIndex, udg_SNDINDEX_GOING2 )
else
call ChangeCartSound( nPlayerIndex, udg_SNDINDEX_GOING3 )
endif
endfunction
function TurnWheel takes player plPlayer, integer nTurning returns nothing
local integer nPlayerIndex = -1
set nPlayerIndex = GetPlayerIndex(plPlayer)
if ( nPlayerIndex < 0 ) then
return
endif
set udg_Turning[nPlayerIndex] = nTurning
endfunction
function ReleaseWheel takes player plPlayer, integer nTurning returns nothing
local integer nPlayerIndex = GetPlayerIndex(plPlayer)
if ( nPlayerIndex < 0 ) then
return
endif
if ( udg_Turning[nPlayerIndex] == nTurning ) then
set udg_Turning[nPlayerIndex] = udg_TURNING_NOTURN
endif
endfunction
function Accelerate takes player plPlayer, integer nAccelerating returns nothing
local integer nPlayerIndex = GetPlayerIndex(plPlayer)
if ( nPlayerIndex < 0 ) then
return
endif
if ( udg_Accelerating[nPlayerIndex] != udg_ACCELERATE_COAST ) then
return
endif
set udg_Accelerating[nPlayerIndex] = nAccelerating
endfunction
function Coast takes player plPlayer, integer nAccelerating returns nothing
local integer nPlayerIndex = GetPlayerIndex(plPlayer)
if ( nPlayerIndex < 0 ) then
return
endif
if ( udg_Accelerating[nPlayerIndex] != nAccelerating ) then
return
endif
set udg_Accelerating[nPlayerIndex] = udg_ACCELERATE_COAST
endfunction
function GiveMeNewCart takes integer nPlayerIndex, location loc returns unit
local location loc1 = null
local location loc2 = null
local unit uPlane = null
local real rAngle = 0
local real rDis = 0
local unit uCartFalling = null
local real rHeight = 400
local real rScale = 0
local integer nIndex = 0
set loc1 = Location( GetLocationX(loc), GetLocationY(loc) )
set rAngle = udg_Angle[nPlayerIndex] - 45
set loc2 = PolarProjectionBJ( loc1, 1200, rAngle )
set uPlane = CreateUnitAtLoc( udg_NPC, 'h00I', loc2, rAngle + 180 )
call RemoveLocation( loc2 )
call SetUnitPathing( uPlane, false )
call IssuePointOrderLoc( uPlane, "move", loc1 )
//call SetUnitFlyHeight( uPlane, 300, 5000 )
call SetUnitFlyHeight( uPlane, 500, 60 )
call PolledWait( 2 )
loop
set loc2 = GetUnitLoc( uPlane )
set rDis = DistanceBetweenPoints( loc1, loc2 )
call RemoveLocation( loc2 )
if ( rDis < 20 ) then
exitwhen true
endif
call PolledWait( 0.1 )
endloop
call PolledWait( 0.2 )
set loc2 = PolarProjectionBJ( loc1, 1500, rAngle + 90 )
set uCartFalling = CreateUnitAtLoc( Player(nPlayerIndex), GetModelFlyUnitType( udg_PlayerModels[nPlayerIndex] ), loc1, udg_Angle[nPlayerIndex] )
call RemoveLocation( loc1 )
call SetUnitPathing( uCartFalling, false )
call SetUnitScale( uCartFalling, 0.96, 0.96, 0.96 )
//call SetUnitFlyHeight( uCartFalling, 450, 99999 )
call PolledWait( 0.1 )
set nIndex = 0
loop
call SetUnitFlyHeight( uCartFalling, 0, (nIndex + 1 ) * ( nIndex + 1 ) * 50 )
call PolledWait( 0.1 )
exitwhen nIndex >= 4
if ( nIndex == 2 ) then
call IssuePointOrderLoc( uPlane, "move", loc2 )
call RemoveLocation( loc2 )
endif
set rScale = 0.96 + nIndex * 0.01
call SetUnitScale( uCartFalling, rScale, rScale, rScale )
set nIndex = nIndex + 1
endloop
call RemoveUnit( uCartFalling )
return uPlane
endfunction
function SheepFlee takes nothing returns nothing
local integer nIndex1 = 0
local integer nIndex2 = 0
local unit uSheep = null
local location locTarget = null
set udg_SheepFled = true
set nIndex1 = 0
loop
exitwhen nIndex1 >= 12
set nIndex2 = 0
loop
exitwhen nIndex2 >= 2
set uSheep = CreateUnit( udg_NPC, 'nshe', GetRectCenterX(gg_rct_SheepArea), GetRectCenterY(gg_rct_SheepArea), I2R(GetRandomInt(0, 359)) )
set locTarget = GetRandomLocInRect( gg_rct_SheepMoveTarget )
call IssuePointOrderLoc( uSheep, "move", locTarget )
call RemoveLocation( locTarget )
set nIndex2 = nIndex2 + 1
call PolledWait( 0.2 )
endloop
set nIndex1 = nIndex1 + 1
call PolledWait( 1 )
endloop
endfunction
function ShipAttack takes nothing returns nothing
local integer nIndex = 0
local location loc = null
loop
exitwhen udg_Ships[nIndex] == null
set loc = GetRandomLocInRect( gg_rct_ShipAttackArea )
call IssuePointOrderLoc( udg_Ships[nIndex], "attackground", loc )
call RemoveLocation( loc )
set nIndex = nIndex + 1
endloop
endfunction
function ShipStartMove takes nothing returns nothing
local integer nIndex = 0
loop
exitwhen udg_Ships[nIndex] == null
call PauseUnit( udg_Ships[nIndex], false )
call IssuePointOrderLoc( udg_Ships[nIndex], "Move", udg_ShipTargetPoint[nIndex] )
set nIndex = nIndex + 1
endloop
endfunction
function ShipStartAttack takes nothing returns nothing
local integer nIndex = 0
loop
exitwhen udg_Ships[nIndex] == null
call SetUnitMoveSpeed( udg_Ships[nIndex], 0 )
set nIndex = nIndex + 1
endloop
call TimerStart( udg_ShipAttackTimer, 3, true, null )
call ShipAttack()
endfunction
//===========================================================================
function InitTrig_Driving_Functions takes nothing returns nothing
endfunction
function GetTimeElapsed takes nothing returns string
local integer nSeconds = R2I( TimerGetElapsed( udg_GameTimer ) )
return Second2String( nSeconds, true )
endfunction
function Integer2Meter takes integer n returns string
local string str = ""
if ( n >= 30 ) then
set str = str + "IIIIIIIIIIIIIIIIIIIIIIIIIIIIII"
set n = n - 30
endif
if ( n >= 20 ) then
set str = str + "IIIIIIIIIIIIIIIIIIII"
set n = n - 20
endif
if ( n >= 10 ) then
set str = str + "IIIIIIIIII"
set n = n - 10
endif
if ( n >= 5 ) then
set str = str + "IIIII"
set n = n - 5
endif
loop
exitwhen n <= 0
set str = str + "I"
set n = n - 1
endloop
return str
endfunction
function LifeMeter takes unit uCart returns string
local string str = null
local real rLifePercent = 0
local integer nLife = 0
if ( uCart != null and IsUnitAliveBJ( uCart ) ) then
set rLifePercent = GetUnitLifePercent( uCart )
endif
set nLife = R2I(rLifePercent * 24 / 100)
set str = Integer2Meter( nLife )
if ( nLife > 16 ) then
set str = "|cff00c800" + str + "|r"
elseif ( nLife > 8 ) then
set str = "|cffc8c800" + str + "|r"
else
set str = "|cffc80000" + str + "|r"
endif
if ( nLife < 24 ) then
set str = str + "|cff969696" + Integer2Meter( 24 - nLife ) + "|r"
endif
return str
endfunction
function SpeedMeter takes integer nSpeed, real rMaxSpeed, integer nFlashType, boolean bFlash returns string
local string str = null
local integer n = 0
local integer nStage = 0
local integer nLen = 30
local integer nLenUnit = nLen / 3
set nSpeed = IAbsBJ(nSpeed) * nLen / R2I(rMaxSpeed * 4 / 3)
if ( nFlashType > 0 ) then
set str = Integer2Meter( nSpeed )
if ( bFlash ) then
set str = "|cffff0000" + str + "|r"
else
set str = "|cffffffff" + str + "|r"
endif
set nLen = nLen - nSpeed
elseif ( nFlashType < 0 ) then
set str = Integer2Meter( nSpeed )
if ( bFlash ) then
set str = "|cff00ff00" + str + "|r"
else
set str = "|cffffffff" + str + "|r"
endif
set nLen = nLen - nSpeed
else
set str = ""
set nStage = 0
loop
exitwhen nSpeed <= 0
if ( nSpeed >= nLenUnit ) then
set n = nLenUnit
else
set n = nSpeed
endif
set nLen = nLen - n
if ( nStage == 0 ) then
set str = str + "|cff00c800" + Integer2Meter( n ) + "|r"
elseif ( nStage == 1 ) then
set str = str + "|cffc8c800" + Integer2Meter( n ) + "|r"
elseif ( nStage == 2 ) then
set str = str + "|cffc80000" + Integer2Meter( n ) + "|r"
endif
set nSpeed = nSpeed - n
set nStage = nStage + 1
endloop
endif
if ( nLen > 0 ) then
set str = str + "|cff969696" + Integer2Meter( nLen ) + "|r"
endif
return str
endfunction
function AmmoMeter takes integer nPlayerIndex returns string
local string str = null
local integer nAmmo
set nAmmo = udg_GunAmmo[nPlayerIndex] * 30 / udg_AMMO_MAX
set str = "|cffdaa520" + Integer2Meter( nAmmo ) + "|r"
if ( nAmmo < 30 ) then
set str = str + "|cff969696" + Integer2Meter( 30 - nAmmo ) + "|r"
endif
return str
endfunction
function RefreshBoard takes integer nPlayer returns nothing
local integer nPlayerIndex = 0
local multiboarditem mbitem = null
local integer nRow
local real array rWidth
local integer nSeconds
set rWidth[0] = 0.01
set rWidth[1] = 0.08
set rWidth[2] = 0.03
set rWidth[3] = 0.07
if ( udg_GameGoingStatus[nPlayer] != udg_GAME_FINISHING and udg_GameGoingStatus[nPlayer] != udg_GAME_OVER ) then
call MultiboardSetTitleText( udg_mb[nPlayer], "TOTAL LAPs = " + I2S(udg_LapNumber) + " " + GetTimeElapsed( ) )
else
set nSeconds = R2I( udg_TimeUsed[ nPlayerIndex ] )
call MultiboardSetTitleText( udg_mb[nPlayer], "TOTAL LAPs = " + I2S(udg_LapNumber) + " " + Second2String( nSeconds, true ) )
endif
call MultiboardSetRowCount( udg_mb[nPlayer], udg_PlaceNum + 1 + 3 )
set nRow = 1
loop
exitwhen nRow > udg_PlaceNum
set nPlayerIndex = udg_Places[nRow - 1]
//Place
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 0 )
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemValueColor( mbitem, 255, 255, 255, 255 )
call MultiboardSetItemWidth( mbitem, rWidth[0] )
call MultiboardSetItemValue( mbitem, I2S(nRow) )
call MultiboardReleaseItem( mbitem )
//Player Name
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 1 )
call MultiboardSetItemStyle( mbitem, true, true )
call MultiboardSetItemValue( mbitem, GetPlayerName( Player(nPlayerIndex) ) )
call MultiboardSetItemValueColor( mbitem, udg_PlayerColorRed[nPlayerIndex], udg_PlayerColorGreen[nPlayerIndex], udg_PlayerColorBlue[nPlayerIndex], 255 )
call MultiboardSetItemIcon( mbitem, udg_ModelIcons[udg_PlayerModels[nPlayerIndex]] )
call MultiboardSetItemWidth( mbitem, rWidth[1] )
call MultiboardReleaseItem( mbitem )
//Lap
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 2)
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemValueColor( mbitem, 255, 255, 255, 255 )
call MultiboardSetItemWidth( mbitem, rWidth[2] )
if ( udg_GameGoingStatus[nPlayerIndex] == udg_GAME_DRIVING or udg_GameGoingStatus[nPlayerIndex] == udg_GAME_REPAIRING or udg_GameGoingStatus[nPlayerIndex] == udg_GAME_PREPARING ) then
call MultiboardSetItemValue( mbitem, I2S( udg_PlaceChkPtLap[nPlayerIndex] + 1 ) )
else
call MultiboardSetItemValue( mbitem, I2S( udg_PlaceChkPtLap[nPlayerIndex] ) )
endif
call MultiboardReleaseItem( mbitem )
//HP
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 3)
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemWidth( mbitem, rWidth[3] )
call MultiboardSetItemValue( mbitem, LifeMeter( udg_Carts[nPlayerIndex] ) )
call MultiboardReleaseItem( mbitem )
set nRow = nRow + 1
endloop
//======== Empty Line =====================
//Place
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 0 )
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, rWidth[0] + rWidth[1] + rWidth[2] + rWidth[3] )
//call MultiboardSetItemValue( mbitem, "" )
call MultiboardReleaseItem( mbitem )
//Player Name
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 1 )
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, 0 )
call MultiboardReleaseItem( mbitem )
//Lap
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 2)
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, 0 )
call MultiboardReleaseItem( mbitem )
//Speed
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 3)
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, 0 )
call MultiboardReleaseItem( mbitem )
set nRow = nRow + 1
//======== Speed Meter =====================
//Place
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 0 )
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemWidth( mbitem, rWidth[0] + rWidth[1] + rWidth[2] + rWidth[3] )
call MultiboardSetItemValue( mbitem, "Speed: " + SpeedMeter( R2I( udg_Speed[nPlayer] ), GetModelMaxSpeed(udg_PlayerModels[nPlayer]), 0, false ) )
call MultiboardReleaseItem( mbitem )
//Player Name
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 1 )
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, 0 )
call MultiboardReleaseItem( mbitem )
//Lap
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 2)
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, 0 )
call MultiboardReleaseItem( mbitem )
//Speed
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 3)
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, 0 )
call MultiboardReleaseItem( mbitem )
set nRow = nRow + 1
//======== Ammo Meter =====================
//Place
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 0 )
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemWidth( mbitem, rWidth[0] + rWidth[1] + rWidth[2] + rWidth[3] )
call MultiboardSetItemValue( mbitem, "Ammo: " + AmmoMeter (nPlayer) )
call MultiboardReleaseItem( mbitem )
//Player Name
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 1 )
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, 0 )
call MultiboardReleaseItem( mbitem )
//Lap
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 2)
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, 0 )
call MultiboardReleaseItem( mbitem )
//Speed
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 3)
call MultiboardSetItemStyle( mbitem, false, false )
call MultiboardSetItemWidth( mbitem, 0 )
call MultiboardReleaseItem( mbitem )
endfunction
function RefreshBoards takes nothing returns nothing
local integer nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
if ( GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
call RefreshBoard( nPlayerIndex )
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
endfunction
function CreateBoard takes integer nPlayer returns nothing
local integer nPlayerIndex = 0
local multiboarditem mbitem = null
local integer nRow = 1
local real array rWidth
set rWidth[0] = 0.01
set rWidth[1] = 0.08
set rWidth[2] = 0.03
set rWidth[3] = 0.07
set udg_mb[nPlayer] = CreateMultiboard()
call MultiboardSetColumnCount( udg_mb[nPlayer], 4 )
call MultiboardSetRowCount( udg_mb[nPlayer], 1 )
set mbitem = MultiboardGetItem( udg_mb[nPlayer], 0, 0 )
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemValue( mbitem, " " )
call MultiboardSetItemValueColor( mbitem, 255, 255, 255, 255 )
call MultiboardSetItemWidth( mbitem, rWidth[0] )
call MultiboardReleaseItem( mbitem )
set mbitem = MultiboardGetItem( udg_mb[nPlayer], 0, 1 )
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemValue( mbitem, "Player" )
call MultiboardSetItemValueColor( mbitem, 255, 255, 255, 255 )
call MultiboardSetItemWidth( mbitem, rWidth[1] )
call MultiboardReleaseItem( mbitem )
set mbitem = MultiboardGetItem( udg_mb[nPlayer], 0, 2 )
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemValue( mbitem, "Lap" )
call MultiboardSetItemValueColor( mbitem, 255, 255, 255, 255 )
call MultiboardSetItemWidth( mbitem, rWidth[2] )
call MultiboardReleaseItem( mbitem )
set mbitem = MultiboardGetItem( udg_mb[nPlayer], 0, 3 )
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemValue( mbitem, "HP" )
call MultiboardSetItemValueColor( mbitem, 255, 255, 255, 255 )
call MultiboardSetItemWidth( mbitem, rWidth[3] )
call MultiboardReleaseItem( mbitem )
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
if ( GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
set udg_BoardPlayerIndexes[nRow - 1] = nPlayerIndex
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 0 )
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemValueColor( mbitem, 255, 255, 255, 255 )
call MultiboardSetItemWidth( mbitem, rWidth[0] )
call MultiboardReleaseItem( mbitem )
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 1 )
call MultiboardSetItemStyle( mbitem, true, true )
call MultiboardSetItemValue( mbitem, GetPlayerName( Player(nPlayerIndex) ) )
call MultiboardSetItemValueColor( mbitem, udg_PlayerColorRed[nPlayerIndex], udg_PlayerColorGreen[nPlayerIndex], udg_PlayerColorBlue[nPlayerIndex], 255 )
call MultiboardSetItemIcon( mbitem, udg_ModelIcons[udg_PlayerModels[nPlayerIndex]] )
call MultiboardSetItemWidth( mbitem, rWidth[1] )
call MultiboardReleaseItem( mbitem )
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 2)
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemValueColor( mbitem, 255, 255, 255, 255 )
call MultiboardSetItemWidth( mbitem, rWidth[2] )
call MultiboardReleaseItem( mbitem )
set mbitem = MultiboardGetItem( udg_mb[nPlayer], nRow, 3)
call MultiboardSetItemStyle( mbitem, true, false )
call MultiboardSetItemWidth( mbitem, rWidth[3] )
call MultiboardReleaseItem( mbitem )
set nRow = nRow + 1
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
endfunction
function DisplayBoards takes nothing returns nothing
local integer nPlayer = 0
loop
exitwhen nPlayer >= udg_PLAYER_MAXNUM
if ( GetPlayerController(Player(nPlayer)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayer)) == PLAYER_SLOT_STATE_PLAYING ) then
if ( GetLocalPlayer() == Player(nPlayer) ) then
call MultiboardDisplay( udg_mb[nPlayer], true )
call MultiboardMinimize( udg_mb[nPlayer], false )
endif
endif
set nPlayer = nPlayer + 1
endloop
endfunction
function CreateBoards takes nothing returns nothing
local integer nPlayerIndex = 0
loop
exitwhen nPlayerIndex >= udg_PLAYER_MAXNUM
if ( GetPlayerController(Player(nPlayerIndex)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(nPlayerIndex)) == PLAYER_SLOT_STATE_PLAYING ) then
call CreateBoard( nPlayerIndex )
endif
set nPlayerIndex = nPlayerIndex + 1
endloop
call TimerStart( udg_BoardTimer, 1.00, true, null )
call RefreshBoards()
call DisplayBoards()
endfunction
//===========================================================================
function InitTrig_Multi_Board_Functions takes nothing returns nothing
endfunction
function DeselectCart takes player plPlayer, unit uCart returns nothing
local integer nPlayerIndex = GetPlayerIndex(plPlayer)
if ( nPlayerIndex < 0 ) then
return
endif
if ( udg_Carts[nPlayerIndex] == null or uCart != udg_Carts[nPlayerIndex] or IsUnitDeadBJ( udg_Carts[nPlayerIndex] ) ) then
return
endif
call ClearSelectionForPlayer( plPlayer )
call SelectUnitForPlayerSingle( udg_Carts[nPlayerIndex], plPlayer )
endfunction
function SelectSomethingElse takes player plPlayer, unit uSelected returns nothing
local integer nPlayerIndex = GetPlayerIndex(plPlayer)
if ( nPlayerIndex < 0 ) then
return
endif
if ( udg_Carts[nPlayerIndex] == null or uSelected == udg_Carts[nPlayerIndex] or IsUnitDeadBJ( udg_Carts[nPlayerIndex] ) ) then
return
endif
call ClearSelectionForPlayer( plPlayer )
call SelectUnitForPlayerSingle( udg_Carts[nPlayerIndex], plPlayer )
endfunction
//===========================================================================
function InitTrig_Select_Cart_Functions takes nothing returns nothing
endfunction
function Repair takes unit uCart, integer nSpot, real rFace returns nothing
local player plPlayer = GetOwningPlayer( uCart )
local integer nPlayerIndex = GetPlayerIndex( plPlayer )
local location locGarage = null
local real rHPCur = 0
local real rHPMax = 0
local real rTimePassed = 0
local unit uAssistant = null
local integer array nPowerUps
if ( nPlayerIndex < 0 ) then
return
endif
if ( udg_PitGarageOccupied[nSpot] ) then
return
endif
if ( udg_GameGoingStatus[nPlayerIndex] != udg_GAME_DRIVING ) then
return
endif
if ( GetUnitState( udg_Carts[nPlayerIndex], UNIT_STATE_LIFE ) >= GetUnitState( udg_Carts[nPlayerIndex], UNIT_STATE_MAX_LIFE ) and udg_GunAmmo[nPlayerIndex] >= udg_AMMO_MAX ) then
return
endif
set udg_GameGoingStatus[nPlayerIndex] = udg_GAME_REPAIRING
set udg_PitGarageOccupied[nSpot] = true
call StopCart( nPlayerIndex )
set locGarage = GetUnitLoc( udg_PitGarages[nSpot] )
if ( udg_ItsForDebug ) then
call SetUnitLifeBJ(uCart, 10)
endif
set rFace = rFace + 40
set rHPCur = GetUnitState( udg_Carts[nPlayerIndex], UNIT_STATE_LIFE)
set nPowerUps[0] = GetCartSlotPowerUp( nPlayerIndex, 0 )
set nPowerUps[1] = GetCartSlotPowerUp( nPlayerIndex, 1 )
set nPowerUps[2] = GetCartSlotPowerUp( nPlayerIndex, 2 )
set nPowerUps[3] = GetCartSlotPowerUp( nPlayerIndex, 3 )
call RemoveUnit( udg_Carts[nPlayerIndex] )
set udg_Carts[nPlayerIndex] = CreateUnitAtLoc( Player(nPlayerIndex), GetModelUnitType( udg_PlayerModels[nPlayerIndex] ), locGarage, rFace )
call SetUnitLifeBJ( udg_Carts[nPlayerIndex], rHPCur )
if ( nPowerUps[0] != 0 ) then
call UnitAddAbility( udg_Carts[nPlayerIndex], nPowerUps[0] )
endif
if ( nPowerUps[1] != 0 ) then
call UnitAddAbility( udg_Carts[nPlayerIndex], nPowerUps[1] )
endif
if ( nPowerUps[2] != 0 ) then
call UnitAddAbility( udg_Carts[nPlayerIndex], nPowerUps[2] )
endif
if ( nPowerUps[3] != 0 ) then
call UnitAddAbility( udg_Carts[nPlayerIndex], nPowerUps[3] )
endif
set udg_Angle[nPlayerIndex] = rFace
call ClearSelectionForPlayer( Player(nPlayerIndex) )
call SelectUnitForPlayerSingle( udg_Carts[nPlayerIndex], Player(nPlayerIndex) )
call ChargeBigGunSingle( nPlayerIndex )
call ResetCameraTarget( nPlayerIndex, udg_Carts[nPlayerIndex] )
call ResetCamera( nPlayerIndex )
call PolledWait( 0.2 )
set rHPMax = GetUnitState( udg_Carts[nPlayerIndex], UNIT_STATE_MAX_LIFE)
loop
set rHPCur = rHPCur + 80
if ( rHPCur > rHPMax ) then
set rHPCur = rHPMax
endif
call SetUnitLifeBJ( udg_Carts[nPlayerIndex], rHPCur )
if ( rHPCur >= rHPMax ) then
call SetUnitAnimationByIndex( udg_PitCrews[nSpot], 2 )
exitwhen true
endif
if ( rTimePassed >= 0.5 ) then
call SetUnitAnimationByIndex( udg_PitCrews[nSpot], 7 )
set rTimePassed = 0
endif
call PolledWait(0.1)
set rTimePassed = rTimePassed + 0.1
endloop
call PlaySoundPlayer( Player(nPlayerIndex), gg_snd_HeroTinkerWhat4 )
call DisplayTextToPlayer( Player(nPlayerIndex), 0, 0, "Repairing is done. Now get out of here." )
set udg_GameGoingStatus[nPlayerIndex] = udg_GAME_DRIVING
set udg_PitGarageOccupied[nSpot] = false
call RemoveLocation( locGarage )
set uAssistant = CreateAssistant1( nPlayerIndex, 2 )
call IssueTargetOrder( uAssistant, "unholyfrenzy", udg_Carts[nPlayerIndex] )
endfunction
//===========================================================================
function InitTrig_Repairing_Functions takes nothing returns nothing
endfunction
function MineCartReachStop takes unit uWagon, rect rcStart, rect rcTarget returns nothing
//local effect eff
//local location loc = Location( GetRectCenterX(rcStart), GetRectCenterY(rcTarget) )
//set eff = AddSpecialEffectLoc( "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", loc)
//call DestroyEffect( eff )
call IssuePointOrder( uWagon, "move", GetRectCenterX(rcStart), GetRectCenterY(rcTarget) )
endfunction
function CreateMineCart takes rect rectStart, rect rectEnd, integer nCartId, real rSpeed, real rFace returns unit
local location loc1 = GetRectCenter( rectStart )
local unit uCart = CreateUnitAtLoc( udg_NPC, nCartId, loc1, rFace )
//call ShowGeneralMsg( "mine cart", false )
call RemoveLocation( loc1 )
call SetUnitPathing( uCart, false )
call SetUnitMoveSpeed( uCart, rSpeed )
call MineCartReachStop( uCart, rectStart, rectEnd )
return uCart
endfunction
function FirstStop takes unit uWagon returns nothing
local integer nTypeId = GetUnitTypeId( uWagon )
if ( nTypeId == 'h00K' ) then //11
call MineCartReachStop( uWagon, gg_rct_MineCartStart11, gg_rct_MineCartEnd1 )
elseif ( nTypeId == 'h003' ) then //21
call MineCartReachStop( uWagon, gg_rct_MineCartStart21, gg_rct_MineCartPath2 )
elseif ( nTypeId == 'h005' ) then //12
call MineCartReachStop( uWagon, gg_rct_MineCartStart12, gg_rct_MineCartEnd1 )
elseif ( nTypeId == 'h006' ) then //22
call MineCartReachStop( uWagon, gg_rct_MineCartStart22, gg_rct_MineCartPath2 )
endif
endfunction
function SecondStop takes unit uWagon returns nothing
local integer nTypeId = GetUnitTypeId( uWagon )
if ( nTypeId == 'h00K' ) then //11
call MineCartReachStop( uWagon, gg_rct_MineCartStart11, gg_rct_MineCartPath1 )
elseif ( nTypeId == 'h003' ) then //21
call MineCartReachStop( uWagon, gg_rct_MineCartStart21, gg_rct_MineCartPath3 )
elseif ( nTypeId == 'h005' ) then //12
call MineCartReachStop( uWagon, gg_rct_MineCartStart12, gg_rct_MineCartPath1 )
elseif ( nTypeId == 'h006' ) then //22
call MineCartReachStop( uWagon, gg_rct_MineCartStart22, gg_rct_MineCartPath3 )
endif
endfunction
function ThirdStop takes unit uWagon returns nothing
local integer nTypeId = GetUnitTypeId( uWagon )
if ( nTypeId == 'h00K' ) then //11
call MineCartReachStop( uWagon, gg_rct_MineCartStart11, gg_rct_MineCartPath2 )
elseif ( nTypeId == 'h003' ) then //21
call MineCartReachStop( uWagon, gg_rct_MineCartStart21, gg_rct_MineCartPath4 )
elseif ( nTypeId == 'h005' ) then //12
call MineCartReachStop( uWagon, gg_rct_MineCartStart12, gg_rct_MineCartPath2 )
elseif ( nTypeId == 'h006' ) then //22
call MineCartReachStop( uWagon, gg_rct_MineCartStart22, gg_rct_MineCartPath4 )
endif
endfunction
function ForthStop takes unit uWagon returns nothing
local integer nTypeId = GetUnitTypeId( uWagon )
if ( nTypeId == 'h00K' ) then //11
call MineCartReachStop( uWagon, gg_rct_MineCartStart11, gg_rct_MineCartPath3 )
elseif ( nTypeId == 'h003' ) then //21
call MineCartReachStop( uWagon, gg_rct_MineCartStart21, gg_rct_MineCartEnd2 )
elseif ( nTypeId == 'h005' ) then //12
call MineCartReachStop( uWagon, gg_rct_MineCartStart12, gg_rct_MineCartPath3 )
elseif ( nTypeId == 'h006' ) then //22
call MineCartReachStop( uWagon, gg_rct_MineCartStart22, gg_rct_MineCartEnd2 )
endif
endfunction
function MineCartControl takes nothing returns nothing
if ( ModuloInteger( udg_MineCartTimerCount, 4 ) == 0 ) then
//call CreateMineCart( gg_rct_MineCartStart11, gg_rct_MineCartPath4, 'h00K', 300, 270 )
call CreateMineCart( gg_rct_MineCartStart21, gg_rct_MineCartPath1, 'h003', 300, 90 )
endif
if ( ModuloInteger( udg_MineCartTimerCount, 3 ) == 0 ) then
call CreateMineCart( gg_rct_MineCartStart12, gg_rct_MineCartPath4, 'h005', 400, 270 )
call CreateMineCart( gg_rct_MineCartStart22, gg_rct_MineCartPath1, 'h006', 400, 90 )
endif
set udg_MineCartTimerCount = udg_MineCartTimerCount + 1
if ( udg_MineCartTimerCount == 12 ) then
set udg_MineCartTimerCount = 0
endif
endfunction
//===========================================================================
function InitTrig_Cross_Road_Functions takes nothing returns nothing
endfunction
function CreateCinematicDriverSingle takes integer nPlace returns unit
local integer nPlayerIndex = udg_Places[nPlace]
local integer nModelIndex = udg_PlayerModels[nPlayerIndex]
local integer nDriverType = GetModelDriverUnitType( nModelIndex )
local rect rct = null
local real rAngle = 0
local unit u
if ( nPlace == 0 ) then
set rct = gg_rct_PlaceArea1
set rAngle = 290
elseif ( nPlace == 1 ) then
set rct = gg_rct_PlaceArea2
set rAngle = 250
elseif ( nPlace == 2 ) then
set rct = gg_rct_PlaceArea3
set rAngle = 270
else
return null
endif
if ( nPlace == 0 ) then
set udg_ChampionDriverAnim = udg_DriverAnimName[GetModelDriverAnimID( nModelIndex )]
set udg_ChampionDriverSound = udg_DriverSound[GetModelDriverSound( nModelIndex )]
set udg_VictoryString = GetPlayerName( Player(nPlayerIndex) ) + " has raced to victory at a stunning time of: " + Second2String( R2I(udg_TimeUsed[nPlayerIndex]), false )
endif
set u = CreateUnit( Player(nPlayerIndex), nDriverType, GetRectCenterX(rct), GetRectCenterY(rct), rAngle )
call SetUnitAnimationByIndex( u, GetModelAnimVictoryID(nModelIndex) )
return u
endfunction
function CreateCinematicDrivers takes nothing returns unit
local integer nPlace = 0
local integer nNum = udg_PlaceNum
local unit uFirst = null
if ( nNum > 3 ) then
set nNum = 3
endif
loop
exitwhen nPlace >= nNum
if ( nPlace == 0 ) then
set uFirst = CreateCinematicDriverSingle( nPlace )
else
call CreateCinematicDriverSingle( nPlace )
endif
set nPlace = nPlace + 1
endloop
return uFirst
endfunction
//===========================================================================
function InitTrig_Ending_Cinematic_Functions takes nothing returns nothing
endfunction