[Coding] Realistic Deviation [WIP]

Making or wanting help making your own asset? Check in here
Wolfe
Posts: 1057
Joined: 2007-03-06 03:15

Post by Wolfe »

Primary Objectives:
  1. Reduce/Eliminate prone spam.
  2. Reduce/Eliminate run'n gun.
  3. Promote realistic CQB weapons and tactics.
  4. Maintain weapon accuracy.
Definition of "Realistic Deviation":
BF2 does not have weapon sway. Realistic infantry combat cannot exist without it, so the only known way to create it is to simulate it through weapon deviation. This decreases the weapon accuracy but increases the realistic deviation when that weapon is in the hands of a soldier. So by "Realistic Deviation", I am referring to deviation when the weapon is in the hands of a soldier, not when it is locked down with clamps and firing down range in perfect lab conditions.

Coding Outline:
  • High deviation when non-zoomed (firing from the hip).
  • Low deviation when zoomed.
  • Increase zoom-in delays and zoom-in animation times.
  • Slightly increase v.75 max deviations (fire, turn, move).
  • Slightly increase v.75 recovery times (fire, turn, move).
  • Slightly reduce G3 recoil (Recoil is too easily negated with mouse movements, especially those who can adjust dpi on the fly. Reducing the recoil effect minimally affects deviation while simultaneously narrowing the gap between those who have a dpi mouse and those who don't.
  • Decrease turn rate for open sight weapons (iron sights, LAT, grenadier, etc.)
  • Add single-shot max fire rate to single-shot rifles.
  • Sniper: Decrease tracking deviation, increase move recovery time.
  • LAT: Slightly increase min and max deviation.
  • Grenadier: Slightly increase min and max deviation.
  • Support: Increase move recovery time.
  • Remove "auto return" recoil effect from assault rifles.
Special Coding Values:
The following information is being provided as a technical reference for myself as well as a reference for anyone who is interested in understanding deviation coding. I will be adding more to this section as time allows.

Per-shot delay*:
Located in the weapon.tweak file. Regulates how often pressing the "fire" or "zoom" key will be registered in a given amount of time. For example, a value of 10 will only allow the weapon to be fired/zoomed once every ~10 seconds. A value of 0.08 will only allow the weapon to fire 5-6 bullets per second. Firing a weapon as quickly as you can click a button is unrealistic. Using this code adds a valuable element of realism by limiting rapid single-shot to human-like abilities.
rem ---BeginComp :D efaultAnimationComp ---
ObjectTemplate.createComponent DefaultAnimationComp
ObjectTemplate.animation.useShiftAnimation 1
ObjectTemplate.animation.shiftDelay 0.08


Fire-Delay-From-Prone:
Located in the soldier/common/common.con file. Prevents a weapon from being fired when switching to the crouch/stand position from the prone position. Helps to prevent jack-in-the-box shooting from prone.
rem *** number of seconds the player must wait to fire weapon after being prone...
Vars.Set fire-delay-from-prone 1.2


Ironsight Zoom Factor:
Located in the weapon.tweak file. This removes 99% of the zoom effect; a vast improvement over the current 0.9 value.
ObjectTemplate.zoom.addZoomFactor 1.099

Zoom Delay:
Located in the weapon.tweak file. This is the delay (in seconds) before a weapon will switch to and from the final zoom view after the zoom key is pressed. During this delay, the weapon cannot be fired.
ObjectTemplate.zoom.zoomDelay 0.7

Zoom Field-of-View Delay:
Located in the weapon.tweak file. This prevents the background from slowly zooming in during the zoom delay so that once the zoom animation completes, the view instantly switches to the zoom mode (instead of slowly zooming in during the animation). This code should only be used for scopes where the scope view has black screen edges. This code should NOT be used for open scope weapons such as iron sights or reflex sights such as the spec ops weapon.
ObjectTemplate.zoom.changeFovDelay 0.7

Mouse Turning Rate:
Located in the weapon.tweak file. This regulates how quickly you can turn while zoomed in. Values range from 1.0 (no restriction) to 0.0 (no turning). This code is not used for scoped weapons and more useful for ironsights with a value of .8. The lower the number, the slowing the turning rate. Useful for preventing a soldier from doing rapid 180 degree turns.
ObjectTemplate.zoom.mouseSpeedMod 0.4

Deviation Calculation:
Documentation regarding how BF2 calculates deviation is rare, outdated, and often incorrect. For example, the BF2 wiki page states that deviation is calculated as [(Mindev * Stance) + (Fire + Speed + Turn) * Zoom] but have found this to be inconsistent with ingame results. If this were true, a (0 base dev), (2 stance), and (5 additional shot) should result: 0 * 2 + 5 = 5, but it does not. The in-game result is 10, not 5. This and other testing leads me to believe the deviation calculation is as follows (if anyone can confirm or correct this, please do):

[(Mindev + Fire,Speed,Turn) * Stance * Zoom]

Known Issues:

Development Status:
The following represents the latest deviation models:

Rifleman
rem ---BeginComp:SoldierBasedRecoilComp ---
rem 556 Standard Recoil Assault Rifle
ObjectTemplate.createComponent SoldierBasedRecoilComp
ObjectTemplate.recoil.hasRecoilForce 1
ObjectTemplate.recoil.recoilForceUp CRD_UNIFORM/1.2/1.3/0
ObjectTemplate.recoil.recoilForceLeftRight CRD_UNIFORM/-0.1/-0.3/0
ObjectTemplate.recoil.zoomModifier 0.4
ObjectTemplate.recoil.goBackOnRecoil 0
rem ---EndComp ---

rem ---BeginComp:SoldierDeviationComp ---
rem 556 Optical Sight Standard Accuracy Assault Rifle
ObjectTemplate.createComponent SoldierDeviationComp
ObjectTemplate.deviation.minDev .333
ObjectTemplate.deviation.setFireDev 1.5 1.5 .038
ObjectTemplate.deviation.setTurnDev 3 .225 .225 .075
ObjectTemplate.deviation.setSpeedDev 1.5 .1 .1 .015
ObjectTemplate.deviation.setMiscDev 5 5 .05
ObjectTemplate.deviation.devModStand 1.6
ObjectTemplate.deviation.devModCrouch 1.5
ObjectTemplate.deviation.devModLie 1.3
ObjectTemplate.deviation.devModZoom .3
rem ---EndComp ---
Last edited by Wolfe on 2008-07-23 19:26, edited 89 times in total.
Mosquill
Retired PR Developer
Posts: 857
Joined: 2007-08-12 10:13

Re: [WIP] Realistic Deviation

Post by Mosquill »

Wolfe wrote:Known Issues:
  • Scope-in animation- ANIMATORS! HELP!
    When increasing the scope in delay (zoomDelay), you get a very neat and cinematic effect as the camera slowly zooms towards your target while your scope moves towards your eye. I thought this would be perfect until after a few hours of play testing. Because scoped rifles are zoomed in/out many times, our testers (including myself) began to get sick from vertigo. I wanted realism, and barfing due to combat is realistic, but this wasn't the realism I had in mind.

    The only alternative was to stop the camera from slowly zooming in. To do that, I added (changeFovDelay) but it changes the animation effect slightly. Instead, the rifle quickly moves to the eye and remains there while you stare at the scope bracket, after which, it then switches to looking through the scope.

    To correct this, my idea was to slow down the scope-in animation. Problem is, animators are in short supply and the time Involved to change every animation for every scoped weapon might be too much. Then again, this would only have to be done for the assult rifles with scopes.

    Another alternative would be to create a single generic animation that could be used for all scoped weapons... but not quite sure how that would work.. just an idea.

    Marksmen and snipers probably don't need any animation; they could keep the zoom-in effect because 1) they don't zoom/unzoom as often as riflemen (or do they?) and 2) it looks really really cool on a sniper weapon.. movie like.
