Page 1 of 1

Bomb objective crash [Solved]

Posted: Thu Mar 10, 2011 5:31 pm
by TK432
Hey there. I've been trying to set up a "pick up bomb at A and get it to B and blow everything up"-objective.

Here it is:
Hidden/Spoiler:
function Objective3()
if unexpected_condition then error() end


Objective3 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, text = "level.yavin1.objectives.campaign.6", popupText = "level.yavin1.objectives.campaign.6_popup"}

Objective3:AddFlag{name = "yav_flag_bomb", captureRegion = "bomb_capture",
capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0,
mapIcon = "flag_icon", mapIconScale = 2.0}

StartTimer(bomb_timer)


Objective3.OnStart = function (self)

objectiveSequence.delayNextSetTime = 14.0


ScriptCB_SndPlaySound("YAV_obj_21")
ScriptCB_PlayInGameMusic("imp_yav_amb_bomb_retrieve")


BombSpawn = GetPathPoint("bomb_spawn", 0) --Put the rebel plans on this spawn path.
CreateEntity("yav_flag_bomb", bomb_spawn, "yav_flag_bomb") --Spawns the Holocron.
SetProperty ("yav_flag_bomb", "AllowAIPickUp", 0)


ATTFlag = AddAIGoal (ATT, "CTFOffense",100,"yav_flag_bomb")
DEFFlag = AddAIGoal (DEF, "Defend",100,"yav_flag_bomb")


bomb_capture_on = OnFlagPickUp(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapAddEntityMarker("gate1", "hud_objective_icon_circle_circle", 4.0, ATT, "YELLOW", true)
ScriptCB_PlayInGameMusic("imp_yav_amb_bomb_return")
end
end,
"yav_flag_bomb"
)

bomb_capture_off = OnFlagDrop(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapRemoveEntityMarker("gate1")
end
end,
"yav_flag_bomb"
)
end

Objective3.OnComplete = function (self)

DeleteAIGoal(ATTFlag)
DeleteAIGoal(DEFFlag)


MapRemoveEntityMarker("gate1")
ReleaseFlagPickUp (bomb_capture_on)
ReleaseFlagDrop (bomb_capture_off)
OBJ1_ReinforcementCount = GetReinforcementCount(ATT)

SetReinforcementCount(ATT, OBJ1_ReinforcementCount + 30)
ShowMessageText("game.objectives.complete", ATT)
if self.winningTeam == self.teamDEF then
BroadcastVoiceOver("yav_obj_08")
end

--create a timer for the bomb
bomb_timer = CreateTimer("bomb_timer")
SetTimerValue(bomb_timer, 10.0)
StartTimer(bomb_timer)
ShowTimer("bomb_timer")
OnTimerElapse(
function(timer)
ShowTimer(nil)
KillObject ("gate1")
KillObject ("gate2")
KillObject ("gate3")
KillObject ("gate4")
end,
bomb_timer
)
end

end


If I add this function to my lua the game crashes instantly after the map started loading

