Allow for item use when not root
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user