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
+1 -6
View File
@@ -34,7 +34,6 @@ data ItemUse
{ _heldDelay :: UseDelay
, _heldAim :: AimParams
, _heldParams :: HeldParams
-- , _heldTriggerType :: TriggerType
, _heldFrame :: Int
, _heldUseEffect :: HeldUseEffect
}
@@ -107,11 +106,7 @@ data AmmoParams
| NoAmmoParams
deriving (Eq, Show, Read) --Generic, Flat)
data AimParams = AimParams
{ _aimWeight :: Int
, _aimTurnSpeed :: Float
, _aimMuzzles :: [Muzzle]
}
data AimParams = AimParams { _aimMuzzles :: [Muzzle] }
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data FlareType
+1 -5
View File
@@ -9,11 +9,7 @@ import Linear
defaultAimParams :: AimParams
defaultAimParams =
AimParams
{ _aimWeight = 0
, _aimTurnSpeed = 1
-- , _aimZoom = defaultItZoom
--, _aimHandlePos = V2 3 0
, _aimMuzzles =
{ _aimMuzzles =
[ Muzzle
{ _mzPos = V2 20 0
, _mzRot = 0
-3
View File
@@ -22,7 +22,6 @@ teslaGun =
& itUse . heldParams .~ BeamShooterParams-- (Just (elecCrackleS, 2))
& itParams .~ teslaParams
& itUse . heldDelay .~ NoDelay
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 10 0
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itUse . heldAim . aimMuzzles . ix 0 . mzFlareType .~ TeslaGunFlare
@@ -56,7 +55,6 @@ laser =
, _itTgID = Nothing
, _itTgActive = False
}
& itUse . heldAim . aimWeight .~ 6
& itType .~ HELD LASER
-- previous attractionPower values: 1, -1, -10, 0
@@ -67,7 +65,6 @@ tractorGun =
& itAmmoSlots .~ singleAmmo ElectricalAmmo
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 30 0
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimMuzzles . ix 0 . mzFlareType .~ NoFlare
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleTractor
& itType .~ HELD TRACTORGUN
-4
View File
@@ -30,7 +30,6 @@ defaultBangCane =
volleyGun :: Int -> Item
volleyGun i =
defaultBangCane
& itUse . heldAim . aimWeight .~ 6
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles .~ getZipList
(ZipList [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 6]
@@ -52,7 +51,6 @@ rifle :: Item
rifle =
defaultBangCane
& itType .~ HELD RIFLE
& itUse . heldAim . aimWeight .~ 6
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 25 0
@@ -90,11 +88,9 @@ miniGunX :: Int -> Item
miniGunX i =
autoRifle
& itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100, _warmSound = crankSlowS}
& itUse . heldAim . aimWeight .~ 6
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itAmmoSlots .~ singleAmmo BeltBulletAmmo
-- & itUse . heldParams . bulGunSound ?~ (mini1S,2)
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimMuzzles
.~ replicate i
(Muzzle (V2 30 0) 0 0.05 0 MiniGunFlare MuzzleShootBullet (UseExactly 1) 0)
-2
View File
@@ -28,8 +28,6 @@ bangCone =
blunderbuss :: Item
blunderbuss =
bangCone
& itUse . heldAim . aimWeight .~ 6
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles . ix 0 . mzPos . _x .~ 30
& itType .~ HELD BLUNDERBUSS
-1
View File
@@ -15,7 +15,6 @@ rLauncher :: Item
rLauncher =
defaultHeldItem
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0
& itUse . heldAim . aimMuzzles . ix 0 . mzEffect .~ MuzzleRLauncher
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 20 0
-1
View File
@@ -24,7 +24,6 @@ bangRod =
-- & itUse . heldParams . bulGunSound ?~ (bangEchoS,0)
& itUse . heldDelay . rateMax .~ 12
& itType .~ HELD BANGROD
& itUse . heldAim . aimWeight .~ 8
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 30 0
-1
View File
@@ -72,7 +72,6 @@ flameThrower =
defaultHeldItem
& itParams .~ NoParams
& itUse . heldDelay .~ NoDelay
& itUse . heldAim . aimWeight .~ 5
-- & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 18 0) 0 0 0 NoFlare
MuzzleNozzle
-2
View File
@@ -21,8 +21,6 @@ flatShield :: Item
flatShield =
defaultHeldItem
& itEffect . ieInv .~ EffectRootNotroot CreateShieldWall RemoveShieldWall
& itUse . heldAim . aimWeight .~ 5
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itType .~ HELD FLATSHIELD
keyCard :: Int -> Item
+245 -243
View File
File diff suppressed because it is too large Load Diff