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
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -82,7 +82,7 @@ data HeldParams
= DefaultHeldParams
| GasSprayParams
{ _gasCreation :: GasCreate
, _recoil :: Float
-- , _recoil :: Float
, _torqueAfter :: Float
, _randomOffset :: Float
, _sidePush :: Float
@@ -96,7 +96,7 @@ data HeldParams
| BulletShooterParams
{ _muzVel :: GenFloat
, _rifling :: GenFloat
, _recoil :: Float
-- , _recoil :: Float
, _torqueAfter :: Float
, _randomOffset :: Float
, _sidePush :: Float
+1 -1
View File
@@ -31,7 +31,7 @@ defaultHeldUse = UseHeld
, _heldParams = BulletShooterParams
{ _muzVel = ConstFloat 0.8
, _rifling = ConstFloat 0.8
, _recoil = 10
-- , _recoil = 10
, _torqueAfter = 0.2
, _randomOffset = 0
, _sidePush = 0
+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
+3 -4
View File
@@ -21,7 +21,7 @@ defaultBangCane :: Item
defaultBangCane =
defaultBulletWeapon
& itUse . heldParams . rifling .~ ConstFloat 0.9
& itUse . heldParams . recoil .~ 50
-- & itUse . heldParams . recoil .~ 50
& itUse . heldParams . torqueAfter .~ 0.1
& itUse . heldDelay . rateMax .~ 6
-- & itUse . heldMods .~ BangCaneMod
@@ -31,7 +31,6 @@ defaultBangCane =
volleyGun :: Int -> Item
volleyGun i =
defaultBangCane
-- & itUse . heldMods .~ VolleyGunMod
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandFlat
@@ -46,7 +45,7 @@ volleyGun i =
)
& itUse . heldParams . weaponInvLock .~ i + 1
& itUse . heldParams . torqueAfter .~ 0.1
& itUse . heldParams . recoil .~ 30
-- & itUse . heldParams . recoil .~ 30
& itType .~ HELD (VOLLEYGUN i)
& itAmmoSlots .~ IM.fromList (zip [0..i-1] $ repeat BulletAmmo)
& itUse . heldParams . weaponRepeat .~ [1..i-1]
@@ -106,7 +105,7 @@ miniGunX i =
& itUse . heldAim . aimMuzzles
.~ replicate i
(Muzzle (V2 30 0) 0 0.05 0 MiniGunFlare MuzzleShootBullet (UseExactly 1) 0)
& itUse . heldParams . recoil .~ 10 * fromIntegral i
-- & itUse . heldParams . recoil .~ 10 * fromIntegral i
& itUse . heldParams . torqueAfter .~ 0.04 + 0.02 * fromIntegral i
& itUse . heldParams . sidePush .~ 10 * fromIntegral i
& itUse . heldParams . randomOffset .~ 10
+2 -2
View File
@@ -18,7 +18,7 @@ bangCone =
& itUse . heldAim . aimMuzzles . ix 0 . mzFlareType .~ BasicFlare
& itUse . heldParams . muzVel .~ UniRandFloat 0.5 0.8
& itUse . heldParams . rifling .~ UniRandFloat 0.3 0.8
& itUse . heldParams . recoil .~ 150
-- & itUse . heldParams . recoil .~ 150
& itUse . heldParams . torqueAfter .~ 0.1
& itUse . heldParams . randomOffset .~ 12
& itUse . heldParams . bulGunSound ?~ (bangEchoS,0)
@@ -37,6 +37,6 @@ grapeCannon :: Int -> Item
grapeCannon i =
blunderbuss
& itType .~ HELD (GRAPECANNON i)
& itUse . heldParams . recoil .~ (150 + fromIntegral i * 50)
-- & itUse . heldParams . recoil .~ (150 + fromIntegral i * 50)
& itUse . heldParams . torqueAfter .~ (0.1 + 0.2 * fromIntegral i)
& itUse . heldParams . randomOffset .~ (12 + 4 * fromIntegral i)
+1 -1
View File
@@ -23,7 +23,7 @@ rLauncher =
& itType .~ HELD RLAUNCHER
& itUse . heldParams . muzVel .~ ConstFloat 0
& itUse . heldParams . rifling .~ ConstFloat 0
& itUse . heldParams . recoil .~ 0
-- & itUse . heldParams . recoil .~ 0
& itUse . heldParams . torqueAfter .~ 0
& itUse . heldParams . bulGunSound ?~ (tap4S, 0)
+2 -2
View File
@@ -19,7 +19,7 @@ bangRod :: Item
bangRod =
defaultBulletWeapon
& itUse . heldParams . rifling .~ ConstFloat 1
& itUse . heldParams . recoil .~ 50
-- & itUse . heldParams . recoil .~ 50
& itUse . heldParams . torqueAfter .~ 0.3
& itUse . heldParams . bulGunSound ?~ (bangEchoS,0)
& itUse . heldDelay . rateMax .~ 12
@@ -39,7 +39,7 @@ elephantGun =
& itType .~ HELD ELEPHANTGUN
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldParams . recoil .~ 50
-- & itUse . heldParams . recoil .~ 50
amr :: Item
amr =
+2 -2
View File
@@ -20,7 +20,7 @@ poisonSprayer =
& itType .~ HELD POISONSPRAYER
& itAmmoSlots .~ singleAmmo GasAmmo
& itUse . heldParams . gasCreation .~ CreatePoisonGas --aGasCloud
& itUse . heldParams . recoil .~ 0
-- & itUse . heldParams . recoil .~ 0
& itUse . heldParams . torqueAfter .~ 0
& itUse . heldParams . randomOffset .~ 0
& itUse . heldParams . sidePush .~ 0
@@ -91,7 +91,7 @@ flameThrower =
& itType .~ HELD FLAMETHROWER
& itUse . heldParams .~ GasSprayParams
{_gasCreation = CreateFlame
, _recoil = 0
-- , _recoil = 0
, _torqueAfter = 0
, _randomOffset = 0
, _sidePush = 25
+3 -3
View File
@@ -16,7 +16,7 @@ import LensHelp
bangStick :: Int -> Item
bangStick i =
defaultBulletWeapon
& itUse . heldParams . recoil .~ 25
-- & itUse . heldParams . recoil .~ 25
& itUse . heldParams . torqueAfter .~ 0.18 + 0.02 * fromIntegral i
& itType .~ HELD (BANGSTICK i)
& itUse . heldDelay . rateMax .~ 8
@@ -49,7 +49,7 @@ pistol =
& itUse . heldParams
%~ ( (muzVel .~ ConstFloat 0.8)
. (rifling .~ ConstFloat 0.8)
. (recoil .~ 10)
-- . (recoil .~ 10)
. (torqueAfter .~ 0.2)
. (sidePush .~ 50)
)
@@ -67,7 +67,7 @@ machinePistol =
autoPistol
& itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 50, _warmSound = crankSlowS}
& itType .~ HELD MACHINEPISTOL
& itUse . heldParams . recoil .~ 20
-- & itUse . heldParams . recoil .~ 20
smg :: Item
smg =
+3 -1
View File
@@ -234,13 +234,15 @@ listControls =
, ("<wheelscroll>", "SELECT ITEM")
, ("<space>", "PICKUP ITEM")
, ("f", "DROP ITEM")
, ("<ctrl>+<wheelscroll>", "SWAP ITEMS")
, ("<caps>+<wheelscroll>", "SWAP ITEMS")
, ("<shift>&q|e|0-9", "SET HOTKEY")
, ("q|e|0-9", "USE HOTKEY")
, ("<caps>&q|e|0-9", "JUMP TO HOTKEY")
, ("c", "COMBINE ITEMS")
-- , ("x", "EXAMINE ITEMS")
-- , ("m", "DISPLAY MAP")
, ("p|<esc>", "PAUSE")
, ("<lmb>", "SELECT/MOVE ITEMS")
, ("<F1>", "NORMAL CAMERA")
, ("<F2>", "DEBUG CAMERA")
, ("<F5>", "QUICKSAVE")