I've been sick the past couple of days which means I've been frustrated that my brain is firing on all cylinders. When I'm sick I try to keep my brain working via coding or the like, so after I knocked out a lil script to help a math professor prove some mathy thing I didn't understand, I turned to the Battlefield 2 (BF2 from here on out) server I run for my house. Thankfully EA/Dice has an official Linux dedicated server that is easy to set up and customize, unfortunately not all mods return the favor. I'll quickly go through setting up the official server, then customizing it, and if I can get it running myself, the Nations at War 5.1 server!
Installation
I started by creating a bf2 user so that I could give my roommates shell access to start and stop the server if they needed (ok, wanted) to while I wasn't there.
Then I created a folder for the server, in my case that was /usr/bf2, but wherever you decide to install this will be referred to as [base-dir] from here on. Move into that directory, then wget the server files and unzip. I won't go into much more detail than that because a few sites already spell it out nicely.
The final bit of installation is turning rcon (remote control) on. You want to create the file "[base-dir]/admin/default.cfg" consisting of:
port=4711
password=your_password
Now when you're playing you can open the console, type 'rcon login your_password' and execute admin commands.
Customization
Customization is where the bf2 server gets fun. I don't run my server on the Internet, only within my house, so I have a lot of coop (LAN party goodness) settings. All the files yuou're going to want to modify are inside the [base-dir]/mods/bf2/settings directory. Lets start with serversettings.con as it is the logical place to start. I'll lay out some of the important server (sv) settings.
Server settings, how it'll appear in the game browser and port it uses. Change the port to run multiple servers on the same box.
sv.serverName "Snarky's roughnecks"
sv.password ""
sv.internet 0
sv.serverIP "192.168.0.3"
sv.serverPort 16567
sv.welcomeMessage "Welcome to... THE ROCK!"
Player settings, I turn off punkbuster so we can use no-cd hacks and share disks at LAN parties. Also make sure Friendly fire is on, but turn friendly fire with mines off so people don't get mad when they run over my claymores. Of course, ya wanna turn off tk punish, just in case *grin*.
sv.punkBuster 0
sv.soldierFriendlyFire 100
sv.vehicleFriendlyFire 100
sv.soldierSplashFriendlyFire 100
sv.vehicleSplashFriendlyFire 100
sv.tkPunishEnabled 0
sv.tkNumPunishToKick 3
sv.tkPunishByDefault 0
Bot settings, what makes coop fun! This turns team balance off, then stacks 75% of the bots on team 2 (against US) and gives them medium difficulty. This is enough for two humans (and 10 bots) to have a difficult, but winnable game.
sv.autoBalanceTeam 0
sv.teamRatioPercent 100
sv.coopBotRatio 75
sv.coopBotCount 30
sv.coopBotDifficulty 50
Round settings, the number of players s human playersso you can ignore that. I bump the ticket ratio up for a longer game, play two rounds before changing maps, and have no time limit, and no scoring limit (so we can rack up over 200 points).
sv.maxPlayers 32
sv.ticketRatio 300
sv.roundsPerMap 2
sv.timeLimit 0
sv.scoreLimit 0
Fake sponsor junk, get your roommates to buy you chips in return for admining their server!
sv.sponsorText "Sponsered by your local neighborhood Snarky."
sv.sponsorLogoURL ""
sv.communityLogoURL ""
Now you'll want to edit maplist.con, in the same directory. I have all mine set to gpm_coop, and 16 player maps (the largest EA/Dice make their coops for). This is where you'd drop in the names of any new maps you download, I have a few in here, and highly recommend heli_attack!
maplist.append "goods_station" "gpm_coop" 16
maplist.append "cp_abadan" "gpm_coop" 16
maplist.append "dalian_plant" "gpm_coop" 32
maplist.append "daqing_oilfields" "gpm_coop" 32
maplist.append "dragon_valley" "gpm_coop" 32
maplist.append "fushe_pass" "gpm_coop" 32
maplist.append "gulf_of_oman" "gpm_coop" 32
maplist.append "operation_clean_sweep" "gpm_coop" 32
maplist.append "road_to_jalalabad" "gpm_coop" 32
maplist.append "sharqi_peninsula" "gpm_coop" 32
maplist.append "songhua_stalemate" "gpm_coop" 32
maplist.append "strike_at_karkand" "gpm_coop" 32
maplist.append "zatar_wetlands" "gpm_coop" 32
maplist.append "boat_wars" "gpm_coop" 16
maplist.append "heli_attack" "gpm_coop" 16
maplist.append "tank_master" "gpm_coop" 16
maplist.append "jammed" "gpm_coop" 16
The most unique part of my server, I believe, is the bot names. These can be found in "[base-dir]/mods/bf2/ai/botnames.ai" and are set by default to boring military looking names (J.Smith, B. Bradley, etc). I went through and removed them all, and have been adding random bots based on varius naming schemes. My first was famous dictators such as:
aiSettings.addBotName Saddam Hussain
aiSettings.addBotName Adolf Hitler
aiSettings.addBotName Darth Vader
I've done all kinds of naming conventions such as famous Star Trek characters, the pilots from Top Gun, and great old games like Commander Keen! Now you'll hear peals of laughter across the house when we realize Luke Skywalker just knifed Darth Vader... it fits so perfectly! (Also good is the time Bill Gates shot down Steve Jobs).
Common Problems
The problem I ran into most often was maps (and mods) that liked Windows naming conventions. For a map all you have to do to fix it is unixify all files/directories in/below the maps directory ("[base-dir]/mods/bf2/levels/[map]"). Also, make sure it has the type of level you're trying to play. If it has gpm_cq, but no gpm_coop, it won't let you add it as gpm_coop, unfortunately. You can check this by looking at "[base-dir]/mods/bf2/levels/[map]/info/[map].desc". If the server is running when you make these changes, or add a map, you'll have to restart it in order to have it recognize the new map.
Nations at War
For whatever reason EA/Dice decided to make the linux server only like lower-case filenames. This is a bit of a pain, and by a bit I mean a lot. For a mod that uses UNIX file naming conventions (undercase, no spaces, etc) there's really no problem taking the Windows server and dropping it into your mods directory on Linux. Unfortunately not all mod designers have access to Linux (or so they claim, I say everyone has access to it) and some just love their Windows capitalization which makes a HUGE problem. Well, a huge problem if you can't script.
To install the Nations at War 5.1 server, grab the install files:
wget http://www.nawtek.com/5.01/NAW-5.01-Server-Full.zip
Then unzip that into your dedicated server's mods directory. If you try to run the server now it'll crash silently, not too helpful, huh? It turns out the first bit of crashing (I believe) is caused by filenames, they're not unixified. I have a quick and dirty perl script that renames everything in the working directory and below to be lowercase and have underscores instead of spaces, but EA/Dice has their own version found at "[base-dir]/lowercaseDir.py" which may work better. Either one you use, make sure you rename everything to lowercase.
Next you want to check the files in "[base-dir]/mods/naw/python/game/" and find scoringcommon.py. If it is not scoringCommon.py, move it to that, as that file is specifically called in the init script.
Finally, make sure there's at least one map in "[base-dir]/mods/naw/settings/maplist.con" that can be loaded, otherwise it'll again crash silently. The one that finally worked for me was:
maplist.append "iraq_oilfields" "gpm_cq" 32
Now you should be able to start the server from the [base-dir] directory with:
./start.sh +modPath mods/naw
Hopefully you'll now see the server screen, as the above worked for me. Unfortunately some maps caused my client to crash to desktop, and I'm not sure why. Currently I'm blaming it on the map.
Other Mods
While NAW was interesting as a mod, I'm far more impressed by Allied Intent Extended. Awesome new skins on almost everything, tons of new planes, boats, and ways to die. Think the Spec Ops died before he could blow the C4? Too bad it was on a 20 second timer... Oh look a plane, I'm safe in a tank. Oh, nuts it was an A-10 Warthog. Oh, and it takes no effort to run under Linux!
I wanted to keep the same settings and botnames, so for the important files mention above I recommend linking them to your main files.
ln -s [base-dir]/mods/bf2/ai/botnames.ai [base-dir]/mods/aix/ai/botnames.ai
And so forth. This way to can tweak your main server as you like, and all the others will follow it.



