So currently I'm in the process of trying to create new game modes. I'm thinking I'm close to figuring out how to make things work how I need them to but I'm having difficulty making the AI do what I want them to.
Right now I'm trying to set up a scenario where one team stands in a set region and defends a single cp while the other team attempts to capture it. I'm attempting to edit a conquest lua to make this mode. My problem, no matter what I try, the AI still run off trying to play a normal "conquest". I tried to creat a campaign style set up but that didn't work, so now I'm trying to just set up AI goals. That kind of works but the AI eventually run off from the where they are suppose to defend. Here is the lua I'm trying:
--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "CP1"}
cp2 = CommandPost:New{name = "CP2"}
cp3 = CommandPost:New{name = "CP3"}
cp4 = CommandPost:New{name = "CP4"}
cp5 = CommandPost:New{name = "CP5"}
cp6 = CommandPost:New{name = "CP6"}
--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}
--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(cp4)
conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)
*Note that "zone" is the region I set up for them to defend and "center" is an object I placed on top of the cp for them to defend.*
Recently I tried adding this line under conquest.OnStart = function(self):
conquest.goal1 = RemoveAIGoal(REP, "Conquest", 100 )
But that causes no units on either team to spawn now.
So basically I'm asking how to take the conquest game play out even if the mode is still named conquest. A odd request I know, if there is an easier way to set up new game modes I'm open to try it.
Also while I'm on the topic. I believe it would be useful to the community if some one with experience creating new game modes (Like Zerted or Tean) would write a tutorial of all the steps they went threw to create a game mode like king of the hill, TDM, Holocron, etc.
Set the AI behavior of the attacking team to "conquest" (deathmatch would work too, if there were pathing), and the AI of the defending team to "defend" (you'll need to set an object name to defend, in this case. Alternatively, you could set the behavior of the attackers to conquest and the AI of the defenders to deathmatch, and just make pathing around their defend-target.
Also while I'm on the topic. I believe it would be useful to the community if some one with experience creating new game modes (Like Zerted or Tean) would write a tutorial of all the steps they went threw to create a game mode like king of the hill, TDM, Holocron, etc.
You can't really write a tutorial for creating a new mode, since each mode is going to take different coding. If I'm writing something new I usually take an assault .lua and strip it down to build from there, but once you get started there's not a lot you can write tutorials about. I suggest reading the BF2_scripting_system doc and psych0fred's LUA callbacks doc; both are invaluable in learning what you can and can't do with .lua.
Zaniac wrote:...one team stands in a set region and defends a single cp while the other team attempts to capture it...
You do know that that is almost exactly the same as King of the Hill with only one hill?
The easiest way to solve your problems is to wipe out ScriptPostLoad() and start that function over. You're not playing conquest, so you don't need anything relating to that game mode. The CPs will work fine without CommandPost:New, thats just Conquest mode configurations.
I'm not sure what you are doing with conquest.goal1. Thats a variable and after you clear/add an AI goal, you store it in goal1 then overwrite it with the next one. You can also directly tell them to defend the CP object itself.
Yes, a tutorial on building game modes and campaign maps would be great, but those are extremely hard to write. A good way to learn it to take a normal map, open its game mode script, and change one thing at a time and view the change in SWBF2. I made an effort to provide comments on everything going on in my game mode scripts. They don't talk about general game mode setup, but line-by-line they provide good info on how to do things.