Script Problem [Solved]

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
GAB
1st Lieutenant
1st Lieutenant
Posts: 431
Joined: Sun Jul 03, 2011 8:56 pm
Location: Somewhere around the world
Contact:

Script Problem [Solved]

Post by GAB »

Today I started venturing myself on scripting some objectives. I managed to script the first one but I'm getting this error when munging:
PC_MungeLog wrote:D:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\AL3\AL3c_c.lua:343: `end' expected (to close `function' at line 21) near `<eof>'
ERROR[scriptmunge scripts\AL3\AL3c_c.lua]:Could not read input file.ERROR[scriptmunge scripts\AL3\AL3c_c.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings

ERROR[levelpack mission\AL3c_c.req]:Expecting bracket, but none was found.
File : munged\pc\al3c_c.script.req(1)...

ucft <--
ERROR[levelpack mission\AL3c_c.req]:Expecting bracket, but none was found.
File : munged\pc\al3c_c.script.req(1)...

ucft <--

2 Errors 0 Warnings
Here's my LUA:
Hidden/Spoiler:
[quote]--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("setup_teams")
ScriptCB_SetGameRules("campaign")

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

function ScriptPostLoad() <- This is line 21

--Prepare the map for the mission

SetAIDifficulty(1, 2, "medium")
DisableAIAutoBalance()
AICanCaptureCP("cw_cp1", DEF, false)
SetProperty("turret1","Team",0)
SetProperty("turret2","Team",0)
SetProperty("turret3","Team",0)
SetProperty("turret4","Team",0)
SetProperty("turret5","Team",0)
SetProperty("turret6","Team",0)
SetProperty("turret7","Team",0)
SetProperty("turret8","Team",0)
SetProperty("turret9","Team",0)
SetProperty("turret10","Team",0)
BlockPlanningGraphArcs("entry1")
BlockPlanningGraphArcs("entry2")
BlockPlanningGraphArcs("entry3")
BlockPlanningGraphArcs("entry4")
ScriptCB_SetSpawnDisplayGain(0.2, 0.5)
ClearAIGoals(ATT)
ClearAIGoals(DEF)
--ClearAIGoals(3)
AddDeathRegion("deathregion")

--This delays the objectives until the player spawns
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil

ScriptCB_PlayInGameMusic("")
onfirstspawn = nil
start_timer = CreateTimer("start_timer")
SetTimerValue(start_timer, 2)
StartTimer(start_timer)
begin_objectives = OnTimerElapse(
function()
BeginObjectives()
ReleaseTimerElapse(begin_objectives)
begin_objectives = nil
end,
start_timer
)
end
end)

--OBJECTIVE 1: Destroy the CIS Defense Turrets----------------------------------------------------------------------------------------------------------------------------

Turret1 = Target:New{name = "turret1"}
Turret2 = Target:New{name = "turret2"}
Turret3 = Target:New{name = "turret3"}
Turret4 = Target:New{name = "turret4"}
Turret5 = Target:New{name = "turret5"}
Turret6 = Target:New{name = "turret6"}
Turret7 = Target:New{name = "turret7"}
Turret8 = Target:New{name = "turret8"}
Turret9 = Target:New{name = "turret9"}
Turret10 = Target:New{name = "turret10"}

Objective1 = ObjectiveAssaultNew{teamATT = ATT, teamDEF = DEF, text = "level.AL3.cw_objectives.1", popupText = "level.AL3.cw_objectives.1_popup", AIGoalWeight = 100}

Objective1:AddTarget(Turret1)
Objective1:AddTarget(Turret2)
Objective1:AddTarget(Turret3)
Objective1:AddTarget(Turret4)
Objective1:AddTarget(Turret5)
Objective1:AddTarget(Turret6)
Objective1:AddTarget(Turret7)
Objective1:AddTarget(Turret8)
Objective1:AddTarget(Turret9)
Objective1:AddTarget(Turret10)

Objective1.OnStart = function(self)

SetProperty("turret1","Team",2)
SetProperty("turret2","Team",2)
SetProperty("turret3","Team",2)
SetProperty("turret4","Team",2)
SetProperty("turret5","Team",2)
SetProperty("turret6","Team",2)
SetProperty("turret7","Team",2)
SetProperty("turret8","Team",2)
SetProperty("turret9","Team",2)
SetProperty("turret10","Team",2)

