Page 1 of 1

Help with mini campaign script

Posted: Mon Mar 09, 2009 7:03 pm
by Commander_Fett
I was trying to set up a mini campaign in the death star, but I'm running into some problems; the campaign won't start. I can chose the side I want to join, and after that, no objectives pop up. could someone help me out with this?

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

-- load the gametype script
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("setup_teams")
---------------------------------------------------------------------------
-- 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 ScriptPostLoad()

TrashStuff();
PlayAnimExtend();
PlayAnimTakExtend();

BlockPlanningGraphArcs("compactor")
OnObjectKillName(CompactorConnectionOn, "grate01")

DisableBarriers("start_room_barrier")
DisableBarriers("dr_left")
DisableBarriers("circle_bar1")
DisableBarriers("circle_bar2")

-- handle reinforcment loss and defeat condition
OnCharacterDeathTeam(function(character, killer) AddReinforcements(1, -1) end, 1)
OnTicketCountChange(function(team, count) if count == 0 then MissionDefeat(team) end end)

OnObjectRespawnName(PlayAnimExtend, "Panel-Chasm");
OnObjectKillName(PlayAnimRetract, "Panel-Chasm");

OnObjectRespawnName(PlayAnimTakExtend, "Panel-Tak");
OnObjectKillName(PlayAnimTakRetract, "Panel-Tak");

KillObject("CP6")

SetAIDifficulty(0, 2, "hard")
AllowAISpawn(ATT, false)
AllowAISpawn(DEF, true)
EnableSPScriptedHeroes()
ScriptCB_SetGameRules("campaign")

onfirstspawn = OnCharacterSpawn(
function(character)
if character == 0 then
ShowPopup("level.geo1.hints.hints")
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
BeginObjectivesTimer()
ScriptCB_EnableCommandPostVO(0)

end
end)
SetProperty("CP1", "CaptureRegion", "")
SetProperty("CP2", "CaptureRegion", "")
SetProperty("CP3", "CaptureRegion", "")
SetProperty("CP4", "CaptureRegion", "")
SetProperty("CP5", "CaptureRegion", "")
-- SetProperty("CP6", "CaptureRegion", "")
SetProperty("CP7", "CaptureRegion", "")
SetProperty("CP1", "Team", 1)
SetProperty("CP4", "Team", 2)
SetProperty("CP5", "Team", 2)
-- SetProperty("CP6", "Team", 2)
SetProperty("CP7", "Team", 2)
KillObject("CP3")
KillObject("CP4")
KillObject("CP5")
KillObject("CP7")
SetClassProperty ("cis_hero_jangofett","MaxHealth",2500)

--kill 10 of their riflemen
Objective1= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.mwp.dea.bounty1", popupText = "level.mwp.dea.bounty1_popup"}

Dclass = TargetType:New{classname = "enm_inf_rifleman", killLimit = 10}
Objective1:AddTarget(Dclass)

Objective1.OnStart = function(self)
Objective1.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "CP2")
Objective1.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "CP2")
end

Objective1.OnComplete = function(self)
DeleteAIGoal(Objective1.Dclass_cpGoal1)
DeleteAIGoal(Objective1.Dclass_cpGoal2)
RespawnObject("CP3")
RespawnObject("CP4")
KillObject("CP2")
end



--kill 5 concord dawn dudes
Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.mwp.dea.bounty2", popupText = "level.mwp.dea.bounty2_popup"}

Dclass = TargetType:New{classname = "enm_inf_concord1", killLimit = 5}
Objective2:AddTarget(Dclass)

Objective2.OnStart = function(self)
Objective2.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "CP4")
Objective2.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "CP4")
end

Objective2.OnComplete = function(self)
DeleteAIGoal(Objective2.Dclass_cpGoal1)
DeleteAIGoal(Objective2.Dclass_cpGoal2)
RespawnObject("CP2")
end



--kill 3 of jaba's guys
Objective3= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.mwp.dea.bounty3", popupText = "level.mwp.dea.bounty3_popup"}

Dclass = TargetType:New{classname = "gam_inf_gamorreanguard", killLimit = 3}
Objective3:AddTarget(Dclass)

Objective3.OnStart = function(self)
Objective3.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "CP7")
Objective3.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "CP7")
end

Objective3.OnComplete = function(self)
DeleteAIGoal(Objective3.Dclass_cpGoal1)
DeleteAIGoal(Objective3.Dclass_cpGoal2)
end



