Remove data Hammers

This commit is contained in:
2024-12-31 12:42:03 +00:00
parent 9e2dc995e9
commit 17da9e00f8
15 changed files with 146 additions and 166 deletions
+91 -55
View File
@@ -7,9 +7,8 @@ module Dodge.HeldUse (
mcUseHeld,
) where
import Control.Applicative
import Dodge.Item.Weapon.Bullet
import Color
import Control.Applicative
import Control.Monad
import Data.Maybe
import Dodge.Base.Collide
@@ -22,6 +21,7 @@ import Dodge.Data.World
import Dodge.Gas
import Dodge.Inventory.Lock
import Dodge.Item.HeldOffset
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.Shatter
import Dodge.Projectile.Create
import Dodge.RadarSweep
@@ -35,8 +35,13 @@ import Picture.Base
import RandomHelp
import qualified SDL
heldEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
heldEffect = hammerCheck heldEffectNoHammerCheck
heldEffect ::
PressType ->
LabelDoubleTree ComposeLinkType Item ->
Creature ->
World ->
World
heldEffect pt = hammerCheck pt heldEffectNoHammerCheck
heldEffectNoHammerCheck ::
LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
@@ -49,12 +54,18 @@ type ChainEffect =
World ->
World
hammerCheck :: ChainEffect
hammerCheck f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
Just HammerTrigger | nomakeauto
-> case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> f it cr w
_ -> w
hammerCheck ::
PressType ->
(LabelDoubleTree ComposeLinkType Item -> t1 -> t2 -> t2) ->
LabelDoubleTree ComposeLinkType Item ->
t1 ->
t2 ->
t2
hammerCheck pt f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
Just HammerTrigger | nomakeauto ->
case pt of
InitialPress -> f it cr w
_ -> w
_ -> f it cr w
where
nomakeauto = isNothing $ lookup MakeAutoLink (it ^. ldtRight)
@@ -88,26 +99,34 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
heldEffectMuzzles t cr w =
doHeldUseEffect t cr $
uncurry (applyCME (_ldtValue t) cr) cmew
-- & cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles
& doWeaponRepetitions upitm cr
uncurry (applyCME (_ldtValue t) cr) cmew
-- & cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles
& doWeaponRepetitions upitm cr
where
muzzles = t ^. ldtValue . itUse . heldAim . aimMuzzles
(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
cmew = foldl' (useLoadedAmmo t cr) (CME 0 0 False, w) $ zip [0 ..] loadedmuzzles
doHeldUseEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
Just (RandomiseMuzzleFrames x) -> fromMaybe w $ do
i <- t ^? ldtValue . itLocation . ilInvID
let g = w ^. randGen
(is,g') = runState (shuffle [0..x-1]) g
return $ w & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i . itUse . heldAim . aimMuzzles %~ zipWith (\j mz -> mz & mzFrame .~ j) is
& randGen .~ g'
(is, g') = runState (shuffle [0 .. x -1]) g
return $
w & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i . itUse . heldAim . aimMuzzles %~ zipWith (\j mz -> mz & mzFrame .~ j) is
& randGen .~ g'
Just SwitchAlteRifle -> fromMaybe w $ do
i <- t ^? ldtValue . itLocation . ilInvID
return $ w & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itUse . heldAim . aimMuzzles . ix 0 . mzAmmoSlot %~ ((`mod` 2) . (+1))
return $
w
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itUse
. heldAim
. aimMuzzles
. ix 0
. mzAmmoSlot
%~ ((`mod` 2) . (+ 1))
Just NoHeldUseEffect -> w
Nothing -> w
@@ -117,7 +136,7 @@ doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponR
Just xs -> cWorld . lWorld . delayedEvents .++~ map f xs
_ -> id
where
f x = (x,WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
f x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
upitm x =
itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
& ldtValue . itUse . heldTriggerType .~ AutoTrigger
@@ -300,8 +319,14 @@ 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
(getPJStabiliser itmtree) 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
@@ -409,25 +434,25 @@ removeAmmoFromMag x mid cr = fromMaybe id $ do
-~ x
getBulletType ::
-- LabelDoubleTree ComposeLinkType Item ->
-- LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree ComposeLinkType Item ->
-- Muzzle ->
-- Creature ->
-- World ->
-- Muzzle ->
-- Creature ->
-- World ->
Maybe Bullet
--getBulletType itmtree magtree mz cr w =
getBulletType magtree =
magtree ^? ldtValue . itConsumables . magParams . ampBullet
-- <&> buTrajectory .~ btraj
-- <&> buTrajectory .~ btraj
<&> buPayload .~ bpayload
<&> buEffect .~ beffect
where
-- btraj = fromMaybe BasicBulletTrajectory $ do
-- targetingtree <- lookup WeaponTargetingLink (itmtree ^. ldtRight) -- left or right for these?
-- tp <- targetingtree ^? ldtValue . itTargeting . itTgPos . _Just
-- attree <- lookup AmmoTargetingLink (magtree ^. ldtLeft)
-- bt <- attree ^? ldtValue . itUse . ubMod . bmTrajectory
-- return $ getBulletTrajectory mz (itmtree ^. ldtValue) bt tp cr w
-- btraj = fromMaybe BasicBulletTrajectory $ do
-- targetingtree <- lookup WeaponTargetingLink (itmtree ^. ldtRight) -- left or right for these?
-- tp <- targetingtree ^? ldtValue . itTargeting . itTgPos . _Just
-- attree <- lookup AmmoTargetingLink (magtree ^. ldtLeft)
-- bt <- attree ^? ldtValue . itUse . ubMod . bmTrajectory
-- return $ getBulletTrajectory mz (itmtree ^. ldtValue) bt tp cr w
bpayload = fromMaybe BulSpark $ do
attree <- lookup AmmoPayloadLink (magtree ^. ldtLeft)
attree ^? ldtValue . itUse . ubMod . bmPayload
@@ -462,7 +487,7 @@ shootBullet ::
World ->
World
shootBullet itmtree cr (mz, x, magtree) w = fromMaybe w $ do
-- thebullet <- getBulletType itmtree magtree mz cr w
-- thebullet <- getBulletType itmtree magtree mz cr w
thebullet <- getBulletType magtree
return $ foldl' (&) w (replicate x (makeBullet' thebullet (itmtree ^. ldtValue) cr mz))
@@ -566,17 +591,24 @@ mcShootLaser _ mc = cWorld . lWorld . lasers .:~ lasRayAt yellow dam phasev pos
mcShootAuto :: Item -> Machine -> World -> World
mcShootAuto itm mc w
| Just (FixedRate x 0) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay
= w & cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
. itUse . heldDelay . rateTime .~ x
| Just (FixedRate x 0) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay =
w
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
. itUse
. heldDelay
. rateTime
.~ x
& makeBullet defaultBullet itm pos dir
| otherwise
= w & cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
. itUse . heldDelay . rateTime -~ 1
| otherwise =
w
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
. itUse
. heldDelay
. rateTime
-~ 1
where
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
dir = mc ^?! mcType . _McTurret . tuDir
-- | assumes that the item is held
shootTeslaArc :: Item -> Creature -> Muzzle -> World -> World
@@ -595,8 +627,9 @@ determineProjectileTracking ::
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree ComposeLinkType Item ->
RocketHoming
determineProjectileTracking magtree itmtree = fromMaybe NoHoming $
finddronecontrols <|> findexternaltracking
determineProjectileTracking magtree itmtree =
fromMaybe NoHoming $
finddronecontrols <|> findexternaltracking
where
finddronecontrols = do
screen <- lookup RemoteScreenLink (magtree ^. ldtLeft)
@@ -615,23 +648,23 @@ createProjectileR ::
World ->
World
createProjectileR itmtree magtree =
createProjectile
(Rocket
createProjectile
( Rocket
(determineProjectileTracking magtree itmtree)
smoke
) magtree
)
magtree
(getPJStabiliser itmtree)
where
smoke
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
Just GYROSCOPE -> Just StabSpinIncrease
_ -> Nothing
_ -> Nothing
@@ -646,12 +679,15 @@ createProjectile ::
createProjectile pjtype magtree stab muz cr = fromMaybe failsound $ do
magid <- magtree ^? ldtValue . itLocation . ilInvID
ammoitem <- cr ^? crInv . ix magid
let rdetonate = (^. ldtValue . itID) <$>
lookup RemoteDetonatorLink (magtree ^. ldtLeft)
rscreen = (^. ldtValue . itID) <$>
lookup RemoteScreenLink (magtree ^. ldtLeft)
aparams <- ((magtree ^? ldtLeft) >>= lookup AmmoPayloadLink >>= (^? ldtValue . itType . ibtAttach . shellPayload))
<|> ammoitem ^? itConsumables . magParams . ampPayload
let rdetonate =
(^. ldtValue . itID)
<$> lookup RemoteDetonatorLink (magtree ^. ldtLeft)
rscreen =
(^. ldtValue . itID)
<$> lookup RemoteScreenLink (magtree ^. ldtLeft)
aparams <-
((magtree ^? ldtLeft) >>= lookup AmmoPayloadLink >>= (^? ldtValue . itType . ibtAttach . shellPayload))
<|> ammoitem ^? itConsumables . magParams . ampPayload
return $
createShell rdetonate rscreen stab pjtype aparams muz cr
. startthesound