Move towards positional item targeting

This commit is contained in:
2023-05-19 23:03:52 +01:00
parent 7cb17034f8
commit 2d3b76dfd4
8 changed files with 29 additions and 19 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ moduleModification imt = case imt of
. (itUse . heldConsumption . laAmmoType . amBullet . buTimer .~ 3) . (itUse . heldConsumption . laAmmoType . amBullet . buTimer .~ 3)
BULPAY thepayload -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ thepayload BULPAY thepayload -> itUse . heldConsumption . laAmmoType . amBullet . buSpawn .~ thepayload
BULBODY thebody -> itUse . heldConsumption . laAmmoType . amBullet . buEffect .~ thebody BULBODY thebody -> itUse . heldConsumption . laAmmoType . amBullet . buEffect .~ thebody
TARGET t -> itUse . useTargeting ?~ t TARGET {} -> id -- itUse . useTargeting ?~ t
BULTRAJ BasicBulletTrajectoryType -> id BULTRAJ BasicBulletTrajectoryType -> id
BULTRAJ MagnetTrajectoryType -> BULTRAJ MagnetTrajectoryType ->
(itUse . heldConsumption . laAmmoType . amBullet . buTrajectory .~ MagnetTrajectory 0) (itUse . heldConsumption . laAmmoType . amBullet . buTrajectory .~ MagnetTrajectory 0)
@@ -38,7 +38,7 @@ moduleModification imt = case imt of
where where
makeDirectedTele it = makeDirectedTele it =
it it
& itUse . useTargeting ?~ TargetRBPress -- & itUse . useTargeting ?~ TargetRBPress
& itUse . heldMods %~ ModWithDirectedTeleport -- .:~ withPosDirWallCheck directedTelPos & itUse . heldMods %~ ModWithDirectedTeleport -- .:~ withPosDirWallCheck directedTelPos
-- for the camera: the simplest option is to remove all zoom/offset -- for the camera: the simplest option is to remove all zoom/offset
& itUse . heldAim . aimZoom . izFac .~ 1 & itUse . heldAim . aimZoom . izFac .~ 1
+16 -9
View File
@@ -3,6 +3,7 @@ module Dodge.Creature.State (
doDamage, doDamage,
) where ) where
import Control.Applicative
import Data.Foldable import Data.Foldable
import Data.Maybe import Data.Maybe
import Dodge.Base import Dodge.Base
@@ -15,7 +16,7 @@ import Dodge.Creature.Test
import Dodge.Damage import Dodge.Damage
import Dodge.Data.World import Dodge.Data.World
import Dodge.EnergyBall import Dodge.EnergyBall
import Dodge.Equipment --import Dodge.Equipment
import Dodge.Euse import Dodge.Euse
import Dodge.Hammer import Dodge.Hammer
import Dodge.ItEffect import Dodge.ItEffect
@@ -271,14 +272,20 @@ updateAutoRecharge it = case it ^? itUse . leftConsumption of
crGetTargeting :: Creature -> Maybe TargetType crGetTargeting :: Creature -> Maybe TargetType
crGetTargeting cr = do crGetTargeting cr = do
itm <- find hastargeting $ helditem ++ IM.elems (getCrEquipment cr) i <- cr ^? crManipulation . manObject . inInventory . ispItem
itm ^? itUse . useTargeting . _Just itm <- cr ^? crInv . ix i
where itm ^? itType . iyModules . ix ModTarget . imtTargetType
hastargeting itm = isJust (itm ^? itUse . useTargeting . _Just) <|> cr ^? crInv . ix (i+1) . itUse . equipTargeting . _Just
helditem = fromMaybe [] $ do
i <- cr ^? crManipulation . manObject . inInventory . ispItem
itm <- cr ^? crInv . ix i -- itm <- find hastargeting $ helditem ++ IM.elems (getCrEquipment cr)
return [itm] -- itm ^? itUse . useTargeting . _Just
-- where
-- hastargeting itm = isJust (itm ^? itUse . useTargeting . _Just)
-- helditem = fromMaybe [] $ do
-- i <- cr ^? crManipulation . manObject . inInventory . ispItem
-- itm <- cr ^? crInv . ix i
-- return [itm]
weaponReloadSounds :: Creature -> World -> World weaponReloadSounds :: Creature -> World -> World
weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory . iselAction of weaponReloadSounds cr w = case cr ^? crManipulation . manObject . inInventory . iselAction of
+2 -1
View File
@@ -191,7 +191,7 @@ data ItemModuleType
| BULPAY BulletSpawn | BULPAY BulletSpawn
| BULBODY BulletEffect | BULBODY BulletEffect
| BULTRAJ BulletTrajectoryType | BULTRAJ BulletTrajectoryType
| TARGET TargetType | TARGET {_imtTargetType :: TargetType}
| INCENDLAS | INCENDLAS
| SPLITLAS | SPLITLAS
| STATICLAS | STATICLAS
@@ -224,6 +224,7 @@ data ModuleSlot
makeLenses ''ItemType makeLenses ''ItemType
makeLenses ''ItemBaseType makeLenses ''ItemBaseType
makeLenses ''HeldItemType makeLenses ''HeldItemType
makeLenses ''ItemModuleType
deriveJSON defaultOptions ''Stack deriveJSON defaultOptions ''Stack
deriveJSON defaultOptions ''CraftType deriveJSON defaultOptions ''CraftType
deriveJSON defaultOptions ''ConsumableItemType deriveJSON defaultOptions ''ConsumableItemType
+2 -2
View File
@@ -34,7 +34,7 @@ data ItemUse
, _heldAim :: AimParams , _heldAim :: AimParams
, _heldScroll :: HeldScroll , _heldScroll :: HeldScroll
, _heldConsumption :: HeldConsumption , _heldConsumption :: HeldConsumption
, _useTargeting :: Maybe TargetType -- , _useTargeting :: Maybe TargetType
} }
| LeftUse | LeftUse
{ _leftUse :: Luse { _leftUse :: Luse
@@ -49,7 +49,7 @@ data ItemUse
} }
| EquipUse | EquipUse
{ _equipEffect :: EquipEffect { _equipEffect :: EquipEffect
, _useTargeting :: Maybe TargetType , _equipTargeting :: Maybe TargetType
} }
| CraftUse | CraftUse
{_useAmount :: ItAmount} {_useAmount :: ItAmount}
+2 -2
View File
@@ -23,7 +23,7 @@ defaultLeftUse =
defaultEquipUse :: ItemUse defaultEquipUse :: ItemUse
defaultEquipUse = EquipUse defaultEquipUse = EquipUse
{ _equipEffect = defaultEquip { _equipEffect = defaultEquip
, _useTargeting = Nothing , _equipTargeting = Nothing
} }
defaultHeldUse :: ItemUse defaultHeldUse :: ItemUse
@@ -36,5 +36,5 @@ defaultHeldUse =
, _heldAim = defaultAimParams , _heldAim = defaultAimParams
, _heldScroll = HeldScrollDoNothing , _heldScroll = HeldScrollDoNothing
, _heldConsumption = defaultLoadable , _heldConsumption = defaultLoadable
, _useTargeting = Nothing -- , _useTargeting = Nothing
} }
+1 -1
View File
@@ -111,7 +111,7 @@ targetingHat tt =
defaultEquipment defaultEquipment
& itUse . equipEffect . eeSite .~ GoesOnHead & itUse . equipEffect . eeSite .~ GoesOnHead
& itType . iyBase .~ EQUIP (TARGETINGHAT tt) & itType . iyBase .~ EQUIP (TARGETINGHAT tt)
& itUse . useTargeting ?~ tt -- & itUse . useTargeting ?~ tt
headLamp :: Item headLamp :: Item
headLamp = headLamp =
+2 -1
View File
@@ -72,7 +72,8 @@ sniperRifle =
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5,_izFac = 1} & itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 0.5, _izMin = 0.5,_izFac = 1}
& itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun & itUse . heldScroll .~ HeldScrollZoom -- zoomLongGun
& itScope .~ ZoomScope (V2 0 0) 1 0.5 False & itScope .~ ZoomScope (V2 0 0) 1 0.5 False
& itUse . useTargeting ?~ TargetLaser & itType . iyModules . at ModTarget ?~ TARGET TargetLaser
-- & itUse . useTargeting ?~ TargetLaser
machineGun :: Item machineGun :: Item
machineGun = machineGun =
+2 -1
View File
@@ -52,7 +52,8 @@ torch =
forceFieldGun :: Item forceFieldGun :: Item
forceFieldGun = forceFieldGun =
defaultWeapon defaultWeapon
& itUse . useTargeting ?~ TargetRBLine -- & itUse . useTargeting ?~ TargetRBLine
& itType . iyModules . at ModTarget ?~ TARGET TargetRBLine
& itParams .~ ParamMID Nothing & itParams .~ ParamMID Nothing
& itUse . heldUse .~ HeldForceField --useForceFieldGun & itUse . heldUse .~ HeldForceField --useForceFieldGun
& itUse . heldDelay .~ NoDelay & itUse . heldDelay .~ NoDelay