Jump to content
Official BF Editor Forums
Sign in to follow this  
phresh

Create a custom game mode (in a mod)

Recommended Posts

Any folders I mention that you do not have, you should create. Any files you do not have in your mod folder you can copy from the mods/bf2 content and modify as described.

1. Create your custom python game mode file:

-------- Goes in ..modsmodnamepythonyour gpm_xxx.py

-------- (for sake of example this can be a renamed copy of gpm_cq.py)

2. Add support for the mode to your map.

-- A - Edit ..levelsmap_nameinfomap_name.desc

------------ within <modes> you need to have:

<mode type="gpm_xxx">



	 <maptype ai="1" players="16" type="whatever" locid="GAMEMODE_DESCRIPTION_whatever">Unlocalized test for this mode on this map</maptype>



	 <maptype players="32" type="whatever" locid="GAMEMODE_DESCRIPTION_whatever">Unlocalized test for this mode on this map</maptype>



	 <maptype players="64" type="whatever" locid="GAMEMODE_DESCRIPTION_whatever">Unlocalized test for this mode on this map</maptype>



 </mode>

-----------this can replace an existing one you don't plan on including (like supply line) or add it on.

-- B - in ..levelsmap_namegamemode you need a gpm_xxx folder with 16/32/64 folders in it for each map size you'll support

-------------You can simply copy one of the existing ones and name it accordingly for our example.

------** With the latest editor (jan06) we can modify it to support the mode:

----------in ..Battlefield 2bf2editormodsmodnameLayerInit.con

----------add or edit a line like this:

LayerManager.CreateDefaultFilter gpm_xxx Whatever

------------If you do this before you create a map to test on, your map should have step B done and you can skip it. It does appear, however, that you still have to do step A manually.

3. You can add appropriate entries in the localization files to make things look pretty

--------- In ..modsmodnameLocalizationEnglishEnglish_Patch.utxt add lines like these:

GAMEMODE_whatever       	 __Whatever__



GAMEMODE_DESCRIPTION_whatever  __Whatever Mode__

4. You can edit ..modnameMenuExternalFlashMenugameModes.con

--------Add a line such as:

swiffHost.addGameMode "gpm_xxx" "Whatever"

--------This makes it display 'Whatever' as your mode's name in the create local server menu.

At this point you can package your mod. Launch the game and through multiplayer -> "create local" you'll see 'Whatever' in there under game modes. It should run and if it doesn't there is some problem with the code in your custom gpm_xxx.py file.

Most, if not all, of this info is already on these forums but I figured I'd condense it into a tutorial for the community's sake.

Credit and thanks go out to the following people who helped me figure all of this out in other posts:

[RC]Azaezel[WWX]

Jaguar

JJeep

[iS2]TheFlyingCorpse

SuperB

Rexman

(anyone else who contributed to related discussions - sorry if I left you out)

Please reply to this if you find anything wrong or have something to add.

Cheers!

Share this post


Link to post
Share on other sites

OK, got that working so far... thanks! I have a question about distribution.

The only files I usually have in the mod's level folder is the info folder, with the map_name.desc inside it. That's enough to use the map as stock in the mod.

Since we're mucking around in the .zip files, does that mean that we have to redistribute the entire level folders just to switch game modes? That seems like an awful lot to force people to download.

Share this post


Link to post
Share on other sites

Well only that .desc file in the info folder and the server.zip get modded to allow the new game mode. So, you will need to have a modded server.zip along with your info fodler at a minimum if you're running a local (listen) server (not sure it'll work like this but it should. Otherwise, if you're running a dedicated server, that server needs to have the modded server.zip and info folder - then I beleve the clients could use the stock maps and play it. I believe this all to be true based on what I know but I can''t say I've tested/verified it all. Perhaps one of the DCon or CE Legends guys can confirm this.

Please post up any findings to help document this stuff.

-phresh

Share this post


Link to post
Share on other sites

OK, I'm having a problem that I *know* I read about in another thread, but I have some other odd results. Here are my tests:

gpm_xxx.py location: Nowhere

Effect: Loaded conquest

gpm_xxx.py location: mods/mymod/python

Effect: Loaded conquest

gpm_xxx.py location: mods/mymod/python/Game

Effect: Loaded conquest

gpm_xxx.py location: mods/mymod/python/Game/gamemodes

Effect: Debug assertion failed! Text: failed to initialize gamemode

Python log: ImportError: No module named gpm_xxx

gpm_xxx.py location: mods/bf2/python

Effect: Loaded conquest

gpm_xxx.py location: mods/bf2/python/Game

Effect: Loaded conquest

gpm_xxx.py location: mods/bf2/python/Game/gamemodes

Effect: Worked!

In conclusion, it seems to me like the gpm_xxx.py needs to go in the mods/bf2/python/Game/gamemodes/ folder to actually work. In order to work as an actual mod, it makes sense that it should go in mods/mymod/python/Game/gamemodes, but as I mentioned, that doesn't work.

The ever-popular rally mod has the gpm_rally.py file where I would expect them (in the mods/rally/python/Game/gamemodes folder) but I can't really find any differences that would cause the "ImportError: No module named gpm_xxx" in my python log.

Any ideas? I hope this hasn't been answered already.

Share this post


Link to post
Share on other sites

gpm_xxx.py location: mods/mymod/python/Game/gamemodes

Effect: Debug assertion failed! Text: failed to initialize gamemode

Python log: ImportError: No module named gpm_xxx

This error seems to be caused when __init__.py is missing, are you sure its there? (Yes I figured this out the hard way too:P)

__init__.py is usually empty, its just there.

Share this post


Link to post
Share on other sites

OK, well that was odd.

I did have an __init__.py in the gamemodes folder, but on a hunch from your post, Harry, I did the following:

1) Deleted the entire mods/mymod/python folder

2) Copied mods/bf2/python to mods/mymod

3) Dropped my gpm_xxx.py into mods/mymod/python/game/gamemodes

4) Played with my fancy new game mode!

What was actually wrong with my __init__.py files is a complete mystery to me, that should be an easy out for anyone having the same probs as me.

Thanks guiys!

Share this post


Link to post
Share on other sites

I have seen the game incorrectly call python files before if they are parented(it added /mods/modname/python/ to the existing parent python url and bugged out), which is not init python file related.

Share this post


Link to post
Share on other sites

It seems that thy python folder and all subfolders must be named completely lowercase, but the editor capitalises them when it creates it for you. That would be why it only worked when you deleted the python folder and copied the bf2 one across.

Share this post


Link to post
Share on other sites
It seems that thy python folder and all subfolders must be named completely lowercase, but the editor capitalises them when it creates it for you. That would be why it only worked when you deleted the python folder and copied the bf2 one across.

Good to know - when I was playing with this stuff before I noticed the same custom_gpm.py file fail at one point and work at another point - which was weird to me. Now in hidsight this makes sense because I had run the script to make the mod linux friendly - which is just renaming everything to all lowercase.

Cheers guys, glad to see this tut is being used to some extent =]

-phresh

Share this post


Link to post
Share on other sites

ok somthing happened to mine. i followed the tut exactly (i didnt have the english_patch.utxt so i copied the one from the bf2 folder and added the code at the bottom) and after i followed it not only did my game mode not come up but my map was gone too.

i really dont know why it did it. i followed it EXACTLY.

Share this post


Link to post
Share on other sites

Battlelauncher only supports gpm_cq, you could try to use BF2CC. Ive seen other launchers from different mods, dunno if they released them though but they usually support more gpms.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×