Survival mode script

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
bobfinkl
Rebel Colonel
Rebel Colonel
Posts: 593
Joined: Sun Jul 13, 2008 9:01 am
Projects :: Lots of unreleased stuff
Games I'm Playing :: Life
xbox live or psn: No gamertag set
Location: The quaint little city gametoast.

Survival mode script

Post by bobfinkl »

Well I've been trying to add new content to my map Galidraan but my new script just refuses to work, I'm making a survival mode and I've gotten the first objective to work fine but after that the second objective doesn't appear and the map continues until your team runs out of reinforcements.

Here is my lua:
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("Ambush")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_SetGameRules("Campaign")

-- Rebels Attacking (attacker is always #1)
local ALL = 1
local IMP = 2
-- These variables do not change
local ATT = 1
local DEF = 2

function ScriptPostLoad()

ScriptCB_SetGameRules("Campaign")
KillObject("cp1")
KillObject("cp4")
KillObject("cp3")
KillObject("tank")
KillObject("tank1")
SetProperty("cp2", "CaptureRegion", "")
SetProperty("cp6", "CaptureRegion", "")
SetProperty("cp7", "CaptureRegion", "")
SetProperty("cp5", "Team", 1)
SetProperty("cp8", "Team", 1)
SetProperty("cp2", "Team", 2)
SetProperty("cp6", "Team", 2)
SetProperty("cp7", "Team", 2)
KillObject("transport")
MapRemoveEntityMarker("cp2")
MapRemoveEntityMarker("cp6")
MapRemoveEntityMarker("cp7")
AddAIGoal(ATT, "Defend", 500, "cp8")
AddAIGoal(ATT, "Deathmatch", 200)
AddAIGoal(DEF, "Defend", 800, "cp5")
AddAIGoal(DEF, "Defend", 500, "cp8")
AddAIGoal(DEF, "Deathmatch", 200)

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(0)
end,
objectives_timer
)
end
end
)

--Head towards bunker objective #1
Objective1CP = CommandPost:New{"cp5"}
Objective1 = ObjectiveConquest:New{TeamATT = ATT, -- objective made
text = "level.hoth.s.1", popupText = "level.gad.s.pop.1", -- show objective on screen
timeLimit = 10, timeLimitWinningTeam = 1, AIGoalWeight = 0}
Objective1:AddCommandPost(Objective1CP)
Objective1.OnComplete = function(self)
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 10)
end

Objective2CP = CommandPost:New{"cp5"}
Objective2 = ObjectiveConquest:New{TeamATT = ATT, -- objective made
text = "level.hoth.s.1", popupText = "level.gad.s.pop.1", -- show objective on screen
timeLimit = 60, timeLimitWinningTeam = 1, AIGoalWeight = 0}
Objective2:AddCommandPost(Objective2CP)
Objective2.OnComplete = function(self)
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 10)
end

Objective3 = Objective:New{teamATT = ATT, teamDEF = DEF, text = "level.gad.s.3",
timeLimit = 70, timeLimitWinningTeam = ATT}
Objective3.OnComplete = function(self)
DEF_UnitCount = GetUnitCount(DEF)
SetUnitCount(DEF, DEF_UnitCount + 10)
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 5)
end

Objective4 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level.gad.s.4",
timeLimit = 80, timeLimitWinningTeam = ATT}
Objective4.OnComplete = function(self)
DEF_UnitCount = GetUnitCount(DEF)
SetUnitCount(DEF, DEF_UnitCount + 10)
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 5)
end

BlockPlanningGraphArcs("balance")

DisableBarriers("nobunker1")
DisableBarriers("nobunker2")
DisableBarriers("nobunker3")

SetUberMode(1)

EnableSPHeroRules()

end

function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 2.0 }
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective3)
objectiveSequence:AddObjectiveSet(Objective4)
objectiveSequence:Start()
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 ScriptInit()

ReadDataFile("dc:Load\\common.lvl")

ReadDataFile("ingame.lvl")



SetMaxFlyHeight(40)
SetMaxPlayerFlyHeight(40)


SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo


ReadDataFile("sound\\nab.lvl;nab2gcw")
ReadDataFile("SIDE\\all.lvl",
"all_inf_rifleman_snow",
"all_inf_rocketeer_snow",
"all_inf_sniper_snow",
"all_inf_engineer_snow",
"all_inf_officer_snow",
"all_inf_wookiee_snow",
"all_hero_chewbacca")