--kill 1 leader
Objective4= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.mwp.dea.bounty4", popupText = "level.mwp.dea.bounty4_popup"}

Dclass = TargetType:New{classname = "gar_inf_temple_soldier", killLimit = 1}
Objective4:AddTarget(Dclass)

Objective4.OnStart = function(self)
Objective4.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "CP2")
Objective4.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "CP2")
end

Objective4.OnComplete = function(self)
DeleteAIGoal(Objective4.Dclass_cpGoal1)
DeleteAIGoal(Objective4.Dclass_cpGoal2)
end



--end



function BeginObjectivesTimer()
beginobjectivestimer = CreateTimer("beginobjectivestimer")
OnTimerElapse(BeginObjectives, beginobjectivestimer)
SetTimerValue(beginobjectivestimer, 4)
StartTimer(beginobjectivestimer)
end

function BeginObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 6}
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective3)
objectiveSequence:AddObjectiveSet(Objective4)

objectiveSequence:Start()



end

end


function CompactorConnectionOn()
UnblockPlanningGraphArcs ("compactor")
end
--START BRIDGEWORK!

-- OPEN
function PlayAnimExtend()
PauseAnimation("bridgeclose");
RewindAnimation("bridgeopen");
PlayAnimation("bridgeopen");

-- allow the AI to run across it
UnblockPlanningGraphArcs("Connection122");
DisableBarriers("BridgeBarrier");

end
-- CLOSE
function PlayAnimRetract()
PauseAnimation("bridgeopen");
RewindAnimation("bridgeclose");
PlayAnimation("bridgeclose");

-- prevent the AI from running across it
BlockPlanningGraphArcs("Connection122");
EnableBarriers("BridgeBarrier");

end

--START BRIDGEWORK TAK!!!

-- OPEN
function PlayAnimTakExtend()
PauseAnimation("TakBridgeOpen");
RewindAnimation("TakBridgeClose");
PlayAnimation("TakBridgeClose");

-- allow the AI to run across it
UnblockPlanningGraphArcs("Connection128");
DisableBarriers("Barrier222");

end
-- CLOSE
function PlayAnimTakRetract()
PauseAnimation("TakBridgeClose");
RewindAnimation("TakBridgeOpen");
PlayAnimation("TakBridgeOpen");

-- prevent the AI from running across it
BlockPlanningGraphArcs("Connection128");
EnableBarriers("Barrier222");

end

function TrashStuff()

trash_open = 1
trash_closed = 0

trash_timer = CreateTimer("trash_timer")
SetTimerValue(trash_timer, 7)
StartTimer(trash_timer)
trash_death = OnTimerElapse(
function(timer)
if trash_open == 1 then
AddDeathRegion("deathregion")
SetTimerValue(trash_timer, 5)
StartTimer(trash_timer)
trash_closed = 1
trash_open = 0
print("death region added")

elseif trash_closed == 1 then
RemoveRegion("deathregion")
SetTimerValue(trash_timer, 15)
StartTimer(trash_timer)
print("death region removed")
trash_closed = 0
trash_open = 1
end
end,
trash_timer
)
end


function ScriptInit()
StealArtistHeap(650*1024)
-- Designers, these two lines *MUST* be first.
SetPS2ModelMemory(4200000)
ReadDataFile("ingame.lvl")

AISnipeSuitabilityDist(30)