att_obj1_destroy1 = AddAIGoal(ATT, "Destroy", 9, "turret1")
att_obj1_destroy2 = AddAIGoal(ATT, "Destroy", 9, "turret2")
att_obj1_destroy3 = AddAIGoal(ATT, "Destroy", 9, "turret3")
att_obj1_destroy4 = AddAIGoal(ATT, "Destroy", 9, "turret4")
att_obj1_destroy5 = AddAIGoal(ATT, "Destroy", 9, "turret5")
att_obj1_destroy6 = AddAIGoal(ATT, "Destroy", 9, "turret6")
att_obj1_destroy7 = AddAIGoal(ATT, "Destroy", 9, "turret7")
att_obj1_destroy8 = AddAIGoal(ATT, "Destroy", 9, "turret8")
att_obj1_destroy9 = AddAIGoal(ATT, "Destroy", 9, "turret9")
att_obj1_destroy10 = AddAIGoal(ATT, "Destroy", 9, "turret10")
att_obj1_tdm = AddAIGoal(ATT,"DeathMatch", 10)
def_obj1_tdm = AddAIGoal(DEF,"DeathMatch", 100)

turret_count = 10
TurretKill = OnObjectKillClass(
function(object, killer)
if killer and IsCharacterHuman(killer) then
turret_count = turret_count - 1
if turret_count > 0 then
ShowMessageText("level.AL3.cw_objectives.1-" .. turret_count, 1)
end
end
end,
"tur_bldg_recoilless_fel_auto"
)
end

Objective1.OnComplete = function(self)
ReleaseObjectKill(TurretKill)
TurretKill = nil

ShowMessageText("game.objectives.complete", ATT)
DeleteAIGoal(att_obj1_destroy1)
DeleteAIGoal(att_obj1_destroy2)
DeleteAIGoal(att_obj1_destroy3)
DeleteAIGoal(att_obj1_destroy4)
DeleteAIGoal(att_obj1_destroy5)
DeleteAIGoal(att_obj1_destroy6)
DeleteAIGoal(att_obj1_destroy7)
DeleteAIGoal(att_obj1_destroy8)
DeleteAIGoal(att_obj1_destroy9)
DeleteAIGoal(att_obj1_destroy10)
DeleteAIGoal(att_obj1_tdm)
DeleteAIGoal(def_obj1_tdm)

end

function BeginObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 3.0}
objectiveSequence:AddObjectiveSet(Objective1)
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\\AL3_con.lvl")
ReadDataFile("dc:ingame.lvl")
ReadDataFile("ingame.lvl")

SetMaxFlyHeight(20)
SetMaxPlayerFlyHeight(20)

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\\kas.lvl;kas2cw")
ReadDataFile("dc:sound\\AL3.lvl;al3cw")

ReadDataFile("SIDE\\rep.lvl",
"rep_inf_ep3_rifleman",
"rep_inf_ep3_rocketeer",
"rep_inf_ep3_engineer",
"rep_inf_ep3_sniper",
"rep_inf_ep3_officer",
"rep_inf_ep3_jettrooper")

ReadDataFile("SIDE\\cis.lvl",
"cis_inf_rifleman",
"cis_inf_rocketeer",
"cis_inf_engineer",
"cis_inf_sniper",
"cis_inf_officer",
"cis_inf_droideka")

ReadDataFile("dc:SIDE\\tur.lvl",
"tur_bldg_recoilless_fel_auto")

ReadDataFile("dc:SIDE\\AL3.lvl")

SetupTeams{
rep = {
team = REP,
units = 32,
reinforcements = 150,
soldier = { "rep_inf_ep3_rifleman",8, 24},
assault = { "rep_inf_ep3_rocketeer",4, 8},
engineer = { "rep_inf_ep3_engineer",4, 8},
sniper = { "rep_inf_ep3_sniper",1, 3},
officer = {"rep_inf_ep3_officer",1, 4},
special = { "rep_inf_ep3_jettrooper",1, 4},

},
cis = {
team = CIS,
units = 32,
reinforcements = 150,
soldier = { "cis_inf_rifleman",8, 24},
assault = { "cis_inf_rocketeer",4, 8},
engineer = { "cis_inf_engineer",4, 8},
sniper = { "cis_inf_sniper",1, 3},
officer = {"cis_inf_officer",1, 4},
special = { "cis_inf_droideka",1, 4},
}
}

-- Level Stats
ClearWalkers()
AddWalkerType(0, 4) -- special -> droidekas
AddWalkerType(1, 4) -- 1x2 (1 pair of legs)

local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 32)
SetMemoryPoolSize("EntityFlyer", 32)
SetMemoryPoolSize("EntityWalker", 32)
SetMemoryPoolSize("EntityHover", 32)
SetMemoryPoolSize("EntityLight", 256)
SetMemoryPoolSize("EntityRemoteTerminal", 12)
SetMemoryPoolSize("EntitySoundStream", 12)
SetMemoryPoolSize("EntitySoundStatic", 32)
SetMemoryPoolSize("MountedTurret", 32)
SetMemoryPoolSize("Navigator", 128)
SetMemoryPoolSize("Obstacle", 1024)
SetMemoryPoolSize("PathNode", 1024)
SetMemoryPoolSize("RedOmniLight", 252)
SetMemoryPoolSize("SoundSpaceRegion", 64)
SetMemoryPoolSize("SoldierAnimation", 500)
SetMemoryPoolSize("TreeGridStack", 1024)
SetMemoryPoolSize("UnitAgent", 128)
SetMemoryPoolSize("UnitController", 128)
SetMemoryPoolSize("Weapon", weaponCnt)

