Fix scope rotation after torque

This commit is contained in:
2023-05-28 16:22:54 +01:00
parent 24939094c6
commit 9283ae187f
7 changed files with 39 additions and 41 deletions
+9 -6
View File
@@ -59,6 +59,7 @@ module Dodge.Item.Weapon.TriggerType (
blCheck,
) where
import Dodge.Item.Location
import Dodge.Creature.HandPos
import Data.Foldable
import Data.Maybe
@@ -202,16 +203,16 @@ withWarmUp ::
withWarmUp soundID f item cr w
| curWarmUp < maxWarmUp && crWeaponReady cr =
w
& pointerToItem . itUse . heldDelay . warmTime +~ 2
& pointertoitem . itUse . heldDelay . warmTime +~ 2
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
| otherwise =
w
& pointerToItem . itUse . heldDelay . warmTime .~ maxWarmUp
& pointertoitem . itUse . heldDelay . warmTime .~ maxWarmUp
& f item cr
where
cid = _crID cr
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
pointertoitem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
curWarmUp = _warmTime . _heldDelay $ _itUse item
maxWarmUp = _warmMax . _heldDelay $ _itUse item
@@ -411,7 +412,7 @@ shootL ::
World
shootL f item cr w
| fireCondition =
f item cr w & pointerToItem
f item cr w & cWorld . lWorld . creatures . ix cid . crInv . ix invid
%~ ( itUseCharge 1
. (itUse . leftDelay . rateTime .~ _rateMax (_leftDelay (_itUse item)))
)
@@ -420,7 +421,6 @@ shootL f item cr w
where
cid = _crID cr
invid = _ipInvID $ _itLocation item
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix invid
fireCondition =
_rateTime (_leftDelay (_itUse item)) == 0
&& _arLoaded (_leftConsumption (_itUse item)) > 0
@@ -587,13 +587,16 @@ torqueBeforeAtLeast minTorque exTorque feff item cr w
withTorqueAfter :: ChainEffect
withTorqueAfter feff item cr w
-- | cid == 0 = rotateScope $ set randGen g $ over cameraRot (+rot) $ feff item cr w
| cid == 0 = set randGen g $ over (wCam . camRot) (+ rot) $ feff item cr w
| cid == 0 = rotateScope . set randGen g $ over (wCam . camRot) (+ rot) $ feff item cr w
| otherwise = set randGen g $ over (cWorld . lWorld . creatures . ix cid . crDir) (+ rot) $ feff item cr w
where
cid = _crID cr
(rot, g) = randomR (- torque, torque) $ _randGen w
torque = fromMaybe 0 $ item ^? itParams . torqueAfter
--rotateScope = cWorld . lWorld . creatures . ix 0 . crInv . ix (_crInvSel (_creatures w IM.! 0))
rotateScope = pointerYourItem . itScope . scopePos %~ rotateV rot
sideEffectOnFrame ::
Int ->
(Item -> Creature -> WdWd) ->