Compare commits

...

10 Commits

42 changed files with 494 additions and 375 deletions
+5 -4
View File
@@ -4,6 +4,7 @@ module Dodge.Combine (
combineList',
) where
import Dodge.Item.SlotsTaken
import Dodge.Data.Universe
import Dodge.Data.Combine
import Dodge.Item.Display
@@ -46,19 +47,19 @@ combineItemListYouX = map (first $ concatMap g) . lookupItems . yourInv
combineList :: World -> [SelectionItem CombinableItem]
combineList w = case combineList' w of
[] -> [SelectionInfo ["No possible combinations"] 1 False white 0]
[] -> [SelectionInfo ["No possible combinations"] 1 False white 0 0]
xs -> xs
combineList' :: World -> [SelectionItem CombinableItem]
combineList' = map f . combineListInfo
where
f (is,(strs,itm)) = SelectionItem
{ _siPictures = itemDisplay itm
, _siHeight = length (itemDisplay itm)
{ _siPictures = basicItemDisplay itm
, _siHeight = itSlotsTaken itm
, _siIsSelectable = True
--, _siWidth = maximum (map length (itemDisplay itm))
, _siColor = _itInvColor itm
, _siOffX = 0
, _siOffY = 0
, _siPayload = CombinableItem is itm strs
}
+3 -3
View File
@@ -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 =
+2
View File
@@ -262,4 +262,6 @@ stackedInventory =
, flameThrower
, poisonSprayer
, launcher
, bulletBeltPack
, bulletBeltBracer
]
+11 -27
View File
@@ -10,18 +10,15 @@ import Dodge.Hotkey
import Control.Lens
import Control.Monad
import Data.Foldable
import qualified Data.Map.Strict as M
import Data.Maybe
import Dodge.Cuse
import Dodge.Data.World
import Dodge.Euse
import Dodge.HeldUse
import Dodge.Inventory
import Dodge.Item.Location
import Dodge.Luse
import Dodge.Reloading
import qualified IntMapHelp as IM
import qualified SDL
useItemRightClick :: Creature -> World -> World
useItemRightClick cr' w = fromMaybe (f w) $ do
@@ -37,38 +34,19 @@ 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
foldl' (&) (useHeld eff) (useMod usemods) it cr w
LeftUse{} -> doequipmentchange
EquipUse{} -> doequipmentchange
-- ConsumeUse will cause problems if the item is not selected
(ConsumeUse eff _) -> setuhamdown $ hammerTest $ useC eff it cr . rmInvItem (_crID cr) itRef
CraftUse{} -> setuhamdown w
(ConsumeUse eff _) -> useC eff it cr $ rmInvItem (_crID cr) itRef w
CraftUse{} -> w
where
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
hammerTest f = case _crHammerPosition cr of
HammerUp -> f w
HammerUp -> f w & setuhamdown
_ -> w & setuhamdown
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
doequipmentchange =
setuhamdown $
hammerTest
( toggleEquipmentAt itRef cr
)
tryReload :: Creature -> Item -> Input -> (World -> World) -> World -> World
tryReload cr it theinput f
| cid == 0 && itNeedsLoading it && _mouseButtons theinput M.!? SDL.ButtonLeft == Just 0 =
cWorld . lWorld . creatures . ix cid %~ crToggleReloading
| otherwise =
(runIdentity . pointerToItemLocation (_itLocation it) (return . (itUse . heldHammer .~ HammerDown)))
. f
where
cid = _crID cr
itNeedsLoading :: Item -> Bool
itNeedsLoading it = _laLoaded ic == 0 || not (_laPrimed ic)
where
ic = _heldConsumption (_itUse it)
doequipmentchange = hammerTest $ toggleEquipmentAt itRef cr
toggleEquipmentAt :: Int -> Creature -> World -> World
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
@@ -119,10 +97,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) %~ crUpdateLoadSource)
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 & setuhamdown
_ -> w & setuhamdown
setuhamdown = cWorld . lWorld . creatures . ix (_crID cr) . crHammerPosition .~ HammerDown
useItemHotkey :: Int -> Int -> World -> World
useItemHotkey crid invid w = fromMaybe w $ do
+1 -1
View File
@@ -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 =
+6 -2
View File
@@ -40,8 +40,12 @@ 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)
AboveSource -> do
x <- cr ^? crInv . ix (i - 1) . itUse . equipEffect . eeUse . euseAmmoAmount
return (x > 0)
crCanSeeCr :: Creature -> (World, Creature) -> Bool
crCanSeeCr tcr (w, cr) = hasLOS (_crPos cr) (_crPos tcr) w
+2
View File
@@ -115,6 +115,8 @@ data EquipItemType
| JETPACK
| FUELPACK
| BULLETBELTPACK
| BULLETBELTBRACER
| BATTERYPACK
| AUTODETECTOR Detector
+8
View File
@@ -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 -7
View File
@@ -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
| AboveSource
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
@@ -42,6 +42,7 @@ data InventoryManipulation
data InvSelAction
= NoInvSelAction
| AttachLoadSourceAction {_actionProgress :: Int}
| ReloadAction {_actionProgress :: Int, _reloadAction :: LoadAction}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
+2
View File
@@ -78,6 +78,7 @@ data SelectionItem a
, _siIsSelectable :: Bool
, _siColor :: Color
, _siOffX :: Int
, _siOffY :: Int
, _siPayload :: a
}
| SelectionInfo
@@ -86,6 +87,7 @@ data SelectionItem a
, _siIsSelectable :: Bool
, _siColor :: Color
, _siOffX :: Int
, _siOffY :: Int
}
makeLenses ''ListDisplayParams
+12 -7
View File
@@ -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
+26 -13
View File
@@ -1,4 +1,4 @@
{-# LANGUAGE TupleSections #-}
--{-# LANGUAGE TupleSections #-}
--{-# OPTIONS_GHC -fno-full-laziness #-}
@@ -53,14 +53,14 @@ updateCombineSections w cfig sss =
invitms <- w ^? hud . hudElement . diSections . sssSections . ix 0 . ssItems
return $ IM.filter (flip (andOrRegex $ regexCombs invitms) str) allcombs
showncombs
| null filtcombs = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
| null filtcombs = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0 0
| otherwise = filtcombs
filtinv = fromMaybe mempty $ do
str <- mstr
return $
IM.singleton
0
(SelectionInfo ["COMBINATIONS FILTER: " ++ str, numfiltitems] 2 True white 0)
(SelectionInfo ["COMBINATIONS FILTER: " ++ str, numfiltitems] 2 True white 0 0)
mstr = w ^? hud . hudElement . subInventory . ciSections . sssExtra . sssFilters . ix (-1) . _Just
numfiltitems = " " ++ show (length allcombs - length filtcombs) ++ " FILTERED"
@@ -105,7 +105,7 @@ updateDisplaySections w cfig sss =
(filtinv, invx) = filtpair (-1) invitems' "INV. "
(filtclose, closex) = filtpair 2 coitems' "NEARBY "
youx = (1, youitems)
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 ()
youitems = IM.singleton 0 $ SelectionItem [thetext] 1 True invDimColor 2 0 ()
thetext = displayFreeSlots nfreeslots
availablelines = getAvailableListLines (invDisplayParams w) cfig
coitems' =
@@ -126,7 +126,7 @@ updateDisplaySections w cfig sss =
return $
IM.singleton
0
(SelectionInfo [filtdescription ++ "FILTER: " ++ str, numfiltitems] 2 True white 0)
(SelectionInfo [filtdescription ++ "FILTER: " ++ str, numfiltitems] 2 True white 0 0)
itms' = fromMaybe itms $ do
str <- mstr
return $ IM.filter (plainRegex str) itms
@@ -195,7 +195,7 @@ updateSection sis mcsel availablelines ss =
scurs = do
csel <- mcsel
(_, si) <- IM.lookupGE csel sis -- this is not right?
let cpos = sum (fmap (length . _siPictures) . fst . IM.split csel $ sis)
let cpos = sum (fmap _siHeight . fst . IM.split csel $ sis)
csize = length $ _siPictures si
ccolor = _siColor si
return $ SectionCursor (cpos - offset) csize ccolor
@@ -240,13 +240,26 @@ updateSection sis mcsel availablelines ss =
++ [translate 0 100 . color moredowncolor . textVMirror $ theindent ++ replicate 15 '^']
| otherwise = tweakfirst shownstrings
moredowncolor = fromMaybe white $ allstrings ^? ix (offset + availablelines - 1) . _1
allstrings :: [(Color, String)]
allstrings = foldMap g sis
allstrings :: [(Color, Picture)]
allstrings = IM.elems $ overlapSelectionItems $ IM.elems sis
shownstrings = drop offset allstrings
h (col, str) = color col . text $ theindent ++ str
h (_, str) = translate (fromIntegral (_ssIndent ss) * 100) 0 str
theindent = replicate (_ssIndent ss) ' '
--xtra str = color white . text $ theindent ++ str ++ " MORE " ++ _ssDescriptor ss
g si = map (_siColor si,) $ _siPictures si
overlapSelectionItems :: [SelectionItem a] -> IM.IntMap (Color, Picture)
overlapSelectionItems = go 0
where
go _ [] = mempty
go i (si : xs) = doinsert $ go (i + _siHeight si) xs
where
thecol = _siColor si
doinsert m =
ifoldr
(\j str -> IM.insertWith ihelp (i + j + _siOffY si) (thecol,color thecol (text str)))
m
(_siPictures si)
ihelp (_,x) (col,y) = ( col, x<>y)
enterCombineInv :: Configuration -> World -> World
enterCombineInv cfig w =
@@ -257,7 +270,7 @@ enterCombineInv cfig w =
where
cm' = IM.fromAscList $ zip [0 ..] $ combineList' w
cm
| null cm' = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
| null cm' = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0 0
| otherwise = cm'
sss =
SelectionSections
@@ -274,7 +287,7 @@ enterCombineInv cfig w =
availablelines = getAvailableListLines secondColumnParams cfig
filtsection =
SelectionSection
{ _ssItems = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0
{ _ssItems = IM.singleton 0 $ SelectionInfo ["No possible combinations"] 1 False white 0 0
, _ssCursor = Nothing
, _ssMinSize = 0
, _ssOffset = 0
@@ -288,7 +301,7 @@ enterCombineInv cfig w =
{ _ssItems = cm
, _ssCursor = do
(_, si) <- IM.lookupMin cm
return $ SectionCursor 0 (length (_siPictures si)) (_siColor si)
return $ SectionCursor 0 (_siHeight si) (_siColor si)
, _ssMinSize = 5
, _ssOffset = 0
, _ssShownItems = mempty
+11 -3
View File
@@ -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)
)
+26 -18
View File
@@ -62,7 +62,7 @@ useMod hm = case hm of
, withSoundStart tap4S
, useTimeCheck
, ammoCheckI
, hammerCheckI
, blCheck
]
TeslaMod ->
[ useAmmoAmount 1
@@ -109,20 +109,22 @@ useMod hm = case hm of
, withSoundStart tap4S
, useTimeCheck
, ammoCheckI
, hammerCheckI
, blCheck
]
ShatterMod ->
[ useAmmoAmount 1
-- , withSoundStart tap3S
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
AmmoCheckMod -> [ammoCheckI]
AmmoUseCheckMod -> [ammoUseCheck]
AmmoUseCheckMod -> [useAmmoAmount 1,useTimeCheck, ammoCheckI]
AmmoHammerTimeUseOneMod ->
[ useAmmoAmount 1
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
BangCaneMod ->
[ withMuzFlareI
@@ -133,7 +135,8 @@ useMod hm = case hm of
, useAmmoAmount 1
, withSoundStart tap3S
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
VolleyGunMod ->
[ withRecoil
@@ -144,7 +147,8 @@ useMod hm = case hm of
, useAllAmmo
, withSoundItemChoiceStart caneStickSoundChoice
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
AutoRifleMod ->
-- note this is the same as BangCanemMod with the first changed
@@ -167,7 +171,8 @@ useMod hm = case hm of
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
ElephantGunMod ->
[ withRecoil
@@ -178,7 +183,8 @@ useMod hm = case hm of
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
AutoAmrMod ->
[ withRecoil
@@ -209,7 +215,8 @@ useMod hm = case hm of
, useAllAmmo
, withSoundItemChoiceStart bangStickSoundChoice
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
PistolMod ->
[ withMuzFlareI
@@ -220,7 +227,8 @@ useMod hm = case hm of
, withSoundStart tap3S
, useAmmoAmount 1
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
AutoPistolMod ->
[ withMuzFlareI
@@ -254,7 +262,8 @@ useMod hm = case hm of
, lockInvFor 7
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
BurstRifleRepeatMod ->
[ withRecoil
@@ -305,7 +314,8 @@ useMod hm = case hm of
-- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames
, useTimeCheck
, ammoHammerCheck
, ammoCheckI
, blCheck
]
RevolverXRepeatMod ->
[ withRecoil
@@ -328,8 +338,8 @@ useMod hm = case hm of
, useAllAmmo
, withSoundStart bangEchoS
, useTimeCheck
, hammerCheckI
, ammoCheckI
, blCheck
]
where
f = do
@@ -465,13 +475,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
+10 -7
View File
@@ -3,6 +3,7 @@ module Dodge.Inventory.SelectionList (
closeObjectToSelectionItem,
) where
import Padding
import Dodge.Equipment.Text
import Dodge.Data.SelectionList
import Dodge.Data.World
@@ -15,20 +16,21 @@ invSelectionItem :: Creature -> Int -> Item -> SelectionItem ()
invSelectionItem cr i it =
SelectionItem
{ _siPictures = pics & ix 0 %~ (++ anyequippos ++ anyhotkey)
, _siHeight = length pics
, _siHeight = itSlotsTaken it
, _siIsSelectable = True
, _siColor = col
, _siOffX = 0
, _siOffY = 0
, _siPayload = ()
}
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
_ | cr ^? crManipulation . manObject . inInventory . ispItem == Just i -> selectedItemDisplay cr it
_ -> itemDisplay it
pics = case _itCurseStatus it of
UndroppableIdentified -> itemDisplay cr it
-- _ | cr ^? crManipulation . manObject . inInventory . ispItem == Just i -> selectedItemDisplay cr it
_ -> itemDisplay cr it
hotkeyToString :: Hotkey -> String
hotkeyToString x = case x of
@@ -54,6 +56,7 @@ closeObjectToSelectionItem e =
, --, _siWidth = 15
_siColor = col
, _siOffX = 2
, _siOffY = 0
, _siPayload = ()
}
where
@@ -62,5 +65,5 @@ closeObjectToSelectionItem e =
--
closeObjectToTextPictures :: Either FloorItem Button -> ([String], Color)
closeObjectToTextPictures e = case e of
Left flit -> let it = _flIt flit in (itemDisplay it, _itInvColor it)
Left flit -> let it = _flIt flit in (basicItemDisplay it, _itInvColor it)
Right bt -> ([_btText bt], yellow)
+2
View File
@@ -46,6 +46,8 @@ itemFromEquipType et = case et of
JETPACK -> jetPack
BATTERYPACK -> batteryPack
FUELPACK -> fuelPack
BULLETBELTPACK -> bulletBeltPack
BULLETBELTBRACER -> bulletBeltBracer
AUTODETECTOR d -> autoDetector d
itemFromLeftType :: LeftItemType -> Item
+86 -59
View File
@@ -1,40 +1,48 @@
module Dodge.Item.Display (
itemDisplay,
selectedItemDisplay,
-- selectedItemDisplay,
itemString,
itemBaseName,
basicItemDisplay,
) where
import Control.Applicative
import Control.Monad
import Dodge.Item.Info
import Data.Maybe
import Data.Sequence
import Dodge.Data.Creature
import Dodge.Item.SlotsTaken
import Dodge.Module
import LensHelp
import Padding
itemDisplay :: Item -> [String]
itemDisplay it = itemDisplayWithNumber (showConsumption (_itUse it)) it
itemDisplay :: Creature -> Item -> [String]
itemDisplay cr itm = --itemDisplayWithNumber (showConsumption cr it) it
zipWithDefaults id (leftPad 15 ' ') itemDisplayPad (basicItemDisplay itm) (itemNumberDisplay cr itm)
itemDisplayWithNumber :: String -> Item -> [String]
itemDisplayWithNumber numberstr it =
Prelude.take (itSlotsTaken it) $
(midPadL 15 ' ' thename (' ' : numberstr) ++ theparam) :
catMaybes [maybeWarmupStatus it, maybeRateStatus it]
++ moduleStrings it
++ repeat "\\"
zipWithDefaults :: (a -> c) -> (b -> c) -> (a -> b -> c) -> [a] -> [b] -> [c]
zipWithDefaults f g h = go
where
thename = itemBaseName it
theparam =
fromMaybe []
. listToMaybe
$ mapMaybe
($ it)
[ maybeModeStatus
]
go [] bs = map g bs
go as [] = map f as
go (a:as) (b:bs) = h a b : go as bs
itemDisplayPad :: [Char] -> String -> [Char]
itemDisplayPad ls rs
| rs == "" = ls
| otherwise = midPadL 15 ' ' ls (' ':rs)
basicItemDisplay :: Item -> [String]
basicItemDisplay itm =
Prelude.take (itSlotsTaken itm) $
itemBaseName itm :
catMaybes [maybeWarmupStatus itm, maybeRateStatus itm]
++ moduleStrings itm
++ repeat "*"
itemString :: Item -> String
itemString = head . itemDisplay
itemString = head . basicItemDisplay
itemBaseName :: Item -> String
itemBaseName it = case _iyBase $ _itType it of
@@ -47,17 +55,6 @@ itemBaseName it = case _iyBase $ _itType it of
EQUIP eit -> show eit
Consumable cit -> show cit
selectedItemDisplay :: Creature -> Item -> [String]
selectedItemDisplay cr it = itemDisplayWithNumber (showSelectedConsumption cr (_itUse it)) it
-- | 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)
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
EquipUse{} -> ""
_ -> show $ iu ^?! useAmount . getItAmount -- partial, be careful if adding new data constructors
showAutoRechargeProgress :: LeftConsumption -> String
showAutoRechargeProgress lc = case lc of
AutoRecharging{}
@@ -65,36 +62,71 @@ showAutoRechargeProgress lc = case lc of
| otherwise -> show (_arLoaded lc)
ChargeableAmmo{} -> show (_wpCharge lc)
showReloadProgress :: Creature -> HeldConsumption -> 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)
--showReloadProgress :: Creature -> Item -> String
--showReloadProgress cr itm = case cr ^? crManipulation . manObject . inInventory . iselAction of
-- 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
-- AboveSource -> fromMaybe "XXXX" $ do
-- i <- fmap (subtract 1) $ itm ^? itLocation . ipInvID
-- x <- cr ^? crInv . ix i . itUse . equipEffect . eeUse . euseAmmoAmount
-- return $ showIntKMG' x
-- where
-- ic = (itm ^?! itUse . heldConsumption . laSource)
showConsumption :: ItemUse -> String
showConsumption iu = case iu of
HeldUse{} -> showReloadProgress' (_heldConsumption iu)
LeftUse{} -> showAutoRechargeProgress (_leftConsumption iu)
EquipUse {_equipEffect = ee} -> showEUseNumber ee
_ -> show $ iu ^?! useAmount . getItAmount
itemNumberDisplay :: Creature -> Item -> [String]
itemNumberDisplay cr itm = case iu of
HeldUse{} -> [showReloadProgress cr itm]
LeftUse{} -> [showAutoRechargeProgress (_leftConsumption iu)]
EquipUse{} -> showEquipmentNumber cr itm
_ -> [show $ iu ^?! useAmount . getItAmount]
where
iu = itm ^?! itUse
showEUseNumber :: EquipEffect -> String
showEUseNumber ee = case _eeUse ee of
EFuelSource x _ -> show x
showEquipmentNumber :: Creature -> Item -> [String]
showEquipmentNumber cr itm = case _eeUse ee of
EFuelSource x _ -> [show x]
EAmmoSource {} -> showAmmoSource cr itm
EBatterySource {_euseBatteryAmount = x} -> [show x]
_ -> [""]
where
ee = itm ^?! itUse . equipEffect
showAmmoSource :: Creature -> Item -> [String]
showAmmoSource cr itm = fromMaybe ["FAIL"] $ do
eu <- itm ^? itUse . equipEffect . eeUse
atype <- eu ^? euseAmmoSourceType
x <- fmap showIntKMG' $ eu ^? euseAmmoAmount
i <- itm ^? itLocation . ipInvID
(do
at' <- cr ^? crInv . ix (i + 1) . itUse . heldConsumption . laSourceType
as <- cr ^? crInv . ix (i + 1) . itUse . heldConsumption . laSource
guard (at' == atype && as == AboveSource)
return ["vvvv",x] ) <|> Just [x]
showReloadProgress :: Creature -> Item -> String
showReloadProgress cr itm = case ic ^? laSource of
Just (InternalSource ia) -> case ia ^? iaProgress . _Just . ix 0 of
Nothing -> maybe "" show $ ic ^? laSource . _InternalSource . iaLoaded
Just la -> showLoadActionType la (_laSource ic)
Just AboveSource -> fromMaybe "||||" $ do
i <- fmap (subtract 1) $ itm ^? itLocation . ipInvID
_ <- cr ^? crInv . ix i . itUse . equipEffect . eeUse . euseAmmoAmount
return ""
_ -> ""
where
ic = itm ^?! itUse . heldConsumption
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)
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
@@ -106,11 +138,6 @@ maybeWarmupStatus it = case it ^? itUse . heldDelay . warmMax of
let n = show x
in Just $ Prelude.take (5 - Prelude.length n) "*WARM" ++ n
maybeModeStatus :: Item -> Maybe String
maybeModeStatus it = case it ^? itUse . heldScroll of
Just HeldScrollCharMode{_hsCharMode = (c :<| _)} -> Just [' ', c]
_ -> Nothing
maybeRateStatus :: Item -> Maybe String
maybeRateStatus it = case it ^? itUse . heldDelay . rateMaxMax of
Nothing -> Nothing
+12 -6
View File
@@ -50,6 +50,10 @@ equipItemSPic et _ = case et of
BATTERYPACK -> noPic $ colorSH blue backpackShape
FUELPACK ->
noPic $ colorSH yellow $ upperPrismPolyMT 10 $ polyCirc 3 5
BULLETBELTPACK ->
noPic $ colorSH green backpackShape
BULLETBELTBRACER
-> noPic (colorSH green $ upperPrismPolySU 3 $ rectWH 2 2)
AUTODETECTOR dt -> noPic (colorSH (detectorColor dt) $ upperPrismPolySU 3 $ rectWH 2 2)
backpackShape :: Shape
@@ -249,7 +253,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 +319,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 $
@@ -370,13 +374,15 @@ volleyGunShape i =
[0 .. i -1]
)
-- to get this rotating should probably add extra state to the minigun
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
+19
View File
@@ -12,6 +12,8 @@ module Dodge.Item.Equipment (
jetPack,
fuelPack,
batteryPack,
bulletBeltPack,
bulletBeltBracer,
speedLegs,
jumpLegs,
flameShield,
@@ -59,6 +61,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 +71,22 @@ 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 2000 2000 BulletSource Nothing
bulletBeltBracer :: Item
bulletBeltBracer =
defaultEquipment
& itUse . equipEffect . eeSite .~ GoesOnWrist
& itType . iyBase .~ EQUIP BULLETBELTBRACER
& itUse . equipEffect . eeAttachPos .~ V3 (-9) 0 10
& itUse . equipEffect . eeUse .~ EAmmoSource 100 100 BulletSource Nothing
jetPack :: Item
jetPack =
defaultEquipment
+7 -7
View File
@@ -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
View File
@@ -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 .~ AboveSource)
--(defaultBulletLoadable
-- & laSource . iaMax .~ 1500
-- & laSource . iaLoaded .~ 1500
--)
& heldConsumption . laSource . _InternalSource . iaCycle .~ [loadEject 40, loadInsert 40, loadPrime 40]
miniGunX :: Int -> Item
miniGunX i =
+6 -6
View File
@@ -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)
+5 -5
View File
@@ -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
+5 -5
View File
@@ -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?
+4 -4
View File
@@ -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
+7 -7
View File
@@ -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)
+51 -35
View File
@@ -1,16 +1,17 @@
module Dodge.Item.Info where
import StringHelp
import Dodge.Module.Info
import Data.Char
import Dodge.Data.Item
import qualified Data.Map.Strict as M
import Dodge.Data.Item
import Dodge.Module.Info
import LensHelp
import StringHelp
itemInfo :: Item -> String
itemInfo itm = itmBaseInfo itm ++ " " ++ itmUsageInfo itm
++ itmSpaceInfo itm
++ itmModuleInfo (itm ^. itType . iyModules)
itemInfo itm =
itmBaseInfo itm ++ " " ++ itmUsageInfo itm
++ itmSpaceInfo itm
++ itmModuleInfo (itm ^. itType . iyModules)
itmSpaceInfo :: Item -> String
itmSpaceInfo itm = case ceiling $ _itInvSize itm of
@@ -43,20 +44,34 @@ showInt i = case i of
12 -> "a dozen"
_ -> "more than a dozen"
showIntKMG :: Int -> String
showIntKMG x
| x < 1000 = show x
| x < 1000000 = show (x `div` 1000) ++ "K"
| x < 1000000000 = show (x `div` 1000000) ++ "M"
| otherwise = show (x `div` 1000000000) ++ "G"
showIntKMG' :: Int -> String
showIntKMG' x
| x < 1000 = show x
| x < 1000000 = take 3 (show ((fromIntegral x :: Float) / 1000)) ++ "K"
| x < 1000000000 = take 3 (show ((fromIntegral x :: Float) / 1000000)) ++ "M"
| otherwise = take 3 (show ((fromIntegral x :: Float) / 1000000000)) ++ "G"
heldInfo :: HeldItemType -> String
heldInfo hit = case hit of
BANGSTICK 1 -> "A firearm with a short barrel that requires reloading after each shot."
BANGSTICK i -> over _head toUpper (showInt i)++" small gun barrels strapped together. Each barrel must be individually loaded, but not all need be loaded for the weapon to fire. All loaded barrels discharge simultaneously, with significant spread."
BANGSTICK i -> over _head toUpper (showInt i) ++ " small gun barrels strapped together. Each barrel must be individually loaded, but not all need be loaded for the weapon to fire. All loaded barrels discharge simultaneously, with significant spread."
PISTOL -> "A small firearm fed by a magazine. The entire magazine must be replaced when reloading the weapon."
REVOLVER -> "A small firearm fed by a revolving cylinder. Single shot and load."
REVOLVERX i -> "A small firearm fed by "++ showInt i++ "revolving cylinders."
REVOLVERX i -> "A small firearm fed by " ++ showInt i ++ "revolving cylinders."
MACHINEPISTOL -> "A small firearm automatically, and extremely rapidly, fed by a magazine. The entire magazine must be replaced when reloading the weapon."
AUTOPISTOL -> "A small firearm automatically fed by a magazine. The entire magazine must be replaced when reloading the weapon."
SMG -> "A small firearm with an attached stock for stability."
BANGCONE -> "A container for debris. Exposive action propels the debris away from the user. Quite unweildy."
BLUNDERBUSS -> "A container for debris on the end of a stick. Explosive action propels the debris away from the user."
GRAPECANNON 1 -> "A large container for debris on the end of a stick. Explosive action propels the debris away from the user."
GRAPECANNON i -> "An "++ replicate (i-1) 'X' ++"L container for debris on the end of a stick. Explosive action propels the debris away from the user."
GRAPECANNON i -> "An " ++ replicate (i -1) 'X' ++ "L container for debris on the end of a stick. Explosive action propels the debris away from the user."
MINIGUNX i -> over _head toUpper (showInt i) ++ " gun barrels that revolve rapidly around a central stick. Requires considerable time to warm up, but has an extremely rapid rate of fire. It is also extremely difficult to stabilise."
VOLLEYGUN i -> over _head toUpper (showInt i) ++ " gun barrels lined up to be roughly parallel. Each barrel must be individually loaded, but not all need be loaded for the weapon to fire. All loaded barrels discharge simultaneously."
RIFLE -> "A firearm with a mid length barrel that requires reloading after each shot."
@@ -82,17 +97,17 @@ heldInfo hit = case hit of
LASWIDE _ -> "A weapon that continuously emits photons in a narrow beam. The beam expands as the weapon heats up."
TRACTORGUN -> "An item that produces a beam of gravitons."
LAUNCHER -> "A large tube that can launch self propelled projectiles. Moving the tube after launch will cause the projectile to spin."
LAUNCHERX i -> over _head toUpper (showInt i)++" tubes that can launch self propelled projectiles. Tubes that do not face forward launch their projecitles at an angle."
LAUNCHERX i -> over _head toUpper (showInt i) ++ " tubes that can launch self propelled projectiles. Tubes that do not face forward launch their projecitles at an angle."
REMOTELAUNCHER -> "A large tube that can launch self propelled projectiles. Contains a transmitter allowing for remote control of launched projectiles."
POISONSPRAYER -> "A weapon that releases noxious gases."
DRONELAUNCHER -> "A device for launching drones."
SHATTERGUN -> "A seismic device that shatters hard items in its line of fire."
FORCEFIELDGUN -> "A device that produces a durable forcefield."
HELDDETECTOR d -> "A device that detects "++detectorInfo d ++" in an expanding radius."
HELDDETECTOR d -> "A device that detects " ++ detectorInfo d ++ " in an expanding radius."
TORCH -> "A stick with a light on the end."
BINOCULARS -> "Two cylinders with lenses. Scroll to zoom."
FLATSHIELD -> "A panel of metal that blocks unwanted objects from the front of the user."
KEYCARD i -> "A keycard. It is labelled " ++ show i++ "."
KEYCARD i -> "A keycard. It is labelled " ++ show i ++ "."
leftInfo :: LeftItemType -> String
leftInfo lit = case lit of
@@ -114,17 +129,17 @@ equipInfo eit = case eit of
INVISIBILITYEQUIPMENT _ -> "A device that bends light around its user."
BRAINHAT -> "An iq enhancer. Useless."
HAT -> "A hat."
TARGETINGHAT tt -> "Headwear that "++ targetingInfo tt
TARGETINGHAT tt -> "Headwear that " ++ targetingInfo tt
HEADLAMP -> "A torch strapped to a hat."
POWERLEGS -> "Strength enhancing legs."
SPEEDLEGS -> "Speed enhancing legs."
JUMPLEGS -> "Jump enhancing legs."
JETPACK -> "A device enabling flight."
FUELPACK -> "A liquid container with attached hose."
BULLETBELTPACK -> "A container holding a long belt of bullets."
BULLETBELTBRACER -> "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. "
AUTODETECTOR d -> "A device that detects " ++ detectorInfo d ++ " in an expanding radius. Pulses automatically. "
targetingInfo :: TargetType -> String
targetingInfo tt = case tt of
@@ -145,10 +160,8 @@ craftInfo fit = case fit of
TUBE -> "A wide rigid cylinder."
HARDWARE -> "A collection of equipment and devices useful for general construction."
SPRING -> "An object that exerts an opposing force when compressed or stretched."
HOSE -> "A flexible cylinder."
TAPE -> "A strip of material with an adhesive side."
CAN -> "A small metal cylindrical container."
TIN -> "A small metal continer."
STEELDRUM -> "A metal cylindrical container."
@@ -192,12 +205,9 @@ craftInfo fit = case fit of
TIMEMODULE -> "A device that can affect temporality."
SIZEMODULE -> "A device that can affect physical size."
GRAVITYMODULE -> "A device that can affect gravitational fields."
TARGETMODULE _ -> "A targeting module."
FLAKCRAFT -> "Creates flak bullets."
FRAGCRAFT -> "Creates fragmentation bullets."
detectorInfo :: Detector -> String
detectorInfo d = case d of
@@ -208,8 +218,9 @@ detectorInfo d = case d of
itmUsageInfo :: Item -> String
itmUsageInfo itm = case itm ^. itType . iyBase of
HELD _ -> heldPositionInfo itm
LEFT _ -> "This item can be equipped" ++ itmEquipSiteInfo itm
++ ". When equipped, it can be activated."
LEFT _ ->
"This item can be equipped" ++ itmEquipSiteInfo itm
++ ". When equipped, it can be activated."
EQUIP _ -> "This item can be equipped " ++ itmEquipSiteInfo itm ++ "."
Consumable _ -> "This item can be consumed."
CRAFT _ -> ""
@@ -220,9 +231,10 @@ heldPositionInfo = maybe undefined aimStanceInfo . (^? itUse . heldAim . aimStan
aimStanceInfo :: AimStance -> String
aimStanceInfo as = case as of
TwoHandTwist -> "It is held in two hands along its length."
TwoHandTwist -> "It is held in two hands along its length."
TwoHandFlat -> "It is held in two hands at its sides."
OneHand -> "It is held in one hand."
-- LeaveHolstered -> "It is to be left holstered."
itmEquipSiteInfo :: Item -> String
@@ -237,23 +249,27 @@ equipSiteInfo es = case es of
GoesOnLegs -> " on both legs"
itmModuleInfo :: M.Map ModuleSlot ItemModuleType -> String
itmModuleInfo m
itmModuleInfo m
| m == mempty = ""
| otherwise = mms ++ ems
| otherwise = mms ++ ems
where
(mademods,emptymods) = M.partition (/= EMPTYMODULE) m
mms | mademods == mempty = ""
| otherwise = " Modifications have been made "
++ makeCommaList (map moduleInfo $ M.keys mademods)
ems | emptymods == mempty = ""
| otherwise = " Modifications can be made "
++ makeCommaList (map moduleInfo $ M.keys emptymods)
(mademods, emptymods) = M.partition (/= EMPTYMODULE) m
mms
| mademods == mempty = ""
| otherwise =
" Modifications have been made "
++ makeCommaList (map moduleInfo $ M.keys mademods)
ems
| emptymods == mempty = ""
| otherwise =
" Modifications can be made "
++ makeCommaList (map moduleInfo $ M.keys emptymods)
makeCommaList :: [String] -> String
makeCommaList [] = ""
makeCommaList [x] = x ++ "."
makeCommaList [x,y] = x ++ " and " ++ y ++ "."
makeCommaList (x:xs) = x ++ ", " ++ makeCommaList xs
makeCommaList [x, y] = x ++ " and " ++ y ++ "."
makeCommaList (x : xs) = x ++ ", " ++ makeCommaList xs
moduleInfo :: ModuleSlot -> String
moduleInfo imt = case imt of
+1 -1
View File
@@ -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
+14 -10
View File
@@ -1,22 +1,26 @@
module Dodge.Item.Weapon.FractionLoaded
( fractionLoadedAmmo
, fractionLoadedAmmo2
) where
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
+36 -54
View File
@@ -19,7 +19,6 @@ module Dodge.Item.Weapon.TriggerType (
withItem,
withItemUpdate,
withItemUpdate',
ammoUseCheck,
rateIncAB,
torqueBefore,
torqueBeforeAtLeast,
@@ -55,16 +54,16 @@ module Dodge.Item.Weapon.TriggerType (
duplicateOffsets,
duplicateOffsetsV2,
duplicateOffsetsFocus,
hammerCheckI,
hammerCheckL,
shootL,
useTimeCheck,
ammoCheckI,
applyInaccuracy,
modClock,
ammoHammerCheck,
blCheck,
) where
import qualified SDL
import Data.Foldable
import Data.Maybe
import Dodge.Base
@@ -80,6 +79,7 @@ import Geometry
import LensHelp
import RandomHelp
import Sound.Data
import qualified IntMapHelp as IM
type ChainEffect =
(Item -> Creature -> World -> World) ->
@@ -136,28 +136,25 @@ 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
ammoCheckI eff itm cr w = case itm ^? itUse . heldConsumption . laSource of
Just (InternalSource ia) | _iaLoaded ia <= 0 || not (_iaPrimed ia)
-> failsound w
Just AboveSource | fromMaybe True $ do
invid <- itm ^? itLocation . ipInvID
x <- cr ^? crInv . ix (invid - 1) . itUse . equipEffect . eeUse . euseAmmoAmount
return $ x <= 0
-> failsound w
_ -> eff itm cr $ w & cWorld . lWorld . creatures . ix (_crID cr) %~ crCancelReloading
where
ic = _heldConsumption $ _itUse itm
-- 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
_ -> w
where
ic = _heldConsumption $ _itUse it
failsound = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> soundStart (CrReloadSound (_crID cr)) (_crPos cr) click1S Nothing
_ -> soundContinue (CrReloadSound (_crID cr)) (_crPos cr) click1S Nothing
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 +338,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,9 +354,18 @@ 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 %~ useAmmoAmount' itref amAmount) -- . _InternalSource . iaLoaded -~ amAmount)
where
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
itref = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
useAmmoAmount' :: Int -> Int -> IM.IntMap Item -> IM.IntMap Item
useAmmoAmount' itref x inv = case inv ^? ix itref . itUse . heldConsumption . laSource of
Just InternalSource{}
-> inv & ix itref . itUse . heldConsumption . laSource . _InternalSource . iaLoaded -~ x
Just AboveSource
-> inv & ix (itref - 1) . itUse . equipEffect . eeUse . euseAmmoAmount -~ x
_ -> inv
-- . crInv . ix itRef . itUse . heldConsumption . laSource
{- |
Applies a world effect after an item use cooldown check.
@@ -374,37 +380,13 @@ useTimeCheck f item cr w = case item ^? itUse . heldDelay . rateTime of
itRef = cr ^?! crManipulation . manObject . inInventory . ispItem -- unsafe!! TODO change
userate = fromMaybe 0 $ item ^? itUse . heldDelay . rateMax
-- | Applies a world effect after a hammer position check.
hammerCheckI :: ChainEffect
hammerCheckI f it cr w = case it ^? itUse . heldHammer of
Just HammerUp
| _laPrimed (_heldConsumption (_itUse it)) ->
f it cr w
blCheck :: ChainEffect
blCheck f it cr w = case w ^? input . mouseButtons . ix SDL.ButtonLeft of
Just 0 -> 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 +631,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 +666,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 +677,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
+2
View File
@@ -100,6 +100,7 @@ colStrToSelItem (col, str) =
, _siIsSelectable = True
, _siColor = col
, _siOffX = 0
, _siOffY = 0
, _siPayload = id
}
@@ -120,6 +121,7 @@ menuOptionToSelectionItem w padAmount mo =
, _siIsSelectable = isselectable
, _siColor = thecol
, _siOffX = 0
, _siOffY = 0
, _siPayload = (f, g)
}
where
+37 -32
View File
@@ -1,14 +1,13 @@
module Dodge.Reloading (
crCancelReloading,
crToggleReloading,
crUpdateLoadSource,
stepReloading,
tryStartLoading,
) where
import Dodge.Data.Item.Use.Consumption.LoadAction
import Control.Lens
import Dodge.Data.Creature
import Data.Maybe
import Dodge.Data.Creature
crCancelReloading :: Creature -> Creature
crCancelReloading cr =
@@ -18,7 +17,9 @@ 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,59 +28,63 @@ 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
& crManipulation . manObject . inInventory . iselAction . reloadAction .~ la
_ -> cr
crToggleReloading :: Creature -> Creature
crToggleReloading cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
Just ReloadAction{} -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
_ -> cr & tryStartLoading
crUpdateLoadSource :: Creature -> Creature
crUpdateLoadSource cr = case cr ^? crManipulation . manObject . inInventory . iselAction of
Just NoInvSelAction -> cr & tryStartLoading
_ -> cr & crManipulation . manObject . inInventory . iselAction .~ NoInvSelAction
tryStartLoading :: Creature -> Creature
tryStartLoading cr = fromMaybe cr $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
hc <- cr ^? crInv . ix i . itUse . heldConsumption
return $ startLoading hc cr
ia <- cr ^? crInv . ix i . itUse . heldConsumption . laSource . _InternalSource
return $ startLoading ia cr
startLoading :: HeldConsumption -> Creature -> Creature
startLoading ic cr = case ic ^? laProgress . _Just . ix 0 of
-- case as of
-- InternalSource ia -> return $ startLoading ia cr
-- AboveSource -> return cr
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 -> cr
Just [] -> error "item has empty load cycle"
Just _ | _laLoaded ic >= _laMax ic -> cr
Just (la : las) -> fromMaybe (error "item loading error") $ do
Nothing -> case ic ^. iaCycle of
[] -> error "item has empty load cycle"
_ | _iaLoaded ic >= _iaMax ic -> cr
(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)
return $
cr & startLoadingStep la
& 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 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
+3 -4
View File
@@ -99,6 +99,7 @@ drawExamineInventory cfig mtweaki w =
, _siIsSelectable = True
, _siColor = white
, _siOffX = 0
, _siOffY = 0
, _siPayload = ()
}
@@ -172,12 +173,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
@@ -217,7 +215,7 @@ displayTerminal tid cfig w = fromMaybe mempty $ do
invHead cfig (_tmTitle tm ++ ":T" ++ show tid)
<> drawSelectionList secondColumnParams cfig (thesellist tm)
where
toselitm (str, col) = SelectionItem [str] 1 True col 0 ()
toselitm (str, col) = SelectionItem [str] 1 True col 0 0 ()
thesellist tm = defaultSelectionList & slItems .~ thelist tm
thelist tm =
map toselitm . displayTermInput tm
@@ -336,6 +334,7 @@ picsToSelectable pics =
, _siIsSelectable = True
, _siColor = white
, _siOffX = 0
, _siOffY = 0
, _siPayload = ()
}
+2 -2
View File
@@ -12,6 +12,7 @@ module Dodge.Render.List (
listCursorChooseBorderScale,
) where
import Dodge.SelectionSections
import Data.Maybe
import Dodge.Base.Window
import Dodge.Data.CardinalPoint
@@ -19,7 +20,6 @@ import Dodge.Data.Config
import Dodge.Data.SelectionList
import Dodge.ScreenPos
import Dodge.SelectionList
import Dodge.SelectionSections
import Geometry
import LensHelp
import ListHelp
@@ -98,7 +98,7 @@ selSecDrawCursor xsize ldp sss = fromMaybe mempty $ do
xint
(_siColor si)
xsize
(length $ _siPictures si)
(_siHeight si)
-- displays a cursor that should match up to list text pictures
listCursorChooseBorderScale ::
+1 -1
View File
@@ -19,7 +19,7 @@ import RandomHelp
roomsContaining :: RandomGen g => [Creature] -> [Item] -> State g (MetaTree Room String)
roomsContaining crs its = tToBTree str <$> roomsContaining' crs its
where
str = "roomsContaining " ++ concatMap _crName crs ++ concatMap (head . itemDisplay) its
str = "roomsContaining " ++ concatMap _crName crs ++ concatMap (head . basicItemDisplay) its
roomsContaining' :: RandomGen g => [Creature] -> [Item] -> State g (Tree Room)
roomsContaining' crs its = do
+1 -1
View File
@@ -130,7 +130,7 @@ selSecYint i j sss = do
return . (secpos +)
. subtract (ss ^. ssOffset)
. sum
. fmap (length . _siPictures)
. fmap (_siHeight)
. fst
$ IM.split j (ss ^. ssItems)
where
+1 -1
View File
@@ -116,7 +116,7 @@ updateInitialPressInGame uv sc = case sc of
ScancodeP -> pauseGame uv
ScancodeF -> over uvWorld youDropItem uv
ScancodeM -> toggleMap uv
ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crToggleReloading uv
ScancodeR -> over (uvWorld . cWorld . lWorld . creatures . ix 0) crUpdateLoadSource uv
ScancodeT -> over uvWorld testEvent uv
ScancodeX -> uv & uvWorld %~ toggleTweakInv
ScancodeC -> toggleCombineInv uv
+20 -28
View File
@@ -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,38 +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
. optionScreenDefaultEffect mop
. mouseClickOptionsList screen
. mouseOverSelectionList ldps screen
. mouseOverSelectionList
. optionScreenDefaultEffect
. mouseClickOptionsList
. menuWheelEvents
. over (uvScreenLayers . _head) (setSelectionListRestriction (u ^. uvConfig))
$ u
where
mop = _scPositionedMenuOption screen
ldps = _scListDisplayParams screen
optionScreenDefaultEffect :: EscapeMenuOption -> Universe -> Universe
optionScreenDefaultEffect f u =
fromMaybe
id
( do
ptype <- u ^. uvWorld . input . pressedKeys . at ScancodeEscape
guard $ ptype == InitialPress
f ^? emoMenuOption . moEff
)
u
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) <*> 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
@@ -79,8 +69,11 @@ mouseClickOptionsList screen u = fromMaybe u $ do
return $ f u
_ -> u
mouseOverSelectionList :: ListDisplayParams -> ScreenLayer -> Universe -> Universe
mouseOverSelectionList ldps screen u = fromMaybe u $ do
mouseOverSelectionList :: Universe -> Universe
mouseOverSelectionList u = fromMaybe u $ do
screen <- u ^? uvScreenLayers . ix 0
ldps <- screen ^? scListDisplayParams
let ymax = maybe 0 length $ screen ^? scSelectionList . slItems
yi <- ldpVerticalSelection (u ^. uvConfig) ldps (u ^. uvWorld . input . mousePos)
guard $ mmoving || (_scDisplayTime screen <= 1)
let myi = do
@@ -91,7 +84,6 @@ mouseOverSelectionList ldps screen u = fromMaybe u $ do
isselectable yi =
fromMaybe False $
u ^? uvScreenLayers . _head . scSelectionList . slItems . ix yi . siIsSelectable
ymax = maybe 0 length $ screen ^? scSelectionList . slItems
mmoving = u ^. uvWorld . input . mouseMoving
ldpVerticalSelection :: Configuration -> ListDisplayParams -> Point2 -> Maybe Int
+2 -2
View File
@@ -103,8 +103,8 @@ terminalWheelEvent yi tmid w
scrollRBOption :: Int -> Int -> Int -> Int
scrollRBOption dy ymax
| dy < 0 = (min (ymax -1) . subtract dy)
| dy > 0 = (max 0 . subtract dy)
| dy < 0 = min (ymax -1) . subtract dy
| dy > 0 = max 0 . subtract dy
| otherwise = id
moveTweakSel :: Int -> World -> World
+3 -1
View File
@@ -329,7 +329,9 @@ stringToList gap = concatMap (uncurry charToTuple) . zip [0, 100 + gap ..]
charToTuple :: Float -> Char -> [(Point3, Point4, Point3)]
{-# INLINE charToTuple #-}
charToTuple xoff c = [f 0 0, f 1 0, f 1 1, f 0 0, f 1 1, f 0 1]
charToTuple xoff c
| fromEnum c == 32 = [] -- don't draw space characters
| otherwise = [f 0 0, f 1 0, f 1 1, f 0 0, f 1 1, f 0 1]
where
f x y = (V3 (xoff + x * 100) (y * 200) 0, white, V3 x (1 - y) charnum)
-- textures in opengl have origins at the lower left, my char array has its