-- Republic Attacking (attacker is always #1)
local REP = 1
local CIS = 2
-- These variables do not change
local ATT = 1
local DEF = 2

ReadDataFile("sound\\dea.lvl;dea1cw")

ReadDataFile("dc:SIDE\\man.lvl",
"cis_hero_jangofett")
ReadDataFile("SIDE\\gam.lvl",
"gam_inf_gamorreanguard")
ReadDataFile("dc:SIDE\\enm.lvl",
"enm_inf_concord1",
"enm_inf_rifleman",
"gar_inf_temple_soldier")

SetAttackingTeam(ATT)

SetupTeams{
rep = {
team = REP,
units = 1,
reinforcements = 1,
soldier = { "cis_hero_jangofett",1, 1},

},
cis = {
team = CIS,
units = 20,
reinforcements = -1,
soldier = { "enm_inf_rifleman",1, 11},
assault = { "enm_inf_concord1",1,5},
engineer = { "gam_inf_gamorreanguard",1,3},
sniper = { "gar_inf_temple_soldier",1,1},
}
}


-- Level Stats
ClearWalkers()
AddWalkerType(0, 2)
local weaponNum = 220
SetMemoryPoolSize ("Aimer", 10)
SetMemoryPoolSize ("AmmoCounter", weaponNum)
SetMemoryPoolSize ("BaseHint", 300)
SetMemoryPoolSize ("EnergyBar", weaponNum)
SetMemoryPoolSize ("EntityFlyer", 6)
SetMemoryPoolSize ("EntityLight", 100)
SetMemoryPoolSize ("EntitySoundStatic", 30)
SetMemoryPoolSize ("MountedTurret", 2)
SetMemoryPoolSize ("Navigator", 45)
SetMemoryPoolSize ("Obstacle", 270)
SetMemoryPoolSize ("PathFollower", 45)
SetMemoryPoolSize ("PathNode", 512)
SetMemoryPoolSize ("SoundSpaceRegion", 50)
SetMemoryPoolSize ("TreeGridStack", 250)
SetMemoryPoolSize ("Weapon", weaponNum)


-- SetMemoryPoolSize("Obstacle", 725)
SetSpawnDelay(10.0, 0.25)
ReadDataFile("dea\\dea1.lvl", "dea1_Conquest")
SetDenseEnvironment("false")

SetMaxFlyHeight(72)
SetMaxPlayerFlyHeight(72)

AddDeathRegion("DeathRegion01")
AddDeathRegion("DeathRegion02")
AddDeathRegion("DeathRegion03")
AddDeathRegion("DeathRegion04")
AddDeathRegion("DeathRegion05")

-- Sound Stats

voiceSlow = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)

voiceQuick = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "cw_music")
OpenAudioStream("sound\\dea.lvl", "dea1")
OpenAudioStream("sound\\dea.lvl", "dea1")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
--OpenAudioStream("sound\\dea.lvl", "dea1_emt")

