From 224db733f6dd7da9818774f54f13134771e24621 Mon Sep 17 00:00:00 2001 From: justin Date: Sat, 27 Nov 2021 14:29:44 +0000 Subject: [PATCH] Fold in more ammo parameters, distinguish loadable and charging weapons --- src/Dodge/Creature/Action.hs | 8 ++--- src/Dodge/Creature/State.hs | 31 +++++++++++----- src/Dodge/Creature/Test.hs | 4 +-- src/Dodge/Data.hs | 27 ++++++++------ src/Dodge/Default/Weapon.hs | 6 ++-- src/Dodge/Item/Weapon/AmmoParams.hs | 2 +- src/Dodge/Item/Weapon/BatteryGuns.hs | 9 ++--- src/Dodge/Item/Weapon/Booster.hs | 3 +- src/Dodge/Item/Weapon/BulletGuns.hs | 44 ++++++++++------------- src/Dodge/Item/Weapon/Drone.hs | 5 ++- src/Dodge/Item/Weapon/ExtraEffect.hs | 2 +- src/Dodge/Item/Weapon/InventoryDisplay.hs | 20 ++++++----- src/Dodge/Item/Weapon/Launcher.hs | 10 +++--- src/Dodge/Item/Weapon/Radar.hs | 6 ++-- src/Dodge/Item/Weapon/Spawn.hs | 3 +- src/Dodge/Item/Weapon/SprayGuns.hs | 6 ++-- src/Dodge/Item/Weapon/TriggerType.hs | 12 +++---- src/Dodge/Item/Weapon/Utility.hs | 23 ++++++------ src/Dodge/Render/HUD.hs | 2 -- 19 files changed, 112 insertions(+), 111 deletions(-) diff --git a/src/Dodge/Creature/Action.hs b/src/Dodge/Creature/Action.hs index 27742abe0..6e8c26ff5 100644 --- a/src/Dodge/Creature/Action.hs +++ b/src/Dodge/Creature/Action.hs @@ -152,19 +152,19 @@ startReloadingWeapon cr w = it = _crInv cr IM.! _crInvSel cr itRef = creatures . ix cid . crInv . ix (_crInvSel cr) in case it of - Weapon {_wpAmmo = LoadableAmmo {_wpMaxAmmo=maxA,_wpLoadedAmmo=lA },_wpReloadState=rS,_wpReloadTime=rT} + Weapon {_wpAmmo = LoadableAmmo {_wpMaxAmmo=maxA,_wpLoadedAmmo=lA ,_wpReloadState=rS,_wpReloadTime=rT}} | lA < maxA && rS == 0 -> Just $ set ( itRef . wpAmmo . wpLoadedAmmo) maxA - $ set ( itRef . wpReloadState) rT w + $ set ( itRef . wpAmmo . wpReloadState) rT w _ -> Nothing {- | Start reloading if clip is empty. -} crAutoReload :: Creature -> Creature crAutoReload cr = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo of Just 0 | _posture (_crStance cr) /= Aiming - -> cr & crInv . ix (_crInvSel cr) . wpReloadState %~ (`fromMaybe` reloadT) + -> cr & crInv . ix (_crInvSel cr) . wpAmmo . wpReloadState %~ (`fromMaybe` reloadT) & crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo %~ (`fromMaybe` maxA) _ -> cr where - reloadT = cr ^? crInv . ix (_crInvSel cr) . wpReloadTime + reloadT = cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpReloadTime maxA = cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpMaxAmmo {- | Teleport a creature to the mouse position -} blinkAction diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index dbe21b47c..d2257aea8 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -123,17 +123,30 @@ invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr) Just g -> g (_itEffect it) cr i w' weaponReloadSounds :: Creature -> World -> World -weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of - Just Weapon{_wpReloadType = PassiveReload stype,_wpReloadTime=rt,_wpReloadState=rs} - | rt == rs -> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w - | otherwise -> w - Just Weapon{_wpReloadState = 0} -> w - Just Weapon{_wpReloadState = 1} -> stopSoundFrom (CrReloadSound cid) w - Just Weapon{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w - _ -> w +weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo of + Just am@LoadableAmmo{} -> case _wpReloadType am of + PassiveReload stype |_wpReloadTime am ==_wpReloadState am + -> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w + PassiveReload _ -> w + ActiveReload | _wpReloadState am == 1 -> stopSoundFrom (CrReloadSound cid) w + ActiveReload | _wpReloadState am == 0 -> w + ActiveReload -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w + Just ChargeableAmmo {} -> w + Nothing -> w where cid = _crID cr +--weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of +-- Just Weapon{_wpAmmo=LoadableAmmo{_wpReloadType = PassiveReload stype,_wpReloadTime=rt,_wpReloadState=rs} } +-- | rt == rs -> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w +-- | otherwise -> w +-- Just Weapon{_wpAmmo=LoadableAmmo{_wpReloadState = 0}} -> w +-- Just Weapon{_wpAmmo=LoadableAmmo{_wpReloadState = 1}} -> stopSoundFrom (CrReloadSound cid) w +-- Just Weapon{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w +-- _ -> w +-- where +-- cid = _crID cr + updateMovement :: Creature -> Creature updateMovement cr | isFrictionless cr = over crPos (+.+ momentum) $ setOldPos cr @@ -157,7 +170,7 @@ stepItemUseCooldown cr = cr & crInv . ix iSel %~ iSel = _crInvSel cr stepReloading :: Creature -> Creature -stepReloading cr = over (crInv . ix iSel . wpReloadState) decreaseToZero cr +stepReloading cr = over (crInv . ix iSel . wpAmmo . wpReloadState) decreaseToZero cr where iSel = _crInvSel cr diff --git a/src/Dodge/Creature/Test.hs b/src/Dodge/Creature/Test.hs index 858fbde60..b9fa9a72b 100644 --- a/src/Dodge/Creature/Test.hs +++ b/src/Dodge/Creature/Test.hs @@ -35,12 +35,12 @@ onBoth :: (a -> b -> c) -> (d -> a) -> (d -> b) -> d -> c onBoth f g h x = f (g x) (h x) crIsReloading :: (World, Creature) -> Bool -crIsReloading (_,cr) = case cr ^? crInv . ix (_crInvSel cr) . wpReloadState of +crIsReloading (_,cr) = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpReloadState of Just t -> t > 0 _ -> False crIsReloadingR :: Creature -> Reader World Bool -crIsReloadingR cr = return $ case cr ^? crInv . ix (_crInvSel cr) . wpReloadState of +crIsReloadingR cr = return $ case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpReloadState of Just t -> t > 0 _ -> False diff --git a/src/Dodge/Data.hs b/src/Dodge/Data.hs index 8d8bcd551..71b16d8f7 100644 --- a/src/Dodge/Data.hs +++ b/src/Dodge/Data.hs @@ -290,31 +290,38 @@ data ItemPos = InInv { _itCrId :: Int , _itInvId :: Int } | OnFloor { _itFlID :: Int } data ItemUse - = RightUse { _rUse :: Item -> Creature -> World -> World } - | LeftUse { _lUse :: Creature -> Int -> World -> World } + = RightUse + { _rUse :: Item -> Creature -> World -> World + } + | LeftUse + { _lUse :: Creature -> Int -> World -> World + } | NoUse data ItemAmmo = LoadableAmmo { _aoType :: AmmoType , _wpMaxAmmo :: Int , _wpLoadedAmmo :: Int + , _wpReloadTime :: Int + , _wpReloadState :: Int + , _wpReloadType :: ReloadType + } + | ChargeableAmmo + { _wpMaxCharge :: Int + , _wpCharge :: Int } data Item = Weapon { _itName :: String , _wpAmmo :: ItemAmmo - , _wpReloadTime :: Int - , _wpReloadState :: Int - , _wpReloadType :: ReloadType - , _wpMaxWarmUp :: Int - , _wpCurWarmUp :: Int - , _wpMaxCoolDown :: Int - , _wpCurCoolDown :: Int + , _wpMaxWarmUp :: Int + , _wpCurWarmUp :: Int + , _wpMaxCoolDown :: Int + , _wpCurCoolDown :: Int , _itUseRate :: Int , _itUseTime :: Int , _itUse :: ItemUse , _itUseModifiers :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World] - --, _itLeftClickUse :: Maybe (Creature -> Int -> World -> World) , _wpSpread :: Float , _wpRange :: Float , _itHammer :: HammerPosition diff --git a/src/Dodge/Default/Weapon.hs b/src/Dodge/Default/Weapon.hs index 5098309d8..301784a8b 100644 --- a/src/Dodge/Default/Weapon.hs +++ b/src/Dodge/Default/Weapon.hs @@ -15,6 +15,9 @@ defaultAmmo = LoadableAmmo { _aoType = GenericAmmo , _wpMaxAmmo = 15 , _wpLoadedAmmo = 15 + , _wpReloadTime = 40 + , _wpReloadState = 0 + , _wpReloadType = ActiveReload } defaultGun :: Item @@ -23,9 +26,6 @@ defaultGun = Weapon , _itCurseStatus = Uncursed , _itIdentity = Pistol , _wpAmmo = defaultAmmo - , _wpReloadTime = 40 - , _wpReloadState = 0 - , _wpReloadType = ActiveReload , _wpMaxWarmUp = 0 , _wpCurWarmUp = 0 , _wpMaxCoolDown = 0 diff --git a/src/Dodge/Item/Weapon/AmmoParams.hs b/src/Dodge/Item/Weapon/AmmoParams.hs index 3f5f33ea6..468a614bf 100644 --- a/src/Dodge/Item/Weapon/AmmoParams.hs +++ b/src/Dodge/Item/Weapon/AmmoParams.hs @@ -53,7 +53,7 @@ withDelayedVelWthHiteff vfact vel width hiteff cr = over particles (newbul : ) loadedAmmo :: Item -> Int loadedAmmo it - | _wpReloadState it == 0 = _wpLoadedAmmo (_wpAmmo it) + | _wpReloadState (_wpAmmo it) == 0 = _wpLoadedAmmo (_wpAmmo it) | otherwise = 0 fractionLoadedAmmo :: Item -> Float diff --git a/src/Dodge/Item/Weapon/BatteryGuns.hs b/src/Dodge/Item/Weapon/BatteryGuns.hs index 9f6be6206..ec98f96f6 100644 --- a/src/Dodge/Item/Weapon/BatteryGuns.hs +++ b/src/Dodge/Item/Weapon/BatteryGuns.hs @@ -40,9 +40,8 @@ teslaGun = defaultGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 200 , _wpLoadedAmmo = 200 + , _wpReloadTime = 80 } - , _wpReloadTime = 80 - , _wpReloadState = 0 , _itUseRate = 0 , _itAimStance = TwoHandFlat , _itUseTime = 0 @@ -76,9 +75,8 @@ lasGun = defaultAutoGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 200 , _wpLoadedAmmo = 200 + , _wpReloadTime = 80 } - , _wpReloadTime = 80 - , _wpReloadState = 0 , _itUseRate = 0 , _itUseTime = 0 , _itUse = RightUse $ const aLaser @@ -118,9 +116,8 @@ tractorGun = defaultAutoGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 10000 , _wpLoadedAmmo = 10000 + , _wpReloadTime = 40 } - , _wpReloadTime = 40 - , _wpReloadState = 0 , _itUseRate = 0 , _itUseTime = 0 , _itUse = RightUse aTractorBeam diff --git a/src/Dodge/Item/Weapon/Booster.hs b/src/Dodge/Item/Weapon/Booster.hs index 42fe9ba87..634fa727c 100644 --- a/src/Dodge/Item/Weapon/Booster.hs +++ b/src/Dodge/Item/Weapon/Booster.hs @@ -116,9 +116,8 @@ boosterGun = defaultGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 100 , _wpLoadedAmmo = 100 + , _wpReloadTime = 20 } - , _wpReloadTime = 20 - , _wpReloadState = 0 , _itUseRate = 0 , _itUseTime = 0 , _itUse = LeftUse $ boostSelfL 10 diff --git a/src/Dodge/Item/Weapon/BulletGuns.hs b/src/Dodge/Item/Weapon/BulletGuns.hs index a7ade1d9e..2d4785b23 100644 --- a/src/Dodge/Item/Weapon/BulletGuns.hs +++ b/src/Dodge/Item/Weapon/BulletGuns.hs @@ -35,13 +35,12 @@ autoGun :: Item autoGun = defaultAutoGun { _itName = "AUTOGUN" , _itIdentity = AutoGun - , _wpAmmo = LoadableAmmo - {_aoType = basicBullet + , _wpAmmo = defaultAmmo + { _aoType = basicBullet , _wpMaxAmmo = 30 , _wpLoadedAmmo = 30 + , _wpReloadTime = 80 } - , _wpReloadTime = 80 - , _wpReloadState = 0 , _itUseRate = 5 , _itUseTime = 0 , _itUse = useAmmoParams @@ -88,13 +87,12 @@ pistol :: Item pistol = defaultGun { _itName = "PISTOL" , _itIdentity = Pistol - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = basicBullet , _wpMaxAmmo = 15 , _wpLoadedAmmo = 15 + , _wpReloadTime = 40 } - , _wpReloadTime = 40 - , _wpReloadState = 0 , _itUseRate = 8 , _itUseTime = 0 , _itUse = useAmmoParams @@ -138,13 +136,12 @@ hvAutoGun :: Item hvAutoGun = defaultAutoGun { _itName = "AUTO-HV" , _itIdentity = HvAutoGun - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = hvBullet , _wpMaxAmmo = 100 , _wpLoadedAmmo = 100 + , _wpReloadTime = 200 } - , _wpReloadTime = 200 - , _wpReloadState = 0 , _itUseRate = 25 , _itUseTime = 0 , _itUse = useAmmoParams @@ -175,13 +172,12 @@ ltAutoGun :: Item ltAutoGun = defaultAutoGun { _itName = "AUTO-LT" , _itIdentity = LtAutoGun - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = ltBullet , _wpMaxAmmo = 25 , _wpLoadedAmmo = 25 + , _wpReloadTime = 80 } - , _wpReloadTime = 80 - , _wpReloadState = 0 , _itUseRate = 3 , _itUseTime = 0 , _itUse = useAmmoParams @@ -218,13 +214,12 @@ miniGun :: Item miniGun = defaultAutoGun { _itName = "MINI-G" , _itIdentity = MiniGun - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = basicBullet , _wpMaxAmmo = 1500 , _wpLoadedAmmo = 1500 + , _wpReloadTime = 200 } - , _wpReloadTime = 200 - , _wpReloadState = 0 , _wpMaxWarmUp = 100 , _itUseRate = 0 , _itUseTime = 0 @@ -311,13 +306,12 @@ spreadGun :: Item spreadGun = defaultGun { _itName = "SPREAD" , _itIdentity = SpreadGun - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = basicBullet , _wpMaxAmmo = 5 , _wpLoadedAmmo = 5 + , _wpReloadTime = 80 } - , _wpReloadTime = 80 - , _wpReloadState = 0 , _itUseRate = 20 , _itUseTime = 0 --, _itUse = \_ -> spreadNumVelWthHiteff spreadGunSpread 9 (V2 30 0) 2 basicBulletEffect @@ -351,13 +345,12 @@ multGun :: Item multGun = defaultGun { _itName = "MULTGUN" , _itIdentity = MultGun - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = basicBullet , _wpMaxAmmo = 2 , _wpLoadedAmmo = 2 + , _wpReloadTime = 40 } - , _wpReloadTime = 40 - , _wpReloadState = 0 , _itUseRate = 20 , _itUseTime = 0 , _itUse = useAmmoParams @@ -400,14 +393,13 @@ longGun :: Item longGun = defaultGun { _itName = "LONGGUN" , _itIdentity = LongGun - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = hvBullet , _wpMaxAmmo = 1 , _wpLoadedAmmo = 1 + , _wpReloadTime = 100 + , _wpReloadType = PassiveReload skwareFadeTwoSecS } - , _wpReloadTime = 100 - , _wpReloadState = 0 - , _wpReloadType = PassiveReload skwareFadeTwoSecS , _itUseRate = 100 , _itUseTime = 0 , _itUse = useAmmoParams diff --git a/src/Dodge/Item/Weapon/Drone.hs b/src/Dodge/Item/Weapon/Drone.hs index 831a1de84..778fa3c46 100644 --- a/src/Dodge/Item/Weapon/Drone.hs +++ b/src/Dodge/Item/Weapon/Drone.hs @@ -22,13 +22,12 @@ lasDrones :: Item lasDrones = defaultGun { _itName = "DRONES" , _itIdentity = Generic - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = DroneAmmo { _amString = "LASDRONE" } , _wpMaxAmmo = 2 , _wpLoadedAmmo = 2 + , _wpReloadTime = 80 } - , _wpReloadTime = 80 - , _wpReloadState = 0 , _itUseRate = 20 , _itUseTime = 0 , _itUse = RightUse aDroneWithItemParams diff --git a/src/Dodge/Item/Weapon/ExtraEffect.hs b/src/Dodge/Item/Weapon/ExtraEffect.hs index e4a9ae178..d428a548a 100644 --- a/src/Dodge/Item/Weapon/ExtraEffect.hs +++ b/src/Dodge/Item/Weapon/ExtraEffect.hs @@ -83,7 +83,7 @@ itemLaserScopeEffect it = (cr ^. crInv) IM.! invid reloadFrac | _wpLoadedAmmo (_wpAmmo it) == 0 = 1 - | otherwise = fromIntegral (_wpReloadState it) / fromIntegral (_wpReloadTime it) + | otherwise = fromIntegral (_wpReloadState (_wpAmmo it)) / fromIntegral (_wpReloadTime (_wpAmmo it)) --col = mixColors reloadFrac (1-reloadFrac) red green {- | Automatically send out radar pulses that detect walls. -} autoRadarEffect :: ItEffect diff --git a/src/Dodge/Item/Weapon/InventoryDisplay.hs b/src/Dodge/Item/Weapon/InventoryDisplay.hs index e8d715a31..97c30b72d 100644 --- a/src/Dodge/Item/Weapon/InventoryDisplay.hs +++ b/src/Dodge/Item/Weapon/InventoryDisplay.hs @@ -11,12 +11,16 @@ import Data.Sequence import Control.Lens {- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -} basicWeaponDisplay :: Item -> String -basicWeaponDisplay it = case it ^? itAttachment of - Just ItCharMode {_itCharMode = (c :<| _)} -> midPadL 10 ' ' (_itName it) (' ' : aIfLoaded) ++ [' ',c] - Just ItMode {_itMode = i} -> midPadL 10 ' ' (_itName it) (' ' : aIfLoaded) ++ show i - _ -> midPadL 10 ' ' (_itName it) (' ' : aIfLoaded) +basicWeaponDisplay it = midPadL 10 ' ' thename (' ' : thenumber) ++ theparam where - aIfLoaded = case it ^? wpReloadState of - Just 0 -> show $ _wpLoadedAmmo (_wpAmmo it) - Just x -> "R" ++ show x - _ -> "" + thename = _itName it + thenumber = case it ^? wpAmmo of + Just am@LoadableAmmo{} -> case _wpReloadState am of + 0 -> show $ _wpLoadedAmmo am + x -> "R" ++ show x + Just am@ChargeableAmmo{} -> show $ _wpCharge am + Nothing -> "" + theparam = case it ^? itAttachment of + Just ItCharMode {_itCharMode = (c :<| _)} -> [' ',c] + Just ItMode {_itMode = i} -> show i + _ -> [] diff --git a/src/Dodge/Item/Weapon/Launcher.hs b/src/Dodge/Item/Weapon/Launcher.hs index 871c665f0..cbf67b3b5 100644 --- a/src/Dodge/Item/Weapon/Launcher.hs +++ b/src/Dodge/Item/Weapon/Launcher.hs @@ -37,7 +37,7 @@ launcher :: Item launcher = defaultGun { _itName = "ROCKO" , _itIdentity = Launcher - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = defaultShellAmmo { _amPayload = makeExplosionAt , _amString = "" @@ -46,9 +46,8 @@ launcher = defaultGun } , _wpMaxAmmo = 30 , _wpLoadedAmmo = 30 + , _wpReloadTime = 80 } - , _wpReloadTime = 80 - , _wpReloadState = 0 , _itUseRate = 20 , _itUseTime = 0 , _itUse = RightUse aRocketWithItemParams @@ -240,7 +239,7 @@ remoteLauncher :: Item remoteLauncher = defaultGun { _itName = "ROCKO-REM" , _itIdentity = RemoteLauncher - , _wpAmmo = LoadableAmmo + , _wpAmmo = defaultAmmo { _aoType = defaultShellAmmo { _amPayload = makeExplosionAt , _amString = "" @@ -249,9 +248,8 @@ remoteLauncher = defaultGun } , _wpMaxAmmo = 30 , _wpLoadedAmmo = 30 + , _wpReloadTime = 80 } - , _wpReloadTime = 80 - , _wpReloadState = 0 , _itUseRate = 10 , _itUseTime = 0 , _itUse = RightUse $ const fireRemoteLauncher diff --git a/src/Dodge/Item/Weapon/Radar.hs b/src/Dodge/Item/Weapon/Radar.hs index f120d0308..abe99836b 100644 --- a/src/Dodge/Item/Weapon/Radar.hs +++ b/src/Dodge/Item/Weapon/Radar.hs @@ -23,9 +23,8 @@ radar = defaultGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 100 , _wpLoadedAmmo = 100 + , _wpReloadTime = 200 } - , _wpReloadTime = 200 - , _wpReloadState = 0 , _itUseRate = 120 , _itUseTime = 0 , _itUse = RightUse $ const aRadarPulse @@ -50,9 +49,8 @@ sonar = defaultGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 100 , _wpLoadedAmmo = 100 + , _wpReloadTime = 200 } - , _wpReloadTime = 200 - , _wpReloadState = 0 , _itUseRate = 120 , _itUseTime = 0 , _itUse = RightUse $ const aSonarPulse diff --git a/src/Dodge/Item/Weapon/Spawn.hs b/src/Dodge/Item/Weapon/Spawn.hs index 2e16f0180..fb0548088 100644 --- a/src/Dodge/Item/Weapon/Spawn.hs +++ b/src/Dodge/Item/Weapon/Spawn.hs @@ -19,9 +19,8 @@ spawnGun cr = defaultGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 1 , _wpLoadedAmmo = 1 + , _wpReloadTime = 80 } - , _wpReloadTime = 80 - , _wpReloadState = 0 , _itUseRate = 100 , _itUse = RightUse $ \_ -> spawnCrNextTo cr , _itUseModifiers = diff --git a/src/Dodge/Item/Weapon/SprayGuns.hs b/src/Dodge/Item/Weapon/SprayGuns.hs index c58b5dd08..9e11fbd78 100644 --- a/src/Dodge/Item/Weapon/SprayGuns.hs +++ b/src/Dodge/Item/Weapon/SprayGuns.hs @@ -37,9 +37,8 @@ poisonSprayer = defaultAutoGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 500 , _wpLoadedAmmo = 500 + , _wpReloadTime = 100 } - , _wpReloadTime = 100 - , _wpReloadState = 0 , _itUseRate = 0 , _itUseTime = 0 , _itUse = RightUse $ const aGasCloud @@ -65,9 +64,8 @@ flamer = defaultAutoGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 250 , _wpLoadedAmmo = 250 + , _wpReloadTime = 100 } - , _wpReloadTime = 100 - , _wpReloadState = 0 , _itUseRate = 0 , _itUseTime = 0 , _itUse = RightUse $ \_ -> randWalkAngle 0.2 0.01 aFlame diff --git a/src/Dodge/Item/Weapon/TriggerType.hs b/src/Dodge/Item/Weapon/TriggerType.hs index 551a31f54..f4eb0d230 100644 --- a/src/Dodge/Item/Weapon/TriggerType.hs +++ b/src/Dodge/Item/Weapon/TriggerType.hs @@ -96,7 +96,7 @@ ammoCheckI :: ChainEffect ammoCheckI eff item cr w | _wpLoadedAmmo (_wpAmmo item) <= 0 = fromMaybe w (startReloadingWeapon cr w) - | _wpReloadState item > 0 = w + | _wpReloadState (_wpAmmo item) > 0 = w | otherwise = eff item cr w {- | Fires at an increasing rate. @@ -125,14 +125,14 @@ rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w itRef = _crInvSel cr pointItem = creatures . ix cid . crInv . ix itRef currentRate = _itUseRate item - repeatFire = _wpReloadState item == 0 && _itUseTime item == 1 - firstFire = _wpReloadState item == 0 && _itUseTime item == 0 + repeatFire = _wpReloadState (_wpAmmo item) == 0 && _itUseTime item == 1 + firstFire = _wpReloadState (_wpAmmo item) == 0 && _itUseTime item == 0 {- | Apply effect after a warm up. -} withWarmUpI :: SoundID -- ^ warm up sound id -> ChainEffect withWarmUpI soundID f item cr w - | _wpReloadState item /= 0 = w + | _wpReloadState (_wpAmmo item) /= 0 = w | curWarmUp < maxWarmUp = w & pointerToItem . wpCurWarmUp +~ 2 & soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2) @@ -247,7 +247,7 @@ ammoUseCheckI f item cr w cid = _crID cr itRef = _crInvSel cr pointerToItem = creatures . ix cid . crInv . ix itRef - fireCondition = _wpReloadState item == 0 + fireCondition = _wpReloadState (_wpAmmo item) == 0 && _itUseTime item == 0 && _wpLoadedAmmo (_wpAmmo item) > 0 reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0 @@ -283,7 +283,7 @@ shootL f cr invid w cid = _crID cr item = _crInv cr IM.! invid pointerToItem = creatures . ix cid . crInv . ix invid - fireCondition = _wpReloadState item == 0 + fireCondition = _wpReloadState (_wpAmmo item) == 0 && _itUseTime item == 0 && _wpLoadedAmmo (_wpAmmo item) > 0 reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0 diff --git a/src/Dodge/Item/Weapon/Utility.hs b/src/Dodge/Item/Weapon/Utility.hs index cfed2baca..5413c0c31 100644 --- a/src/Dodge/Item/Weapon/Utility.hs +++ b/src/Dodge/Item/Weapon/Utility.hs @@ -20,20 +20,21 @@ rewindGun :: Item rewindGun = defaultGun { _itName = "REWINDER" , _itIdentity = Rewinder - , _wpAmmo = defaultAmmo - { _wpMaxAmmo = 0 - , _wpLoadedAmmo = 0 + , _wpAmmo = ChargeableAmmo + { _wpMaxCharge = 250 + , _wpCharge = 0 } , _itEffect = ItRewindEffect rewindEffect [] , _itUse = LeftUse $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr } rewindEffect :: ItEffect -> Creature -> Int -> World -> World rewindEffect _ cr invid w - | Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take 250 . (w' : )) - & creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpLoadedAmmo .~ length (_rewindWorlds w) + | Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : )) + & creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpCharge .~ length (_rewindWorlds w) | otherwise = w & rewindWorlds .~ [] - & creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpLoadedAmmo .~ 0 + & creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpCharge .~ 0 where + maxcharge = _wpMaxCharge . _wpAmmo $ _crInv cr IM.! invid w' = w & rewindWorlds .~ [] & rewinding .~ True @@ -57,9 +58,8 @@ shrinkGun = defaultGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 100 , _wpLoadedAmmo = 100 + , _wpReloadTime = 20 } - , _wpReloadTime = 20 - , _wpReloadState = 0 , _itUseRate = 0 , _itUseTime = 0 , _itAimStance = TwoHandFlat @@ -97,9 +97,8 @@ blinkGun = defaultGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 100 , _wpLoadedAmmo = 100 + , _wpReloadTime = 20 } - , _wpReloadTime = 20 - , _wpReloadState = 0 , _itUseRate = 0 , _itUseTime = 0 , _itUse = LeftUse $ hammerCheckL $ shootL aSelfL @@ -138,9 +137,9 @@ forceFieldGun = defaultGun , _wpAmmo = defaultAmmo { _wpMaxAmmo = 100 , _wpLoadedAmmo = 100 + , _wpReloadTime = 40 + , _wpReloadState = 0 } - , _wpReloadTime = 40 - , _wpReloadState = 0 , _itUseRate = 10 , _itUseTime = 0 , _itUse = undefined diff --git a/src/Dodge/Render/HUD.hs b/src/Dodge/Render/HUD.hs index 9ffed595e..f57d245dc 100644 --- a/src/Dodge/Render/HUD.hs +++ b/src/Dodge/Render/HUD.hs @@ -209,8 +209,6 @@ itemText NoItem = text "----" itemText it = case _itCurseStatus it of UndroppableIdentified -> color black (text (_itInvDisplay it it)) <> color (withAlpha 0.9 thecolor) (polygon (rectNSEW 110 (-65) 885 (-90))) --- <> color (withAlpha 0.9 thecolor) (polygon (rectNSEW 115 (-70) 895 (-95))) --- <> color (withAlpha 0.9 thecolor) (polygon (rectNSEW 120 (-70) 900 (-100))) _ -> color thecolor $ text (_itInvDisplay it it) where thecolor = _itInvColor it