[code]--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_SetGameRules("Campaign")
-- REP Attacking (attacker is always #1)
ALL = 1;
IMP = 2;
TAR = 3;
CIV = 4;
-- These variables do not change
ATT = ALL;
DEF = IMP;
function ScriptPostLoad()
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
objectives_timer = CreateTimer("objectives_timer")
SetTimerValue(objectives_timer, 2)
StartTimer(objectives_timer)
begin_objectives = OnTimerElapse(
function(timer)
StartObjectives ()
ScriptCB_EnableCommandPostVO(1)
end,
objectives_timer
)
end
end
)
ForceHumansOntoTeam1()
--This defines the CPs. These need to happen first
CP1 = CommandPost:New{name = "cp1"}
CP2 = CommandPost:New{name = "cp2"}
CP3 = CommandPost:New{name = "cp3"}
CP6 = CommandPost:New{name = "cp6"}
CP7 = CommandPost:New{name = "cp7"}
CP8 = CommandPost:New{name = "cp8"}
--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, textATT = "game.modes.con", textDEF = "game.modes.con2", multiplayerRules = true,
popupText = "game.modes.con",}
--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp6)
conquest:AddCommandPost(cp7)
conquest:AddCommandPost(cp8)
conquest:Start()
--Setup Timer--
timePop = CreateTimer("timePop")
SetTimerValue(timePop, 3.0)
dumb = CreateTimer("dumb")
SetTimerValue(dumb, 0.5)
StartTimer(dumb)
OnTimerElapse(
function(timer)
ClearAIGoals(2)
AddAIGoal(2, "follow", 1000, GetCharacterUnit(target))
MapAddEntityMarker(GetCharacterUnit(target), "hud_objective_icon_circle", 5, 1, "RED", true, true, true)
DestroyTimer(dumb)
end,
dumb
)
SetTeamAsFriend(2,1)
SetTeamAsNeutral(1,3)
SetTeamAsFriend(3,1)
SetTeamAsFriend(1,2)
SetTeamAsFriend(4,1)
SetTeamAsFriend(4,2)
SetTeamAsFriend(4,3)
SetTeamAsFriend(1,4)
SetTeamAsFriend(2,4)
SetTeamAsFriend(3,4)
SetTeamAsFriend(2,3)
SetTeamAsFriend(3,2)
tarhp = nil
deathcheck = OnCharacterDeath(
function(character, killer)
if GetNumTeamMembersAlive(1) == 0 then
MissionDefeat(1)
elseif GetNumTeamMembersAlive(3) == 0 then
ClearAIGoals(2)
AddAIGoal(2, "destroy", 1000, GetCharacterUnit(killer))
ActivateRegion("CP2_Control")
SetTeamAsEnemy(1,2)
SetTeamAsEnemy(2,1)
MapAddRegionMarker("CP2_Control", "hud_objective_icon_circle", 5, 1, "BLUE", true, true, true)
end
end)
i = 1
TEAM = OnCharacterDeath(
function(character, killer)
if GetObjectTeam(killer) == 1 then
SpawnCharacter(GetTeamMember(1,i),GetEntityMatrix(killer))
i = i + 1
end
end)
conquestComplete = OnEnterRegion(
function(region, character)
conquest:Complete(ATT)
end,
"CP2_Control"
)
x = 1
AllowAISpawn(1, false)
dmgcheck = OnObjectDamage(function(object, damager)
print("check")
if GetObjectTeam(GetCharacterUnit(damager)) == 1 and x == 1 then
ClearAIGoals(3)
AddAIGoal(3, "follow", 1000, "com_item_weaponrecharge0")
ClearAIGoals(2)
AddAIGoal(2, "destroy", 500, GetCharacterUnit(damager))
AddAIGoal(2, "follow", 500, GetCharacterUnit(target))
SetTeamAsEnemy(1,2)
SetTeamAsEnemy(2,1)
x = 2
end
end)
SetTeamAggressiveness(2, 1.0)
DisableAIAutoBalance()
SetAIDifficulty(0, 3)
conquest.OnStart = function (self)
ForceHumansOntoTeam1()
AICanCaptureCP("cp1", 2, false)
AICanCaptureCP("cp2", 2, false)
AICanCaptureCP("cp3", 2, false)
AICanCaptureCP("cp6", 2, false)
AICanCaptureCP("cp7", 2, false)
AICanCaptureCP("cp8", 2, false)
AICanCaptureCP("cp1", 3, false)
AICanCaptureCP("cp2", 3, false)
AICanCaptureCP("cp3", 3, false)
AICanCaptureCP("cp6", 3, false)
AICanCaptureCP("cp7", 3, false)
AICanCaptureCP("cp8", 3, false)
SetAIDifficulty(999, -999, "hard")
target = GetTeamMember(3,0)
Deathmatch4 = AddAIGoal(4, "deathmatch", 100)
Deathmatch3 = AddAIGoal(3, "deathmatch", 100)
--AddAIGoal(2, "deathmatch", 100)
SelectCharacterClass(target, "imp_inf_officer")
SpawnCharacter(target, GetPathPoint("CP3_SpawnPath", 0)) --target spawnpoint
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
MoveCameraToEntity(GetCharacterUnit(target))
AllowAISpawn(2, false)
AllowAISpawn(3, false)
AllowAISpawn(4, false)
tarhp = GetObjectHealth(GetCharacterUnit(target))
--ShowMessageText("level.abc.kill")
end
end
)
end
conquest.OnComplete = function (self)
ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(Deathmatch4)
DeleteAIGoal(Deathmatch3)
end
end
ForceHumansOntoTeam1()
--This defines the CPs. These need to happen first
CP1 = CommandPost:New{name = "cp1"}
CP2 = CommandPost:New{name = "cp2"}
CP3 = CommandPost:New{name = "cp3"}
CP6 = CommandPost:New{name = "cp6"}
CP7 = CommandPost:New{name = "cp7"}
CP8 = CommandPost:New{name = "cp8"}
--This sets up the actual objective. This needs to happen after cp's are defined
conquest2 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, textATT = "game.modes.con", textDEF = "game.modes.con2", multiplayerRules = true,
popupText = "game.modes.con",}
--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest2:AddCommandPost(cp1)
conquest2:AddCommandPost(cp2)
conquest2:AddCommandPost(cp3)
conquest2:AddCommandPost(cp6)
conquest2:AddCommandPost(cp7)
conquest2:AddCommandPost(cp8)
conquest2:Start()
--Setup Timer--
timePop = CreateTimer("timePop")
SetTimerValue(timePop, 3.0)
dumb = CreateTimer("dumb")
SetTimerValue(dumb, 0.5)
StartTimer(dumb)
OnTimerElapse(
function(timer)
ClearAIGoals(2)
AddAIGoal(2, "follow", 1000, GetCharacterUnit(target))
MapAddEntityMarker(GetCharacterUnit(target), "hud_objective_icon_circle", 5, 1, "RED", true, true, true)
DestroyTimer(dumb)
end,
dumb
)
SetTeamAsFriend(2,1)
SetTeamAsNeutral(1,3)
SetTeamAsFriend(3,1)
SetTeamAsFriend(1,2)
SetTeamAsFriend(4,1)
SetTeamAsFriend(4,2)
SetTeamAsFriend(4,3)
SetTeamAsFriend(1,4)
SetTeamAsFriend(2,4)
SetTeamAsFriend(3,4)
SetTeamAsFriend(2,3)
SetTeamAsFriend(3,2)
tarhp = nil
deathcheck = OnCharacterDeath(
function(character, killer)
if GetNumTeamMembersAlive(1) == 0 then
MissionDefeat(1)
elseif GetNumTeamMembersAlive(3) == 0 then
ClearAIGoals(2)
AddAIGoal(2, "destroy", 1000, GetCharacterUnit(killer))
ActivateRegion("CP2_Control")
SetTeamAsEnemy(1,2)
SetTeamAsEnemy(2,1)
MapAddRegionMarker("CP2_Control", "hud_objective_icon_circle", 5, 1, "BLUE", true, true, true)
end
end)
i = 1
TEAM = OnCharacterDeath(
function(character, killer)
if GetObjectTeam(killer) == 1 then
SpawnCharacter(GetTeamMember(1,i),GetEntityMatrix(killer))
i = i + 1
end
end)
conquest2Complete = OnEnterRegion(
function(region, character)
conquest2:Complete(ATT)
end,
"CP2_Control"
)
x = 1
AllowAISpawn(1, false)
dmgcheck = OnObjectDamage(function(object, damager)
print("check")
if GetObjectTeam(GetCharacterUnit(damager)) == 1 and x == 1 then
ClearAIGoals(3)
AddAIGoal(3, "follow", 1000, "com_item_weaponrecharge0")
ClearAIGoals(2)
AddAIGoal(2, "destroy", 500, GetCharacterUnit(damager))
AddAIGoal(2, "follow", 500, GetCharacterUnit(target))
SetTeamAsEnemy(1,2)
SetTeamAsEnemy(2,1)
x = 2
end
end)
SetTeamAggressiveness(2, 1.0)
DisableAIAutoBalance()
SetAIDifficulty(0, 3)
conquest2.OnStart = function (self)
ForceHumansOntoTeam1()
AICanCaptureCP("cp1", 2, false)
AICanCaptureCP("cp2", 2, false)
AICanCaptureCP("cp3", 2, false)
AICanCaptureCP("cp6", 2, false)
AICanCaptureCP("cp7", 2, false)
AICanCaptureCP("cp8", 2, false)
AICanCaptureCP("cp1", 3, false)
AICanCaptureCP("cp2", 3, false)
AICanCaptureCP("cp3", 3, false)
AICanCaptureCP("cp6", 3, false)
AICanCaptureCP("cp7", 3, false)
AICanCaptureCP("cp8", 3, false)
SetAIDifficulty(999, -999, "hard")
target = GetTeamMember(3,0)
Deathmatch4 = AddAIGoal(4, "deathmatch", 100)
Deathmatch3 = AddAIGoal(3, "deathmatch", 100)
--AddAIGoal(2, "deathmatch", 100)
SelectCharacterClass(target, "imp_inf_officer")
SpawnCharacter(target, GetPathPoint("CP3_SpawnPath", 0)) --target spawnpoint
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
MoveCameraToEntity(GetCharacterUnit(target))
AllowAISpawn(2, false)
AllowAISpawn(3, false)
AllowAISpawn(4, false)
tarhp = GetObjectHealth(GetCharacterUnit(target))
--ShowMessageText("level.abc.kill")
end
end
)
end
conquest2.OnComplete = function (self)
ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(Deathmatch4)
DeleteAIGoal(Deathmatch3)
end
---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------
function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 4.0}
objectiveSequence:AddObjectiveSet(conquest)
objectiveSequence:AddObjectiveSet(conquest2)
objectiveSequence:Start()
end
function ScriptInit()
-- Designers, these two lines *MUST* be first!
StealArtistHeap(256*1024)
SetPS2ModelMemory(2097152 + 65536 * 10)
ReadDataFile("ingame.lvl")
SetTeamAggressiveness(ALL, 0.95)
SetTeamAggressiveness(IMP, 0.95)
SetMaxFlyHeight(40)
SetMaxPlayerFlyHeight(40)
ReadDataFile("sound\\tat.lvl;tat2gcw")
ReadDataFile("SIDE\\all.lvl",
"all_inf_rifleman",
"all_inf_rocketeer",
"all_inf_sniper",
"all_inf_engineer",
"all_inf_officer",
"all_inf_wookiee",
"all_hero_hansolo_tat")
ReadDataFile("SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_rocketeer",
"imp_inf_engineer",
"imp_inf_sniper",
"imp_inf_officer",
"imp_inf_dark_trooper",
"imp_hero_bobafett",
"imp_fly_destroyer_dome" )
ReadDataFile("SIDE\\des.lvl",
"tat_inf_jawa")
ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_tat_barge",
"tur_bldg_laser")
SetupTeams{
all = {
team = ALL,
units = 20,
reinforcements = -1,
soldier = { "all_inf_rifleman",10, 10},
assault = { "all_inf_rocketeer",0, 0},
engineer = { "all_inf_engineer",0, 0},
sniper = { "all_inf_sniper",0, 0},
officer = {"all_inf_officer",0, 0},
special = { "all_inf_wookiee",0, 0},
},
imp = {
team = IMP,
units = 10,
reinforcements = -1,
officer = {"imp_inf_rifleman",12, 12},
}
}
SetTeamName (3, "target")
AddUnitClass (3, "imp_inf_officer", 1)
SetUnitCount (3, 1)
SetTeamName (4, "citizens")
AddUnitClass (4, "all_inf_rifleman", 10)
AddUnitClass (4, "all_inf_rocketeer", 10)
AddUnitClass (4, "all_inf_engineer", 10)
AddUnitClass (4, "all_inf_sniper", 10)
AddUnitClass (4, "all_inf_officer", 10)
SetUnitCount (4, 50)
SetHeroClass(IMP, "imp_inf_officer")
SetHeroClass(ALL, "all_hero_luke")
-- Level Stats
ClearWalkers()
AddWalkerType(0, 3) -- special -> droidekas
AddWalkerType(1, 0) -- 1x2 (1 pair of legs)
AddWalkerType(2, 0) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 0) -- 3x2 (3 pairs of legs)
local weaponCnt = 230
SetMemoryPoolSize("Aimer", 23)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 325)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 19)
SetMemoryPoolSize("EntityFlyer", 6) -- to account for rocket upgrade
SetMemoryPoolSize("EntityHover", 1)
SetMemoryPoolSize("EntitySoundStream", 2)
SetMemoryPoolSize("EntitySoundStatic", 43)
SetMemoryPoolSize("SoldierAnimation", 500)
SetMemoryPoolSize("MountedTurret", 15)
SetMemoryPoolSize("Navigator", 50)
SetMemoryPoolSize("Obstacle", 667)
SetMemoryPoolSize("PathFollower", 50)
SetMemoryPoolSize("PathNode", 256)
SetMemoryPoolSize("TreeGridStack", 325)
SetMemoryPoolSize("UnitAgent", 50)
SetMemoryPoolSize("UnitController", 50)
SetMemoryPoolSize("Weapon", weaponCnt)
SetSpawnDelay(0.0, 0.0)
ReadDataFile("TAT\\tat2.lvl", "tat2_con")
SetDenseEnvironment("false")
-- Sound Stats
voiceSlow = OpenAudioStream("sound\\global.lvl", "all_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "des_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)
voiceQuick = OpenAudioStream("sound\\global.lvl", "all_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_quick", voiceQuick)
OpenAudioStream("sound\\global.lvl", "gcw_music")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\tat.lvl", "tat2")
OpenAudioStream("sound\\tat.lvl", "tat2")
SetBleedingVoiceOver(ALL, ALL, "all_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(ALL, IMP, "all_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, ALL, "imp_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, IMP, "imp_off_com_report_us_overwhelmed", 1)
SetLowReinforcementsVoiceOver(ALL, ALL, "all_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, ALL, "all_off_victory_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, IMP, "imp_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, ALL, "imp_off_victory_im", .1, 1)
SetOutOfBoundsVoiceOver(1, "allleaving")
SetOutOfBoundsVoiceOver(2, "impleaving")
SetAmbientMusic(ALL, 1.0, "all_tat_amb_start", 0,1)
SetAmbientMusic(ALL, 0.8, "all_tat_amb_middle", 1,1)
SetAmbientMusic(ALL, 0.2,"all_tat_amb_end", 2,1)
SetAmbientMusic(IMP, 1.0, "imp_tat_amb_start", 0,1)
SetAmbientMusic(IMP, 0.8, "imp_tat_amb_middle", 1,1)
SetAmbientMusic(IMP, 0.2,"imp_tat_amb_end", 2,1)
SetVictoryMusic(ALL, "imp_tat_amb_victory")
SetDefeatMusic (ALL, "imp_tat_amb_defeat")
SetVictoryMusic(IMP, "imp_tat_amb_victory")
SetDefeatMusic (IMP, "imp_tat_amb_defeat")
SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--SetSoundEffect("WeaponUnableSelect", "com_weap_inf_weaponchange_null")
--SetSoundEffect("WeaponModeUnableSelect", "com_weap_inf_modechange_null")
SetSoundEffect("SpawnDisplayUnitChange", "shell_select_unit")
SetSoundEffect("SpawnDisplayUnitAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplaySpawnPointChange", "shell_select_change")
SetSoundEffect("SpawnDisplaySpawnPointAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplayBack", "shell_menu_exit")
SetAttackingTeam(ATT)
-- Camera Stats
--Tat2 Mos Eisley
AddCameraShot(0.974338, -0.222180, 0.035172, 0.008020, -82.664650, 23.668301, 43.955681);
AddCameraShot(0.390197, -0.089729, -0.893040, -0.205362, 23.563562, 12.914885, -101.465561);
AddCameraShot(0.169759, 0.002225, -0.985398, 0.012916, 126.972809, 4.039628, -22.020613);
AddCameraShot(0.677453, -0.041535, 0.733016, 0.044942, 97.517807, 4.039628, 36.853477);
AddCameraShot(0.866029, -0.156506, 0.467299, 0.084449, 7.685640, 7.130688, -10.895234);
end
[/code]