Tweak twisting when aiming

This commit is contained in:
2021-12-05 16:54:08 +00:00
parent d9c5cfc26d
commit 22e3256da3
30 changed files with 350 additions and 252 deletions
+16 -2
View File
@@ -32,9 +32,22 @@ wasdWithAiming
-> Creature
-> Creature
wasdWithAiming w speed i cr
| isAiming = set crDir mouseDir $ theMovement cr
| otherwise = theMovement $ theTurn cr
| isAiming
= addAnyTwist $ set crDir mouseDir $ theMovement cr
| (isReloading && SDL.ButtonRight `S.member` _mouseButtons w)
= addAnyTwist $ set crDir (mouseDir + anytwist) $ theMovement cr
| otherwise = theMovement $ theTurn $ removeTwist cr
where
twistamount = 1.6
removeTwist cr' = case _crTwist cr' of
t -> cr' & crDir +~ t & crTwist .~ 0
anytwist = case cr ^? crInv . ix (_crInvSel (_creatures w IM.! i)) . itUse . useAim . aimStance of
Just TwoHandTwist -> twistamount * pi
_ -> 0
addAnyTwist cr'
= case cr' ^? crInv . ix (_crInvSel (_creatures w IM.! i)) . itUse . useAim . aimStance of
Just TwoHandTwist -> cr' & crTwist .~ twistamount * pi
_ -> cr'
theMovement
| movDir == V2 0 0 = id
| otherwise = crMvAbsolute (speed *.* movAbs) . set crMvDir dir
@@ -43,6 +56,7 @@ wasdWithAiming w speed i cr
dir = _cameraRot w + argV movDir
movAbs = rotateV (_cameraRot w) $ normalizeV movDir
isAiming = _posture (_crStance cr) == Aiming
isReloading = _posture (_crStance cr) == Reloading
mouseDir = case w ^? creatures . ix i . crInv . ix (_crInvSel (_creatures w IM.! i))
. itAttachment of
Just ItScope{_scopePos = p} -> normalizeAngle $ argV