You don't need new animations to solve this. Go to your weapon's AnimationSystem1p.inc and find something like this: animationSystem.createAnimation Objects/Weapons/Handheld/usrif_m16a4/animations/1p/1p_m16a2_tozoom.baf
animationManager.looping 0
animationManager.length 0.083333

Just change the lenght to what you want. If there is no 'animationManager.length' for the animation, add one. The animation you need usually has '_tozoom' at the end.
space
Posts: 2337
Joined: 2008-03-02 06:42

Re: [WIP] Realistic Deviation

Post by space »

Good sfuff - anything which reduces prone spamming has got to be good - I can hear the prone spammers crying now! - Good luck.
DeltaFart
Posts: 2409
Joined: 2008-02-12 20:36

Re: [WIP] Realistic Deviation

Post by DeltaFart »

sheesh jonny I was just asking no need for that :'-(
Wolfe
Posts: 1057
Joined: 2007-03-06 03:15

Re: [WIP] Realistic Deviation

Post by Wolfe »

Jonny wrote:Recoil:
See my ballistics spreadsheet for a model of the relative recoil effects.
Thank you; that should save time. Are these values already in the game or is this something new?

[quote=""'[R-CON"]Mosquill;673693']You don't need new animations to solve this. Go to your weapon's AnimationSystem1p.inc[/quote]

