Page 1 of 1

How create CTF objective? (No game mode)

Posted: Wed Aug 05, 2009 5:44 pm
by ForceMaster
Hello friends, I hope not to be annoyed with these questions may be basic.

I need to create a objective of "capture the flag", so far I do not know what code to use in the LUA.
My situation is this:
I have a different flag mnodel, no the conventional flag, is just another geometric object; and i have a different flag carried model.

What code use in the lua? assuming it would be one of several objectives.

and

I just put the "flag" in Zero editor as any model?

thanks guys!

Re: How create CTF objective? (No game mode)

Posted: Wed Aug 05, 2009 5:47 pm
by Frisbeetarian
It would help to check the campaign scripts, many of them have a capture the flag type objective and none of them use the flag mesh. For Geonosis, check the 5th objective.
ForceMaster wrote:I just put the "flag" in Zero editor as any model?
No, you don't need it in ZE at all.

Re: How create CTF objective? (No game mode)

Posted: Wed Aug 05, 2009 5:50 pm
by ForceMaster
ok i understand. only put it in the world/msh folder? or common/msh folder?

Re: How create CTF objective? (No game mode)

Posted: Wed Aug 05, 2009 5:55 pm
by Frisbeetarian
I think if you just have with the rest of the maps files, it should be fine. That's how Geonosis does it.

When looking at an objective, make sure to check the end of the previous objective:
geo1c_c.lua Objective4.OnComplete wrote:

Code: Select all

--spawn the flag object for the next objective
		plans_spawn = GetPathPoint("plans_spawn", 0) --gets the path point
        CreateEntity("geo1_flag_disk", plans_spawn, "plans") --spawns the flag

Re: How create CTF objective? (No game mode)

Posted: Wed Aug 05, 2009 7:03 pm
by ForceMaster
ok I need to show the flag just before the start the objective.

but do not know if this flag must be in the folder common / mshs or world / MSH. where it should be the geometry of the flag?

(and thanks my friend)

Re: How create CTF objective? (No game mode)

Posted: Wed Aug 05, 2009 7:55 pm
by Frisbeetarian
Loading through your world folder should be fine.

Re: How create CTF objective? (No game mode)

Posted: Wed Aug 05, 2009 8:12 pm
by Eggman
Frisbeetarian wrote:Loading through your world folder should be fine.
Yup. For example, the flag models/odfs for Felucia's ctf objective are in its world folders.

Re: How create CTF objective? (No game mode)

Posted: Thu Aug 06, 2009 3:46 pm
by ForceMaster
ok, i check the scripts for campaing in coruscant, the 4th or 5th objective and the geonosis script.
I'm testing with a holocron of coruscant.
this is my objective now

Code: Select all

Objective8 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, text = "level.CRP.objectives.campaign.8",
                                    popupText = "level.CRP.objectives.campaign.8popup"}
    
    Objective8:AddFlag{name = "holocron1", captureRegion = "cp6_capture"}
                    
    Objective8.OnStart = function (self)
    
        Holocron1Spawn = GetPathPoint("holocron_spawn", 0) 
        CreateEntity("cor1_item_holocron", Holocron1Spawn, "holocron1")
        SetProperty ("holocron1", "AllowAIPickUp", 0)
    
		holocron_capture_on = OnFlagPickUp(
			function(flag, carrier)
				if IsCharacterHuman(carrier) then
					MapAddEntityMarker("cp6", "hud_objective_icon_circle", 4.0, ATT, "YELLOW", true)
				end
			end,
			"holocron"
		)
		
		holocron_capture_off = OnFlagDrop(
			function(flag, carrier)
				if IsCharacterHuman(carrier) then
					MapRemoveEntityMarker("Veranda_CP")				
				end
			end,
			"holocron"
		)
	
		
	end
					
	Objective8.OnComplete = function (self)
		ShowMessageText("game.objectives.complete", ATT)	
    	ReleaseFlagPickUp(holocron_capture_on)
		ReleaseFlagDrop(holocron_capture_off)
		MapRemoveEntityMarker("cp6")
		DeleteAIGoal(att_obj8_aigoal)
		DeleteAIGoal(def_obj8_aigoal)
		DeleteAIGoal(def_obj8_aigoal2)
	end

 
