Tools you'll need:
- PR 1.4x
- Winrar\etc for working with archives.
- Notepad(++) for coding.
Bf2 modding is all about modifying files with code that engine parsing into objects templates to be created&simulated later in game. As a bf1942 legacy, all objects still being initialized through .con files, but difference in bf2 is that .tweak files used to assign objects parameters like mass, torque, wings lift, rotation etc. You can edit them with your favorite vim or other editor(i prefer Notepad++ but heard mats using pycharm)
Small note about locating files:
Jets configs usually placed in /objects/vehicles/air/<jetname>/<jetname>.tweak
Directory /objects/ is always mounted in <root_game>/mods/<mod_name>/ folder, regardless if it's a actual folder(bf2editor work only with unpacked folder), or it's mounted zipfile(game works only with archives). Archives are being mounted through client or serverarchives.con in mod root.
To change something in-game, you need to change content in needed archive, as for pr jets it's in <mod_root>/content/objects_vehicles_server.zip
MAKE BACKUPS FIRST OR YOU WON'T BE ABLE PLAY ONLINE
2. Editing parameters
All objects in engine are being created from templates which we describe in those files.
Coding objects in bf2 are done via selecting objects and tweaking them.
Code: Select all
ObjectTemplate.create Wing ru_jet_su27_Wing_Front
ObjectTemplate.setWingLift 0.3Code: Select all
ObjectTemplate.activeSafe RotationalBundle ru_jet_su27_AirBrake
ObjectTemplate.setMaxRotation 0/50/0
After selecting object we can tweak it. In first case for example i'm modifying wing lift, and for second object i'm tweaking it's maximum rotation.
Most of commands are self-explanatory, but if you have bfeditor downloaded, some commands are explained in <game_root>/bfeditor/help/ folder.
So tl;dr if you see some tweak command that's mean it's tweaking object that's been created or activated somewhere's higher in code.
3. Main body parameters
Speaking about jets, we're specifically interested in this parts of code:
In main PCO(PlayerControlObject) there's few values that affect plane physics as a whole object.
Code: Select all
ObjectTemplate.drag 1
ObjectTemplate.gravityModifier 1- .drag affecting how much "air" resist when flying. The more value, the less max speed plane will be able to achieve.
Side effect is that drag affecting vertical movement aswell. If remove wings, increasing-decreasing value will affect how jet will drift aswell. Ideally this should be kept at 0.1 for jets. - .gravityModifier affecting how stronk gravity will be. Keep in mind that if you will change it, you'll need to tweak landing gear aswell.
Basically just telling to use object created somewhere else, and setting up it's position and rotation.ObjectTemplate.addTemplate ru_jet_su27_EngineMain
ObjectTemplate.setPosition 0.0/0.0/-10
ObjectTemplate.addTemplate ru_jet_su27_RudderYaw
ObjectTemplate.setPosition 0/0.0/-7.0
ObjectTemplate.setRotation 0/-30.0/-90.0000
In bf2 engine x/y/z position is floating point values(16bit precision iirc), where x for left(negative)&right(positive), y for top&bottom, z for front&back. Same goes for yaw/pitch/roll.
4. Engine
Code: Select all
ObjectTemplate.create Engine ru_jet_su27_EngineMain
ObjectTemplate.setMinRotation 0/0/0
ObjectTemplate.setMaxRotation 0/0/2000
ObjectTemplate.setMaxSpeed 0/0/1000
ObjectTemplate.setAcceleration 0/0/100
Code: Select all
ObjectTemplate.setTorque 150
ObjectTemplate.setDifferential 900
Second part is torque and differential and it responsible for jet thrust and max speed. While torque directly responsible for torque, differential affect max speed in weird way, but generally increasing it increasing max speed aswell.
The primary issue with engines in bf2 is that we can't have inertial. So basically only force that keep pushing jet through the air is it's engine.
5. Wings
Code: Select all
ObjectTemplate.create Wing ru_jet_su27_Wing_Front
ObjectTemplate.setWingLift 0.3First of all - they do not automatically lift you in air. Winglift value describing only how much resistance wing will cause when moving through air. That's something we've used in our Mk82 retarded bombs in the Falklands update.
As for controlling jet in air, we just have a set of wings that can rotate around so jet can yaw, pitch, roll.
Code: Select all
ObjectTemplate.create Wing ru_jet_su27_Winglet
ObjectTemplate.setMinRotation 0/-15/0
ObjectTemplate.setMaxRotation 0/20/0
ObjectTemplate.setMaxSpeed 0/300/0
ObjectTemplate.setAcceleration 0/-150/0
ObjectTemplate.setInputToPitch PIPitch
ObjectTemplate.setWingLift 0.2
ObjectTemplate.setFlapLift 0.15Second part is tricky one. While winglift working all the time, flaplift activates only when you rotate wing, and being added to winglift.
6. PR 1.4 jets setup
Previously, in pre-1.4 pr versions jets had wings mixed with rotational bundles and those being control surfaces at different coordinates on each jet. For 1.4.x setup i decided to split up rotational bundles visual wings and real physical wings. This allows me to have nicer numbers
Starting from scratch, i quickly(no) found cheapest(in terms of networkables) model possible is being a 3-point setup with back wing allowed to rotate for pitch controls. Later by center point were replaced by pair of roll controls on sides, and added vertical wing + rudder for yaw control.
Using su27 as example:


Modifying values at those points will change behavior of jet as you need, all you need for now just try and mistake. Do not hesitate to ask questions as otherwise i wasted ~2 years on experiments with physics

