CTF objective in campaign [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
TK432
2nd Lieutenant
2nd Lieutenant
Posts: 408
Joined: Tue May 26, 2009 4:18 pm
Location: Somewhere far away

CTF objective in campaign [Solved]

Post by TK432 »

I'm trying to set up an objective in which you have to capture a holocron and bring it back to a CP (cp6 in my case).

Heres the objective (I've used the mustafar and the coruscant CTF objectives as sources):
Hidden/Spoiler:
Objective5 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, popupText = "level.mus1.objectives.campaign.12_popup", text = "level.mus1.objectives.campaign.5"}
Objective5:AddFlag{name = "cor1_item_holocron", captureRegion = "flagcapture"}
Objective5.OnStart = function(self)

Flag1Spawn = GetPathPoint("holospawn", 0)
CreateEntity("cor1_item_holocron", Flag, "cor1_item_holocron")
SetProperty ("cor1_item_holocron", "AllowAIPickUp", 0)

Flag_capture_on = OnFlagPickUp(
function(Flag, carrier)
if IsCharacterHuman(carrier) then
--ShowMessageText("level.dea1.objectives.campaign.4_pickup", ATT)
MapAddEntityMarker("cp6", "hud_objective_icon_circle", 4.0, ATT, "YELLOW", true)
ScriptCB_PlayInGameMusic("rep_cor_amb_holocron_return_01")
end
end,
"holocron"
)

Flag_capture_off = OnFlagDrop(
function(Flag, carrier)
if IsCharacterHuman(carrier) then
MapRemoveEntityMarker("cp6")
--ShowMessageText("level.dea1.objectives.campaign.4_drop", ATT)
end
end,
"holocron"
)

objectiveSequence.delayNextSetTime = 0.5
ScriptCB_SndPlaySound("cor_obj_33")
ScriptCB_PlayInGameMusic("rep_cor_objComplete_01")

end

Objective5.OnComplete = function (self)
ScriptCB_PlayInGameMusic("rep_cor_amb_holocron_return_01")

MapRemoveEntityMarker("cp6")

ReleaseFlagPickUp(Flag_capture_on)
ReleaseFlagDrop(Flag_capture_off)

OBJ4_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, OBJ5_ReinforcementCount + 30)

UnlockHeroForTeam(ATT)
ShowMessageText("game.objectives.complete", ATT)
The relevant errors I get are:
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 "cor1_item_holocron" not found

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

Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaHelper.cpp(312)
CallProc failed: ERROR: flag cor1_item_holocron 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>
Although there IS of course a item on my map called "cor1_item_holocron"

I also set up a region and a spawn path as they're named in the objective

In-game the objective shows up but doesn't start
Last edited by TK432 on Mon Jul 19, 2010 4:33 pm, edited 2 times in total.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: CTF objective in campaign

Post by Maveritchell »

Looks like you didn't add "FlagItem" to your memory pools. See stock campaigns for further detail.
User avatar
TK432
2nd Lieutenant
2nd Lieutenant
Posts: 408
Joined: Tue May 26, 2009 4:18 pm
Location: Somewhere far away

Re: CTF objective in campaign

Post by TK432 »

I've added the line:

Code: Select all

SetMemoryPoolSize("FlagItem", 1)
Now the objective works fine, but somehow I have no enemys now

Only error left regarding my objective:
Hidden/Spoiler:
Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(635)
Entity "flagcapture" not found
updating markers for flag: cor1_item_holocron
no carrier
updating markers for flag: cor1_item_holocron
no carrier
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: CTF objective in campaign

Post by Maveritchell »

TK432 wrote:I've added the line:

Code: Select all

SetMemoryPoolSize("FlagItem", 1)
Now the objective works fine, but somehow I have no enemys now

Only error left regarding my objective:
Hidden/Spoiler:
Message Severity: 2
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(635)
Entity "flagcapture" not found
updating markers for flag: cor1_item_holocron
no carrier
updating markers for flag: cor1_item_holocron
no carrier
Make sure your region is correctly named in both fields (ID and properties should both be "flagcapture"). You're probably not having any AI spawn because the objective is either failing to set up its goals as the result of not having a region to point to, or because you simply don't have any AI goals to start with. I'd guess the former, but you'll know once you fix that region.
User avatar
TK432
2nd Lieutenant
2nd Lieutenant
Posts: 408
Joined: Tue May 26, 2009 4:18 pm
Location: Somewhere far away

Re: CTF objective in campaign

Post by TK432 »

EDIT: found it out, I've set the AI goal up to defend the holocron

thanks for your fast help mav

EDIT
I have one more question regarding this objective

How can I avoid that the flag from spawning from beginning until the objective starts

I've tried with KillObject and RespawnObject but then the flag just spawned at some random position under the surface.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: CTF objective in campaign

Post by Maveritchell »

Take a look at how the stock campaigns do it. (Coruscant is a good example.)
User avatar
TK432
2nd Lieutenant
2nd Lieutenant
Posts: 408
Joined: Tue May 26, 2009 4:18 pm
Location: Somewhere far away

Re: CTF objective in campaign

Post by TK432 »

