Remove aimParam records

This commit is contained in:
2025-06-04 09:22:01 +01:00
parent a1a35745d6
commit a71e237789
12 changed files with 356 additions and 276 deletions
+51 -1
View File
@@ -1,3 +1,4 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Creature.Statistics (
getCrMoveSpeed,
getCrDexterity,
@@ -30,4 +31,53 @@ strFromHeldItem :: Creature -> Int
strFromHeldItem cr = fromMaybe 0 $ do
Aiming <- cr ^? crStance . posture
i <- cr ^? crManipulation . manObject . imRootSelectedItem
fmap negate $ cr ^? crInv . ix i . itUse . heldAim . aimWeight
fmap (negate . itemWeight) $ cr ^? crInv . ix i
itemWeight :: Item -> Int
itemWeight it = case it ^. itType of
HELD hit -> heldItemWeight hit
_ -> 1
heldItemWeight :: HeldItemType -> Int
heldItemWeight = \case
BANGSTICK{} -> 5
REWINDER -> 5
TIMESTOPPER -> 5
TIMESCROLLER -> 5
PISTOL -> 5
MACHINEPISTOL -> 5
AUTOPISTOL -> 5
SMG -> 10
BANGCONE -> 5
BLUNDERBUSS -> 10
GRAPECANNON{} -> 10
MINIGUNX{} -> 20
VOLLEYGUN{} -> 15
RIFLE -> 10
ALTERIFLE -> 10
AUTORIFLE -> 10
BURSTRIFLE -> 10
BANGROD -> 10
ELEPHANTGUN -> 10
AMR -> 10
AUTOAMR -> 10
SNIPERRIFLE -> 10
FLAMESPITTER -> 5
FLAMETHROWER -> 10
FLAMETORRENT -> 10
FLAMEWALL -> 10
BLOWTORCH -> 10
SPARKGUN -> 15
TESLAGUN -> 15
LASER -> 15
TRACTORGUN -> 10
RLAUNCHER -> 20
RLAUNCHERX{} -> 20
GLAUNCHER -> 10
POISONSPRAYER -> 10
SHATTERGUN -> 10
TORCH -> 5
FLATSHIELD -> 15
KEYCARD {} -> 5
BLINKER -> 5
BLINKERUNSAFE -> 5
+58 -7
View File
@@ -1,18 +1,20 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Creature.YourControl (
yourControl,
) where
import Dodge.Data.AimStance
import Dodge.Item.AimStance
import Control.Monad
import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Creature.Impulse.Movement
import Dodge.Creature.Impulse.UseItem
import Dodge.Data.AimStance
import Dodge.Data.World
import Dodge.Hotkey
import Dodge.InputFocus
import Dodge.Inventory
import Dodge.Item.AimStance
import Dodge.SelectedClose
import Dodge.WASD
import Geometry
@@ -41,7 +43,7 @@ yourControl _ w
handleHotkeys :: World -> World
handleHotkeys w
| ispressed SDL.ScancodeLShift || ispressed SDL.ScancodeRShift
, Just hk <-
, Just hk <-
listToMaybe . mapMaybe scancodeToHotkey . M.keys $ w ^. input . pressedKeys
, Just invid <- lw ^? creatures . ix 0 . crManipulation . manObject . imSelectedItem
, Just itid <- lw ^? creatures . ix 0 . crInv . ix invid . itID =
@@ -121,9 +123,9 @@ wasdWithAiming w cr = wasdAim inp w $ wasdMovement inp cam speed cr
wasdAim :: Input -> World -> Creature -> Creature
wasdAim inp w cr
| Just 0 <- inp ^? mouseButtons . ix SDL.ButtonRight
, Nothing <- inp ^? mouseButtons . ix SDL.ButtonLeft
= setAimPosture cr
| Just 0 <- inp ^? mouseButtons . ix SDL.ButtonRight
, Nothing <- inp ^? mouseButtons . ix SDL.ButtonLeft =
setAimPosture cr
| SDL.ButtonRight `M.member` _mouseButtons inp = aimTurn mousedir cr
| Aiming <- cr ^. crStance . posture = removeAimPosture cr
| otherwise = creatureTurnTowardDir (_crMvAim cr) 0.2 cr
@@ -163,7 +165,56 @@ aimTurn a cr = creatureTurnTowardDir a (x * 0.2) cr
where
x = fromMaybe 1 $ do
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
cr ^? crInv . ix itRef . itUse . heldAim . aimTurnSpeed
fmap itemBulkiness $ cr ^? crInv . ix itRef . itType
itemBulkiness :: ItemType -> Float
itemBulkiness = \case
HELD hit -> heldItemBulkiness hit
_ -> 1
heldItemBulkiness :: HeldItemType -> Float
heldItemBulkiness = \case
BANGSTICK{} -> 1
REWINDER -> 1
TIMESTOPPER -> 1
TIMESCROLLER -> 1
PISTOL -> 1
MACHINEPISTOL -> 1
AUTOPISTOL -> 1
SMG -> 1
BANGCONE -> 1
BLUNDERBUSS -> 1
GRAPECANNON{} -> 1
MINIGUNX{} -> 0.5
VOLLEYGUN{} -> 1
RIFLE -> 1
ALTERIFLE -> 1
AUTORIFLE -> 1
BURSTRIFLE -> 1
BANGROD -> 1
ELEPHANTGUN -> 1
AMR -> 1
AUTOAMR -> 1
SNIPERRIFLE -> 1
FLAMESPITTER -> 1
FLAMETHROWER -> 1
FLAMETORRENT -> 1
FLAMEWALL -> 1
BLOWTORCH -> 1
SPARKGUN -> 1
TESLAGUN -> 1
LASER -> 1
TRACTORGUN -> 1
RLAUNCHER -> 0.9
RLAUNCHERX{} -> 0.9
GLAUNCHER -> 1
POISONSPRAYER -> 1
SHATTERGUN -> 1
TORCH -> 1
FLATSHIELD -> 0.5
KEYCARD{} -> 1
BLINKER -> 1
BLINKERUNSAFE -> 1
tryClickUse :: M.Map SDL.MouseButton Int -> World -> World
tryClickUse pkeys w = fromMaybe w $ do