if not ScriptCB_InMultiplayer() then

WeatherMode = math.random(1,2)

if WeatherMode == 1 then
ReadDataFile("dc:AL3\\sky.lvl", "dawn")
ReadDataFile("dc:AL3\\AL3.lvl", "AL3_Objective_CW", "AL3_dawn")
SetDenseEnvironment("false")

elseif WeatherMode == 2 then
ReadDataFile("dc:AL3\\sky.lvl", "dusk")
ReadDataFile("dc:AL3\\AL3.lvl", "AL3_Objective_CW", "AL3_dusk")
SetDenseEnvironment("false")

end

elseif ScriptCB_InMultiplayer() then

ReadDataFile("dc:AL3\\sky.lvl", "dawn")
ReadDataFile("dc:AL3\\AL3.lvl", "AL3_Objective_CW", "AL3_dawn")
SetDenseEnvironment("false")

end

SetSpawnDelay(10.0, 0.25)

-- Sound Stats

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")

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("dc:sound\\AL3.lvl", "al31")
OpenAudioStream("dc:sound\\AL3.lvl", "al31")

SetBleedingVoiceOver(REP, REP, "rep_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(REP, CIS, "rep_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, REP, "cis_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, CIS, "cis_off_com_report_us_overwhelmed", 1)

SetOutOfBoundsVoiceOver(2, "cisleaving")
SetOutOfBoundsVoiceOver(1, "repleaving")

--SetAmbientMusic(REP, 1.0, "rep_kas_amb_start", 0,1)
--SetAmbientMusic(REP, 0.8, "rep_kas_amb_middle", 1,1)
--SetAmbientMusic(REP, 0.2,"rep_kas_amb_end", 2,1)
--SetAmbientMusic(CIS, 1.0, "cis_kas_amb_start", 0,1)
--SetAmbientMusic(CIS, 0.8, "cis_kas_amb_middle", 1,1)
--SetAmbientMusic(CIS, 0.2,"cis_kas_amb_end", 2,1)

SetVictoryMusic(REP, "rep_kas_amb_victory")
SetDefeatMusic (REP, "rep_kas_amb_defeat")
SetVictoryMusic(CIS, "cis_kas_amb_victory")
SetDefeatMusic (CIS, "cis_kas_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
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")

--OpeningSateliteShot
AddCameraShot(0.690961, -0.023666, 0.722081, 0.024732, -90.000000, 6.373174, 259.261047);

end <- This is line 343[/quote]
I'm pretty sure this is caused by a missing "end" somewhere. I've already tried placing it in some places. When I do so, the .lua is munged fine and the map runs, but the objective does not start and I get this error on my BFront2 log
BFront2 wrote:Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `ObjectiveAssaultNew' (a nil value)
stack traceback:
(none): in function `ScriptPostLoad'
Last edited by GAB on Sun Dec 02, 2012 12:19 pm, edited 2 times in total.
LEO
First Lance Corporal
First Lance Corporal
Posts: 130
Joined: Tue Nov 20, 2012 5:06 pm
Projects :: Map_for_swbf2
Games I'm Playing :: Swbf2
xbox live or psn: No gamertag set

Re: Script Problem

Post by LEO »

if nothing work than go into your projects lua and copy the lua.bak from the era with the error
(i think its clonewars by you ;D) and start from scratch.
I know it's hard to delete houres of work but sometimes there's a need to do this.
User avatar
ANDEWEGET
Ancient Force
Ancient Force
Posts: 1266
Joined: Tue Apr 01, 2008 8:42 am
Location: Germany
Contact:

Re: Script Problem

Post by ANDEWEGET »

Maybe it's ObjectiveAssault:New and not ObjectiveAssaultNew (after you initialized all the turrets)?
User avatar
GAB
1st Lieutenant
1st Lieutenant
Posts: 431
Joined: Sun Jul 03, 2011 8:56 pm
Location: Somewhere around the world
Contact:

Re: Script Problem

Post by GAB »

Oh yeah. It works now. The objective is running greatly.

Thanks ANDE :thumbs:

I also had to add an extra end before ScriptInit() to get the lua munged. So the missing things were an end and the little ":".
stealthunt3r
Private Recruit
Posts: 22
Joined: Mon May 12, 2014 6:37 pm
Projects :: Clones Revenge
Games I'm Playing :: star wars
xbox live or psn: No gamertag set

Re: Script Problem

Post by stealthunt3r »

GAB wrote:Oh yeah. It works now. The objective is running greatly.

Thanks ANDE :thumbs:

I also had to add an extra end before ScriptInit() to get the lua munged. So the missing things were an end and the little ":".
may i aske how you put those in? i have the same problem
Post Reply