Fold in more ammo parameters, distinguish loadable and charging weapons
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
+17
-10
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
_ -> []
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user