ReadDataFile("SIDE\\imp.lvl",
"imp_inf_rifleman_snow",
"imp_inf_rocketeer_snow",
"imp_inf_engineer_snow",
"imp_inf_sniper_snow",
"imp_inf_officer",
"imp_inf_dark_trooper",
"imp_hero_darthvader",
"imp_hover_fightertank" )

ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_tat_barge",
"tur_bldg_chaingun_tripod")

SetupTeams{
all = {
team = ALL,
units = 30,
reinforcements = 150,
soldier = { "all_inf_rifleman_snow",9, 35},
assault = { "all_inf_rocketeer_snow",1,14},
engineer = { "all_inf_engineer_snow",1,14},
sniper = { "all_inf_sniper_snow",1,14},
officer = { "all_inf_officer_snow",1,4},
special = { "all_inf_wookiee_snow",1,4},

},
imp = {
team = IMP,
units = 30,
reinforcements = -1,
soldier = { "imp_inf_rifleman_snow",9, 35},
assault = { "imp_inf_rocketeer_snow",1,14},
engineer = { "imp_inf_engineer_snow",1,14},
sniper = { "imp_inf_sniper_snow",1,14},
officer = { "imp_inf_officer",1,4},
special = { "imp_inf_dark_trooper",1,4},
},
}

SetHeroClass(ALL, "all_hero_chewbacca")
SetHeroClass(IMP, "imp_hero_darthvader")

-- Level Stats
ClearWalkers()
AddWalkerType(0, 0) -- 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 = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 2024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 41)
SetMemoryPoolSize("EntityFlyer", 2)
SetMemoryPoolSize("EntityHover", 32)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("EntitySoundStream", 4)
SetMemoryPoolSize("EntitySoundStatic", 32)
SetMemoryPoolSize("MountedTurret", 32)
SetMemoryPoolSize("Navigator", 128)
SetMemoryPoolSize("Obstacle", 1024)
SetMemoryPoolSize("PathNode", 1024)
SetMemoryPoolSize("SoundSpaceRegion", 64)
SetMemoryPoolSize("TreeGridStack", 1024)
SetMemoryPoolSize("UnitAgent", 128)
SetMemoryPoolSize("UnitController", 128)
SetMemoryPoolSize("Weapon", weaponCnt)

SetSpawnDelay(10.0, 0.25)
ReadDataFile("dc:GAD\\GAD.lvl", "GAD_conquest")
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\\nab.lvl", "nab2")
OpenAudioStream("sound\\nab.lvl", "nab2")
OpenAudioStream("sound\\nab.lvl", "nab2_emt")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")

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(ALL, IMP, "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(2, "Allleaving")
SetOutOfBoundsVoiceOver(1, "Impleaving")

SetAmbientMusic(ALL, 1.0, "all_nab_amb_start", 0,1)
SetAmbientMusic(ALL, 0.8, "all_nab_amb_middle", 1,1)
SetAmbientMusic(ALL, 0.2, "all_nab_amb_end", 2,1)
SetAmbientMusic(IMP, 1.0, "imp_nab_amb_start", 0,1)
SetAmbientMusic(IMP, 0.8, "imp_nab_amb_middle", 1,1)
SetAmbientMusic(IMP, 0.2, "imp_nab_amb_end", 2,1)

SetVictoryMusic(ALL, "all_nab_amb_victory")
SetDefeatMusic (ALL, "all_nab_amb_defeat")
SetVictoryMusic(IMP, "imp_nab_amb_victory")
SetDefeatMusic (IMP, "imp_nab_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")

-- 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
And here are the most suspicious lines in my bfront2.log
Hidden/Spoiler:
Message Severity: 2
.\Source\EntityBuilding.cpp(695)
Building missing explosion "com_weap_bldg_gunturret_exp"
uf_updateClassIndex(): Added class: all_inf_rifleman_snow
uf_updateClassIndex(): Added class: all_inf_rocketeer_snow
uf_updateClassIndex(): Added class: all_inf_sniper_snow
uf_updateClassIndex(): Added class: all_inf_engineer_snow
uf_updateClassIndex(): Added class: all_inf_officer_snow
uf_updateClassIndex(): Added class: all_inf_wookiee_snow
uf_updateClassIndex(): Added class: imp_inf_rifleman_snow
uf_updateClassIndex(): Added class: imp_inf_rocketeer_snow
uf_updateClassIndex(): Added class: imp_inf_sniper_snow
uf_updateClassIndex(): Added class: imp_inf_engineer_snow
uf_updateClassIndex(): Added class: imp_inf_officer
uf_updateClassIndex(): Added class: imp_inf_dark_trooper
uf_updateClassIndex(): Added class: all_hero_chewbacca
uf_updateClassIndex(): Added class: imp_hero_darthvader
utility_functions2: ReadDataFile(): This map's code, mode: gad gad_conquest

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "tank" not found

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "tank1" not found

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "transport" not found

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(3776)
Command Post "noname" not found

Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to perform arithmetic on a nil value
stack traceback:
(none): in function `AddCommandPost'
(none): in function `ScriptPostLoad'


Message Severity: 2
.\Source\ConnectivityGraphFollower.cpp(382)
No valid positions for type [SOLDIER] radius [0.49] in node [Hub26]

Message Severity: 2
.\Source\ConnectivityGraphFollower.cpp(382)
No valid positions for type [SOLDIER] radius [0.49] in node [Hub45]

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(2523)
Timer "victoryTimer" not found

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(2523)
Timer "delayTimer" not found

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(2523)
Timer "loseTimer" not found

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "noname" not found

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "noname" not found
Yodakid
Second Lance Corporal
Second Lance Corporal
Posts: 117
Joined: Sat Nov 22, 2008 5:43 pm
Projects :: Something old
Games I'm Playing :: TES Online AC Unity
xbox live or psn: No gamertag set
Location: Finland

Re: Survival mode script

Post by Yodakid »

Hidden/Spoiler:
--Head towards bunker objective #1
Objective1CP = CommandPost:New{"cp5"}
Objective1 = ObjectiveConquest:New{TeamATT = ATT, -- objective made
text = "level.hoth.s.1", popupText = "level.gad.s.pop.1", -- show objective on screen
timeLimit = 10, timeLimitWinningTeam = 1, AIGoalWeight = 0}
Objective1:AddCommandPost(Objective1CP)
Objective1.OnComplete = function(self)
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 10)
end

