Page 1 of 1

[Help] How to Mod BF2

Posted: 2010-10-13 17:48
by Bluedrake42
I have an idea for a game play aspect of PR BF2 and I want to try and do it myself. I'm gonna post it in the suggestions forum too later, but right now I want to see if I can do it myself.

Right now what I want to do is this.

You know how when you fire a gun there's recoil?
You know how we don't like the limited deviation system right now?

Here's what I was thinking. When you get shot, or generally just when you have large radius of deviation, there would be a continuous recoil animation that animated at the intensity equal to your current amount of deviation.

Kind of like this
YouTube - SMOD: Tactical Delta 6 Early Gameplay

Go to around 50 seconds in the video,
Notice the effect when the player is hurt.
So that's what I'm thinking of, can anyone help me understand how I start coding for this?

Re: How to Mod BF2? Help

Posted: 2010-10-13 17:50
by Jigsaw
Moved to PR:BF2 Community Modding.

Re: How to Mod BF2? Help

Posted: 2010-10-13 17:52
by Bluedrake42
[R-MOD]Jigsaw wrote:Moved to PR:BF2 Community Modding.
Oh sorry thanks a lot man

Re: How to Mod BF2? Help

Posted: 2010-10-14 04:01
by Sniperdog
Deviation for handheld weapons in bf2 is not handled by animations but rather by deviation and recoil properties assigned specifically to each firearm.

Take for example:

pr\objects\weapons_server.zip/Handheld/usrif_m16a4/usrif_m16a4.tweak

You'll see a section in that file where it defines:

Code: Select all

rem ---BeginComp:SoldierBasedRecoilComp ---
rem 556 Standard Recoil Assault Rifle
ObjectTemplate.createComponent SoldierBasedRecoilComp
ObjectTemplate.recoil.hasRecoilForce 1
ObjectTemplate.recoil.recoilForceUp CRD_UNIFORM/1.8/1.8/0
ObjectTemplate.recoil.recoilForceLeftRight CRD_UNIFORM/-1/1/1
ObjectTemplate.recoil.zoomModifier 0.6
ObjectTemplate.recoil.goBackOnRecoil 1
ObjectTemplate.recoil.recoilGraphFrameCount 5
ObjectTemplate.recoil.recoilGraphExponent 5
ObjectTemplate.recoil.recoilGraphTotalMovement 0.25
rem ---EndComp ---
rem ---BeginComp:SoldierDeviationComp ---
rem 556 Optical Sight Standard Accuracy Assault Rifle
ObjectTemplate.createComponent SoldierDeviationComp
ObjectTemplate.deviation.minDev .333
ObjectTemplate.deviation.setFireDev 1.4 .7 .023
ObjectTemplate.deviation.setTurnDev 2 .15 .15 .05
ObjectTemplate.deviation.setSpeedDev 3 .02 .02 .02
ObjectTemplate.deviation.setMiscDev 20 20 .15
ObjectTemplate.deviation.devModStand 1.5
ObjectTemplate.deviation.devModCrouch 1.0
ObjectTemplate.deviation.devModLie 0.9
ObjectTemplate.deviation.devModZoom .3
rem ---EndComp ---
The numbers in the recoil component define specifically what the gun does when you fire a bullet.

The numbers in the deviation component define specifically how the spread of your weapon increases as you move, turn, fire, crouch, etc... and how it decreases as time passes.

Coding wise you have two options:

1. Duplicate your mod directory, Edit tweak files like the above, and save it in the archive. Then go in game and try it out.

or

2. Set up your mod for the bfeditor (heres a link with instructions: https://www.realitymod.com/forum/f189-m ... dding.html) and open the weapon and test fire it in there.

I also suggest you read as much of the stuff from this section:

https://www.realitymod.com/forum/f189-modding-tutorials

as you can; there is a wealth of excellent info there.

Re: How to Mod BF2? Help

Posted: 2010-10-14 05:29
by Bluedrake42
Oh I know deviation isn't handled by animation, but is there some way to link animation to deviation values? not to what they're set as in the properties mind you, I'm talking about being linked to the real time deviation values in the game... or am I missing something?

Re: How to Mod BF2? Help

Posted: 2010-10-14 12:29
by Sniperdog
Bluedrake42 wrote:Oh I know deviation isn't handled by animation, but is there some way to link animation to deviation values? not to what they're set as in the properties mind you, I'm talking about being linked to the real time deviation values in the game... or am I missing something?
No we can't actually change the in game deveation values in real-time, we can only set the properties according to the above. There is no way to link animations to the deviation values (nothing that wouldn't be extremely complicated and involve reading/writing to the memory at least)