Page 1 of 1

How do I make a ctf objective? [Solved]

Posted: Tue Jan 26, 2010 10:03 pm
by wishihadaname
Its probably something really simple that i'm missing here. I placed a flag (copied from the corrusant map) into my map near a crashed gunship and named it holocron2. I then copied and pasted the following lua lines directly out of the cor script then modified to fit my map. The map doesn't seem to recognise that I placed the flag though because I get this error

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "holocron2" not found

Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: ERROR: flag holocron2 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 `BeginObjectives'

It doesn't crash, its just that there is no holocron near the gunship and the objective is uncompletable.
Here is the script portion from my .lua
Hidden/Spoiler:
--Find the transponder

Objective4 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, text = "level.LPR.campaign.capture1",
popupText = "level.LPR.campaign.popup4"}

Objective4:AddFlag{name = "holocron2", captureRegion = "Team1_Capture"}

Objective4.OnDrop = function(self, flag)
SetProperty(flag.name, "AllowAIPickUp", 0)
end

Objective4.OnStart = function (self)

holocron_capture_on = OnFlagPickUp(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapAddEntityMarker("cp2", "hud_objective_icon_circle", 4.0, ATT, "YELLOW", true)
end
end,
"holocron"
)

holocron_capture_off = OnFlagDrop(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapRemoveEntityMarker("cp2")
end
end,
"holocron"
)


att_obj4_aigoal = AddAIGoal(ATT, "Defend", 100, "cp2")
def_obj4_aigoal = AddAIGoal(DEF, "Deathmatch")

end

Objective4.OnComplete = function (self)

MapRemoveEntityMarker("cp2")

ReleaseFlagPickUp(holocron_capture_on)
ReleaseFlagDrop(holocron_capture_off)

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

DeleteAIGoal(att_obj4_aigoal)
DeleteAIGoal(def_obj4_aigoal)

end

Re: How do I make a ctf objective?

Posted: Tue Jan 26, 2010 10:20 pm
by Eggman
Make sure you add the flag to your world's .req file. It's an easy step to overlook, I've made that mistake multiple times. Take a look at the .req for a shipped world with a flag objective to see where you need to add in the line for the flag.

Re: How do I make a ctf objective?

Posted: Thu Jan 28, 2010 1:08 am
by wishihadaname
I did that but its still not working. Error is exactly the same so I thought it may have something to do with the actual object, so I switched the object and script accordingly, in this case I copied over the felucia ctf objective and modified it to my ends, the object in-game is palced from the very beggining, its in the campaign layer and I never kill it, its a felucia powercell named powercell. I copied over the line from the felucia.req file that added the flag but still no results. IDK what the problem is

here is the bug
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: ERROR: flag powercell 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 `BeginObjectives'

here is the script
Hidden/Spoiler:
--Find the transponder
Objective4 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, text = "level.LPR.campaign.capture1", popupText = "level.LPR.campaign.popup4", AIGoalWeight = 0}
Objective4:AddFlag{name = "powercell", homeRegion = "", captureRegion = "cp2_capture",
capRegionMarker = "hud_objective_icon_circle", capRegionMarkerScale = 3.0,
mapIcon = "flag_icon", mapIconScale = 2.0}

Objective4.OnDrop = function(self, flag)
SetProperty(flag.name, "AllowAIPickUp", 0)
end

Objective4.OnStart = function(self)
MapAddEntityMarker("crashed_gunship", "hud_objective_icon_circle", 3.0, 1, "YELLOW", true)

SetUnitCount (6, 5)

SetupAmbushTrigger("gunshipambush1", "droidpath2", 5, 6)
SetupAmbushTrigger("gunshipambush2", "droidpath3", 5, 6)
SetupAmbushTrigger("gunshipambush3", "droidpath4", 5, 6)
SetupAmbushTrigger("gunshipambush4", "droidpath5", 5, 6)

powercell_capture_on = OnFlagPickUp(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapAddEntityMarker("cp2", "hud_objective_icon_circle", 4.0, ATT, "YELLOW", true)
end
end,
"powercell"
)

powercell_capture_off = OnFlagDrop(
function(flag, carrier)
if IsCharacterHuman(carrier) then
MapRemoveEntityMarker("cp2")
end
end,
"powercell"
)

att_obj4_dm = AddAIGoal(ATT, "Defend", 100, "cp2")
def_obj4_dm = AddAIGoal(DEF, "Deathmatch", 100)
dtm_obj4_dm = AddAIGoal(6, "Deathmatch", 100)
end

Objective4.OnComplete = function(self)
MapRemoveEntityMarker("crashed_gunship")
ShowMessageText("game.objectives.complete", ATT)
MapRemoveEntityMarker("cp2")

ReleaseFlagPickUp(powercell_capture_on)
powercell_capture_on = nil
ReleaseFlagDrop(powercell_capture_off)
powercell_capture_off = nil

DeleteAIGoal(dtm_obj4_dm)
DeleteAIGoal(att_obj4_dm)
DeleteAIGoal(def_obj4_dm)

ATTReinforcementCount = GetReinforcementCount(ATT)
SetReinforcementCount(ATT, ATTReinforcementCount + 30)

end

end
I'm at a total loss as to what i'm doing wrong.

edit*
Its definantly something to do with my script. I tried using a com_item_flag as the target and it still doesn't work! What am I missing here? I place a the flag out of my common folder ingame, I name it flag1, label it flag1, set its team to 2. Then I go and make this script in my .lua, I munge and it doesn't work, the flag does not appear ingame... I got it to appear when I used com_item_flag_rep but I couldn't pick it up...

Re: How do I make a ctf objective? [ really need some help ]

Posted: Sat Jan 30, 2010 11:10 pm
by ForceMaster

Re: How do I make a ctf objective? [ really need some help ]

Posted: Sun Jan 31, 2010 1:33 am
by wishihadaname
THANK YOU!!!!!! :bowdown: :bowdown: It works!! Now that I've gotten all the objective types to work all I need to do is finish writing my script! You guys can expect to see a WIP thread posted some time this week and possibly a release of the final map some time this month.

Re: How do I make a ctf objective? [Solved]

Posted: Sun Jan 31, 2010 3:14 pm
by ForceMaster
You wellcome man! :D