I add a path for spawn, "holocron_spawn" with a only node "0" in the conquest layer
the objective begins but no spawn the holocron.

Re: How create CTF objective? (No game mode)

Posted: Fri Aug 07, 2009 5:15 am
by theultimat
I don't know if this is the problem, but in one line you have

Code: Select all

holocron_spawn
But on another line you have

Code: Select all

Holocron_spawn
You could try changing so that they ware both the same as the path name in ZE.
Hope that helps.

Re: How create CTF objective? (No game mode)

Posted: Fri Aug 07, 2009 11:31 am
by [RDH]Zerted
You should always check your debug log.

Re: How create CTF objective? (No game mode)

Posted: Fri Aug 07, 2009 11:56 am
by Maveritchell
I am not sure what the above posters meant by "it's ok to load it just through the worlds folder," but you need to do more than just have it in the worlds folder and munge. None of those munged files are compiled into a .lvl file that the game reads unless the .lvl file has a reason to call for them. This means that somewhere, a .req file is going to have to reference your flag, directly or indirectly.

The easiest way to do this will simply be dropping a flag into your map somewhere in an unreachable location, then you can create flags with CreateEntity to your heart's content.

Re: How create CTF objective? (No game mode)

Posted: Mon Aug 10, 2009 5:10 pm
by ForceMaster
I add this to the .req of the world

Code: Select all

	REQN
	{
		"class"
		"cor1_item_holocron"
	}
but no spawn the holocron

this is the error in Bfront2.log

Code: Select all

Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call method `AddFlag' (a nil value)
stack traceback:
	(none): in function `ScriptPostLoad'

Re: How create CTF objective? (No game mode)

Posted: Mon Aug 10, 2009 5:16 pm
by Xavious
Do you have the Capture the Flag script loaded in your campaign?

Code: Select all

ScriptCB_DoFile("ObjectiveCTF")

Re: How create CTF objective? (No game mode)

Posted: Mon Aug 10, 2009 5:18 pm
by ForceMaster
Yes sr.

EDIT:

this is my actual objective

Code: Select all

	(THIS SECTION AT THE END OF THE PREVIUS OBJECTIVE)
	--spawn the flag object for the next objective
		plans_spawn = GetPathPoint("holocron_spawn", 0) --gets the path point
        CreateEntity("cor1_item_holocron", plans_spawn, "plans") --spawns the flag
        --SetProperty("plans", "GeometryName", "cor1_prop_holocron")
        --SetProperty("plans", "CarriedGeometryName", "cor1_prop_holocron")


Objective8 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, text = "level.CRP.objectives.campaing.8", popupText = "level.CRP.objectives.campaing.8popup",  AIGoalWeight = 0}
	Objective5:AddFlag{name = "plans", homeRegion = "", captureRegion = "cp6_capture",
				capRegionMarker = "hud_objective_icon", capRegionMarkerScale = 3.0, 
				mapIcon = "flag_icon", mapIconScale = 2.0}
	
	Objective8.OnStart = function(self)
		att_obj8_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
		def_obj8_aigoal = AddAIGoal(DEF, "Defend", 50, "cp6")
		def_obj8_aigoal2 = AddAIGoal(DEF, "Deathmatch", 50)
		plans_capture_on = OnFlagPickUp(
		function(flag, carrier)
			if IsCharacterHuman(carrier) then
				MapAddEntityMarker("cp6", "hud_objective_icon", 4.0, ATT, "YELLOW", true)				
			end
		end,
		"plans"
		)
	
		
		
		plans_capture_off = OnFlagDrop(
		function(flag, carrier)
			if IsCharacterHuman(carrier) then
				MapRemoveEntityMarker("cp6")				
			end
		end,
		"plans"
		)
		
		
	end
					
	Objective8.OnComplete = function (self)
		ShowMessageText("game.objectives.complete", ATT)
		
		ReleaseFlagPickUp(plans_capture_on)
		ReleaseFlagDrop(plans_capture_off)
		MapRemoveEntityMarker("cp6")
		
		DeleteAIGoal(att_obj8_aigoal)
		DeleteAIGoal(def_obj8_aigoal)
		DeleteAIGoal(def_obj8_aigoal2)
	end


