Fold in more ammo parameters, distinguish loadable and charging weapons

This commit is contained in:
2021-11-27 14:29:44 +00:00
parent 92a8dd59b8
commit 224db733f6
19 changed files with 112 additions and 111 deletions
+4 -4
View File
@@ -152,19 +152,19 @@ startReloadingWeapon cr w =
it = _crInv cr IM.! _crInvSel cr it = _crInv cr IM.! _crInvSel cr
itRef = creatures . ix cid . crInv . ix (_crInvSel cr) itRef = creatures . ix cid . crInv . ix (_crInvSel cr)
in case it of 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 | lA < maxA && rS == 0 -> Just $ set ( itRef . wpAmmo . wpLoadedAmmo) maxA
$ set ( itRef . wpReloadState) rT w $ set ( itRef . wpAmmo . wpReloadState) rT w
_ -> Nothing _ -> Nothing
{- | Start reloading if clip is empty. -} {- | Start reloading if clip is empty. -}
crAutoReload :: Creature -> Creature crAutoReload :: Creature -> Creature
crAutoReload cr = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo of crAutoReload cr = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo of
Just 0 | _posture (_crStance cr) /= Aiming 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) & crInv . ix (_crInvSel cr) . wpAmmo . wpLoadedAmmo %~ (`fromMaybe` maxA)
_ -> cr _ -> cr
where where
reloadT = cr ^? crInv . ix (_crInvSel cr) . wpReloadTime reloadT = cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpReloadTime
maxA = cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpMaxAmmo maxA = cr ^? crInv . ix (_crInvSel cr) . wpAmmo . wpMaxAmmo
{- | Teleport a creature to the mouse position -} {- | Teleport a creature to the mouse position -}
blinkAction blinkAction
+22 -9
View File
@@ -123,17 +123,30 @@ invSideEff cr w = weaponReloadSounds cr $ IM.foldrWithKey f w (_crInv cr)
Just g -> g (_itEffect it) cr i w' Just g -> g (_itEffect it) cr i w'
weaponReloadSounds :: Creature -> World -> World weaponReloadSounds :: Creature -> World -> World
weaponReloadSounds cr w = case _crInv cr IM.!? _crInvSel cr of weaponReloadSounds cr w = case cr ^? crInv . ix (_crInvSel cr) . wpAmmo of
Just Weapon{_wpReloadType = PassiveReload stype,_wpReloadTime=rt,_wpReloadState=rs} Just am@LoadableAmmo{} -> case _wpReloadType am of
| rt == rs -> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w PassiveReload stype |_wpReloadTime am ==_wpReloadState am
| otherwise -> w -> soundContinue (CrReloadSound 0) (_crPos cr) stype Nothing w
Just Weapon{_wpReloadState = 0} -> w PassiveReload _ -> w
Just Weapon{_wpReloadState = 1} -> stopSoundFrom (CrReloadSound cid) w ActiveReload | _wpReloadState am == 1 -> stopSoundFrom (CrReloadSound cid) w
Just Weapon{} -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w ActiveReload | _wpReloadState am == 0 -> w
_ -> w ActiveReload -> soundContinue (CrReloadSound cid) (_crPos cr) reloadS (Just 1) w
Just ChargeableAmmo {} -> w
Nothing -> w
where where
cid = _crID cr 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 :: Creature -> Creature
updateMovement cr updateMovement cr
| isFrictionless cr = over crPos (+.+ momentum) $ setOldPos cr | isFrictionless cr = over crPos (+.+ momentum) $ setOldPos cr
@@ -157,7 +170,7 @@ stepItemUseCooldown cr = cr & crInv . ix iSel %~
iSel = _crInvSel cr iSel = _crInvSel cr
stepReloading :: Creature -> Creature stepReloading :: Creature -> Creature
stepReloading cr = over (crInv . ix iSel . wpReloadState) decreaseToZero cr stepReloading cr = over (crInv . ix iSel . wpAmmo . wpReloadState) decreaseToZero cr
where where
iSel = _crInvSel cr iSel = _crInvSel cr
+2 -2
View File
@@ -35,12 +35,12 @@ onBoth :: (a -> b -> c) -> (d -> a) -> (d -> b) -> d -> c
onBoth f g h x = f (g x) (h x) onBoth f g h x = f (g x) (h x)
crIsReloading :: (World, Creature) -> Bool 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 Just t -> t > 0
_ -> False _ -> False
crIsReloadingR :: Creature -> Reader World Bool 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 Just t -> t > 0
_ -> False _ -> False
+13 -6
View File
@@ -290,22 +290,30 @@ data ItemPos
= InInv { _itCrId :: Int , _itInvId :: Int } = InInv { _itCrId :: Int , _itInvId :: Int }
| OnFloor { _itFlID :: Int } | OnFloor { _itFlID :: Int }
data ItemUse data ItemUse
= RightUse { _rUse :: Item -> Creature -> World -> World } = RightUse
| LeftUse { _lUse :: Creature -> Int -> World -> World } { _rUse :: Item -> Creature -> World -> World
}
| LeftUse
{ _lUse :: Creature -> Int -> World -> World
}
| NoUse | NoUse
data ItemAmmo data ItemAmmo
= LoadableAmmo = LoadableAmmo
{ _aoType :: AmmoType { _aoType :: AmmoType
, _wpMaxAmmo :: Int , _wpMaxAmmo :: Int
, _wpLoadedAmmo :: Int , _wpLoadedAmmo :: Int
, _wpReloadTime :: Int
, _wpReloadState :: Int
, _wpReloadType :: ReloadType
}
| ChargeableAmmo
{ _wpMaxCharge :: Int
, _wpCharge :: Int
} }
data Item data Item
= Weapon = Weapon
{ _itName :: String { _itName :: String
, _wpAmmo :: ItemAmmo , _wpAmmo :: ItemAmmo
, _wpReloadTime :: Int
, _wpReloadState :: Int
, _wpReloadType :: ReloadType
, _wpMaxWarmUp :: Int , _wpMaxWarmUp :: Int
, _wpCurWarmUp :: Int , _wpCurWarmUp :: Int
, _wpMaxCoolDown :: Int , _wpMaxCoolDown :: Int
@@ -314,7 +322,6 @@ data Item
, _itUseTime :: Int , _itUseTime :: Int
, _itUse :: ItemUse , _itUse :: ItemUse
, _itUseModifiers :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World] , _itUseModifiers :: [(Item -> Creature -> World -> World) -> Item -> Creature -> World -> World]
--, _itLeftClickUse :: Maybe (Creature -> Int -> World -> World)
, _wpSpread :: Float , _wpSpread :: Float
, _wpRange :: Float , _wpRange :: Float
, _itHammer :: HammerPosition , _itHammer :: HammerPosition
+3 -3
View File
@@ -15,6 +15,9 @@ defaultAmmo = LoadableAmmo
{ _aoType = GenericAmmo { _aoType = GenericAmmo
, _wpMaxAmmo = 15 , _wpMaxAmmo = 15
, _wpLoadedAmmo = 15 , _wpLoadedAmmo = 15
, _wpReloadTime = 40
, _wpReloadState = 0
, _wpReloadType = ActiveReload
} }
defaultGun :: Item defaultGun :: Item
@@ -23,9 +26,6 @@ defaultGun = Weapon
, _itCurseStatus = Uncursed , _itCurseStatus = Uncursed
, _itIdentity = Pistol , _itIdentity = Pistol
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
, _wpReloadTime = 40
, _wpReloadState = 0
, _wpReloadType = ActiveReload
, _wpMaxWarmUp = 0 , _wpMaxWarmUp = 0
, _wpCurWarmUp = 0 , _wpCurWarmUp = 0
, _wpMaxCoolDown = 0 , _wpMaxCoolDown = 0
+1 -1
View File
@@ -53,7 +53,7 @@ withDelayedVelWthHiteff vfact vel width hiteff cr = over particles (newbul : )
loadedAmmo :: Item -> Int loadedAmmo :: Item -> Int
loadedAmmo it loadedAmmo it
| _wpReloadState it == 0 = _wpLoadedAmmo (_wpAmmo it) | _wpReloadState (_wpAmmo it) == 0 = _wpLoadedAmmo (_wpAmmo it)
| otherwise = 0 | otherwise = 0
fractionLoadedAmmo :: Item -> Float fractionLoadedAmmo :: Item -> Float
+3 -6
View File
@@ -40,9 +40,8 @@ teslaGun = defaultGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 200 { _wpMaxAmmo = 200
, _wpLoadedAmmo = 200 , _wpLoadedAmmo = 200
}
, _wpReloadTime = 80 , _wpReloadTime = 80
, _wpReloadState = 0 }
, _itUseRate = 0 , _itUseRate = 0
, _itAimStance = TwoHandFlat , _itAimStance = TwoHandFlat
, _itUseTime = 0 , _itUseTime = 0
@@ -76,9 +75,8 @@ lasGun = defaultAutoGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 200 { _wpMaxAmmo = 200
, _wpLoadedAmmo = 200 , _wpLoadedAmmo = 200
}
, _wpReloadTime = 80 , _wpReloadTime = 80
, _wpReloadState = 0 }
, _itUseRate = 0 , _itUseRate = 0
, _itUseTime = 0 , _itUseTime = 0
, _itUse = RightUse $ const aLaser , _itUse = RightUse $ const aLaser
@@ -118,9 +116,8 @@ tractorGun = defaultAutoGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 10000 { _wpMaxAmmo = 10000
, _wpLoadedAmmo = 10000 , _wpLoadedAmmo = 10000
}
, _wpReloadTime = 40 , _wpReloadTime = 40
, _wpReloadState = 0 }
, _itUseRate = 0 , _itUseRate = 0
, _itUseTime = 0 , _itUseTime = 0
, _itUse = RightUse aTractorBeam , _itUse = RightUse aTractorBeam
+1 -2
View File
@@ -116,9 +116,8 @@ boosterGun = defaultGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100 { _wpMaxAmmo = 100
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
}
, _wpReloadTime = 20 , _wpReloadTime = 20
, _wpReloadState = 0 }
, _itUseRate = 0 , _itUseRate = 0
, _itUseTime = 0 , _itUseTime = 0
, _itUse = LeftUse $ boostSelfL 10 , _itUse = LeftUse $ boostSelfL 10
+16 -24
View File
@@ -35,13 +35,12 @@ autoGun :: Item
autoGun = defaultAutoGun autoGun = defaultAutoGun
{ _itName = "AUTOGUN" { _itName = "AUTOGUN"
, _itIdentity = AutoGun , _itIdentity = AutoGun
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = basicBullet { _aoType = basicBullet
, _wpMaxAmmo = 30 , _wpMaxAmmo = 30
, _wpLoadedAmmo = 30 , _wpLoadedAmmo = 30
}
, _wpReloadTime = 80 , _wpReloadTime = 80
, _wpReloadState = 0 }
, _itUseRate = 5 , _itUseRate = 5
, _itUseTime = 0 , _itUseTime = 0
, _itUse = useAmmoParams , _itUse = useAmmoParams
@@ -88,13 +87,12 @@ pistol :: Item
pistol = defaultGun pistol = defaultGun
{ _itName = "PISTOL" { _itName = "PISTOL"
, _itIdentity = Pistol , _itIdentity = Pistol
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = basicBullet { _aoType = basicBullet
, _wpMaxAmmo = 15 , _wpMaxAmmo = 15
, _wpLoadedAmmo = 15 , _wpLoadedAmmo = 15
}
, _wpReloadTime = 40 , _wpReloadTime = 40
, _wpReloadState = 0 }
, _itUseRate = 8 , _itUseRate = 8
, _itUseTime = 0 , _itUseTime = 0
, _itUse = useAmmoParams , _itUse = useAmmoParams
@@ -138,13 +136,12 @@ hvAutoGun :: Item
hvAutoGun = defaultAutoGun hvAutoGun = defaultAutoGun
{ _itName = "AUTO-HV" { _itName = "AUTO-HV"
, _itIdentity = HvAutoGun , _itIdentity = HvAutoGun
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = hvBullet { _aoType = hvBullet
, _wpMaxAmmo = 100 , _wpMaxAmmo = 100
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
}
, _wpReloadTime = 200 , _wpReloadTime = 200
, _wpReloadState = 0 }
, _itUseRate = 25 , _itUseRate = 25
, _itUseTime = 0 , _itUseTime = 0
, _itUse = useAmmoParams , _itUse = useAmmoParams
@@ -175,13 +172,12 @@ ltAutoGun :: Item
ltAutoGun = defaultAutoGun ltAutoGun = defaultAutoGun
{ _itName = "AUTO-LT" { _itName = "AUTO-LT"
, _itIdentity = LtAutoGun , _itIdentity = LtAutoGun
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = ltBullet { _aoType = ltBullet
, _wpMaxAmmo = 25 , _wpMaxAmmo = 25
, _wpLoadedAmmo = 25 , _wpLoadedAmmo = 25
}
, _wpReloadTime = 80 , _wpReloadTime = 80
, _wpReloadState = 0 }
, _itUseRate = 3 , _itUseRate = 3
, _itUseTime = 0 , _itUseTime = 0
, _itUse = useAmmoParams , _itUse = useAmmoParams
@@ -218,13 +214,12 @@ miniGun :: Item
miniGun = defaultAutoGun miniGun = defaultAutoGun
{ _itName = "MINI-G" { _itName = "MINI-G"
, _itIdentity = MiniGun , _itIdentity = MiniGun
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = basicBullet { _aoType = basicBullet
, _wpMaxAmmo = 1500 , _wpMaxAmmo = 1500
, _wpLoadedAmmo = 1500 , _wpLoadedAmmo = 1500
}
, _wpReloadTime = 200 , _wpReloadTime = 200
, _wpReloadState = 0 }
, _wpMaxWarmUp = 100 , _wpMaxWarmUp = 100
, _itUseRate = 0 , _itUseRate = 0
, _itUseTime = 0 , _itUseTime = 0
@@ -311,13 +306,12 @@ spreadGun :: Item
spreadGun = defaultGun spreadGun = defaultGun
{ _itName = "SPREAD" { _itName = "SPREAD"
, _itIdentity = SpreadGun , _itIdentity = SpreadGun
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = basicBullet { _aoType = basicBullet
, _wpMaxAmmo = 5 , _wpMaxAmmo = 5
, _wpLoadedAmmo = 5 , _wpLoadedAmmo = 5
}
, _wpReloadTime = 80 , _wpReloadTime = 80
, _wpReloadState = 0 }
, _itUseRate = 20 , _itUseRate = 20
, _itUseTime = 0 , _itUseTime = 0
--, _itUse = \_ -> spreadNumVelWthHiteff spreadGunSpread 9 (V2 30 0) 2 basicBulletEffect --, _itUse = \_ -> spreadNumVelWthHiteff spreadGunSpread 9 (V2 30 0) 2 basicBulletEffect
@@ -351,13 +345,12 @@ multGun :: Item
multGun = defaultGun multGun = defaultGun
{ _itName = "MULTGUN" { _itName = "MULTGUN"
, _itIdentity = MultGun , _itIdentity = MultGun
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = basicBullet { _aoType = basicBullet
, _wpMaxAmmo = 2 , _wpMaxAmmo = 2
, _wpLoadedAmmo = 2 , _wpLoadedAmmo = 2
}
, _wpReloadTime = 40 , _wpReloadTime = 40
, _wpReloadState = 0 }
, _itUseRate = 20 , _itUseRate = 20
, _itUseTime = 0 , _itUseTime = 0
, _itUse = useAmmoParams , _itUse = useAmmoParams
@@ -400,14 +393,13 @@ longGun :: Item
longGun = defaultGun longGun = defaultGun
{ _itName = "LONGGUN" { _itName = "LONGGUN"
, _itIdentity = LongGun , _itIdentity = LongGun
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = hvBullet { _aoType = hvBullet
, _wpMaxAmmo = 1 , _wpMaxAmmo = 1
, _wpLoadedAmmo = 1 , _wpLoadedAmmo = 1
}
, _wpReloadTime = 100 , _wpReloadTime = 100
, _wpReloadState = 0
, _wpReloadType = PassiveReload skwareFadeTwoSecS , _wpReloadType = PassiveReload skwareFadeTwoSecS
}
, _itUseRate = 100 , _itUseRate = 100
, _itUseTime = 0 , _itUseTime = 0
, _itUse = useAmmoParams , _itUse = useAmmoParams
+2 -3
View File
@@ -22,13 +22,12 @@ lasDrones :: Item
lasDrones = defaultGun lasDrones = defaultGun
{ _itName = "DRONES" { _itName = "DRONES"
, _itIdentity = Generic , _itIdentity = Generic
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = DroneAmmo { _amString = "LASDRONE" } { _aoType = DroneAmmo { _amString = "LASDRONE" }
, _wpMaxAmmo = 2 , _wpMaxAmmo = 2
, _wpLoadedAmmo = 2 , _wpLoadedAmmo = 2
}
, _wpReloadTime = 80 , _wpReloadTime = 80
, _wpReloadState = 0 }
, _itUseRate = 20 , _itUseRate = 20
, _itUseTime = 0 , _itUseTime = 0
, _itUse = RightUse aDroneWithItemParams , _itUse = RightUse aDroneWithItemParams
+1 -1
View File
@@ -83,7 +83,7 @@ itemLaserScopeEffect
it = (cr ^. crInv) IM.! invid it = (cr ^. crInv) IM.! invid
reloadFrac reloadFrac
| _wpLoadedAmmo (_wpAmmo it) == 0 = 1 | _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 --col = mixColors reloadFrac (1-reloadFrac) red green
{- | Automatically send out radar pulses that detect walls. -} {- | Automatically send out radar pulses that detect walls. -}
autoRadarEffect :: ItEffect autoRadarEffect :: ItEffect
+12 -8
View File
@@ -11,12 +11,16 @@ import Data.Sequence
import Control.Lens import Control.Lens
{- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -} {- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -}
basicWeaponDisplay :: Item -> String basicWeaponDisplay :: Item -> String
basicWeaponDisplay it = case it ^? itAttachment of basicWeaponDisplay it = midPadL 10 ' ' thename (' ' : thenumber) ++ theparam
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)
where where
aIfLoaded = case it ^? wpReloadState of thename = _itName it
Just 0 -> show $ _wpLoadedAmmo (_wpAmmo it) thenumber = case it ^? wpAmmo of
Just x -> "R" ++ show x 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
_ -> []
+4 -6
View File
@@ -37,7 +37,7 @@ launcher :: Item
launcher = defaultGun launcher = defaultGun
{ _itName = "ROCKO" { _itName = "ROCKO"
, _itIdentity = Launcher , _itIdentity = Launcher
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = defaultShellAmmo { _aoType = defaultShellAmmo
{ _amPayload = makeExplosionAt { _amPayload = makeExplosionAt
, _amString = "" , _amString = ""
@@ -46,9 +46,8 @@ launcher = defaultGun
} }
, _wpMaxAmmo = 30 , _wpMaxAmmo = 30
, _wpLoadedAmmo = 30 , _wpLoadedAmmo = 30
}
, _wpReloadTime = 80 , _wpReloadTime = 80
, _wpReloadState = 0 }
, _itUseRate = 20 , _itUseRate = 20
, _itUseTime = 0 , _itUseTime = 0
, _itUse = RightUse aRocketWithItemParams , _itUse = RightUse aRocketWithItemParams
@@ -240,7 +239,7 @@ remoteLauncher :: Item
remoteLauncher = defaultGun remoteLauncher = defaultGun
{ _itName = "ROCKO-REM" { _itName = "ROCKO-REM"
, _itIdentity = RemoteLauncher , _itIdentity = RemoteLauncher
, _wpAmmo = LoadableAmmo , _wpAmmo = defaultAmmo
{ _aoType = defaultShellAmmo { _aoType = defaultShellAmmo
{ _amPayload = makeExplosionAt { _amPayload = makeExplosionAt
, _amString = "" , _amString = ""
@@ -249,9 +248,8 @@ remoteLauncher = defaultGun
} }
, _wpMaxAmmo = 30 , _wpMaxAmmo = 30
, _wpLoadedAmmo = 30 , _wpLoadedAmmo = 30
}
, _wpReloadTime = 80 , _wpReloadTime = 80
, _wpReloadState = 0 }
, _itUseRate = 10 , _itUseRate = 10
, _itUseTime = 0 , _itUseTime = 0
, _itUse = RightUse $ const fireRemoteLauncher , _itUse = RightUse $ const fireRemoteLauncher
+2 -4
View File
@@ -23,9 +23,8 @@ radar = defaultGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100 { _wpMaxAmmo = 100
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
}
, _wpReloadTime = 200 , _wpReloadTime = 200
, _wpReloadState = 0 }
, _itUseRate = 120 , _itUseRate = 120
, _itUseTime = 0 , _itUseTime = 0
, _itUse = RightUse $ const aRadarPulse , _itUse = RightUse $ const aRadarPulse
@@ -50,9 +49,8 @@ sonar = defaultGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100 { _wpMaxAmmo = 100
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
}
, _wpReloadTime = 200 , _wpReloadTime = 200
, _wpReloadState = 0 }
, _itUseRate = 120 , _itUseRate = 120
, _itUseTime = 0 , _itUseTime = 0
, _itUse = RightUse $ const aSonarPulse , _itUse = RightUse $ const aSonarPulse
+1 -2
View File
@@ -19,9 +19,8 @@ spawnGun cr = defaultGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 1 { _wpMaxAmmo = 1
, _wpLoadedAmmo = 1 , _wpLoadedAmmo = 1
}
, _wpReloadTime = 80 , _wpReloadTime = 80
, _wpReloadState = 0 }
, _itUseRate = 100 , _itUseRate = 100
, _itUse = RightUse $ \_ -> spawnCrNextTo cr , _itUse = RightUse $ \_ -> spawnCrNextTo cr
, _itUseModifiers = , _itUseModifiers =
+2 -4
View File
@@ -37,9 +37,8 @@ poisonSprayer = defaultAutoGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 500 { _wpMaxAmmo = 500
, _wpLoadedAmmo = 500 , _wpLoadedAmmo = 500
}
, _wpReloadTime = 100 , _wpReloadTime = 100
, _wpReloadState = 0 }
, _itUseRate = 0 , _itUseRate = 0
, _itUseTime = 0 , _itUseTime = 0
, _itUse = RightUse $ const aGasCloud , _itUse = RightUse $ const aGasCloud
@@ -65,9 +64,8 @@ flamer = defaultAutoGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 250 { _wpMaxAmmo = 250
, _wpLoadedAmmo = 250 , _wpLoadedAmmo = 250
}
, _wpReloadTime = 100 , _wpReloadTime = 100
, _wpReloadState = 0 }
, _itUseRate = 0 , _itUseRate = 0
, _itUseTime = 0 , _itUseTime = 0
, _itUse = RightUse $ \_ -> randWalkAngle 0.2 0.01 aFlame , _itUse = RightUse $ \_ -> randWalkAngle 0.2 0.01 aFlame
+6 -6
View File
@@ -96,7 +96,7 @@ ammoCheckI :: ChainEffect
ammoCheckI eff item cr w ammoCheckI eff item cr w
| _wpLoadedAmmo (_wpAmmo item) <= 0 | _wpLoadedAmmo (_wpAmmo item) <= 0
= fromMaybe w (startReloadingWeapon cr w) = fromMaybe w (startReloadingWeapon cr w)
| _wpReloadState item > 0 = w | _wpReloadState (_wpAmmo item) > 0 = w
| otherwise = eff item cr w | otherwise = eff item cr w
{- | {- |
Fires at an increasing rate. Fires at an increasing rate.
@@ -125,14 +125,14 @@ rateIncABI startRate fastRate exeffFirst exeffCont eff item cr w
itRef = _crInvSel cr itRef = _crInvSel cr
pointItem = creatures . ix cid . crInv . ix itRef pointItem = creatures . ix cid . crInv . ix itRef
currentRate = _itUseRate item currentRate = _itUseRate item
repeatFire = _wpReloadState item == 0 && _itUseTime item == 1 repeatFire = _wpReloadState (_wpAmmo item) == 0 && _itUseTime item == 1
firstFire = _wpReloadState item == 0 && _itUseTime item == 0 firstFire = _wpReloadState (_wpAmmo item) == 0 && _itUseTime item == 0
{- | Apply effect after a warm up. -} {- | Apply effect after a warm up. -}
withWarmUpI withWarmUpI
:: SoundID -- ^ warm up sound id :: SoundID -- ^ warm up sound id
-> ChainEffect -> ChainEffect
withWarmUpI soundID f item cr w withWarmUpI soundID f item cr w
| _wpReloadState item /= 0 = w | _wpReloadState (_wpAmmo item) /= 0 = w
| curWarmUp < maxWarmUp = w | curWarmUp < maxWarmUp = w
& pointerToItem . wpCurWarmUp +~ 2 & pointerToItem . wpCurWarmUp +~ 2
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2) & soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
@@ -247,7 +247,7 @@ ammoUseCheckI f item cr w
cid = _crID cr cid = _crID cr
itRef = _crInvSel cr itRef = _crInvSel cr
pointerToItem = creatures . ix cid . crInv . ix itRef pointerToItem = creatures . ix cid . crInv . ix itRef
fireCondition = _wpReloadState item == 0 fireCondition = _wpReloadState (_wpAmmo item) == 0
&& _itUseTime item == 0 && _itUseTime item == 0
&& _wpLoadedAmmo (_wpAmmo item) > 0 && _wpLoadedAmmo (_wpAmmo item) > 0
reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0 reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0
@@ -283,7 +283,7 @@ shootL f cr invid w
cid = _crID cr cid = _crID cr
item = _crInv cr IM.! invid item = _crInv cr IM.! invid
pointerToItem = creatures . ix cid . crInv . ix invid pointerToItem = creatures . ix cid . crInv . ix invid
fireCondition = _wpReloadState item == 0 fireCondition = _wpReloadState (_wpAmmo item) == 0
&& _itUseTime item == 0 && _itUseTime item == 0
&& _wpLoadedAmmo (_wpAmmo item) > 0 && _wpLoadedAmmo (_wpAmmo item) > 0
reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0 reloadCondition = _wpLoadedAmmo (_wpAmmo item) == 0
+10 -11
View File
@@ -20,20 +20,21 @@ rewindGun :: Item
rewindGun = defaultGun rewindGun = defaultGun
{ _itName = "REWINDER" { _itName = "REWINDER"
, _itIdentity = Rewinder , _itIdentity = Rewinder
, _wpAmmo = defaultAmmo , _wpAmmo = ChargeableAmmo
{ _wpMaxAmmo = 0 { _wpMaxCharge = 250
, _wpLoadedAmmo = 0 , _wpCharge = 0
} }
, _itEffect = ItRewindEffect rewindEffect [] , _itEffect = ItRewindEffect rewindEffect []
, _itUse = LeftUse $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr , _itUse = LeftUse $ \cr invid -> useRewindGun (_crInv cr IM.! invid) cr
} }
rewindEffect :: ItEffect -> Creature -> Int -> World -> World rewindEffect :: ItEffect -> Creature -> Int -> World -> World
rewindEffect _ cr invid w rewindEffect _ cr invid w
| Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take 250 . (w' : )) | Just invid == _crLeftInvSel cr = w & rewindWorlds %~ (take maxcharge . (w' : ))
& creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpLoadedAmmo .~ length (_rewindWorlds w) & creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpCharge .~ length (_rewindWorlds w)
| otherwise = w & rewindWorlds .~ [] | otherwise = w & rewindWorlds .~ []
& creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpLoadedAmmo .~ 0 & creatures . ix (_crID cr) . crInv . ix invid . wpAmmo . wpCharge .~ 0
where where
maxcharge = _wpMaxCharge . _wpAmmo $ _crInv cr IM.! invid
w' = w & rewindWorlds .~ [] w' = w & rewindWorlds .~ []
& rewinding .~ True & rewinding .~ True
@@ -57,9 +58,8 @@ shrinkGun = defaultGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100 { _wpMaxAmmo = 100
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
}
, _wpReloadTime = 20 , _wpReloadTime = 20
, _wpReloadState = 0 }
, _itUseRate = 0 , _itUseRate = 0
, _itUseTime = 0 , _itUseTime = 0
, _itAimStance = TwoHandFlat , _itAimStance = TwoHandFlat
@@ -97,9 +97,8 @@ blinkGun = defaultGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100 { _wpMaxAmmo = 100
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
}
, _wpReloadTime = 20 , _wpReloadTime = 20
, _wpReloadState = 0 }
, _itUseRate = 0 , _itUseRate = 0
, _itUseTime = 0 , _itUseTime = 0
, _itUse = LeftUse $ hammerCheckL $ shootL aSelfL , _itUse = LeftUse $ hammerCheckL $ shootL aSelfL
@@ -138,9 +137,9 @@ forceFieldGun = defaultGun
, _wpAmmo = defaultAmmo , _wpAmmo = defaultAmmo
{ _wpMaxAmmo = 100 { _wpMaxAmmo = 100
, _wpLoadedAmmo = 100 , _wpLoadedAmmo = 100
}
, _wpReloadTime = 40 , _wpReloadTime = 40
, _wpReloadState = 0 , _wpReloadState = 0
}
, _itUseRate = 10 , _itUseRate = 10
, _itUseTime = 0 , _itUseTime = 0
, _itUse = undefined , _itUse = undefined
-2
View File
@@ -209,8 +209,6 @@ itemText NoItem = text "----"
itemText it = case _itCurseStatus it of itemText it = case _itCurseStatus it of
UndroppableIdentified -> color black (text (_itInvDisplay it it)) 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 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) _ -> color thecolor $ text (_itInvDisplay it it)
where where
thecolor = _itInvColor it thecolor = _itInvColor it