--this goes for all MWP maps-------------------------------------------------------------------------------------------------------------
SetBleedingVoiceOver(REP, REP, "rep_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(REP, CIS, "rep_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, REP, "rep_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, CIS, "rep_off_com_report_us_overwhelmed", 1)

SetLowReinforcementsVoiceOver(REP, REP, "rep_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(REP, CIS, "rep_off_victory_im", .1, 1)
SetLowReinforcementsVoiceOver(CIS, CIS, "rep_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(CIS, REP, "rep_off_victory_im", .1, 1)

SetOutOfBoundsVoiceOver(2, "Repleaving")
SetOutOfBoundsVoiceOver(1, "Repleaving")
--end------------------------------------------------------------------------------------------------------------------------------------

SetAmbientMusic(REP, 1.0, "rep_dea_amb_start", 0,1)
SetAmbientMusic(REP, 0.8, "rep_dea_amb_middle", 1,1)
SetAmbientMusic(REP, 0.2,"rep_dea_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "cis_dea_amb_start", 0,1)
SetAmbientMusic(CIS, 0.8, "cis_dea_amb_middle", 1,1)
SetAmbientMusic(CIS, 0.2,"cis_dea_amb_end", 2,1)

SetVictoryMusic(REP, "rep_dea_amb_victory")
SetDefeatMusic (REP, "rep_dea_amb_defeat")
SetVictoryMusic(CIS, "cis_dea_amb_victory")
SetDefeatMusic (CIS, "cis_dea_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
--Tat 1 - Dune Sea
--Crawler
AddCameraShot(-0.404895, 0.000992, -0.514360, -0.002240, -121.539894, 62.536297, -257.699493)
--Homestead
AddCameraShot(0.040922, -0.004049, -0.994299, -0.098381, -103.729523, 55.546598, -225.360893)
--Sarlac Pit
AddCameraShot(-1.0, 0.0, -0.514360, 0.0, -55.381485, 50.450953, -96.514324)

end

Re: Help with mini campaign script

Posted: Mon Mar 09, 2009 8:10 pm
by Fiodis
Have you tried using a timer?

Re: Help with mini campaign script

Posted: Mon Mar 09, 2009 8:22 pm
by Commander_Fett
What? All I did was write the script post load stuff in the campaignscripter, then copy it over to the deathstar conquest LUA and add the deathstar stuff in for the doors and whatnot.

EDIT: here's my script post load section condensed. I can't tell what's wrong with it. :cry:
Hidden/Spoiler:
function ScriptPostLoad()





SetAIDifficulty(0, 2, "hard")
AllowAISpawn(ATT, false)
AllowAISpawn(DEF, true)
EnableSPScriptedHeroes()
ScriptCB_SetGameRules("campaign")

onfirstspawn = OnCharacterSpawn(
function(character)
if character == 0 then
ShowPopup("level.geo1.hints.hints")
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
BeginObjectivesTimer()
ScriptCB_EnableCommandPostVO(0)

end
end)
SetProperty("CP1", "CaptureRegion", "")
SetProperty("CP2", "CaptureRegion", "")
SetProperty("CP3", "CaptureRegion", "")
SetProperty("CP4", "CaptureRegion", "")
SetProperty("CP5", "CaptureRegion", "")
-- SetProperty("CP6", "CaptureRegion", "")
SetProperty("CP7", "CaptureRegion", "")
SetProperty("CP1", "Team", 1)
SetProperty("CP4", "Team", 2)
SetProperty("CP5", "Team", 2)
-- SetProperty("CP6", "Team", 2)
SetProperty("CP7", "Team", 2)
KillObject("CP3")
KillObject("CP4")
KillObject("CP5")
KillObject("CP7")
KillObject("CP6")
SetClassProperty ("cis_hero_jangofett","MaxHealth",2500)

--kill 10 of their riflemen
Objective1= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.mwp.dea.bounty1", popupText = "level.mwp.dea.bounty1_popup"}

Dclass = TargetType:New{classname = "enm_inf_rifleman", killLimit = 10}
Objective1:AddTarget(Dclass)

Objective1.OnStart = function(self)
Objective1.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "CP2")
Objective1.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "CP2")
end

Objective1.OnComplete = function(self)
DeleteAIGoal(Objective1.Dclass_cpGoal1)
DeleteAIGoal(Objective1.Dclass_cpGoal2)
RespawnObject("CP3")
RespawnObject("CP4")
KillObject("CP2")
end



--kill 5 concord dawn dudes
Objective2= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.mwp.dea.bounty2", popupText = "level.mwp.dea.bounty2_popup"}

Dclass = TargetType:New{classname = "enm_inf_concord1", killLimit = 5}
Objective2:AddTarget(Dclass)

Objective2.OnStart = function(self)
Objective2.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "CP4")
Objective2.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "CP4")
end

Objective2.OnComplete = function(self)
DeleteAIGoal(Objective2.Dclass_cpGoal1)
DeleteAIGoal(Objective2.Dclass_cpGoal2)
RespawnObject("CP2")
end



--kill 3 of jaba's guys
Objective3= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.mwp.dea.bounty3", popupText = "level.mwp.dea.bounty3_popup"}

Dclass = TargetType:New{classname = "gam_inf_gamorreanguard", killLimit = 3}
Objective3:AddTarget(Dclass)

Objective3.OnStart = function(self)
Objective3.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "CP7")
Objective3.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "CP7")
end

Objective3.OnComplete = function(self)
DeleteAIGoal(Objective3.Dclass_cpGoal1)
DeleteAIGoal(Objective3.Dclass_cpGoal2)
end



--kill 1 leader
Objective4= ObjectiveAssault:New{teamATT = ATT, teamDEF = DEF,
text = "level.mwp.dea.bounty4", popupText = "level.mwp.dea.bounty4_popup"}

Dclass = TargetType:New{classname = "gar_inf_temple_soldier", killLimit = 1}
Objective4:AddTarget(Dclass)

Objective4.OnStart = function(self)
Objective4.Dclass_cpGoal1 = AddAIGoal(ATT, "Defend", 100, "CP2")
Objective4.Dclass_cpGoal2 = AddAIGoal(DEF, "Defend", 100, "CP2")
end

Objective4.OnComplete = function(self)
DeleteAIGoal(Objective4.Dclass_cpGoal1)
DeleteAIGoal(Objective4.Dclass_cpGoal2)
end



end



function BeginObjectivesTimer()
beginobjectivestimer = CreateTimer("beginobjectivestimer")
OnTimerElapse(BeginObjectives, beginobjectivestimer)
SetTimerValue(beginobjectivestimer, 3)
StartTimer(beginobjectivestimer)
end

function BeginObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 6}
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective3)
objectiveSequence:AddObjectiveSet(Objective4)

objectiveSequence:Start()



end

Re: Help with mini campaign script

Posted: Tue Mar 10, 2009 1:23 pm
by theultimat
You need to tell the game that it's a campaign mode. The game has to have the following in the ScriptCB_DoFile section of the LUA:

Code: Select all

ScriptCB_SetGameRules("Campaign")
There may be a few more, I can't remember...