Objective2CP = CommandPost:New{"cp5"}
Objective2 = ObjectiveConquest:New{TeamATT = ATT, -- objective made
text = "level.hoth.s.1", popupText = "level.gad.s.pop.1", -- show objective on screen
timeLimit = 60, timeLimitWinningTeam = 1, AIGoalWeight = 0}
Objective2:AddCommandPost(Objective2CP)
Objective2.OnComplete = function(self)
ATT_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATT_ReinforcementCount + 10)
end
Your objective 1 and 2 does look next to identical (exept for the: timeLimit = 60/timeLimit = 10)
Both are saying cp5. And as I can understand it both objectives is for capturing cps. But you can't capture cp5 two times...
User avatar
bobfinkl
Rebel Colonel
Rebel Colonel
Posts: 593
Joined: Sun Jul 13, 2008 9:01 am
Projects :: Lots of unreleased stuff
Games I'm Playing :: Life
xbox live or psn: No gamertag set
Location: The quaint little city gametoast.

Re: Survival mode script

Post by bobfinkl »

Perhaps I'll try putting another objective in there, I'll edit this post once I find out what happens.

EDIT:
No, I can't get any other objectives to work the game just continues until you lose and no new objectives pop up no matter what objective.
Master_Ben
Lieutenant General
Lieutenant General
Posts: 675
Joined: Wed Nov 12, 2008 9:50 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Watching your PC over your shoulder. No, the other sholder....

Re: Survival mode script

Post by Master_Ben »

Can you actually beat the first objective? Because an long as everything is added correctly the next objective should load no matter what after the first objective is beaten.
User avatar
bobfinkl
Rebel Colonel
Rebel Colonel
Posts: 593
Joined: Sun Jul 13, 2008 9:01 am
Projects :: Lots of unreleased stuff
Games I'm Playing :: Life
xbox live or psn: No gamertag set
Location: The quaint little city gametoast.

Re: Survival mode script

Post by bobfinkl »

I can beat it because I don't lose the moment the objectives over, when it ends the map just goes on until you lose.
Master_Ben
Lieutenant General
Lieutenant General
Posts: 675
Joined: Wed Nov 12, 2008 9:50 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Watching your PC over your shoulder. No, the other sholder....

Re: Survival mode script

Post by Master_Ben »

Well... Go for basics. Try to get a victory with one objective, then work up from there.
User avatar
bobfinkl
Rebel Colonel
Rebel Colonel
Posts: 593
Joined: Sun Jul 13, 2008 9:01 am
Projects :: Lots of unreleased stuff
Games I'm Playing :: Life
xbox live or psn: No gamertag set
Location: The quaint little city gametoast.

Re: Survival mode script

Post by bobfinkl »

Alright well I didn't make the script Yodakid did but it's complete.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Survival mode script

Post by [RDH]Zerted »

I am a little confused about what your problem is. Objective 1 starts but never ends? Objective 1 starts, you beat it, but objective 2 never starts? Objective 1 never really starts?
Post Reply