Start moving item records out into functions

This commit is contained in:
2025-06-03 11:46:56 +01:00
parent 6e187c7548
commit 589603e474
11 changed files with 68 additions and 21 deletions
+48 -2
View File
@@ -198,8 +198,54 @@ applySoundCME itm cr = fromMaybe id $ do
applyRecoil :: Item -> Creature -> World -> World
applyRecoil itm cr = cWorld . lWorld . creatures . ix (_crID cr) %~ pushback
where
recoilAmount = fromMaybe 0 $ itm ^? itUse . heldParams . recoil
pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((- recoilAmount) / _crMass cr) 0))
-- recoilAmount = fromMaybe 0 $ itm ^? itUse . heldParams . recoil
pushback = over crPos (+.+ rotateV (_crDir cr) (V2 ((- recoilAmount itm) / _crMass cr) 0))
recoilAmount :: Item -> Float
recoilAmount itm
| HELD hit <- itm ^. itType = case hit of
BANGSTICK _ -> 25
REWINDER -> 0
TIMESTOPPER -> 0
TIMESCROLLER -> 0
PISTOL -> 10
MACHINEPISTOL -> 15
AUTOPISTOL -> 10
SMG -> 10
BANGCONE -> 150
BLUNDERBUSS -> 150
GRAPECANNON i -> 150 + fromIntegral i * 50
MINIGUNX i -> 10 * fromIntegral i
VOLLEYGUN _ -> 30
RIFLE -> 50
ALTERIFLE -> 50
AUTORIFLE -> 50
BURSTRIFLE -> 50
BANGROD -> 50
ELEPHANTGUN -> 50
AMR -> 50
AUTOAMR -> 50
SNIPERRIFLE -> 50
FLAMESPITTER -> 0
FLAMETHROWER -> 0
FLAMETORRENT -> 0
FLAMEWALL -> 0
BLOWTORCH -> 0
SPARKGUN -> 0
TESLAGUN -> 0
LASER -> 0
TRACTORGUN -> 0
RLAUNCHER -> 0
RLAUNCHERX _ -> 0
GLAUNCHER -> 0
POISONSPRAYER -> 0
SHATTERGUN -> 0
TORCH -> 0
FLATSHIELD -> 0
KEYCARD _ -> 0
BLINKER -> 0
BLINKERUNSAFE -> 0
| otherwise = 0
applySidePush :: Float -> Creature -> World -> World
applySidePush 0 _ w = w