I've added these lines now:
Hidden/Spoiler:
Flag1Spawn = GetPathPoint("bombspawn", 0)
CreateEntity("yav_flag_bomb", bomb, "yav_flag_bomb")
SetProperty ("yav_flag_bomb", "AllowAIPickUp", 0)
Do I have to delete the object in ZE now, since it's being spawned on a spawnpath?

As it is now, it doesn't work
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: CTF objective in campaign

Post by Maveritchell »

I can't tell what your problem is without seeing it in context. What you want to do is place a flag - of the same class as the one you want to spawn - in ZE. In your script, you can kill that original flag object, then use CreateEntity to create a flag of the same type on a path node.

Remember that CreateEntity uses this format:
CreateEntity(objectclass, GetPathPoint(pathname, pathnode), newobjectname)
User avatar
TK432
2nd Lieutenant
2nd Lieutenant
Posts: 408
Joined: Tue May 26, 2009 4:18 pm
Location: Somewhere far away

Re: CTF objective in campaign

Post by TK432 »

Heres the whole objective as it is now
Hidden/Spoiler:
Objective5 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, popupText = "level.THF.objectives.campaign.5b_popup", text = "level.THF.objectives.campaign.5b"}
Objective5:AddFlag{name = "yav_flag_bomb", captureRegion = "bombcapture"}
Objective5.OnStart = function(self)

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

Flag_capture_on = OnFlagPickUp(
function(Flag, carrier)
if IsCharacterHuman(carrier) then
--ShowMessageText("level.dea1.objectives.campaign.4_pickup", ATT)
MapAddEntityMarker("turret", "hud_objective_icon_circle", 4.0, ATT, "YELLOW", true)
ScriptCB_PlayInGameMusic("rep_cor_amb_holocron_return_01")
end
end,
"yav_flag_bomb"
)

Flag_capture_off = OnFlagDrop(
function(Flag, carrier)
if IsCharacterHuman(carrier) then
MapRemoveEntityMarker("turret")
--ShowMessageText("level.dea1.objectives.campaign.4_drop", ATT)
end
end,
"yav_flag_bomb"
)

DEFGoal = AddAIGoal (DEF, "Defend" , 50, "yav_flag_bomb")
ATTGoal1 = AddAIGoal (ATT, "Defend" , 30, "yav_flag_bomb")
ATTGoal2 = AddAIGoal (ATT, "Defend" , 60, "turret")

objectiveSequence.delayNextSetTime = 0.5
ScriptCB_SndPlaySound("cor_obj_33")
ScriptCB_PlayInGameMusic("rep_cor_objComplete_01")

-- Music Timer --
music01Timer = CreateTimer("music01")
SetTimerValue(music01Timer, 13.0)

StartTimer(music01Timer)
OnTimerElapse(
function(timer)
ScriptCB_StopInGameMusic("rep_cor_objComplete_01")
ScriptCB_PlayInGameMusic("rep_cor_amb_holocron_retrieve_01")
DestroyTimer(Timer)
end,
music01Timer
)


end

Objective5.OnComplete = function (self)
ScriptCB_PlayInGameMusic("rep_cor_amb_holocron_return_01")
DeleteAIGoal(DEFGoal)
DeleteAIGoal(ATT1Goal)
DeleteAIGoal(ATT2Goal)

MapRemoveEntityMarker("turret")

ReleaseFlagPickUp(Flag_capture_on)
ReleaseFlagDrop(Flag_capture_off)

OBJ5_ReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, OBJ5_ReinforcementCount + 30)
UnlockHeroForTeam(ATT)
ShowMessageText("game.objectives.complete", ATT)

bomb_timer = CreateTimer("bomb_timer")
SetTimerValue(bomb_timer, 10.0)
StartTimer(bomb_timer)
ShowTimer("bomb_timer")
OnTimerElapse(
function(timer)
ShowTimer(nil)
SetProperty ("turret", "CurHealth",0)
KillObject ("turret")
SetProperty ("turret1", "CurHealth",0)
KillObject ("turret1")
end,
bomb_timer
)
end
end
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: CTF objective in campaign

Post by Maveritchell »

And what doesn't work? Do you have an object placed in your world that uses the .odf "yav_flag_bomb.odf?"
User avatar
TK432
2nd Lieutenant
2nd Lieutenant
Posts: 408
Joined: Tue May 26, 2009 4:18 pm
Location: Somewhere far away

Re: CTF objective in campaign

Post by TK432 »

The object is placed in ZE, the problem I have is that the flag is on the map from beginning of the mission (although it should spawn at objective 5)

And if i remove the object the flag doesn't spawn
Last edited by TK432 on Mon Jul 19, 2010 4:21 pm, edited 1 time in total.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: CTF objective in campaign

Post by Maveritchell »

TK432 wrote:The object is placed in ZE, the problem I have is that the flag is on the map from beginning of the mission (although it should spawn at objective 5)
Are you killing the flag you placed in ZE? The objective behind using CreateEntity is to make a new copy of a flag.
User avatar
TK432
2nd Lieutenant
2nd Lieutenant
Posts: 408
Joined: Tue May 26, 2009 4:18 pm
Location: Somewhere far away

Re: CTF objective in campaign

Post by TK432 »

Now it works, I didn't know about the copy

Thank you again for the great help
Post Reply