Heres the BFront2 file I get:
Hidden/Spoiler:
Opened logfile BFront2.log 2011-03-10 2211
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
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BDT\data\_LVL_PC\SIDE\dark.lvl. Adding DT's missions
Found side\rvs.lvl. Adding BRO's extra KotOR missions
Found ..\..\addon\BDT\data\_LVL_PC\SIDE\dark.lvl. Adding BRO's extra Dark Times missions
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BDT\data\_LVL_PC\SIDE\dark.lvl. Adding DT's missions
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BDT\data\_LVL_PC\SIDE\dark.lvl. Adding DT's missions
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BDT\data\_LVL_PC\SIDE\dark.lvl. Adding DT's missions
Tatooine: Tuskencamp - Found rvs.lvl - Adding KotOR era and modes
Tatooine: Tuskencamp - Found 212.lvl - Adding BFX era and mode
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BFX\data\_LVL_PC\mission.lvl. Adding BFX's missions
Found ..\..\addon\BDT\data\_LVL_PC\SIDE\dark.lvl. Adding DT's 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: _tab_instant
missionlist_ExpandMapList()
ifs_missionselect_pcMulti_fnSetMapPreview(): Defaulting index to 1
this.CurButton = check_mode1
cur_button = nil
this.CurButton = check_mode10
cur_button = nil
this.CurButton = check_mode1
cur_button = nil
Checkbox for check_era3 clicked
this.CurButton = check_era3
cur_button = nil
custom_AddMapNew()
custom_printTable(): table: 05E70974
The key, value is: mode_con_b 1
The key, value is: era_g 1
The key, value is: mode_con_c 1
The key is mapluafile, the formated value is: KWF<A>_<B>
The key, value is: bSelected 1
The key, value is: era_1 1
The key, value is: mode_con_1 1
The key, value is: mode_con_a 1
The key, value is: era_c 1
The key, value is: isModLevel 1
The key, value is: era_a 1
The key, value is: mode_con_g 1
The key, value is: mode_c_c 1
The key, value is: era_b 1
custom_printTable(): Returning
custom_printTable(): table: 05A56B4C
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_c Era = era_c subst = c
Adding map: KWFc_c idx: 1
this.CurButton = _map_add
cur_button = nil
this.CurButton = Launch
cur_button = nil
(none):0: attempt to call global `GetRegion' (a nil value)

Does the last line mean that I've set a region wrong or something like that?

However, I've copied the objective straight out of the yavg_c mission and changed it to my fittings.

Re: Bomb objective crash

Posted: Thu Mar 10, 2011 5:43 pm
by fasty
TK432 wrote:Does the last line mean that I've set a region wrong or something like that?
Most likely. Double check everything is referenced correctly, especially the "GetPathPoint("bomb_spawn", 0)" Make sure there is a path named "bomb_spawn" and it has a node # 0. And that it is in the right layer in ZE.

Re: Bomb objective crash

Posted: Thu Mar 10, 2011 5:55 pm
by TK432
Just checked everything and there's defenetly a path with only one node named bomb_spawn and a capture region named bomb_capture.

All the regions are in the campaign layer which is being loaded correctly in my lua.

Aside from that I only have a ambush region and the cp capture regions in the same layer.

Re: Bomb objective crash

Posted: Thu Mar 10, 2011 5:58 pm
by fasty
"yav_flag_bomb" Is loaded with your map? Why not use "common_holocron" (or whatever it is)?

Re: Bomb objective crash

Posted: Thu Mar 10, 2011 6:00 pm
by TK432
Yes it is. I thought it'd be a better bomb than a holo :) I used the bomb already in my Talus map.

But I can try it too if you want.

Re: Bomb objective crash

Posted: Thu Mar 10, 2011 6:03 pm
by fasty
Post your whole lua so I can see if your objectives are loaded correctly.

Re: Bomb objective crash

Posted: Thu Mar 10, 2011 6:07 pm
by TK432
Here's the objective part
Hidden/Spoiler:
-- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("ObjectiveAssault")
ScriptCB_DoFile("MultiObjectiveContainer")
ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("ObjectiveGoto")
ScriptCB_DoFile("Objective3")
ScriptCB_DoFile("Ambush")
ScriptCB_DoFile("setup_teams")

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

Acklays = 3
ACK = Acklays

function ScriptPostLoad ()

ScriptCB_SetGameRules("campaign")
SetAIDifficulty(2, -2, "medium")
AllowAISpawn(ATT, true)
AllowAISpawn(DEF, false)
DisableAIAutoBalance()


SetProperty ("cp1_c", "IsVisible", 1)
SetProperty ("cp1_c","team",ATT)
SetProperty ("cp3_c","team",DEF)
AICanCaptureCP("cp1_c", ATT, false)
AICanCaptureCP("cp2_c", ATT, false)

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
objectives_timer = CreateTimer("objectives_timer")
SetTimerValue(objectives_timer, 4)
StartTimer(objectives_timer)
begin_objectives = OnTimerElapse(
function(timer)
StartObjectives ()
ScriptCB_EnableCommandPostVO(0)
ScriptCB_PlayInGameMusic("rep_cor_amb_obj1_2_explore")

end,
objectives_timer
)
end
end
)

-- OBJECTIVE ONE Conquest Objective. Capture the first cp.-----------------------

Objective1CP = CommandPost:New{name = "cp2_c", hideCPs = false}
Objective1 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level.KWF.objectives.Campaign.1",
popupText = "level.KWF.objectives.Campaign.1_popup"}
Objective1:AddCommandPost(Objective1CP)

Objective1.OnStart = function (self)

Acklayspawn= CreateTimer("Acklayspawn")
SetTimerValue(Acklayspawn, (5))
StartTimer(Acklayspawn)
OnTimerElapse(
function(timer)
SetupAmbushTrigger("acklay_amush_region", "acklay_ambush", 2, 3)
DestroyTimer(timer)
end,
Acklayspawn
)


end

Objective1.OnComplete = function (self)
AllowAISpawn(DEF, true)
objectiveSequence.delayNextSetTime = 0.5
AICanCaptureCP("cp2_c", DEF, false)
SetProperty("cp2_c", "value_ATK_CIS","0")
SetProperty("cp2_c", "value_DEF_Republic","0")
SetProperty ("cp2_c","team",ATT)
SetProperty("cp2_c", "SpawnPath", "cp2_c_spawn")
SetProperty("cp2_c", "CaptureRegion", "cp2_c_capture")
DeleteAIGoal(ATTgoal)
OBJ1_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, OBJ1_ReinforcementCount + 115)
ShowMessageText("game.objectives.complete", ATT)



end

-- OBJECTIVE TWO Conquest Objective. Capture the first cp.-----------------------

Objective2CP = CommandPost:New{name = "cp3_c", hideCPs = false}
Objective2 = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF, text = "level.KWF.objectives.Campaign.1",
popupText = "level.KWF.objectives.Campaign.1_popup"}
Objective2:AddCommandPost(Objective2CP)

Objective2.OnStart = function (self)

AICanCaptureCP("cp3_c", DEF, false)
SetProperty("cp3_c", "value_ATK_CIS","100")
SetProperty("cp3_c", "value_DEF_Republic","10")

Acklayspawn= CreateTimer("Acklayspawn")
SetTimerValue(Acklayspawn, (5))
StartTimer(Acklayspawn)
OnTimerElapse(
function(timer)
SetupAmbushTrigger("acklay_amush_region", "acklay_ambush", 2, 3)
DestroyTimer(timer)
end,
Acklayspawn
)


end

Objective2.OnComplete = function (self)
AllowAISpawn(DEF, true)
objectiveSequence.delayNextSetTime = 0.5
AICanCaptureCP("cp3_c", DEF, false)
SetProperty("cp3_c", "value_ATK_CIS","0")
SetProperty("cp3_c", "value_DEF_Republic","0")
SetProperty ("cp3_c","team",ATT)
SetProperty("cp3_c", "SpawnPath", "cp3_c_spawn")
SetProperty("cp3_c", "CaptureRegion", "cp3_c_capture")
DeleteAIGoal(ATTgoal)
OBJ1_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, OBJ1_ReinforcementCount + 30)
ShowMessageText("game.objectives.complete", ATT)




end
end

Objective3()




----This creates the objective "container" and specifies order of objectives, and gets that Diet Dr. Pepper running
function StartObjectives()
objectiveSequence = MultiObjectiveContainer:New{delayVictoryTime = 6.0 }
objectiveSequence:AddObjectiveSet(Objective1)
objectiveSequence:AddObjectiveSet(Objective2)
objectiveSequence:AddObjectiveSet(Objective3)
objectiveSequence:Start()

end
The 1st two objectives work as they should if I leave the 3rd objective out. It just crashes if I add it in.

Re: Bomb objective crash

Posted: Thu Mar 10, 2011 6:37 pm
by fasty
You have "StartTimer(bomb_timer)" twice in two different spots. Not sure if that means anything. All I can say is try messing around and experimenting. Perhaps you accidentally put ATT where DEF goes. Other than that I can't see any problems. Maybe I'll notice something later when I'm on my modding computer. >.<

Re: Bomb objective crash

Posted: Fri Mar 11, 2011 7:20 am
by TK432
I somehow fixed it by playing around with my regions and moving one "end" that was wrong.

But now the bomb doesn't spawn.

Here are the errors regarding it:
Hidden/Spoiler:
Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\FlagItem.cpp(945)
Could not build FlagItem

Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(635)
Entity "yav_flag_bomb" not found

Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\AIGoalManager.cpp(253)
Invalid goal target for "Defend" goal (team 2, weight 0)

Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(635)
Entity "yav_flag_bomb" not found

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: ERROR: flag yav_flag_bomb does not exist in the map
stack traceback:
[C]: in function `assert'
(none): in function `Start'
(none): in function `ActivateObjectiveSet'
(none): in function `Start'
(none): in function `StartObjectives'
(none): in function <(none):56>
Of course I do have a entity called "yav_flag_bomb" on my map.