Thanks, I'll try that.

[quote="DeltaFart""]will this interfere with the balistics?[/quote]

No. Deviation and Ballistics are two different things and located in two different files. Deviation only affects the initial direction of the bullet based on stance and gun movement at the instant you pull the trigger. After the bullet leaves the gun, separate ballistics tell it how to behave based on gravity and other factors. I am only working on deviation.
Last edited by Wolfe on 2008-05-12 19:58, edited 1 time in total.
Waaah_Wah
Posts: 3167
Joined: 2007-07-26 13:55

Re: [WIP] Realistic Deviation

Post by Waaah_Wah »

Wolfe wrote: At 100 meters, a single shot can hit the center of a truck wheel.
Erm... The wheel is pretty large. Does this mean that we might have trouble with hitting a man sized target 100-150 meters away? In that case, whats the point of having ballistics if the bullet doesnt go where you aimed it anyway?
Never argue with an idiot, he will just drag you down to his level and beat you by experience ;)

Killing for peace is like f*cking for virginity

I :33_love: Jaymz
Wolfe
Posts: 1057
Joined: 2007-03-06 03:15

Re: [WIP] Realistic Deviation

Post by Wolfe »

Waaah_Wah wrote:Erm... The wheel is pretty large. Does this mean that we might have trouble with hitting a man sized target 100-150 meters away?
No. Center of the wheel means dead center.

Scoped @ 100m:
If stationary, you'll score a headshot easily.
If walking towards the target, you'll score a headshot most of the time.
If strafing left/right, you'll score a body shot.
If walking straight towards the target in full auto, 75% of your shots will hit.

Unscoped (firing from the hip) @ 100m:
Regardless if stationary or moving, you're not going hit your target unless you get lucky, but all bullets will go that direction.

P.S.: Mosquill,
That animation code works GREAT. Looks polished now.
Waaah_Wah
Posts: 3167
Joined: 2007-07-26 13:55

Re: [WIP] Realistic Deviation

Post by Waaah_Wah »

Wolfe wrote:No. Center of the wheel means dead center.

Scoped @ 100m:
If stationary, you'll score a headshot easily.
If walking towards the target, you'll score a headshot most of the time.
If strafing left/right, you'll score a body shot.
If walking straight towards the target in full auto, 75% of your shots will hit.

Unscoped (firing from the hip) @ 100m:
Regardless if stationary or moving, you're not going hit your target unless you get lucky, but all bullets will go that direction.
Now why didnt you just say that? :p
Never argue with an idiot, he will just drag you down to his level and beat you by experience ;)

Killing for peace is like f*cking for virginity

I :33_love: Jaymz
zangoo
Posts: 978
Joined: 2007-09-01 03:42

Re: [WIP] Realistic Deviation

Post by zangoo »

hey since you are adjusting deviation, could you add the moa for most guns, i have the moa for like 10 or so. if you want me to give it to you just pm me, or if you have xfire my xfire is zangoo.
Ballistics or Tracers? Please Vote
[DM] member, We are now recruiting!
Xfire:Zangoo
Wolfe
Posts: 1057
Joined: 2007-03-06 03:15

Re: [WIP] Realistic Deviation

Post by Wolfe »

zangoo wrote:hey since you are adjusting deviation, could you add the moa for most guns, i have the moa for like 10 or so. if you want me to give it to you just pm me, or if you have xfire my xfire is zangoo.
I would like to have MOA (and recoil) based in realism, but not copy it exactly. Why not? Because in the real world, you have to deal with many known and random factors to shoot accurately. In the game, all I have to do is move my mouse a fraction of an inch. Realism doesn't always translate well to fiction.

