Partial implementation of more sensible muzzle position determination

This commit is contained in:
2024-11-28 21:15:22 +00:00
parent 0d5e578f07
commit 3763ff2c8a
6 changed files with 188 additions and 133 deletions
+6 -2
View File
@@ -6,6 +6,7 @@ module Dodge.HeldUse (
mcUseHeld,
) where
import Dodge.Item.HeldOffset
import Color
import Control.Monad
import Data.Maybe
@@ -391,7 +392,10 @@ makeBullet thebullet itm cr mz w =
& buDrag *~ drag
)
where
bulpos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm + V2 0 offset)
-- bulpos = _crPos cr
-- + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm + V2 0 offset)
(moff,mrot) = heldItemOrient2D itm cr (_mzPos mz + V2 0 offset) (_mzRot mz)
bulpos = _crPos cr + rotateV (_crDir cr) moff
(a, g'') = randomR (- inacc, inacc) $ _randGen w
inacc = _mzInaccuracy mz
(drag, g') = case _rifling (_heldParams $ _itUse itm) of
@@ -400,7 +404,7 @@ makeBullet thebullet itm cr mz w =
(muzvel, g) = case _muzVel $ _heldParams $ _itUse itm of
ConstFloat x -> (x, g')
UniRandFloat x y -> randomR (x, y) g'
dir = _crDir cr + _mzRot mz + a
dir = _crDir cr + mrot + a
offset = case itm ^? itUse . heldParams . randomOffset of
Just x | x /= 0 -> fst . randomR (- x, x) $ _randGen w
_ -> 0