Is a simple, singe-player, tactical BF2 mod. Gameplay will be more difficult than default BF2 single-player.

Post tutorial Report RSS BF2 Single-Player Modding Tutorial

Basic BF2 Single-Player Modding Tutorial based on what I have learned

Posted by on - Basic Server Side Coding


ON THE H.U.D.:


* To disable names above soldiers: Add the line "renderer.drawNametags 0" to the init.con file in the mods folder

* To make flags visible/invisible on the map: Open the "Levels" folder & then the map you want to tweak. There, open "server.zip" & go to "GameModes". Look for the one you want & open "GamePlayObjects.con". Scroll down to the flags (almost at the end) & when you find the flag you want, add the line "ObjectTemplate.showOnMinimap 0" at the end to make that flag invisible on the map, or remove it to make it visible again.


ON THE A.I.:


* To set number of bots per map: Go to the AI folder inside the mods folder, open the AIDefaults file, the file itself tells you what to do in the 1st lines.

* To make the AI shoot better or worse: Go to the AI folder inside the mods folder, open the AIDefaults file & set the "aiSettings.setBotSkill" line to 1.0 for the highest accuracy or 0.X for something lower

* To make the AI approach the targets only as much as necessary (only works for infantry): You have to tweak each ranged weapon individually. Inside the mods folder, open "Objects_server.rar", "weapons", "handheld", open a weapons folder, open the "ai" folder, open the file inside & set the "weaponTemplate.optimalRangePercentage" line to 99.

* To make AI infantry more prone to take cover: Open the same file of the previous point & set the "weaponTemplate.setFiringPose" line to "Lying"

* To set at which range bots will use a weapon: Open the same file of the previous 2 points & set the distance in the "weaponTemplate.maxRange" line, the equivalency is meters. For vehicle-mounted weapons, the file you need to edit might be in the "vehicles" folder instead of the "weapons" folder (inside that specific vehicles folder) if not, it should be in either the "armament" or the "stationary" folders inside the weapons folder

* To make AI pilots stop abandoning transport helis in-flight: Open the chopper's folder inside the objects_server .zip file. There open the .tweak file % look for the line "ObjectTemplate.setSoldierExitLocation -2/-0.2/0 0/0/0" (the numbers may vary), the line is repeated many times in the file, one for each position, pilot is usually 1st. Under the line add the line "ObjectTemplate.dontAllowExit 1" That makes both ai & player unable to exit, it can be applied to any position

* To make bots man and stay longer on stationary weapons: Try increasing the temperature for the weapon in the "aiTemplate.basicTemp #" line in the object.ai file. I'm not 100% sure it works.

* To disable bots attacking with defibrillators: Open the defibrillator's "weapons.ai" file & set the strength against infantry to 1.0

* To make bots unable to shoot a weapon through smoke: You have to tweak each weapon individually. Open Objects_server.zip, search for each weapon & open the AI folder inside each one, there open weapons.ai & add the line "weaponTemplate.setFiresThroughTransparent 0" at the bottom. I'm not 100% sure this is how it works



ON THE MAPS


* To set the number of tickets(points) each side gets: Enter the "levels" folder inside your mods folder, open the folder of a specific map, then the .zip file "server" & there open the file "init". There you can set the number you want in a series of lines, the 1st of which is "gameLogic.setDefaultNumberOfTicketsEx 16 1". When you play that map the number of tickets for both sides will be twice the number set in the file, I don't know why.

* To set who owns which flag at the beginning: Open any maps folder at the Levels folder & open "server.rar/GameModes/sp1(usually)/X/GamePlayObjects.con". There you have to scroll down almost to the bottom of the file to look for the flags, each one is under a "ObjectTemplate.addTemplate flagpole" line. To set ownership of a flag you must add the line: "ObjectTemplate.team 1(or 2)" under the line "ObjectTemplate.radius X". To quickly check which side is 1 & which 2 for each map, open the "init.con" file inside "server.rar" & scroll down just a little bit.

* To choose which flags are "cappable": You must tweak the same file that in the previous point. There, under each flag, the line: "ObjectTemplate.unableToChangeTeam 1" must be present for the flag to be "uncappable" or absent for it to be a normal flag.

* To set the "capping" range of a flag: You must tweak the same file that in the previous point. Under the flag you want to edit, look for the "ObjectTemplate.radius" line & change the value as you wish.

