Work towards adding external ammo sources

This commit is contained in:
2023-05-17 11:01:52 +01:00
parent 63c71c852d
commit 7df81559d9
30 changed files with 246 additions and 196 deletions
+3 -3
View File
@@ -10,8 +10,8 @@ import LensHelp
moduleModification :: ItemModuleType -> Item -> Item moduleModification :: ItemModuleType -> Item -> Item
moduleModification imt = case imt of moduleModification imt = case imt of
EMPTYMODULE -> id EMPTYMODULE -> id
DRUMMAG -> itUse . heldConsumption . laMax .~ 45 DRUMMAG -> itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 45
BELTMAG -> itUse . heldConsumption . laMax .~ 150 BELTMAG -> itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 150
MAGNETMAG -> itUse . heldDelay . rateMax .~ 4 MAGNETMAG -> itUse . heldDelay . rateMax .~ 4
BULPAY BulFlak -> (itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulFlak) BULPAY BulFlak -> (itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ BulFlak)
. (itUse . heldConsumption . laAmmoType . amBullet . buTimer .~ 3) . (itUse . heldConsumption . laAmmoType . amBullet . buTimer .~ 3)
@@ -33,7 +33,7 @@ moduleModification imt = case imt of
. (itParams . subParams ?~ teslaParams) . (itParams . subParams ?~ teslaParams)
WEPTELE -> makeDirectedTele WEPTELE -> makeDirectedTele
LAUNCHHOME -> itUse . heldConsumption . laAmmoType . amPjCreation .~ CreateTrackingShell LAUNCHHOME -> itUse . heldConsumption . laAmmoType . amPjCreation .~ CreateTrackingShell
EXTRABATTERY -> itUse . heldConsumption . laMax +~ 1000 EXTRABATTERY -> itUse . heldConsumption . laSource . _InternalSource . iaMax +~ 1000
ATTACHTORCH -> id ATTACHTORCH -> id
where where
makeDirectedTele it = makeDirectedTele it =
+11 -4
View File
@@ -37,7 +37,8 @@ useItemRightClick cr' w = fromMaybe (f w) $ do
itemEffect :: Creature -> Item -> World -> World itemEffect :: Creature -> Item -> World -> World
itemEffect cr it w = case it ^. itUse of itemEffect cr it w = case it ^. itUse of
HeldUse{_heldUse = eff, _heldMods = usemods} -> HeldUse{_heldUse = eff, _heldMods = usemods} ->
hammerTest $ tryReload cr it (_input w) $ foldl' (&) (useHeld eff) (useMod usemods) it cr --hammerTest $ tryReload cr it (_input w) $ foldl' (&) (useHeld eff) (useMod usemods) it cr
hammerTest $ foldl' (&) (useHeld eff) (useMod usemods) it cr
LeftUse{} -> doequipmentchange LeftUse{} -> doequipmentchange
EquipUse{} -> doequipmentchange EquipUse{} -> doequipmentchange
-- ConsumeUse will cause problems if the item is not selected -- ConsumeUse will cause problems if the item is not selected
@@ -66,9 +67,9 @@ tryReload cr it theinput f
cid = _crID cr cid = _crID cr
itNeedsLoading :: Item -> Bool itNeedsLoading :: Item -> Bool
itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic) itNeedsLoading it = fromMaybe False $ do
where internalammo <- it ^? itUse . heldConsumption . laSource . _InternalSource
ic = _heldConsumption (_itUse it) return $ _iaLoaded internalammo == 0 || not (_iaPrimed internalammo)
toggleEquipmentAt :: Int -> Creature -> World -> World toggleEquipmentAt :: Int -> Creature -> World -> World
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
@@ -119,10 +120,16 @@ useItemLeftClick cr w = fromMaybe w $ do
invid <- cr ^? crManipulation . manObject . inInventory . ispItem invid <- cr ^? crManipulation . manObject . inInventory . ispItem
ituse <- cr ^? crInv . ix invid . itUse ituse <- cr ^? crInv . ix invid . itUse
case ituse of case ituse of
HeldUse{} -> return $ hammerTest (cWorld . lWorld . creatures . ix (_crID cr) %~ crToggleReloading)
ConsumeUse{} -> return $ useItemRightClick cr w ConsumeUse{} -> return $ useItemRightClick cr w
EquipUse{} -> return $ useItemRightClick cr w EquipUse{} -> return $ useItemRightClick cr w
LeftUse{} -> return $ useItemRightClick cr w LeftUse{} -> return $ useItemRightClick cr w
_ -> Nothing _ -> Nothing
where
hammerTest f = case _crHammerPosition cr of
HammerUp -> f w
_ -> w & setuhamdown
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
useItemHotkey :: Int -> Int -> World -> World useItemHotkey :: Int -> Int -> World -> World
useItemHotkey crid invid w = fromMaybe w $ do useItemHotkey crid invid w = fromMaybe w $ do
+1 -1
View File
@@ -174,7 +174,7 @@ reloadOverride :: Creature -> Creature
reloadOverride cr = fromMaybe cr $ do reloadOverride cr = fromMaybe cr $ do
guard $ cr ^. crStance . posture == Aiming guard $ cr ^. crStance . posture == Aiming
itRef <- cr ^? crManipulation . manObject . inInventory . ispItem itRef <- cr ^? crManipulation . manObject . inInventory . ispItem
guard $ cr ^? crInv . ix itRef . itUse . heldConsumption . laLoaded == Just 0 guard $ cr ^? crInv . ix itRef . itUse . heldConsumption . laSource . _InternalSource . iaLoaded == Just 0
return $ cr & crActionPlan . apStrategy .~ StrategyActions Reload reloadActions return $ cr & crActionPlan . apStrategy .~ StrategyActions Reload reloadActions
where where
reloadActions = reloadActions =
+7 -2
View File
@@ -40,8 +40,13 @@ crIsReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAct
crWeaponReady :: Creature -> Bool crWeaponReady :: Creature -> Bool
crWeaponReady cr = fromMaybe False $ do crWeaponReady cr = fromMaybe False $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem i <- cr ^? crManipulation . manObject . inInventory . ispItem
ic <- cr ^? crInv . ix i . itUse . heldConsumption asource <- cr ^? crInv . ix i . itUse . heldConsumption . laSource
return (_laLoaded ic > 0 && _laPrimed ic) case asource of
InternalSource ia -> return (_iaLoaded ia > 0 && _iaPrimed ia)
ExternalSource ea -> do
srcid <- ea ^? _Just
x <- cr ^? crInv . ix srcid . itUse . equipEffect . eeUse . euseAmmoAmount
return (x > 0)
crCanSeeCr :: Creature -> (World, Creature) -> Bool crCanSeeCr :: Creature -> (World, Creature) -> Bool
crCanSeeCr tcr (w, cr) = hasLOS (_crPos cr) (_crPos tcr) w crCanSeeCr tcr (w, cr) = hasLOS (_crPos cr) (_crPos tcr) w
+1
View File
@@ -115,6 +115,7 @@ data EquipItemType
| JETPACK | JETPACK
| FUELPACK | FUELPACK
| BULLETBELTPACK
| BATTERYPACK | BATTERYPACK
| AUTODETECTOR Detector | AUTODETECTOR Detector
+8
View File
@@ -5,6 +5,7 @@
module Dodge.Data.Item.HeldUse where module Dodge.Data.Item.HeldUse where
import Dodge.Data.Item.Use.Consumption.Ammo
import Data.Aeson import Data.Aeson
import Data.Aeson.TH import Data.Aeson.TH
import Dodge.Data.CamouflageStatus import Dodge.Data.CamouflageStatus
@@ -44,6 +45,13 @@ data Euse
| EonWristShield | EonWristShield
| EoffWristShield | EoffWristShield
| EFuelSource {_euseFuelAmount :: Int, _euseFuelMax :: Int} | EFuelSource {_euseFuelAmount :: Int, _euseFuelMax :: Int}
| EBatterySource {_euseBatteryAmount :: Int, _euseBatteryMax :: Int}
| EAmmoSource
{ _euseAmmoAmount :: Int
, _euseAmmoMax :: Int
, _euseAmmoSourceType :: AmmoSourceType
, _euseAmmoLink :: Maybe Int
}
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Luse data Luse
+20 -7
View File
@@ -20,17 +20,26 @@ import Dodge.Data.Item.Use.Consumption.LoadAction
data HeldConsumption data HeldConsumption
= LoadableAmmo = LoadableAmmo
{ _laAmmoType :: AmmoType { _laAmmoType :: AmmoType
, _laMax :: Int , _laSource :: AmmoSource
, _laLoaded :: Int , _laSourceType :: AmmoSourceType
, _laPrimed :: Bool
, _laCycle :: [LoadAction]
, _laProgress :: Maybe [LoadAction]
} }
| ChargingAmmo { _caCharge :: Int
, _caMax :: Int }
| NoConsumption | NoConsumption
deriving (Eq, Show, Read) --Generic, Flat) deriving (Eq, Show, Read) --Generic, Flat)
data AmmoSource
= InternalSource InternalAmmo
| ExternalSource { _eaAttachment :: Maybe Int }
deriving (Eq, Show, Read) --Generic, Flat)
data InternalAmmo = InternalAmmo
{ _iaMax :: Int
, _iaLoaded :: Int
, _iaPrimed :: Bool
, _iaCycle :: [LoadAction]
, _iaProgress :: Maybe [LoadAction]
}
deriving (Eq, Show, Read) --Generic, Flat)
data LeftConsumption data LeftConsumption
= AutoRecharging = AutoRecharging
{ _arLoaded :: Int { _arLoaded :: Int
@@ -53,6 +62,10 @@ newtype ItAmount = ItAmount {_getItAmount :: Int}
makeLenses ''HeldConsumption makeLenses ''HeldConsumption
makeLenses ''LeftConsumption makeLenses ''LeftConsumption
makeLenses ''ItAmount makeLenses ''ItAmount
makePrisms ''AmmoSource
makeLenses ''InternalAmmo
deriveJSON defaultOptions ''InternalAmmo
deriveJSON defaultOptions ''AmmoSource
deriveJSON defaultOptions ''HeldConsumption deriveJSON defaultOptions ''HeldConsumption
deriveJSON defaultOptions ''LeftConsumption deriveJSON defaultOptions ''LeftConsumption
deriveJSON defaultOptions ''ItAmount deriveJSON defaultOptions ''ItAmount
@@ -34,6 +34,13 @@ data ProjectileUpdate
| PJRemoteShellCollisionCheck | PJRemoteShellCollisionCheck
deriving (Show, Eq, Ord, Read) --Generic, Flat) deriving (Show, Eq, Ord, Read) --Generic, Flat)
data AmmoSourceType
= BulletSource
| ChargeSource
| ChemfuelSource
| BombSource
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data AmmoType data AmmoType
= ProjectileAmmo = ProjectileAmmo
{ _amPayload :: Payload { _amPayload :: Payload
@@ -71,3 +78,4 @@ deriveJSON defaultOptions ''ProjectileUpdate
deriveJSON defaultOptions ''GasCreate deriveJSON defaultOptions ''GasCreate
deriveJSON defaultOptions ''ForceFieldType deriveJSON defaultOptions ''ForceFieldType
deriveJSON defaultOptions ''AmmoType deriveJSON defaultOptions ''AmmoType
deriveJSON defaultOptions ''AmmoSourceType
+12 -7
View File
@@ -1,18 +1,23 @@
module Dodge.Default.Item.Use.Consumption where module Dodge.Default.Item.Use.Consumption where
import Control.Lens
import Dodge.Data.Item.Use.Consumption
import Dodge.Item.Weapon.Bullet import Dodge.Item.Weapon.Bullet
import Dodge.Reloading.Action import Dodge.Reloading.Action
import Dodge.Data.Item.Use.Consumption
import Control.Lens
defaultLoadable :: HeldConsumption defaultLoadable :: HeldConsumption
defaultLoadable = defaultLoadable =
LoadableAmmo LoadableAmmo
{ _laAmmoType = GenericAmmo { _laAmmoType = GenericAmmo
, _laMax = 15 , _laSource =
, _laLoaded = 0 InternalSource InternalAmmo
, _laPrimed = True { _iaMax = 15
, _laCycle = [loadEject 10, loadInsert 10, loadPrime 10] , _iaLoaded = 0
, _laProgress = Nothing , _iaPrimed = True
, _iaCycle = [loadEject 10, loadInsert 10, loadPrime 10]
, _iaProgress = Nothing
}
, _laSourceType = BulletSource
} }
defaultBulletLoadable :: HeldConsumption defaultBulletLoadable :: HeldConsumption
+11 -3
View File
@@ -33,6 +33,14 @@ useE eo = case eo of
EoffWristShield -> onRemoveWristShield EoffWristShield -> onRemoveWristShield
EFuelSource 0 _ -> const . const id EFuelSource 0 _ -> const . const id
EFuelSource{} -> trySiphonFuel EFuelSource{} -> trySiphonFuel
EBatterySource{} -> tryChargeBattery
EAmmoSource{} -> tryAttachBulletBelt
tryAttachBulletBelt :: Item -> Creature -> World -> World
tryAttachBulletBelt _ _ w = w
tryChargeBattery :: Item -> Creature -> World -> World
tryChargeBattery _ _ w = w
trySiphonFuel :: Item -> Creature -> World -> World trySiphonFuel :: Item -> Creature -> World -> World
trySiphonFuel itm cr w = fromMaybe w $ do trySiphonFuel itm cr w = fromMaybe w $ do
@@ -42,12 +50,12 @@ trySiphonFuel itm cr w = fromMaybe w $ do
la <- cr ^? crInv . ix hix . itUse . heldConsumption la <- cr ^? crInv . ix hix . itUse . heldConsumption
atype <- la ^? laAmmoType atype <- la ^? laAmmoType
guard (isGas atype) guard (isGas atype)
amax <- la ^? laMax amax <- la ^? laSource . _InternalSource . iaMax
acur <- la ^? laLoaded acur <- la ^? laSource . _InternalSource . iaLoaded
guard (amax > acur) guard (amax > acur)
return $ return $
w & cWorld . lWorld . creatures . ix (_crID cr) . crInv w & cWorld . lWorld . creatures . ix (_crID cr) . crInv
%~ ( (ix hix . itUse . heldConsumption . laLoaded +~ 1) %~ ( (ix hix . itUse . heldConsumption . laSource . _InternalSource . iaLoaded +~ 1)
. (ix eix . itUse . equipEffect . eeUse . euseFuelAmount -~ 1) . (ix eix . itUse . equipEffect . eeUse . euseFuelAmount -~ 1)
) )
+3 -5
View File
@@ -118,7 +118,7 @@ useMod hm = case hm of
, ammoHammerCheck , ammoHammerCheck
] ]
AmmoCheckMod -> [ammoCheckI] AmmoCheckMod -> [ammoCheckI]
AmmoUseCheckMod -> [ammoUseCheck] AmmoUseCheckMod -> [useAmmoAmount 1,useTimeCheck, ammoCheckI]
AmmoHammerTimeUseOneMod -> AmmoHammerTimeUseOneMod ->
[ useAmmoAmount 1 [ useAmmoAmount 1
, useTimeCheck , useTimeCheck
@@ -465,13 +465,11 @@ fireRemoteShell it cr w =
caneStickSoundChoice :: Item -> SoundID caneStickSoundChoice :: Item -> SoundID
caneStickSoundChoice it caneStickSoundChoice it
| _laLoaded (_heldConsumption (_itUse it)) < 2 = tap3S | (it ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded) < 2 = tap3S
| otherwise = shotgunS | otherwise = shotgunS
bangStickSoundChoice :: Item -> SoundID bangStickSoundChoice :: Item -> SoundID
bangStickSoundChoice it bangStickSoundChoice = caneStickSoundChoice
| _laLoaded (_heldConsumption (_itUse it)) < 2 = tap3S
| otherwise = shotgunS
coneRandItemUpdate :: State StdGen (Item -> Item) coneRandItemUpdate :: State StdGen (Item -> Item)
coneRandItemUpdate = do coneRandItemUpdate = do
+2 -1
View File
@@ -3,6 +3,7 @@ module Dodge.Inventory.SelectionList (
closeObjectToSelectionItem, closeObjectToSelectionItem,
) where ) where
import Padding
import Dodge.Equipment.Text import Dodge.Equipment.Text
import Dodge.Data.SelectionList import Dodge.Data.SelectionList
import Dodge.Data.World import Dodge.Data.World
@@ -23,7 +24,7 @@ invSelectionItem cr i it =
} }
where where
anyhotkey = maybe [] ((' ':) .hotkeyToString) (cr ^? crInvHotkeys . ix i) anyhotkey = maybe [] ((' ':) .hotkeyToString) (cr ^? crInvHotkeys . ix i)
anyequippos = maybe [] ((' ':) . eqPosText) (cr ^? crInvEquipped . ix i) anyequippos = maybe [] (rightPad 8 ' ' . (' ':) . eqPosText) (cr ^? crInvEquipped . ix i)
col = _itInvColor it col = _itInvColor it
pics = take (itSlotsTaken it) . (++ replicate 10 "*") $ case _itCurseStatus it of pics = take (itSlotsTaken it) . (++ replicate 10 "*") $ case _itCurseStatus it of
UndroppableIdentified -> itemDisplay it UndroppableIdentified -> itemDisplay it
+1
View File
@@ -46,6 +46,7 @@ itemFromEquipType et = case et of
JETPACK -> jetPack JETPACK -> jetPack
BATTERYPACK -> batteryPack BATTERYPACK -> batteryPack
FUELPACK -> fuelPack FUELPACK -> fuelPack
BULLETBELTPACK -> bulletBeltPack
AUTODETECTOR d -> autoDetector d AUTODETECTOR d -> autoDetector d
itemFromLeftType :: LeftItemType -> Item itemFromLeftType :: LeftItemType -> Item
+19 -12
View File
@@ -53,7 +53,7 @@ selectedItemDisplay cr it = itemDisplayWithNumber (showSelectedConsumption cr (_
-- | Displays the item name, ammo if loaded, and any selected '_itCharMode'. -- | Displays the item name, ammo if loaded, and any selected '_itCharMode'.
showSelectedConsumption :: Creature -> ItemUse -> String showSelectedConsumption :: Creature -> ItemUse -> String
showSelectedConsumption cr iu = case iu of showSelectedConsumption cr iu = case iu of
HeldUse{} -> showReloadProgress cr (_heldConsumption iu) HeldUse{} -> showReloadProgress cr (iu ^?! heldConsumption . laSource)
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu) LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
EquipUse{} -> "" EquipUse{} -> ""
_ -> show $ iu ^?! useAmount . getItAmount -- partial, be careful if adding new data constructors _ -> show $ iu ^?! useAmount . getItAmount -- partial, be careful if adding new data constructors
@@ -65,12 +65,14 @@ showAutoRechargeProgress lc = case lc of
| otherwise -> show (_arLoaded lc) | otherwise -> show (_arLoaded lc)
ChargeableAmmo{} -> show (_wpCharge lc) ChargeableAmmo{} -> show (_wpCharge lc)
showReloadProgress :: Creature -> HeldConsumption -> String showReloadProgress :: Creature -> AmmoSource -> String
showReloadProgress cr ic = case cr ^? crManipulation . manObject . inInventory . iselAction of showReloadProgress cr ic = case cr ^? crManipulation . manObject . inInventory . iselAction of
Just (ReloadAction i la) -> show i ++ showLoadActionType la (_laLoaded ic) Just (ReloadAction i la) -> show i ++ showLoadActionType la ic
_ -> case ic ^? laProgress . _Just . ix 0 of _ -> case ic of
Nothing -> show $ _laLoaded ic InternalSource ia -> case ia ^? iaProgress . _Just . ix 0 of
Just la -> show (_actionTime la) ++ showLoadActionType la (_laLoaded ic) Nothing -> show $ ia ^. iaLoaded
Just la -> show (_actionTime la) ++ showLoadActionType la ic
_ -> "X"
showConsumption :: ItemUse -> String showConsumption :: ItemUse -> String
showConsumption iu = case iu of showConsumption iu = case iu of
@@ -85,16 +87,21 @@ showEUseNumber ee = case _eeUse ee of
_ -> "" _ -> ""
showReloadProgress' :: HeldConsumption -> String showReloadProgress' :: HeldConsumption -> String
showReloadProgress' ic = case ic ^? laProgress . _Just . ix 0 of showReloadProgress' ic = case ic ^? laSource . _InternalSource . iaProgress . _Just . ix 0 of
Nothing -> show $ _laLoaded ic Nothing -> fromMaybe "X" $ do
Just la -> show (_actionTime la) ++ showLoadActionType la (_laLoaded ic) x <- ic ^? laSource . _InternalSource . iaLoaded
return $ show x
Just la -> show (_actionTime la) ++ showLoadActionType la (_laSource ic)
showLoadActionType :: LoadAction -> Int -> String showLoadActionType :: LoadAction -> AmmoSource -> String
showLoadActionType la x = case la of showLoadActionType la as = case la of
LoadEject{} -> "E" LoadEject{} -> "E"
LoadInsert{} -> "L" LoadInsert{} -> "L"
LoadAdd{} -> "A" ++ show x LoadAdd{} -> "A" ++ x
LoadPrime{} -> "P" LoadPrime{} -> "P"
where
x = maybe "" show $ as ^? _InternalSource . iaLoaded
maybeWarmupStatus :: Item -> Maybe String maybeWarmupStatus :: Item -> Maybe String
maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of
+9 -6
View File
@@ -50,6 +50,8 @@ equipItemSPic et _ = case et of
BATTERYPACK -> noPic $ colorSH blue backpackShape BATTERYPACK -> noPic $ colorSH blue backpackShape
FUELPACK -> FUELPACK ->
noPic $ colorSH yellow $ upperPrismPolyMT 10 $ polyCirc 3 5 noPic $ colorSH yellow $ upperPrismPolyMT 10 $ polyCirc 3 5
BULLETBELTPACK ->
noPic $ colorSH green backpackShape
AUTODETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2) AUTODETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2)
backpackShape :: Shape backpackShape :: Shape
@@ -249,7 +251,7 @@ baseRifleShape = colorSH red $ xCylinderST 3 25
addBullets :: Item -> Shape addBullets :: Item -> Shape
addBullets itm = fromMaybe mempty $ do addBullets itm = fromMaybe mempty $ do
x <- itm ^? itUse . heldConsumption . laLoaded x <- itm ^? itUse . heldConsumption . laSource . _InternalSource . iaLoaded
hit <- itm ^? itType . iyBase . ibtHeld hit <- itm ^? itType . iyBase . ibtHeld
ps <- fmap (take x) $ ammoPosition itm hit ^? amPosDirs ps <- fmap (take x) $ ammoPosition itm hit ^? amPosDirs
return $ foldMap (uncurry (drawBullet itm)) ps return $ foldMap (uncurry (drawBullet itm)) ps
@@ -315,7 +317,7 @@ makeTinClip it =
bulletEffectColor bulletEffectColor
(it ^? itUse . heldConsumption . laAmmoType . amBullet . buEffect) (it ^? itUse . heldConsumption . laAmmoType . amBullet . buEffect)
y = fromIntegral y' * 0.3 y = fromIntegral y' * 0.3
y' = fromMaybe 0 $ it ^? itUse . heldConsumption . laLoaded y' = fromMaybe 0 $ it ^? itUse . heldConsumption . laSource . _InternalSource . iaLoaded
tips = fromMaybe mempty $ do tips = fromMaybe mempty $ do
ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn ebt <- it ^? itUse . heldConsumption . laAmmoType . amBullet . buSpawn
return $ return $
@@ -371,12 +373,13 @@ volleyGunShape i =
) )
miniGunXPictItem :: Int -> Item -> SPic miniGunXPictItem :: Int -> Item -> SPic
miniGunXPictItem i it = miniGunXPict i spin (_laLoaded $ _heldConsumption (_itUse it)) miniGunXPictItem i it = miniGunXPict i spin
where where
spin = (-10) * _laLoaded (_heldConsumption (_itUse it)) + _warmTime (_heldDelay $ _itUse it) spin = (-10) -- * _iaLoaded (_laSource (_heldConsumption (_itUse it)))
+ _warmTime (_heldDelay $ _itUse it)
miniGunXPict :: Int -> Int -> Int -> SPic miniGunXPict :: Int -> Int -> SPic
miniGunXPict i spin _ = miniGunXPict i spin =
( colorSH red (rotateSHx a barrels) ( colorSH red (rotateSHx a barrels)
<> baseRifleShape <> baseRifleShape
, -- <> clip (-1) 0 , -- <> clip (-1) 0
+10
View File
@@ -12,6 +12,7 @@ module Dodge.Item.Equipment (
jetPack, jetPack,
fuelPack, fuelPack,
batteryPack, batteryPack,
bulletBeltPack,
speedLegs, speedLegs,
jumpLegs, jumpLegs,
flameShield, flameShield,
@@ -59,6 +60,7 @@ batteryPack =
& itUse . equipEffect . eeSite .~ GoesOnBack & itUse . equipEffect . eeSite .~ GoesOnBack
& itType . iyBase .~ EQUIP BATTERYPACK & itType . iyBase .~ EQUIP BATTERYPACK
& itUse . equipEffect . eeAttachPos .~ V3 (-8) 0 10 & itUse . equipEffect . eeAttachPos .~ V3 (-8) 0 10
& itUse . equipEffect . eeUse .~ EBatterySource 10000 10000
fuelPack :: Item fuelPack :: Item
fuelPack = fuelPack =
@@ -68,6 +70,14 @@ fuelPack =
& itUse . equipEffect . eeAttachPos .~ V3 (-9) 0 10 & itUse . equipEffect . eeAttachPos .~ V3 (-9) 0 10
& itUse . equipEffect . eeUse .~ EFuelSource 10000 10000 & itUse . equipEffect . eeUse .~ EFuelSource 10000 10000
bulletBeltPack :: Item
bulletBeltPack =
defaultEquipment
& itUse . equipEffect . eeSite .~ GoesOnBack
& itType . iyBase .~ EQUIP BULLETBELTPACK
& itUse . equipEffect . eeAttachPos .~ V3 (-9) 0 10
& itUse . equipEffect . eeUse .~ EAmmoSource 10000 10000 BulletSource Nothing
jetPack :: Item jetPack :: Item
jetPack = jetPack =
defaultEquipment defaultEquipment
+7 -7
View File
@@ -20,8 +20,8 @@ sparkGun =
teslaGun :: Item teslaGun :: Item
teslaGun = teslaGun =
defaultBatteryGun defaultBatteryGun
& itUse . heldConsumption . laMax .~ 200 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 200
& itUse . heldConsumption . laCycle .~ [loadEject 10, loadInsert 10, loadPrime 60] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 10, loadInsert 10, loadPrime 60]
& itDimension . dimRad .~ 9 & itDimension . dimRad .~ 9
& itDimension . dimCenter .~ V3 4 0 0 & itDimension . dimCenter .~ V3 4 0 0
& itParams .~ teslaParams & itParams .~ teslaParams
@@ -39,8 +39,8 @@ lasGun =
defaultAutoBatteryGun defaultAutoBatteryGun
& itUse . heldConsumption & itUse . heldConsumption
.~ ( defaultLoadable .~ ( defaultLoadable
& laMax .~ 200 & laSource . _InternalSource . iaMax .~ 200
& laCycle .~ [loadEject 10, loadInsert 10, loadPrime 60] & laSource . _InternalSource . iaCycle .~ [loadEject 10, loadInsert 10, loadPrime 60]
) )
& itParams & itParams
.~ Refracting .~ Refracting
@@ -79,8 +79,8 @@ tractorGun =
lasGun lasGun
& itUse . heldConsumption & itUse . heldConsumption
.~ ( defaultLoadable .~ ( defaultLoadable
& laMax .~ 10000 & laSource . _InternalSource . iaMax .~ 10000
& laCycle .~ [loadEject 10, loadInsert 10, loadPrime 60] & laSource . _InternalSource . iaCycle .~ [loadEject 10, loadInsert 10, loadPrime 60]
) )
& itParams .~ Attracting{_attractionPower = 1} & itParams .~ Attracting{_attractionPower = 1}
& itTweaks & itTweaks
@@ -136,7 +136,7 @@ lasCircle =
& itType . iyBase .~ HELD LASCIRCLE & itType . iyBase .~ HELD LASCIRCLE
& itParams . lasColor .~ orange & itParams . lasColor .~ orange
& itParams . lasDamage .~ 2 & itParams . lasDamage .~ 2
& itUse . heldConsumption . laMax .~ 10000 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 10000
& itUse . heldUse .~ HeldLaser --shootLaser & itUse . heldUse .~ HeldLaser --shootLaser
& itUse . heldDelay .~ NoDelay & itUse . heldDelay .~ NoDelay
& itUse . heldUse .~ HeldCircleLaser --circleLaser & itUse . heldUse .~ HeldCircleLaser --circleLaser
+13 -12
View File
@@ -36,8 +36,8 @@ defaultBangCane =
& itUse . heldAim . aimStance .~ OneHand & itUse . heldAim . aimStance .~ OneHand
& itUse . heldAim . aimHandlePos .~ 5 & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 15 & itUse . heldAim . aimMuzPos .~ 15
& itUse . heldConsumption . laMax .~ 1 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 1
& itUse . heldConsumption . laCycle .~ [loadPartialInsert 10 1] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadPartialInsert 10 1]
volleyGun :: Int -> Item volleyGun :: Int -> Item
volleyGun i = volleyGun i =
@@ -50,7 +50,7 @@ volleyGun i =
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimHandlePos .~ 5 & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 15 & itUse . heldAim . aimMuzPos .~ 15
& itUse . heldConsumption . laMax .~ i & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
& itParams & itParams
.~ BulletShooter .~ BulletShooter
{ _muzVel = 0.8 { _muzVel = 0.8
@@ -78,8 +78,8 @@ rifle =
defaultBangCane defaultBangCane
& itUse . heldAim . aimStance .~ TwoHandTwist & itUse . heldAim . aimStance .~ TwoHandTwist
& itType . iyBase .~ HELD RIFLE & itType . iyBase .~ HELD RIFLE
& itUse . heldConsumption . laMax .~ 1 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 1
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 5, loadPrime 5] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 5, loadPrime 5]
& itUse . heldAim . aimWeight .~ 6 & itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1 & itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
@@ -90,8 +90,8 @@ repeater =
rifle rifle
& itType . iyModules . at ModRifleMag ?~ EMPTYMODULE & itType . iyModules . at ModRifleMag ?~ EMPTYMODULE
& itType . iyBase .~ HELD REPEATER & itType . iyBase .~ HELD REPEATER
& itUse . heldConsumption . laCycle .~ [loadEject 20, loadInsert 20, loadPrime 20] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 20, loadInsert 20, loadPrime 20]
& itUse . heldConsumption . laMax .~ 15 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 15
autoRifle :: Item autoRifle :: Item
autoRifle = autoRifle =
@@ -121,11 +121,12 @@ miniGunUse i =
& heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& heldAim . aimHandlePos .~ 5 & heldAim . aimHandlePos .~ 5
& heldConsumption & heldConsumption
.~ defaultBulletLoadable .~ (defaultBulletLoadable & laSource .~ ExternalSource Nothing)
{ _laMax = 1500 --(defaultBulletLoadable
, _laLoaded = 1500 -- & laSource . iaMax .~ 1500
} -- & laSource . iaLoaded .~ 1500
& heldConsumption . laCycle .~ [loadEject 40, loadInsert 40, loadPrime 40] --)
& heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 40, loadInsert 40, loadPrime 40]
miniGunX :: Int -> Item miniGunX :: Int -> Item
miniGunX i = miniGunX i =
+6 -6
View File
@@ -27,14 +27,14 @@ bangCone =
& itUse . heldAim . aimHandlePos .~ 5 & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 15 & itUse . heldAim . aimMuzPos .~ 15
& itType . iyBase .~ HELD BANGCONE & itType . iyBase .~ HELD BANGCONE
& itUse . heldConsumption . laMax .~ 5 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 5
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 20, loadPrime 5] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 20, loadPrime 5]
blunderbuss :: Item blunderbuss :: Item
blunderbuss = blunderbuss =
bangCone bangCone
& itUse . heldConsumption . laMax .~ 25 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 25
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 30, loadPrime 5] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 30, loadPrime 5]
& itUse . heldAim . aimStance .~ TwoHandTwist & itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimWeight .~ 6 & itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimHandlePos .~ 5 & itUse . heldAim . aimHandlePos .~ 5
@@ -45,8 +45,8 @@ grapeCannon :: Int -> Item
grapeCannon i = grapeCannon i =
blunderbuss blunderbuss
& itType . iyBase .~ HELD (GRAPECANNON i) & itType . iyBase .~ HELD (GRAPECANNON i)
& itUse . heldConsumption . laMax .~ 25 + 25 * i & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 25 + 25 * i
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert (30 + i * 10), loadPrime 5] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert (30 + i * 10), loadPrime 5]
& itParams . recoil .~ (150 + fromIntegral i * 50) & itParams . recoil .~ (150 + fromIntegral i * 50)
& itParams . torqueAfter .~ (0.1 + 0.2 * fromIntegral i) & itParams . torqueAfter .~ (0.1 + 0.2 * fromIntegral i)
& itParams . randomOffset .~ (12 + 4 * fromIntegral i) & itParams . randomOffset .~ (12 + 4 * fromIntegral i)
+5 -5
View File
@@ -38,9 +38,9 @@ launcher =
, _amPjDraw = DrawShell , _amPjDraw = DrawShell
, _amPjCreation = CreateShell , _amPjCreation = CreateShell
} }
& itUse . heldConsumption . laMax .~ 1 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 1
& itUse . heldConsumption . laLoaded .~ 1 & itUse . heldConsumption . laSource . _InternalSource . iaLoaded .~ 1
& itUse . heldConsumption . laCycle .~ [loadEject 30, loadInsert 30, loadPrime 10] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 30, loadInsert 30, loadPrime 10]
& itType . iyBase .~ HELD LAUNCHER & itType . iyBase .~ HELD LAUNCHER
& itType . iyModules . at ModLauncherHoming ?~ EMPTYMODULE & itType . iyModules . at ModLauncherHoming ?~ EMPTYMODULE
@@ -48,8 +48,8 @@ launcherX :: Int -> Item
launcherX i = launcherX i =
launcher launcher
& itType . iyBase .~ HELD (LAUNCHERX i) & itType . iyBase .~ HELD (LAUNCHERX i)
& itUse . heldConsumption . laMax .~ i & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
& itUse . heldConsumption . laLoaded .~ i & itUse . heldConsumption . laSource . _InternalSource . iaLoaded .~ i
& itUse . heldUse .~ HeldPJCreationX i & itUse . heldUse .~ HeldPJCreationX i
& itUse . heldMods .~ LauncherXMod i & itUse . heldMods .~ LauncherXMod i
+5 -5
View File
@@ -31,8 +31,8 @@ bangRod =
& itUse . heldMods .~ BangRodMod & itUse . heldMods .~ BangRodMod
& itDimension . dimRad .~ 12 & itDimension . dimRad .~ 12
& itDimension . dimCenter .~ V3 5 0 0 & itDimension . dimCenter .~ V3 5 0 0
& itUse . heldConsumption . laMax .~ 1 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 1
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 10, loadPrime 5] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 10, loadPrime 5]
& itType . iyBase .~ HELD BANGROD & itType . iyBase .~ HELD BANGROD
& itUse . heldAim . aimWeight .~ 8 & itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 1 & itUse . heldAim . aimRange .~ 1
@@ -56,7 +56,7 @@ amr :: Item
amr = amr =
elephantGun elephantGun
& itType . iyBase .~ HELD AMR & itType . iyBase .~ HELD AMR
& itUse . heldConsumption . laMax .~ 15 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 15
autoAmr :: Item autoAmr :: Item
autoAmr = autoAmr =
@@ -85,7 +85,7 @@ machineGun =
& itUse . heldAim . aimStance .~ TwoHandTwist & itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5} & itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldDelay .~ VariableRate{_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0} & itUse . heldDelay .~ VariableRate{_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
& itUse . heldConsumption . laMax .~ 100 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 100
& itUse . heldConsumption . laCycle .~ [loadEject 10, loadInsert 40, loadPrime 10] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 10, loadInsert 40, loadPrime 10]
& itInvSize .~ 3 & itInvSize .~ 3
& itParams . torqueAfter .~ 0.2 -- not sure if this is necessary? & itParams . torqueAfter .~ 0.2 -- not sure if this is necessary?
+4 -4
View File
@@ -28,8 +28,8 @@ flameSpitter :: Item
flameSpitter = flameSpitter =
flameThrower flameThrower
& itType . iyBase .~ HELD FLAMESPITTER & itType . iyBase .~ HELD FLAMESPITTER
& itUse . heldConsumption . laMax .~ 10 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 10
& itUse . heldConsumption . laCycle .~ [loadEject 5, loadInsert 10, loadPrime 20] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 10, loadPrime 20]
& itParams . sprayNozzles . ix 0 . nzPressure .~ 4 & itParams . sprayNozzles . ix 0 . nzPressure .~ 4
& itUse . heldAim . aimStance .~ OneHand & itUse . heldAim . aimStance .~ OneHand
& itUse . heldDelay .~ FixedRate{_rateMax = 12, _rateTime = 0} & itUse . heldDelay .~ FixedRate{_rateMax = 12, _rateTime = 0}
@@ -96,12 +96,12 @@ flameThrower =
& itUse . heldAim . aimMuzPos .~ 18 & itUse . heldAim . aimMuzPos .~ 18
& itUse . heldConsumption & itUse . heldConsumption
.~ ( defaultLoadable .~ ( defaultLoadable
& laMax .~ 250 & laSource . _InternalSource . iaMax .~ 250
& laAmmoType & laAmmoType
.~ GasAmmo .~ GasAmmo
{ _amString = "FLAME" { _amString = "FLAME"
, _amCreateGas = CreateFlame --aFlame , _amCreateGas = CreateFlame --aFlame
} }
& laCycle .~ [loadEject 5, loadInsert 10, loadPrime 20] & laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 10, loadPrime 20]
) )
& itType . iyBase .~ HELD FLAMETHROWER & itType . iyBase .~ HELD FLAMETHROWER
+7 -7
View File
@@ -40,8 +40,8 @@ bangStick i =
& itUse . heldMods .~ BangStickMod & itUse . heldMods .~ BangStickMod
& itUse . heldAim . aimHandlePos .~ 5 & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzPos .~ 10 & itUse . heldAim . aimMuzPos .~ 10
& itUse . heldConsumption . laMax .~ i & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i
& itUse . heldConsumption . laCycle .~ [loadPartialInsert 10 1] & itUse . heldConsumption . laSource . _InternalSource . iaCycle .~ [loadPartialInsert 10 1]
baseStickSpread :: Float baseStickSpread :: Float
baseStickSpread = 0.2 baseStickSpread = 0.2
@@ -51,8 +51,8 @@ revolver =
pistol pistol
& itUse . heldConsumption & itUse . heldConsumption
.~ ( defaultBulletLoadable .~ ( defaultBulletLoadable
& laMax .~ 6 & laSource . _InternalSource . iaMax .~ 6
& laCycle .~ [loadPartialInsert 10 1] & laSource . _InternalSource . iaCycle .~ [loadPartialInsert 10 1]
) )
& itType . iyBase .~ HELD REVOLVER & itType . iyBase .~ HELD REVOLVER
@@ -61,8 +61,8 @@ pistol =
bangStick 1 bangStick 1
& itUse . heldConsumption & itUse . heldConsumption
.~ ( defaultBulletLoadable .~ ( defaultBulletLoadable
& laMax .~ 15 & laSource . _InternalSource . iaMax .~ 15
& laCycle .~ [loadEject 5, loadInsert 5, loadPrime 5] & laSource . _InternalSource . iaCycle .~ [loadEject 5, loadInsert 5, loadPrime 5]
) )
& itUse . heldDelay . rateMax .~ 6 & itUse . heldDelay . rateMax .~ 6
& itUse . heldMods .~ PistolMod & itUse . heldMods .~ PistolMod
@@ -106,5 +106,5 @@ revolverX i =
revolver revolver
& itUse . heldDelay . rateMax .~ 8 & itUse . heldDelay . rateMax .~ 8
& itUse . heldMods .~ RevolverXMod & itUse . heldMods .~ RevolverXMod
& itUse . heldConsumption . laMax .~ i * 6 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ i * 6
& itType . iyBase .~ HELD (REVOLVERX i) & itType . iyBase .~ HELD (REVOLVERX i)
+1
View File
@@ -122,6 +122,7 @@ equipInfo eit = case eit of
JETPACK -> "A device enabling flight." JETPACK -> "A device enabling flight."
FUELPACK -> "A liquid container with attached hose." FUELPACK -> "A liquid container with attached hose."
BULLETBELTPACK -> "A container holding a long belt of bullets."
BATTERYPACK -> "A collection of batteries with a universal adapter." BATTERYPACK -> "A collection of batteries with a universal adapter."
AUTODETECTOR d -> "A device that detects "++detectorInfo d ++" in an expanding radius. Pulses automatically. " AUTODETECTOR d -> "A device that detects "++detectorInfo d ++" in an expanding radius. Pulses automatically. "
+1 -1
View File
@@ -17,7 +17,7 @@ droneLauncher =
& itUse . heldAim . aimRange .~ 0.5 & itUse . heldAim . aimRange .~ 0.5
& itUse . heldAim . aimStance .~ TwoHandTwist & itUse . heldAim . aimStance .~ TwoHandTwist
& itUse . heldConsumption . laAmmoType .~ DroneAmmo{_amString = "LASDRONE"} & itUse . heldConsumption . laAmmoType .~ DroneAmmo{_amString = "LASDRONE"}
& itUse . heldConsumption . laMax .~ 2 & itUse . heldConsumption . laSource . _InternalSource . iaMax .~ 2
& itType . iyBase .~ HELD DRONELAUNCHER & itType . iyBase .~ HELD DRONELAUNCHER
lasDronesPic :: Item -> SPic lasDronesPic :: Item -> SPic
+14 -10
View File
@@ -1,22 +1,26 @@
module Dodge.Item.Weapon.FractionLoaded module Dodge.Item.Weapon.FractionLoaded (
( fractionLoadedAmmo fractionLoadedAmmo,
, fractionLoadedAmmo2 fractionLoadedAmmo2,
) where ) where
import Control.Lens
import Data.Maybe
import Dodge.Data.Item import Dodge.Data.Item
---- this shouldn't really be used ---- this shouldn't really be used
loadedAmmo :: Item -> Int loadedAmmo :: Item -> Int
loadedAmmo = _laLoaded . _heldConsumption . _itUse loadedAmmo itm = fromMaybe 0 $ itm ^? itUse . heldConsumption . laSource . _InternalSource . iaLoaded
-- | _laTransfer (_itConsumption it) == NoTransfer = _laLoaded (_itConsumption it) -- | _laTransfer (_itConsumption it) == NoTransfer = _laLoaded (_itConsumption it)
-- | otherwise = 0 -- | otherwise = 0
fractionLoadedAmmo :: Item -> Float fractionLoadedAmmo :: Item -> Float
fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral (itmaxammo it) fractionLoadedAmmo it = fromIntegral (loadedAmmo it) / fromIntegral itmaxammo
where where
itmaxammo = _laMax . _heldConsumption . _itUse itmaxammo = fromMaybe 1 $ it ^? itUse . heldConsumption . laSource . _InternalSource . iaMax
fractionLoadedAmmo2 :: Item -> Float fractionLoadedAmmo2 :: Item -> Float
fractionLoadedAmmo2 it = 1 - fractionLoadedAmmo2 it =
(1 - fromIntegral (loadedAmmo it) / fromIntegral (itMaxAmmo it))**2 1 - (1 - fromIntegral (loadedAmmo it) / fromIntegral itmaxammo) ** 2
where where
itMaxAmmo = _laMax . _heldConsumption . _itUse itmaxammo = fromMaybe 1 $ it ^? itUse . heldConsumption . laSource . _InternalSource . iaMax
+23 -42
View File
@@ -19,7 +19,6 @@ module Dodge.Item.Weapon.TriggerType (
withItem, withItem,
withItemUpdate, withItemUpdate,
withItemUpdate', withItemUpdate',
ammoUseCheck,
rateIncAB, rateIncAB,
torqueBefore, torqueBefore,
torqueBeforeAtLeast, torqueBeforeAtLeast,
@@ -136,28 +135,33 @@ withThickSmokeI eff item cr w =
-- TODO create a trigger that does different things on first and continued -- TODO create a trigger that does different things on first and continued
-- fire. -- fire.
ammoCheckI :: ChainEffect ammoCheckI :: ChainEffect
ammoCheckI eff itm cr w ammoCheckI eff itm cr w = case itm ^? itUse . heldConsumption . laSource of
| _laLoaded ic <= 0 || not (_laPrimed ic) = w Just (InternalSource ia) | _iaLoaded ia <= 0 || not (_iaPrimed ia)
| otherwise = eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading -> w
where Just (ExternalSource ea) | fromMaybe True $ do
ic = _heldConsumption $ _itUse itm invid <- ea ^? _Just
x <- cr ^? crInv . ix invid . itUse . equipEffect . eeUse . euseAmmoAmount
return $ x <= 0
-> w
_ -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
-- combined ammo and hammer check: want to be able to auto-reload even if the -- combined ammo and hammer check: want to be able to auto-reload even if the
-- hammer is down? -- hammer is down?
ammoHammerCheck :: ChainEffect ammoHammerCheck :: ChainEffect
ammoHammerCheck eff it cr w ammoHammerCheck eff itm cr w
| _laLoaded ic <= 0 || not (_laPrimed ic) = w -- fromMaybe w (startReloadingWeapon cr w) | _iaLoaded ic <= 0 || not (_iaPrimed ic) = w
| otherwise = case it ^? itUse . heldHammer of -- fromMaybe w (startReloadingWeapon cr w)
Just HammerUp -> eff it cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading | otherwise = case itm ^? itUse . heldHammer of
Just HammerUp -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
_ -> w _ -> w
where where
ic = _heldConsumption $ _itUse it ic = itm ^?! itUse . heldConsumption . laSource . _InternalSource
itUseCharge :: Int -> Item -> Item itUseCharge :: Int -> Item -> Item
itUseCharge x = itUse . leftConsumption . arLoaded %~ (max 0 . subtract x) itUseCharge x = itUse . leftConsumption . arLoaded %~ (max 0 . subtract x)
itUseAmmo :: Int -> Item -> Item itUseAmmo :: Int -> Item -> Item
itUseAmmo x = itUse . heldConsumption . laLoaded %~ (max 0 . subtract x) itUseAmmo x = itUse . heldConsumption . laSource . _InternalSource . iaLoaded %~ (max 0 . subtract x)
{- | Fires at an increasing rate. {- | Fires at an increasing rate.
Has different effect after first fire. Has different effect after first fire.
@@ -341,14 +345,14 @@ withSidePushAfterI maxSide eff item cr w =
useAllAmmo :: ChainEffect useAllAmmo :: ChainEffect
useAllAmmo eff item cr = useAllAmmo eff item cr =
eff item cr eff item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded .~ 0) . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laSource . _InternalSource . iaLoaded .~ 0)
where where
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
useAmmoUpTo :: Int -> ChainEffect useAmmoUpTo :: Int -> ChainEffect
useAmmoUpTo amAmount eff item cr = useAmmoUpTo amAmount eff item cr =
eff item cr eff item cr
. ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded . ( cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laSource . _InternalSource . iaLoaded
%~ (max 0 . subtract amAmount) %~ (max 0 . subtract amAmount)
) )
where where
@@ -357,7 +361,7 @@ useAmmoUpTo amAmount eff item cr =
useAmmoAmount :: Int -> ChainEffect useAmmoAmount :: Int -> ChainEffect
useAmmoAmount amAmount eff item cr = useAmmoAmount amAmount eff item cr =
eff item cr eff item cr
. (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laLoaded -~ amAmount) . (cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix itRef . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ amAmount)
where where
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
@@ -378,33 +382,10 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
hammerCheckI :: ChainEffect hammerCheckI :: ChainEffect
hammerCheckI f it cr w = case it ^? itUse . heldHammer of hammerCheckI f it cr w = case it ^? itUse . heldHammer of
Just HammerUp Just HammerUp
| _laPrimed (_heldConsumption (_itUse it)) -> | it ^?! itUse . heldConsumption . laSource . _InternalSource . iaPrimed ->
f it cr w f it cr w
_ -> w _ -> w
-- | Applies a world effect after an ammo check.
-- this should be made "safe" incase there is no _rateTime
ammoUseCheck :: ChainEffect
ammoUseCheck f item cr w
| fireCondition =
f item cr w & pointerToItem
%~ ( itUseAmmo 1
. (itUse . heldDelay . rateTime .~ _rateMax (_heldDelay (_itUse item)))
)
-- | reloadCondition = fromMaybe w $ startReloadingWeapon cr w
| otherwise = w
where
cid = _crID cr
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
pointerToItem = cWorld . lWorld . creatures . ix cid . crInv . ix itRef
fireCondition =
crWeaponReady cr
&& _rateTime (_heldDelay (_itUse item)) == 0
&& _laLoaded (_heldConsumption (_itUse item)) > 0
-- reloadCondition = _laLoaded (_itConsumption item) == 0
{- | Applies a world effect after a hammer position check. {- | Applies a world effect after a hammer position check.
Arbitrary inventory position. Arbitrary inventory position.
-} -}
@@ -649,7 +630,7 @@ spreadLoaded eff item cr w = foldr f w dirs
dirs = subtract cd . (spread *) . fromIntegral <$> [0 .. numBulLoaded - 1] dirs = subtract cd . (spread *) . fromIntegral <$> [0 .. numBulLoaded - 1]
f dir = eff item (cr & crDir +~ dir) f dir = eff item (cr & crDir +~ dir)
spread = _spreadAngle . _brlSpread . _gunBarrels $ _itParams item spread = _spreadAngle . _brlSpread . _gunBarrels $ _itParams item
numBulLoaded = _laLoaded $ _heldConsumption (_itUse item) numBulLoaded = item ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
sideEffectOnFrame :: sideEffectOnFrame ::
Int -> Int ->
@@ -684,7 +665,7 @@ duplicateLoaded :: ChainEffect
duplicateLoaded eff it cr w = foldr f w [1 .. numBul] duplicateLoaded eff it cr w = foldr f w [1 .. numBul]
where where
f _ = eff it cr f _ = eff it cr
numBul = _laLoaded $ _heldConsumption (_itUse it) numBul = it ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
duplicateLoadedBarrels :: ChainEffect duplicateLoadedBarrels :: ChainEffect
duplicateLoadedBarrels eff item cr w = foldr f w poss duplicateLoadedBarrels eff item cr w = foldr f w poss
@@ -695,7 +676,7 @@ duplicateLoadedBarrels eff item cr w = foldr f w poss
poss = map (rotateV (_crDir cr) . V2 0 . (* 5) . (+ cp) . fromIntegral) [0 .. numBul - 1] poss = map (rotateV (_crDir cr) . V2 0 . (* 5) . (+ cp) . fromIntegral) [0 .. numBul - 1]
f pos = eff item (cr & crPos %~ (+.+ pos)) f pos = eff item (cr & crPos %~ (+.+ pos))
numBar = _brlNum . _gunBarrels $ _itParams item numBar = _brlNum . _gunBarrels $ _itParams item
numBul = _laLoaded $ _heldConsumption (_itUse item) numBul = item ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded
duplicateOffsetsFocus :: [Float] -> ChainEffect duplicateOffsetsFocus :: [Float] -> ChainEffect
duplicateOffsetsFocus xs eff item cr w = foldr f w poss duplicateOffsetsFocus xs eff item cr w = foldr f w poss
+20 -20
View File
@@ -18,7 +18,7 @@ crCancelReloading cr =
where where
updateProgress = fromMaybe id $ do updateProgress = fromMaybe id $ do
InInventory (SelItem i _) <- cr ^? crManipulation . manObject InInventory (SelItem i _) <- cr ^? crManipulation . manObject
return $ crInv . ix i . itUse . heldConsumption . laProgress %~ const Nothing return $ crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress %~ const Nothing
stepReloading :: Creature -> Creature stepReloading :: Creature -> Creature
stepReloading cr = case cr ^? crManipulation . manObject . inInventory of stepReloading cr = case cr ^? crManipulation . manObject . inInventory of
@@ -27,14 +27,14 @@ stepReloading cr = case cr ^? crManipulation . manObject . inInventory of
cr & crManipulation . manObject . inInventory . iselAction . actionProgress -~ 1 cr & crManipulation . manObject . inInventory . iselAction . actionProgress -~ 1
| otherwise -> | otherwise ->
cr cr
& crInv . ix i . itUse . heldConsumption %~ doLoadAction la & crInv . ix i . itUse . heldConsumption . laSource . _InternalSource %~ doLoadAction la
& crInv . ix i . itUse . heldConsumption %~ rotateActionProgress & crInv . ix i . itUse . heldConsumption . laSource . _InternalSource %~ rotateActionProgress
& tryNextLoadAction & tryNextLoadAction
_ -> cr _ -> cr
tryNextLoadAction :: Creature -> Creature tryNextLoadAction :: Creature -> Creature
tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of tryNextLoadAction cr = case cr ^? crManipulation . manObject . inInventory of
Just (SelItem i _) -> case cr ^? crInv . ix i . itUse . heldConsumption . laProgress . _Just . ix 0 of Just (SelItem i _) -> case cr ^? crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress . _Just . ix 0 of
Nothing -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction Nothing -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
Just la -> Just la ->
cr & crManipulation . manObject . inInventory . iselAction . actionProgress .~ _actionTime la cr & crManipulation . manObject . inInventory . iselAction . actionProgress .~ _actionTime la
@@ -49,37 +49,37 @@ crToggleReloading cr = case cr ^? crManipulation . manObject . inInventory . ise
tryStartLoading :: Creature -> Creature tryStartLoading :: Creature -> Creature
tryStartLoading cr = fromMaybe cr $ do tryStartLoading cr = fromMaybe cr $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem i <- cr ^? crManipulation . manObject . inInventory . ispItem
hc <- cr ^? crInv . ix i . itUse . heldConsumption hc <- cr ^? crInv . ix i . itUse . heldConsumption . laSource . _InternalSource
return $ startLoading hc cr return $ startLoading hc cr
startLoading :: HeldConsumption -> Creature -> Creature startLoading :: InternalAmmo -> Creature -> Creature
startLoading ic cr = case ic ^? laProgress . _Just . ix 0 of startLoading ic cr = case ic ^? iaProgress . _Just . ix 0 of
Just la -> cr & startLoadingStep la Just la -> cr & startLoadingStep la
Nothing -> case ic ^? laCycle of Nothing -> case ic ^? iaCycle of
Nothing -> cr Nothing -> cr
Just [] -> error "item has empty load cycle" Just [] -> error "item has empty load cycle"
Just _ | _laLoaded ic >= _laMax ic -> cr Just _ | _iaLoaded ic >= _iaMax ic -> cr
Just (la : las) -> fromMaybe (error "item loading error") $ do Just (la : las) -> fromMaybe (error "item loading error") $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem i <- cr ^? crManipulation . manObject . inInventory . ispItem
return $ cr & startLoadingStep la return $ cr & startLoadingStep la
& crInv . ix i . itUse . heldConsumption . laProgress ?~ (la : las) & crInv . ix i . itUse . heldConsumption . laSource . _InternalSource . iaProgress ?~ (la : las)
startLoadingStep :: LoadAction -> Creature -> Creature startLoadingStep :: LoadAction -> Creature -> Creature
startLoadingStep la cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la startLoadingStep la cr = cr & crManipulation . manObject . inInventory . iselAction .~ ReloadAction (_actionTime la) la
rotateActionProgress :: HeldConsumption -> HeldConsumption rotateActionProgress :: InternalAmmo -> InternalAmmo
rotateActionProgress ic = case ic ^? laProgress . _Just of rotateActionProgress ic = case ic ^? iaProgress . _Just of
Just (_ : la : las) -> ic & laProgress . _Just .~ (la : las) Just (_ : la : las) -> ic & iaProgress . _Just .~ (la : las)
_ | _laLoaded ic < _laMax ic -> ic & laProgress ?~ _laCycle ic _ | _iaLoaded ic < _iaMax ic -> ic & iaProgress ?~ _iaCycle ic
_ -> ic & laProgress .~ Nothing _ -> ic & iaProgress .~ Nothing
doLoadAction :: LoadAction -> HeldConsumption -> HeldConsumption doLoadAction :: LoadAction -> InternalAmmo -> InternalAmmo
doLoadAction la ic = case la of doLoadAction la ic = case la of
LoadEject{} -> ic & laLoaded .~ 0 & laPrimed .~ False LoadEject{} -> ic & iaLoaded .~ 0 & iaPrimed .~ False
LoadInsert{} -> ic & laLoaded .~ _laMax ic LoadInsert{} -> ic & iaLoaded .~ _iaMax ic
LoadAdd{_insertMax = x} -> LoadAdd{_insertMax = x} ->
ic & laLoaded +~ min x (_laMax ic - _laLoaded ic) ic & iaLoaded +~ min x (_iaMax ic - _iaLoaded ic)
LoadPrime{} -> ic & laPrimed .~ True LoadPrime{} -> ic & iaPrimed .~ True
--{- | Start reloading if clip is empty. -} --{- | Start reloading if clip is empty. -}
--crAutoReload :: Creature -> Creature --crAutoReload :: Creature -> Creature
-3
View File
@@ -172,12 +172,9 @@ drawRBOptions cfig w = fromMaybe mempty $ do
examineInventoryExtra :: Maybe Int -> Configuration -> Picture examineInventoryExtra :: Maybe Int -> Configuration -> Picture
examineInventoryExtra mtweaki cfig = fromMaybe mempty $ do examineInventoryExtra mtweaki cfig = fromMaybe mempty $ do
tweaki <- mtweaki tweaki <- mtweaki
-- consider moving this functionality out into a tweaks module
--tparam <- mitm ^? _Just . itTweaks . tweakParams . ix tweaki
return $ return $
toTopLeft cfig $ toTopLeft cfig $
translate subInvX (-71) $ translate subInvX (-71) $
--listCursorChooseBorderScale 0 1 [North,South,West] tweaki 0 white (length $ showTweak tparam) 1
listCursorChooseBorderScale 0 1 [North, South, West] tweaki 0 white 10 1 listCursorChooseBorderScale 0 1 [North, South, West] tweaki 0 white 10 1
combineInventoryExtra :: SelectionSections CombinableItem -> Configuration -> World -> Picture combineInventoryExtra :: SelectionSections CombinableItem -> Configuration -> World -> Picture
+14 -23
View File
@@ -19,7 +19,7 @@ import SDL
updateUseInputOnScreen :: ScreenLayer -> Universe -> Universe updateUseInputOnScreen :: ScreenLayer -> Universe -> Universe
updateUseInputOnScreen sl = case sl of updateUseInputOnScreen sl = case sl of
InputScreen{} -> doInputScreenInput (sl ^. scInput) InputScreen{} -> doInputScreenInput (sl ^. scInput)
_ -> optionScreenUpdate sl _ -> optionScreenUpdate
doInputScreenInput :: String -> Universe -> Universe doInputScreenInput :: String -> Universe -> Universe
doInputScreenInput s u = doInputScreenInput s u =
@@ -35,37 +35,28 @@ doInputScreenInput s u =
| ispressed ScancodeEscape = uvScreenLayers %~ tail | ispressed ScancodeEscape = uvScreenLayers %~ tail
| otherwise = id | otherwise = id
optionScreenUpdate :: optionScreenUpdate :: Universe -> Universe
ScreenLayer -> optionScreenUpdate u =
Universe ->
Universe
optionScreenUpdate screen u =
(uvScreenLayers . ix 0 . scDisplayTime +~ 1) (uvScreenLayers . ix 0 . scDisplayTime +~ 1)
. refreshOptionsSelectionList . refreshOptionsSelectionList
. mouseOverSelectionList . mouseOverSelectionList
. optionScreenDefaultEffect mop . optionScreenDefaultEffect
. mouseClickOptionsList screen . mouseClickOptionsList
. menuWheelEvents . menuWheelEvents
. over (uvScreenLayers . _head) (setSelectionListRestriction (u ^. uvConfig)) . over (uvScreenLayers . _head) (setSelectionListRestriction (u ^. uvConfig))
$ u $ u
where
mop = _scPositionedMenuOption screen
optionScreenDefaultEffect :: EscapeMenuOption -> Universe -> Universe optionScreenDefaultEffect :: Universe -> Universe
optionScreenDefaultEffect f u = optionScreenDefaultEffect u = fromMaybe u $ do
fromMaybe f <- u ^? uvScreenLayers . ix 0 . scPositionedMenuOption
id ptype <- u ^. uvWorld . input . pressedKeys . at ScancodeEscape
( do guard $ ptype == InitialPress
ptype <- u ^. uvWorld . input . pressedKeys . at ScancodeEscape (f ^? emoMenuOption . moEff) <*> return u
guard $ ptype == InitialPress
f ^? emoMenuOption . moEff
)
u
-- ouch this is not good -- ouch this is not good
mouseClickOptionsList :: ScreenLayer -> Universe -> Universe mouseClickOptionsList :: Universe -> Universe
mouseClickOptionsList screen u = fromMaybe u $ do mouseClickOptionsList u = fromMaybe u $ do
sl <- screen ^? scSelectionList sl <- u ^? uvScreenLayers . ix 0 . scSelectionList
Just $ case u ^. uvWorld . input . mouseButtons . at ButtonLeft of Just $ case u ^. uvWorld . input . mouseButtons . at ButtonLeft of
Just 0 -> fromMaybe u $ do Just 0 -> fromMaybe u $ do
i <- sl ^. slSelPos i <- sl ^. slSelPos