Fix scope rotation after torque
This commit is contained in:
@@ -39,25 +39,14 @@ defaultBangCane =
|
||||
volleyGun :: Int -> Item
|
||||
volleyGun i =
|
||||
defaultBangCane
|
||||
& itUse . heldDelay . rateMax .~ 6
|
||||
& itUse . heldMods .~ VolleyGunMod
|
||||
& itUse . heldAim . aimWeight .~ 6
|
||||
& itUse . heldAim . aimRange .~ 1
|
||||
& itUse . heldAim . aimStance .~ TwoHandFlat
|
||||
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
|
||||
-- & itUse . heldAim . aimHandlePos .~ 5
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 3]
|
||||
& itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
|
||||
& itParams
|
||||
.~ BulletShooter
|
||||
{ _muzVel = 0.8
|
||||
, _rifling = 0.9
|
||||
, _bore = 2
|
||||
, _recoil = 50
|
||||
, _torqueAfter = 0.1
|
||||
, _randomOffset = 0
|
||||
}
|
||||
& itParams . torqueAfter .~ 0.48 + 0.2 * fromIntegral i
|
||||
& itParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
|
||||
& itType . iyBase .~ HELD (VOLLEYGUN i)
|
||||
|
||||
rifle :: Item
|
||||
|
||||
@@ -49,7 +49,6 @@ elephantGun =
|
||||
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
|
||||
& itUse . heldMods .~ ElephantGunMod
|
||||
& itParams . recoil .~ 50
|
||||
& itParams . torqueAfter .~ 0.1
|
||||
|
||||
amr :: Item
|
||||
amr =
|
||||
|
||||
@@ -2,9 +2,11 @@ module Dodge.Item.Location (
|
||||
pointerToItemLocation,
|
||||
getItem,
|
||||
pointerToItem,
|
||||
pointerYourItem,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
import Data.Maybe
|
||||
import Dodge.Data.World
|
||||
|
||||
getItem :: Int -> World -> Maybe Item
|
||||
@@ -26,6 +28,11 @@ pointerToItemLocation (InInv cid invid) = cWorld . lWorld . creatures . ix cid .
|
||||
pointerToItemLocation (OnFloor flid) = cWorld . lWorld . floorItems . ix flid . flIt
|
||||
pointerToItemLocation _ = const pure
|
||||
|
||||
pointerYourItem :: Applicative a => (Item -> a Item) -> World -> a World
|
||||
pointerYourItem f w = fromMaybe (pure w) $ do
|
||||
itinvid <- w ^? cWorld . lWorld . creatures . ix 0 . crManipulation . manObject . inInventory . ispItem
|
||||
Just $ pointerToItemLocation (InInv 0 itinvid) f w
|
||||
|
||||
pointerToItem ::
|
||||
Applicative f =>
|
||||
Item ->
|
||||
|
||||
@@ -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) ->
|
||||
|
||||
Reference in New Issue
Block a user