* To delete the combat area limits: Open the same file as the previous points, scroll down to the very end & delete everything below the "end if" line. This will allow you to flank the bots through areas you couldn't before. Bots will still avoid these areas if they are not included in their pathfinding. I haven't noticed any negative effect on doing this, but if I do, I will report it here. If deleting those lines makes you feel uneasy, make a backup of the map beforehand. I've noticed an issue: Apparently when you're playing a round and you open the map (Caps Lock by default) it doesn't show the entire map but roughly the area contained within the combat area limits. However, when you delete this limits, then it shows the entire map, which might make it uncomfortable to use in small maps, since all the flags and all the area where the bots actually move around are in a small corner of this big-ass map.

* To change a map's description: You will find it in Levels/(map name)/Info/(map name).txt. Its the text between the 2 <briefing> markers. Just write what you want. Adding quotation marks ("") to the description sometimes causes the map no to appear on the map list in-game.

* To change a map's name on the in-game list: Open the same file as the previous point & edit the name in between the two <name> markers.



ON THE SOLDIERS:


* To set infantry moving speed/jump height: Edit the file "Objects\soldiers\Common\Common.con". But reducing the walking & sprinting speed (phy-soldier-speed-factor #) disables the 1p sprinting animation, I haven't found the solution yet.

* To change how long dead bodies stay before disappearing: Go to "Objects_server.rar/soldiers" look for a soldier you'd like to change & open it's tweak file & look for the line: "ObjectTemplate.armor.TimeToStayAsWreck". Change the value to whatever you want. I think it's equivalent to seconds. Setting to -1 makes them last forever, but this causes lag.



ON THE KITS:


* To set how long it takes for dropped kits to disappear: Inside the mod´s folder open "objects_server.rar". Inside open "kits" & look for the one you want to change. Open the .con file & at the bottom of the 1st paragraph add the line: "ObjectTemplate.timeToLiveAfterDeath 75". Change the numbers to whatever you want (equivalent to seconds)

* To change a Kit's name: Inside the mod´s folder open "objects_server.rar". Inside open "kits" & look for the one you want to change. Open the .con file. Near the bottom you will find the line:

"ObjectTemplate.vehicleHud.hudName "HUD_TEXT_MENU_SPAWN_KIT_X""

Change the whole line in caps to whatever you want, save and exit.



ON THE WEAPONS:


* To set the damage of a weapon: Look for the weapon's folder in "objects_server.rar" & open the tweak file. There, look for the lines:

"ObjectTemplate.minDamage x
ObjectTemplate.damage x
ObjectTemplate.distToStartLoseDamage x
ObjectTemplate.distToMinDamage x"

I think these lines are pretty self-explanatory. I have noticed that the damage of BF2s combat knife in-game seems to be like 4 times the value set in the file, I don't know why.

* To set the amount of ammo a weapon gets: Open the same file as the previous point and look for the lines:

"ObjectTemplate.ammo.nrOfMags X
ObjectTemplate.ammo.magSize X"

The 1st line sets quantity of mags and the 2nd sets amount of rounds in each mag.

* To change how effective ammo-kits/med-kits/wench are: Go to: Objects_server.zip/weapons/handheld/wench(for example) & open the .tweak file. The line: ObjectTemplate.ammo.abilityStrength sets how many hp it restores with each "hit". The line: ObjectTemplate.ammo.abilityDrain set how much each "hit" tires the user. The "radius" line changes exactly that (in meters). I don't know what the other lines do yet.

* To change a weapon's deviation(accuracy): Open the weapon's .tweak file. In the file you will find a paragraph that deals with deviation, which will contain some of the following lines:

ObjectTemplate.deviation.devModStand X (I think this means deviation while you're standing up)
ObjectTemplate.deviation.devModCrouch X (I think this means deviation while you're crouching)
ObjectTemplate.deviation.devModZoom X (I think this means deviation while you're aiming)

ObjectTemplate.deviation.devModLie X (I think this means deviation while you're prone).

Change the values in "X" to whatever you want. Keep in mind, higher value means higher deviation(lower accuracy). I don't know yet if changing these values also changes bots' accuracy. As you will see there are other lines in the file that also deal with deviation, but I don't know how these work yet.



ON THE VEHICLES


* To set which camera views are available when pressing "cycle camera" button: Open the "ObjectsServer" zip file in the mods folder. Search for the specific vehicles folder & open the .tweak file. Search for the "Camera_RotationRpm" lines for the different positions & under each one add:
ObjectTemplate.CVMNose 1
ObjectTemplate.CVMChase 1
ObjectTemplate.CVMFrontChase 0
ObjectTemplate.CVMFlyBy 0

If you want only 1st & 3rd person, for example. "Nose"=1st person, "chase"=3rd person, "front chase"=rear view

* To set how long destroyed vehicles last before self-exploding: Open the objects_server.rar file, go to "vehicles" & look for the one you want to tweak (might also be in "booster_server.rar"). Inside the vehicle´s folder open the tweak file, look for the "ObjectTemplate.armor.timeToStayAsWreck" line & set the number you want (equivalent to seconds, -1 makes it stay forever)

* To set how long it takes for vehicles to respawn: It must be done map by map. Inside the mod´s folder go to the levels folder & there to any map´s folder. Open the "server.zip" file & there go to gamemodes, sp1, 16(for example) & there open the "gameplayobjects.con" file. In the file you will see a paragraph for each spawnpoint for vehicles, emplaced guns & command structures. At the bottom of any you want to tweak, add the lines:

ObjectTemplate.minSpawnDelay 360
ObjectTemplate.maxSpawnDelay 360

if they are not there already. Change the numbers to whatever you want (equivalent to seconds, I don´t know what happens when adding 2 different numbers to the 2 lines)

* To choose which vehicle(or defensive weapon) spawns where: You need to open a specific level folder, then open "server.rar/GameModes/sp1(usually)/16(or another)/GamePlayObjects.con". There, you will find a list of the spawn points for vehicles & defensive weapons. they usually have 2 lines that go like this:

ObjectTemplate.setObjectTemplate 1 xxx
ObjectTemplate.setObjectTemplate 2 xxx

The 1st line selects the vehicle for side 1 & the second for side 2, to see which side is which you must open "init.con" inside "server.rar". You can change the vehicles, delete a line so only 1 side will get vehicles from that point, or delete both lines so that no vehicle will spawn there. You supposedly can do the same things with defensive weapons, but I wouldn't tinker too much with those. To change these spawn points you need to use the editor.

* To make a vehicle belong to a faction even when its unmanned: You must choose a map & open the same file as in the previous point, there look for the spawning point of the vehicle you want to tweak, & under the last lines, usually:

ObjectTemplate.minSpawnDelay x
ObjectTemplate.maxSpawnDelay x

Add the line: "ObjectTemplate.teamOnVehicle 1" This makes it so that the vehicle(s) that spawn there belong to the faction that owns that flag. I imagine the same should apply to static weapons, if tweaked the same way. (I now think this is causing crashes when applied to vehicles where the driver can be shot off, like light jeeps).

Post comment Comments
56region
56region - - 180 comments

Thanks for your advice. Now even I can not leave the helicopter or the tank ...)

Reply Good karma Bad karma+1 vote
X1Destroy
X1Destroy - - 963 comments

Do you know how to make AI always try to get inside the gun slot of attack heli?

How to make them use the TV-guided missile?

Reply Good karma Bad karma+1 vote
56region
56region - - 180 comments

In the AI ​​file of the car you need, specify the temperature above 100 for example or 150 for the arrow's place. And the bots will jump there very quickly.

Reply Good karma Bad karma+1 vote
BF2_SP_Freak_on_weed Author
BF2_SP_Freak_on_weed - - 80 comments

Thanks for that

Reply Good karma+1 vote
BF2_SP_Freak_on_weed Author
BF2_SP_Freak_on_weed - - 80 comments

Sorry, I didnt see your comment until now, I dont know but check here: Classic-battlefield-modding.fandom.com

Reply Good karma+1 vote
Guest
Guest - - 690,642 comments

I just want to ask what edits you made to the ai to make them better? I don't really see a difference.

Reply Good karma Bad karma0 votes
BF2_SP_Freak_on_weed Author
BF2_SP_Freak_on_weed - - 80 comments

Mostly they shoot more accurately, from further away, and are more likely to prone or crouch while doing it

Reply Good karma+2 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: