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