Add gimbal and gyroscope, allowing more fine tuned projectile control

This commit is contained in:
2024-12-30 11:41:20 +00:00
parent 4c9632b3f3
commit 87f068f01a
11 changed files with 308 additions and 239 deletions
+15 -3
View File
@@ -300,7 +300,8 @@ useLoadedAmmo itmtree cr (cme, w) (mzid, Just (mz, x, magtree)) = (,) (cme & cme
MuzzleTesla -> shootTeslaArc itm cr mz w
MuzzleTractor -> shootTractorBeam cr w
MuzzleRLauncher -> createProjectileR itmtree magtree mz cr w
MuzzleGLauncher -> createProjectile (Grenade (GBounce 2)) magtree mz cr w
MuzzleGLauncher -> createProjectile (Grenade (GBounce 2)) magtree
(getPJStabiliser itmtree) mz cr w
MuzzleNozzle{} -> useGasParams mid mz itm cr $ walkNozzle mzid mz itm cr w
MuzzleShatter -> shootShatter itm cr w
MuzzleDetector -> itemDetectorEffect itm cr w
@@ -619,19 +620,30 @@ createProjectileR itmtree magtree =
(determineProjectileTracking magtree itmtree)
smoke
) magtree
(getPJStabiliser itmtree)
where
smoke
| isJust $ lookup SmokeReducerLink (magtree ^. ldtLeft) = Just ReducedRocketSmoke
| otherwise = Nothing
getPJStabiliser :: LabelDoubleTree ComposeLinkType Item -> Maybe PJStabiliser
getPJStabiliser ldt = case lookup ProjectileStabiliserLink (ldt ^. ldtRight) of
Just ldt' -> case ldt' ^? ldtValue . itType . ibtAttach of
Just GIMBAL -> Just StabOrthReduce
Just GYROSCOPE -> Just StabSpinIncrease
_ -> Nothing
_ -> Nothing
createProjectile ::
ProjectileType ->
LabelDoubleTree ComposeLinkType Item ->
Maybe PJStabiliser ->
Muzzle ->
Creature ->
World ->
World
createProjectile pjtype magtree muz cr = fromMaybe failsound $ do
createProjectile pjtype magtree stab muz cr = fromMaybe failsound $ do
magid <- magtree ^? ldtValue . itLocation . ilInvID
ammoitem <- cr ^? crInv . ix magid
let rdetonate = (^. ldtValue . itID) <$>
@@ -641,7 +653,7 @@ createProjectile pjtype magtree muz cr = fromMaybe failsound $ do
aparams <- ((magtree ^? ldtLeft) >>= lookup AmmoPayloadLink >>= (^? ldtValue . itType . ibtAttach . shellPayload))
<|> ammoitem ^? itConsumables . magParams . ampPayload
return $
createShell rdetonate rscreen pjtype aparams muz cr
createShell rdetonate rscreen stab pjtype aparams muz cr
. startthesound
where
-- the sound should be moved to the projectile firing