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