Re: How create CTF objective? (No game mode)

Posted: Mon Aug 10, 2009 5:32 pm
by Xavious
Why is it Objective5:AddFlag? Shouldn't that be an 8?

Re: How create CTF objective? (No game mode)

Posted: Mon Aug 10, 2009 5:37 pm
by ForceMaster
EDIT3

IS WORKING!!! :runaway:

Yes, only need put the memorypool in the LUA.

good, a TENTATIVE tutorial for others modders that want to make a CTF objective in a campaign.

1) Get the .odf, .msh and .tgao f your flag or holocron (i use the cor1_item_holocron) and paste it in the C:\BF2_ModTools\data_XXX\Worlds\XXX\odf and C:\BF2_ModTools\data_XXX\Worlds\XXX\msh folders. (XXX is your map 3 letters name)

2) Go to data_XXX\Worlds\XXX\world1 and open your XXX.REQ file with note pad and ad this lines and save:

Code: Select all

   REQN
   {
      "class"
      "cor1_item_holocron"
   }


3) Open your world in ZE and change the layer to "conquest", then go to "path" and add a new path with only one node where you want. rename your path to holocron_spawn save your world and exit.

4) (Now, if you are working in a campaign for your map I recommend using Mission Scripter, is easy to use.) You need a new LUA for your objectives, change one of these for this code:

(IMPORTANT: This is my 8th objective, you change the "8" in the objective for the number of yours. you change the "cp6" for the CP to receive the flag and "cp6_control" for the name of the CP's control region.)

(THIS SECTION AT THE END OF YOUR PREVIUS OBJECTIVE)

Code: Select all

	--spawn the flag object for the next objective
		plans_spawn = GetPathPoint("holocron_spawn", 0) --gets the path point
        CreateEntity("cor1_item_holocron", plans_spawn, "plans") --spawns the flag
        --SetProperty("plans", "GeometryName", "cor1_prop_holocron")
        --SetProperty("plans", "CarriedGeometryName", "cor1_prop_holocron")
(THIS IS THE OBJECTIVE)

Code: Select all

Objective8 = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, captureLimit = 1, text = "level.CRP.objectives.campaing.8", popupText = "level.CRP.objectives.campaing.8popup",  AIGoalWeight = 0}
	Objective8:AddFlag{name = "plans", homeRegion = "", captureRegion = "cp6_capture",
				capRegionMarker = "hud_objective_icon", capRegionMarkerScale = 3.0, 
				mapIcon = "flag_icon", mapIconScale = 2.0}
	
	Objective8.OnStart = function(self)
		att_obj8_aigoal = AddAIGoal(ATT, "Deathmatch", 100)
		def_obj8_aigoal = AddAIGoal(DEF, "Defend", 50, "cp6")
		def_obj8_aigoal2 = AddAIGoal(DEF, "Deathmatch", 50)
		plans_capture_on = OnFlagPickUp(
		function(flag, carrier)
			if IsCharacterHuman(carrier) then
				MapAddEntityMarker("cp6", "hud_objective_icon", 4.0, ATT, "YELLOW", true)				
			end
		end,
		"plans"
		)
	
		
		
		plans_capture_off = OnFlagDrop(
		function(flag, carrier)
			if IsCharacterHuman(carrier) then
				MapRemoveEntityMarker("cp6")				
			end
		end,
		"plans"
		)
		
		
	end
					
	Objective8.OnComplete = function (self)
		ShowMessageText("game.objectives.complete", ATT)
		
		ReleaseFlagPickUp(plans_capture_on)
		ReleaseFlagDrop(plans_capture_off)
		MapRemoveEntityMarker("cp6")
		
		DeleteAIGoal(att_obj8_aigoal)
		DeleteAIGoal(def_obj8_aigoal)
		DeleteAIGoal(def_obj8_aigoal2)
	end

5) now you add this line to the memory pools

Code: Select all

SetMemoryPoolSize("FlagItem", 2)
6) Munge and play.

It works for me... :D Thanks friends.

EDIT4
(please lock this topic)