Crash without Error?

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
Duskwingstudios
Recruit Womprat Killer
Posts: 6
Joined: Thu Feb 28, 2019 10:42 am
Projects :: Bountyhunter Mod
Games I'm Playing :: Muchos gamos
xbox live or psn: No gamertag set
Location: Earth

Crash without Error?

Post by Duskwingstudios »

Hey Guys, maybe someone here can help me.
I couldn't find a thread with this problem, so I created a new topic.

So I experiment a bit with bf2 scripting and created a map for testing.
Everything seems to be fine, no munge errors or other things,
BUT when I start my map in bf2, it crashes in the loading screen :shock:
And the Bf2 log does not issue a "normal" Message Serenity error:
Hidden/Spoiler:
[code] BFfront2.log:

Opened logfile BFront2.log 2019-04-04 1554
shell_interface: Entered
shell_interface: gPlatformStr, gOnlineServiceStr, gLangStr, gLangEnum: PC GameSpy german 4
ifs_era_handler - Entered
ifs_era_handler - Exited
shell_interface: No custom_gc_0.lvl
shell_interface: No custom_gc_1.lvl
shell_interface: No custom_gc_2.lvl
shell_interface: No custom_gc_3.lvl
shell_interface: No custom_gc_4.lvl
shell_interface: No custom_gc_5.lvl
shell_interface: No custom_gc_6.lvl
shell_interface: No custom_gc_7.lvl
shell_interface: No custom_gc_8.lvl
shell_interface: No custom_gc_9.lvl
shell_interface: Found custom_gc_10.lvl
custom_gc_10: Entered
custom_gc_10: Found custom_gc_11.lvl
custom_gc_11: Entered
ifs_freeform_init_dt.lua
ifs_freeform_start_dt.lua
custom_gc_11: Taking control of custom_GetGCButtonList()...
custom_gc_11: Taking control of custom_PressedGCButton()...
custom_gc_11: Exited
custom_gc_10: No custom_gc_12.lvl. Will stop searching for any more cGC scripts.
custom_gc_10: Exited
custom_EraButtonList(): Finished building era button table Known eras buttons: 28
custom_GetGMapEras(): Finished building era table Known eras: 28
custom_GetGMapModes(): Finished building game mode table Known Modes: 39
custom_GetMPGameModeList(): Finished building game mode list table List Length: 40
custom_SetMovieLocation()
custom_gc_11: custom_GetGCButtonList(): Entered
custom_GetGCButtonList()
custom_gc_11: custom_GetGCButtonList(): Exited
custom_SetMovieLocation()
custom_GetFreeformBattleModeList(): Finished building freeform battle mode list Known Modes: 39
ingame stream movies\crawlgr.mvs
shell_interface: Opening movie: movies\shellgr.mvs
shell_interface: Leaving
Mission Checker: Entered addme
Mission Checker: addme: Now listening in on AddDownloadableContent() calls
Mission Checker: Exited addme
adding conquest missions..
adding ctf missions..
adding tdm missions..
adding uber missions..
adding oder66 missions..
adding space missions..
adding hero assault missions..
adding XL missions..
prev = none iLastPage = nil
prev = texture iLastPage = 2
prev = texture iLastPage = 3
ifs_legal.Exit

Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\GameMovie.cpp(399)
Unable to find open movie segment shell_main

ifs_saveop_DoOps LoadFileList
ifs_saveop_DoOps LoadFileList
ifs_saveop_DoOps LoadProfile
ifs_saveop_DoOps LoadProfile
ifs_sp_campaign: Input_Accept(): Entered: [Nil]
ifs_sp_campaign: Input_Accept(): Entered: _tab_instant
missionlist_ExpandMapList()
ifs_missionselect_pcMulti_fnSetMapPreview(): Defaulting index to 1
this.CurButton = check_mode1
cur_button = nil
Checkbox for check_era7 clicked
this.CurButton = check_era7
cur_button = nil
custom_AddMapNew()
custom_printTable(): table: 04FCA20C
The key, value is: era_g 1
The key, value is: isModLevel 1
The key, value is: mode_con_g 1
The key, value is: bSelected 1
The key is mapluafile, the formated value is: BOU<A>_<B>
custom_printTable(): Returning
custom_printTable(): table: 04FCFB4C
The key, value is: key mode_con
The key, value is: subst con
The key, value is: showstr modename.name.con
The key, value is: descstr modename.description.con
The key, value is: icon mode_icon_con
custom_printTable(): Returning
gMapEras.key = era_g Era = era_g subst = g
Adding map: BOUg_con idx: 1
this.CurButton = _map_add
cur_button = nil
this.CurButton = Launch
cur_button = nil
(none):0: attempt to index a nil value

-------
[/code]


So before bf2 triggers the normal unimportant "error messages"
The game already stopped working :cry:

I'm really confused at this point. So, if someone could help me out of my misery, that would be great :mrgreen:
Last edited by Duskwingstudios on Fri Apr 05, 2019 11:37 am, edited 1 time in total.
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4779
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: Crash without Error?

Post by Anakin »

hey and welcome to GT.
Your last message crashes the game. (non):0: attempt to index a nil value means that you try to access a table that does not exist.

can you show us your mission lua?

you can use
Hidden/Spoiler:
and [code] tags to make the post look nice ;)
Duskwingstudios
Recruit Womprat Killer
Posts: 6
Joined: Thu Feb 28, 2019 10:42 am
Projects :: Bountyhunter Mod
Games I'm Playing :: Muchos gamos
xbox live or psn: No gamertag set
Location: Earth

Re: Crash without Error?

Post by Duskwingstudios »

First of all, thanks: D

It's pretty messy, but yea ... here it is:
(I've tried to change noobasaurus script to have two or more same objectives just like a campaign mission.)
Hidden/Spoiler:
[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]
i hope it's now accurate :)

Sry for my noob scripting in advance :wink:
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4779
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: Crash without Error?

Post by Anakin »

All right, i already figured it out. Are you using notepad++ or any other editor with code highlighting?

Your ScriptPostLoad() function ends with this:

Code: Select all

        conquest.OnComplete = function (self)
           ShowMessageText("game.objectives.complete", ATT)
       DeleteAIGoal(Deathmatch4)
       DeleteAIGoal(Deathmatch3)
   end
end
But i'm pretty sure that those parts belong to PostLoad, too:

Code: Select all


   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)
...
An extra tipp using proper indent code helps to identify the position where an 'end' is too much or missing

No need to apologize for your code. We all started somewhen and had all different previous knowledge in programming :D
Duskwingstudios
Recruit Womprat Killer
Posts: 6
Joined: Thu Feb 28, 2019 10:42 am
Projects :: Bountyhunter Mod
Games I'm Playing :: Muchos gamos
xbox live or psn: No gamertag set
Location: Earth

Re: Crash without Error?

Post by Duskwingstudios »

I've already corrected my lua (this time with notepad++ :wink: )
But I get the same error message in my bf2log as before

Corrected Lua:
Hidden/Spoiler:
[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





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




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]
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4779
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: Crash without Error?

Post by Anakin »

All right, i just indent your code in a better way, so it's easier to read. And i added some print commands. use this script and munge. Then take a look at the munge log to identify the position where it crashes.
Hidden/Spoiler:
[code]
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
print("Test1")
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;

print("Test2")

function ScriptPostLoad()

print("Test5")

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

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

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()
print("Test4")
-- 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

print("Test3")
[/code]
Post Reply