I am in the process of making a simple ballistics mod for FNV featuring a basic velocity decrease, bullet drop and wind deflection but I need some help as I am farely new to scripting. If you see any errors in my code (just segments will be portrayed here) please let me know. Skip to "QUESTIONS" if you just want to see the part where I need help and don't need to see my long explanation.
I use precalculated Drag Coefficients (saved in an ini file) for velocity decrease which is used for a linear velocity model as it is easy to implement. The velocity decrease will then be applied as following:
set fProjDistance to rProj.GetProjectileRefDistanceTraveled/70 set fProjSpeedMult to (1-fProjVelCoefficient*fProjDistance) rProj.SetProjectileRefSpeedMult fProjSpeedMult
As you can see I used SetProjectileRefSpeedMult to achieve a velocity decrease and GetProjectileRefDistanceTraveled instead of something time related as I have poor hardware and therefore need consistency and what can I say, it works splendid ingame showing consistent results and little to no fps drops regardless of how many bullets are rendered.
The scripting could've almost ended here so I headed to the second part of the mod, bullet drop. I thought that'll be easy and nothing more but changing the Gravity in the Projectile Tab to a precalculated value, mostly smaller than 0.9. Oh boy was I wrong. When I was testing and shooting I noticed an excessive bullet drop exceeding like 2m at 150m which is far from what I expected or would've been the case in the game without my script. So I tested it with a different Gravity Value of 0.1. No change, still noticing a drop of at least 2m at 150m. Same goes for a value of 0.01, 0.001 and so on. After all those results I set the Gravity Value to 0 and tried a different approach adding Movement Functions and precalculated Gravity Coefficients:
;Bullet Drop set fProjFallHeight to (fProjGravCoefficient*fProjDistance*fProjDistance) ;Vertical Line of Sight set fProjStartAngleX to rProj.GetStartingAngle X set fProjStartAngleSinX to fSin fProjStartAngleX set fProjStartPosZ to rProj.GetStartingPos Z ;Vertical Line of Sight - Bullet Drop set fProjPosZ to (fProjStartPosZ - (fProjDistance*fProjStartAngleSinX + fProjFallHeight)*70) rProj.SetPos Z fProjPosZ
The Bullet Drop section should be pretty self explanatory, like fProjSpeedMult fProjFallHeight is hardcoded to the fly distance of the projectile for the reason of consistency. fProjFallHeight will then be subtracted from the Vertical Line of Sight. However this method is somewhat broken as well. While it works just fine and as expected when hipfiring or aiming through a scope, it is completely unusable with iron sights and it does not work with every projectile. The Projectile is either off center and/or spawning far below the barrel.
QUESTIONS
Either:
How do I change the Projectile Speed mid air without using SetProjectileRefSpeedMult ?
Or:
Is there a way to implement bullet drop without changing the Gravity Value to >0 ?
Or:
Are there better methods of giving projectiles ballistic properties, changing the movement without radically teleporting the projectile etc. ?
PS: If any of you want to know how the bullet trajectory is modelled in my mod, you can use 0.00108 for fProjVelCoefficient and 0.000009168 for fProjGravCoefficient and put it in "v=930*(1-fProjVelCoefficient*fProjDistance)" and "h=fProjGravCoefficient*fProjDistance²". This is an example for the 5.56x45mm NATO M855 cartridge: v0=930m/s | m=62gr | G7 BC=.151, with a seight height of 0cm and a zero of 1m. You can use this data in your Ballistic Calculator of choice and compare it.