For example, the effective range of an abrams tank is 3k-4k meters. That's roughly the size of the entire Kashan map therefore the range of tanks has been reduced. Small arms follows the same principal.
Wolfe
Posts: 1057
Joined: 2007-03-06 03:15

Re: [WIP] Realistic Deviation

Post by Wolfe »

slight animation snag:

M16a4
Try these values:
usrif_m16a4.tweak wrote: rem ---BeginComp :D efaultZoomComp ---
ObjectTemplate.createComponent DefaultZoomComp
ObjectTemplate.zoom.zoomDelay .8
ObjectTemplate.zoom.zoomLod 1
ObjectTemplate.zoom.addZoomFactor 0
ObjectTemplate.zoom.addZoomFactor .25
ObjectTemplate.zoom.changeFovDelay .812
ObjectTemplate.zoom.disableMuzzleWhenZoomed 1
rem ---EndComp ---
and
/usrif_m16a4/AnimationSystem1p.inc wrote: Objects/Weapons/Handheld/usrif_m16a4/animations/1p/1p_m16a2_tozoom.baf
animationManager.looping 0
animationManager.length 0.68
Then zoom in the rifle and note the following:

1. Rifle animation begins, rifle moves to eye
2. Screen flickers for an instant, showing scope at the top of the screen.
3. Your are now looking through the scope as normal.

It's that second part, #2, that I want to eliminate. I just want it to start the animation then change to the zoom screen without that flicker.
zangoo
Posts: 978
Joined: 2007-09-01 03:42

Re: [WIP] Realistic Deviation

Post by zangoo »

Wolfe wrote:I would like to have MOA (and recoil) based in realism, but not copy it exactly. Why not? Because in the real world, you have to deal with many known and random factors to shoot accurately. In the game, all I have to do is move my mouse a fraction of an inch. Realism doesn't always translate well to fiction.

For example, the effective range of an abrams tank is 3k-4k meters. That's roughly the size of the entire Kashan map therefore the range of tanks has been reduced. Small arms follows the same principal.

ok wait, small arms hasent been scaled, right now it is 1:1, i dont see a reason to change that. also with moa in game, most guns would have less deviation then what it is at now snipers aside(they have no deviation after 1.33 sec).
Ballistics or Tracers? Please Vote
[DM] member, We are now recruiting!
Xfire:Zangoo
Mosquill
Retired PR Developer
Posts: 857
Joined: 2007-08-12 10:13

Re: [WIP] Realistic Deviation

Post by Mosquill »

If you set zoom.zoomDelay to 0.8 for sniper rifles, you'll have a big problem with double-zoom. See what I mean?

Also your deviation should include both human factors and gun's accuracy in moa. And it shouldn't be scaled in any way.
Ironcomatose
Posts: 3471
Joined: 2007-02-21 06:07

Re: [WIP] Realistic Deviation

Post by Ironcomatose »

I dont know about this. I kind of like the way it is now TBH. I like the fact that you can drive through an enemy position(not right on top but like with in 20 or 30 yards) with a decent chance of making it out alive. I also like that you could do the same on foot. Meaning that you can run from cover to cover and you have a good chance of making if you play you cards right.

With these new changes you are trying to make, i feel that all of that would be gone and then everyone would have a marksman rifle(and then some) which does not seem right to me.

[R-DEV]DuneHunter - No offense to any female gamers, but never, ever underestimate the amount of havoc a woman can unleash upon innocent unsuspecting electronics.
Wolfe
Posts: 1057
Joined: 2007-03-06 03:15

Post by Wolfe »

The .8 zoom time isn't a big problem for snipers.. in fact i think it enhances it. That's what I meant by a cinematic effect.

As for MOA, I haven't changed the values as of yet.. however testing has shown that hit boxes are larger than the soldier target.. but needs further testing to confirm. If true, some scaling may be necessary if the hit boxes represent a 240lb (wider) man rather than the average 160-180lb (thinner) man.
Last edited by Wolfe on 2008-05-13 02:01, edited 3 times in total.
Post Reply

Return to “PR:BF2 Community Modding”