And my objective again:
Hidden/Spoiler:
function Objective3()
if unexpected_condition then error() end


Objective3 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, text = "level.KWF.objectives.campaign.3", popupText = "level.KWF.objectives.campaign.3_popup"}
Objective3:AddFlag{name = "yav_flag_bomb", captureRegion = "bomb_capture",
capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0,
mapIcon = "flag_icon", mapIconScale = 2.0}

Objective3.OnStart = function (self)


CreateEntity("yav_flag_bomb", GetPathPoint("bomb_spawn", 0), "yav_flag_bomb")
SetProperty ("yav_flag_bomb", "AllowAIPickUp", 0)


ATTFlag = AddAIGoal (ATT, "CTFOffense",100,"yav_flag_bomb")
DEFFlag = AddAIGoal (DEF, "Defend",100,"yav_flag_bomb")


bomb_capture_on = OnFlagPickUp(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapAddEntityMarker("gate1", "hud_objective_icon_circle_circle", 4.0, ATT, "YELLOW", true)
ScriptCB_PlayInGameMusic("imp_yav_amb_bomb_return")
end
end,
"yav_flag_bomb"
)

bomb_capture_off = OnFlagDrop(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapRemoveEntityMarker("gate1")
end
end,
"yav_flag_bomb"
)
end

Objective3.OnComplete = function (self)

DeleteAIGoal(ATTFlag)
DeleteAIGoal(DEFFlag)


MapRemoveEntityMarker("gate1")
ReleaseFlagPickUp (bomb_capture_on)
ReleaseFlagDrop (bomb_capture_off)
OBJ1_ReinforcementCount = GetReinforcementCount(ATT)

SetReinforcementCount(ATT, OBJ1_ReinforcementCount + 30)
ShowMessageText("game.objectives.complete", ATT)
if self.winningTeam == self.teamDEF then
BroadcastVoiceOver("yav_obj_08")
end

--create a timer for the bomb
bomb_timer = CreateTimer("bomb_timer")
SetTimerValue(bomb_timer, 10.0)
StartTimer(bomb_timer)
ShowTimer("bomb_timer")
OnTimerElapse(
function(timer)
ShowTimer(nil)
KillObject ("gate1")
KillObject ("gate2")
KillObject ("gate3")
KillObject ("gate4")
end,
bomb_timer
)
end

end
Wait, I totally had that problem once already and posted about it a while back. :oops: