Allow for item use when not root
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -69,14 +69,14 @@ miniGunCrit =
|
||||
longCrit :: Creature
|
||||
longCrit =
|
||||
defaultCreature
|
||||
& crInv .~ IM.fromList [(0, sniperRifle), (1, medkit 100)]
|
||||
& crInv .~ IM.fromList [(0, sniperRifle)]
|
||||
& crType . humanoidAI .~ LongAI
|
||||
& crType . skinUpper .~ lightx4 red
|
||||
|
||||
multGunCrit :: Creature
|
||||
multGunCrit =
|
||||
defaultCreature
|
||||
& crInv .~ IM.fromList [(0, volleyGun 4), (1, medkit 100)]
|
||||
& crInv .~ IM.fromList [(0, volleyGun 4)]
|
||||
& crType . skinUpper .~ lightx4 red
|
||||
& crType . humanoidAI .~ MultGunAI
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import Dodge.Creature.ChaseCrit
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Data.FloatFunction
|
||||
import Dodge.Default
|
||||
import Dodge.Item.Consumable
|
||||
import Dodge.Item.Equipment
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
@@ -20,7 +19,6 @@ flockArmourChaseCrit =
|
||||
, _crInv =
|
||||
IM.fromList
|
||||
[ (0, frontArmour)
|
||||
, (1, medkit 200)
|
||||
]
|
||||
, _crActionPlan =
|
||||
ActionPlan
|
||||
@@ -43,7 +41,6 @@ armourChaseCrit =
|
||||
_crInv =
|
||||
IM.fromList
|
||||
[ (0, frontArmour)
|
||||
, (1, medkit 200)
|
||||
]
|
||||
, _crMvType = defaultChaseMvType{_mvTurnRad = FloatConst 0.05}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,13 @@ import Dodge.Item.Held.Cane
|
||||
import Control.Lens
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Default
|
||||
import Dodge.Item.Consumable
|
||||
import qualified IntMapHelp as IM
|
||||
import Picture
|
||||
|
||||
autoCrit :: Creature
|
||||
autoCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, autoRifle), (1, medkit 100)]
|
||||
{ _crInv = IM.fromList [(0, autoRifle)]
|
||||
, _crRad = 10
|
||||
, _crHP = 300
|
||||
, _crMvType = defaultAimMvType
|
||||
|
||||
@@ -7,10 +7,8 @@ module Dodge.Creature.ChaseCrit (
|
||||
import Control.Lens
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Default
|
||||
import Dodge.Item.Consumable
|
||||
import Dodge.Item.Equipment
|
||||
import Dodge.SoundLogic
|
||||
import qualified IntMapHelp as IM
|
||||
import Picture
|
||||
|
||||
smallChaseCrit :: Creature
|
||||
@@ -18,7 +16,7 @@ smallChaseCrit =
|
||||
chaseCrit
|
||||
{ _crHP = 1
|
||||
, _crRad = 4
|
||||
, _crInv = IM.fromList [(0, medkit 200)]
|
||||
, _crInv = mempty
|
||||
, _crCorpse = MakeDefaultCorpse
|
||||
}
|
||||
|
||||
@@ -34,7 +32,7 @@ chaseCrit =
|
||||
defaultCreature
|
||||
{ _crName = "chaseCrit"
|
||||
, _crHP = 150
|
||||
, _crInv = IM.fromList [(0, medkit 200)]
|
||||
, _crInv = mempty
|
||||
, _crMeleeCooldown = 0
|
||||
, _crFaction = ColorFaction green
|
||||
, _crVocalization = chaseCritVocalization
|
||||
|
||||
@@ -2,6 +2,7 @@ module Dodge.Creature.Impulse.UseItem (
|
||||
useSelectedItem,
|
||||
) where
|
||||
|
||||
import Dodge.DoubleTree
|
||||
import Control.Lens
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
@@ -22,9 +23,12 @@ useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMayb
|
||||
itRef <- cr ^? crManipulation . manObject . imRootSelectedItem
|
||||
invid <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
itmtree <- invRootTrees (_crInv cr) ^? ix itRef
|
||||
itmloc <- allInvLocs (_crInv cr) ^? ix invid
|
||||
let itm = itmtree ^. ldtValue . _1
|
||||
case itmtree ^. ldtValue . _2 of
|
||||
itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
|
||||
let usedloc = case itmloc ^. locLDT . ldtValue . _1 . itUseFocus of
|
||||
UseFromLocation -> itmloc ^. locLDT
|
||||
UseFromRoot -> locToTop itmloc ^. locLDT
|
||||
let itm = usedloc ^. ldtValue . _1
|
||||
case usedloc ^. ldtValue . _2 of
|
||||
HeldPlatformSF ->
|
||||
return $
|
||||
heldEffect (bimap _iatType fst3 itmtree) cr w
|
||||
@@ -33,10 +37,11 @@ useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMayb
|
||||
return $
|
||||
heldEffect (bimap _iatType fst3 itmtree) cr w
|
||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
EquipmentPlatformSF -> do
|
||||
--EquipmentPlatformSF -> do
|
||||
_ | isJust $ itm ^? itUse . uequipEffect -> do
|
||||
guard (_crHammerPosition cr == HammerUp)
|
||||
invid <- itm ^? itLocation . ilInvID
|
||||
return $ toggleEquipmentAt invid cr w
|
||||
invid' <- itm ^? itLocation . ilInvID
|
||||
return $ toggleEquipmentAt invid' cr w
|
||||
_ -> Nothing
|
||||
where
|
||||
fst3 (x,_,_) = x
|
||||
|
||||
@@ -5,7 +5,6 @@ module Dodge.Creature.LtAutoCrit (
|
||||
import Control.Lens
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Default
|
||||
import Dodge.Item.Consumable
|
||||
import Dodge.Item.Held.Stick
|
||||
import qualified IntMapHelp as IM
|
||||
import Picture
|
||||
@@ -13,7 +12,7 @@ import Picture
|
||||
ltAutoCrit :: Creature
|
||||
ltAutoCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, autoPistol), (1, medkit 100)]
|
||||
{ _crInv = IM.fromList [(0, autoPistol)]
|
||||
, _crRad = 10
|
||||
, _crHP = 500
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ module Dodge.Creature.PistolCrit (
|
||||
import Control.Lens
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Default
|
||||
import Dodge.Item.Consumable
|
||||
import Dodge.Item.Held.Stick
|
||||
import qualified IntMapHelp as IM
|
||||
import Picture
|
||||
@@ -13,7 +12,7 @@ import Picture
|
||||
pistolCrit :: Creature
|
||||
pistolCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, pistol), (1, medkit 100)]
|
||||
{ _crInv = IM.fromList [(0, pistol)]
|
||||
, _crRad = 10
|
||||
, _crHP = 500
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ module Dodge.Creature.SpreadGunCrit (
|
||||
import Control.Lens
|
||||
import Dodge.Data.Creature
|
||||
import Dodge.Default
|
||||
import Dodge.Item.Consumable
|
||||
import Dodge.Item.Held.Stick
|
||||
import qualified IntMapHelp as IM
|
||||
import Picture
|
||||
@@ -13,7 +12,7 @@ import Picture
|
||||
spreadGunCrit :: Creature
|
||||
spreadGunCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, bangStick 6), (1, medkit 100)]
|
||||
{ _crInv = IM.fromList [(0, bangStick 6)]
|
||||
, _crRad = 10
|
||||
, _crHP = 500
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ data Consumables
|
||||
|
||||
data Item = Item
|
||||
{ _itUse :: ItemUse
|
||||
, _itUseCondition :: UseCondition
|
||||
, _itUseFocus :: UseFocus
|
||||
, _itConsumables :: Consumables
|
||||
, _itType :: ItemType
|
||||
, _itID :: NewInt ItmInt
|
||||
|
||||
@@ -16,7 +16,6 @@ data ItemType
|
||||
= HELD {_ibtHeld :: HeldItemType}
|
||||
-- | LEFT {_ibtLeft :: LeftItemType}
|
||||
| EQUIP {_ibtEquip :: EquipItemType}
|
||||
| CONSUMABLE {_ibtConsumable :: ConsumableItemType}
|
||||
| CRAFT {_ibtCraft :: CraftType}
|
||||
| ATTACH {_ibtAttach :: AttachType}
|
||||
| AMMOMAG {_ibtAmmoMag :: AmmoMagType}
|
||||
|
||||
@@ -37,13 +37,9 @@ data ItemUse
|
||||
{ _heldDelay :: UseDelay
|
||||
, _heldHammer :: HammerPosition
|
||||
, _heldAim :: AimParams
|
||||
-- , _heldAmmoTypes :: IM.IntMap AmmoType
|
||||
, _heldParams :: HeldParams
|
||||
, _heldTriggerType :: TriggerType
|
||||
, _useCondition :: UseCondition
|
||||
, _useFocus :: UseFocus
|
||||
}
|
||||
| UseConsume { _cUse :: Cuse }
|
||||
| UseEquip { _uequipEffect :: EquipEffect }
|
||||
| UseAttach {_uaParams :: AttachParams}
|
||||
| UseNothing
|
||||
|
||||
@@ -24,9 +24,10 @@ import Picture
|
||||
|
||||
defaultEquipment :: Item
|
||||
defaultEquipment = defaultHeldItem & itUse .~ defaultEquipUse
|
||||
& itUseFocus .~ UseFromLocation
|
||||
|
||||
defaultFlIt :: FloorItem
|
||||
defaultFlIt = FlIt{_flItRot = 0, _flIt = defaultConsumable, _flItPos = V2 0 0, _flItID = 0}
|
||||
defaultFlIt = FlIt{_flItRot = 0, _flIt = defaultHeldItem, _flItPos = V2 0 0, _flItID = 0}
|
||||
|
||||
defaultMachine :: Machine
|
||||
defaultMachine =
|
||||
|
||||
@@ -2,9 +2,8 @@ module Dodge.Default.Item (
|
||||
defaultHeldItem,
|
||||
singleAmmo,
|
||||
defaultBulletWeapon,
|
||||
-- defaultLeftItem,
|
||||
-- defaultLeftItem,
|
||||
defaultCraftItem,
|
||||
defaultConsumable,
|
||||
module Dodge.Default.Item.Use,
|
||||
) where
|
||||
|
||||
@@ -26,6 +25,8 @@ defaultHeldItem =
|
||||
, _itLocation = InVoid
|
||||
, _itUse = defaultHeldUse
|
||||
, _itParams = NoParams
|
||||
, _itUseCondition = MustBeHeld
|
||||
, _itUseFocus = UseFromRoot
|
||||
}
|
||||
|
||||
--defaultLeftItem :: Item
|
||||
@@ -43,9 +44,6 @@ defaultBulletWeapon =
|
||||
& itAmmoSlots .~ singleAmmo BulletAmmo
|
||||
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.01 0 PistolFlare MuzzleShootBullet (UseExactly 1)]
|
||||
|
||||
defaultConsumable :: Item
|
||||
defaultConsumable = defaultHeldItem & itUse .~ UseConsume CDoNothing
|
||||
|
||||
defaultItEffect :: ItEffect
|
||||
defaultItEffect =
|
||||
ItEffect
|
||||
|
||||
@@ -42,6 +42,4 @@ defaultHeldUse = UseHeld
|
||||
, _weaponRepeat = []
|
||||
}
|
||||
, _heldTriggerType = HammerTrigger
|
||||
, _useCondition = MustBeHeld
|
||||
, _useFocus = UseFromRoot
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ newHotkey lw = fromMaybe maxBound $
|
||||
-- to swap with instead
|
||||
assignHotkey :: Int -> Hotkey -> LWorld -> LWorld
|
||||
assignHotkey invid hk lw = fromMaybe lw $ do
|
||||
guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUse . useCondition
|
||||
guard $ lw ^? creatures . ix 0 . crInv . ix invid . itUseCondition
|
||||
== Just UseableAnytime
|
||||
return $ (setHotkey invid hk . moveOldHotkey invid hk) lw
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
module Dodge.Item (
|
||||
module Dodge.Item.Weapon,
|
||||
module Dodge.Item.Held,
|
||||
module Dodge.Item.Consumable,
|
||||
module Dodge.Item.Equipment,
|
||||
module Dodge.Item.Craftable,
|
||||
itemFromBase,
|
||||
@@ -11,7 +10,6 @@ module Dodge.Item (
|
||||
|
||||
import Dodge.Data.Item
|
||||
import Dodge.Item.Ammo
|
||||
import Dodge.Item.Consumable
|
||||
import Dodge.Item.Craftable
|
||||
import Dodge.Item.Equipment
|
||||
import Dodge.Item.Held
|
||||
@@ -23,7 +21,6 @@ itemFromBase = \case
|
||||
HELD ht -> itemFromHeldType ht
|
||||
-- LEFT lt -> itemFromLeftType lt
|
||||
EQUIP et -> itemFromEquipType et
|
||||
CONSUMABLE et -> itemFromConsumableType et
|
||||
CRAFT cr -> makeTypeCraft cr
|
||||
ATTACH at -> itemFromAttachType at
|
||||
AMMOMAG t -> itemFromAmmoMag t
|
||||
@@ -48,11 +45,6 @@ itemFromAttachType at = case at of
|
||||
HOMINGMODULE -> homingModule
|
||||
AUGMENTEDHUD -> augmentedHUD
|
||||
|
||||
itemFromConsumableType :: ConsumableItemType -> Item
|
||||
itemFromConsumableType ct = case ct of
|
||||
MEDKIT i -> medkit i
|
||||
EXPLOSIVES -> undefined
|
||||
|
||||
itemFromEquipType :: EquipItemType -> Item
|
||||
itemFromEquipType et = case et of
|
||||
MAGSHIELD -> magShield
|
||||
|
||||
@@ -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
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -4,7 +4,6 @@ import qualified Data.Set as S
|
||||
import Dodge.Cleat
|
||||
import Dodge.Data.GenWorld
|
||||
import Dodge.Default.Room
|
||||
import Dodge.Item.Consumable
|
||||
import Dodge.LevelGen.PlacementHelper
|
||||
import Dodge.Placement.Instance
|
||||
import Dodge.Placement.Instance.Analyser
|
||||
@@ -96,7 +95,7 @@ healthTest n = do
|
||||
return $
|
||||
treePost
|
||||
[ door
|
||||
, corridor & rmPmnts .:~ psPtPl (PS 20 0) (PutFlIt (medkit 100))
|
||||
, corridor -- & rmPmnts .:~ psPtPl (PS 20 0) (PutFlIt (medkit 100))
|
||||
, cenroom
|
||||
, triggerDoorRoom n
|
||||
, cleatOnward door
|
||||
|
||||
Reference in New Issue
Block a user