Allow for item use when not root

This commit is contained in:
2024-12-20 16:07:58 +00:00
parent 3a72bd366f
commit d9aaa8cc05
26 changed files with 436 additions and 493 deletions
-25
View File
@@ -1,25 +0,0 @@
module Dodge.Item.Consumable where
import Control.Lens
import Dodge.Data.World
import Dodge.Default
import Dodge.SoundLogic
medkit :: Int -> Item
medkit i =
defaultConsumable
& itUse . cUse .~ CHeal i
& itType .~ CONSUMABLE (MEDKIT i)
heal25 :: Int -> World -> Maybe World
heal25 = heal 25
heal :: Int -> Int -> World -> Maybe World
heal hp n w
| (w ^?! cWorld . lWorld . creatures . ix n . crHP) >= 10000 = Nothing
| otherwise =
Just $
soundStart (CrSound $ _crID cr) (_crPos cr) healS Nothing w
& cWorld . lWorld . creatures . ix n . crHP %~ min 10000 . (+ hp)
where
cr = w ^?! cWorld . lWorld . creatures . ix n --_creatures (_cWorld w) IM.! n
-2
View File
@@ -49,7 +49,6 @@ itemBaseName itm = case _itType itm of
Just i -> takeWhile (/= ' ') (show hit) ++ show i
Nothing -> show hit
EQUIP eit -> showEquipItem eit
CONSUMABLE cit -> show cit
ATTACH ait -> showAttachItem ait itm
AMMOMAG ait -> show ait
TARGETING tt -> show tt
@@ -82,7 +81,6 @@ itemNumberDisplay cr ci = case (ci ^. _2, itm ^?! itUse, itm ^. itType) of
-- (_,UseHotkey{_leftConsumption=lc},_) -> [showAutoRechargeProgress lc]
(_,UseEquip{},_) -> mempty
(_,UseNothing,_) -> []
(_,UseConsume {},_) -> []
(_,UseAttach (APInt i),_) -> [show i]
(_,UseAttach {},_) -> []
(_,UseScope OpticScope {_opticZoom = x},_) -> [shortShow x]
-1
View File
@@ -36,7 +36,6 @@ itemSPic it = case it ^. itType of
CRAFT _ -> defSPic
HELD ht -> heldItemSPic ht it
EQUIP et -> equipItemSPic et it
CONSUMABLE{} -> defSPic
ATTACH{} -> defSPic
AMMOMAG amt -> ammoMagSPic it amt
TARGETING{} -> defSPic
+1 -1
View File
@@ -87,7 +87,7 @@ getAmmoLinks itm =
itemToFunction :: Item -> ItemStructuralFunction
itemToFunction itm = case itm ^. itType of
HELD LASER -> WeaponTargetingSF
HELD{} -> case itm ^? itUse . useCondition of
HELD{} -> case itm ^? itUseCondition of
Just MustBeHeld -> HeldPlatformSF
_ -> GadgetPlatformSF
_ | Just amtype <- itm ^? itConsumables . magType
+1 -1
View File
@@ -35,7 +35,7 @@ Sends out pulses that display walls.
detector :: Detector -> Item
detector dt =
defaultHeldItem
& itUse . useCondition .~ UseableAnytime
& itUseCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}
-7
View File
@@ -24,7 +24,6 @@ itmBaseInfo :: Item -> String
itmBaseInfo itm = case itm ^. itType of
HELD hit -> heldInfo hit
EQUIP eit -> equipInfo eit
CONSUMABLE cit -> consumableInfo cit
CRAFT fit -> craftInfo fit
_ -> "THIS SHOULD NOT BE DISPLAYED"
@@ -122,11 +121,6 @@ equipInfo eit = case eit of
-- TargetRBCreature -> "targets a creature."
-- TargetCursor -> "creates a moving target."
consumableInfo :: ConsumableItemType -> String
consumableInfo cit = case cit of
MEDKIT _ -> "A self-use healing kit."
EXPLOSIVES -> "Explosives."
craftInfo :: CraftType -> String
craftInfo fit = case fit of
PIPE -> "A rigid cylinder."
@@ -195,7 +189,6 @@ itmUsageInfo itm = case itm ^. itType of
-- "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 _ -> ""
_ -> "THIS SHOULD NOT BE DISPLAYED"
+1 -1
View File
@@ -14,7 +14,7 @@ import Dodge.Default
blinker :: Item
blinker =
defaultHeldItem
& itUse . useCondition .~ UseableAnytime
& itUseCondition .~ UseableAnytime
& itUse . heldDelay . rateMax .~ 20
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1}