Remove data Hammers
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -15,14 +15,14 @@ import Dodge.HeldUse
|
||||
--import Dodge.Hotkey
|
||||
import Dodge.Inventory
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Item.Location
|
||||
--import Dodge.Item.Location
|
||||
import qualified IntMapHelp as IM
|
||||
|
||||
useItem :: Int -> PressType -> World -> World
|
||||
useItem invid pt w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
|
||||
usedloc <- useLocation' itmloc
|
||||
usedloc <- useLocation itmloc
|
||||
useItemLoc cr usedloc pt w
|
||||
|
||||
useItemLoc :: Creature -> LocationLDT ItemLink ComposedItem -> PressType
|
||||
@@ -30,15 +30,15 @@ useItemLoc :: Creature -> LocationLDT ItemLink ComposedItem -> PressType
|
||||
useItemLoc cr loc pt w = case loc ^. locLDT . ldtValue . _2 of
|
||||
HeldPlatformSF ->
|
||||
return $
|
||||
heldEffect (bimap _iatType (^. _1) ldt) cr w
|
||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
heldEffect pt (bimap _iatType (^. _1) ldt) cr w
|
||||
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
GadgetPlatformSF ->
|
||||
return $
|
||||
heldEffect (bimap _iatType (^. _1) ldt) cr w
|
||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
heldEffect pt (bimap _iatType (^. _1) ldt) cr w
|
||||
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
RemoteDetonatorSF -> do
|
||||
return $ activateDetonator ldt w
|
||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
_ | isJust $ itm ^? itUse . uequipEffect -> do
|
||||
invid' <- itm ^? itLocation . ilInvID
|
||||
return $ toggleEquipmentAt invid' cr w
|
||||
@@ -47,9 +47,9 @@ useItemLoc cr loc pt w = case loc ^. locLDT . ldtValue . _2 of
|
||||
ldt = loc ^. locLDT
|
||||
itm = ldt ^. ldtValue . _1
|
||||
|
||||
useLocation' :: LocationLDT ItemLink ComposedItem
|
||||
useLocation :: LocationLDT ItemLink ComposedItem
|
||||
-> Maybe (LocationLDT ItemLink ComposedItem)
|
||||
useLocation' loc
|
||||
useLocation loc
|
||||
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uequipEffect = return loc
|
||||
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apLinkedProjectile . _Just
|
||||
= return loc
|
||||
@@ -57,34 +57,34 @@ useLocation' loc
|
||||
= return loc
|
||||
| otherwise = return $ locToTop loc
|
||||
|
||||
useSelectedItem :: Int -> World -> World
|
||||
useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||
invid <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
|
||||
let usedloc = case useLocation itmloc of
|
||||
UseFromLocation -> itmloc ^. locLDT
|
||||
UseFromRoot -> locToTop itmloc ^. locLDT
|
||||
let itm = usedloc ^. ldtValue . _1
|
||||
case usedloc ^. ldtValue . _2 of
|
||||
HeldPlatformSF ->
|
||||
return $
|
||||
heldEffect (bimap _iatType fst3 usedloc) cr w
|
||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
GadgetPlatformSF ->
|
||||
return $
|
||||
heldEffect (bimap _iatType fst3 usedloc) cr w
|
||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
RemoteDetonatorSF -> do
|
||||
return $ activateDetonator usedloc w
|
||||
& pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
_ | isJust $ itm ^? itUse . uequipEffect -> do
|
||||
-- guard (_crHammerPosition cr == HammerUp)
|
||||
invid' <- itm ^? itLocation . ilInvID
|
||||
return $ toggleEquipmentAt invid' cr w
|
||||
_ -> Nothing
|
||||
where
|
||||
fst3 (x, _, _) = x
|
||||
--useSelectedItem :: Int -> World -> World
|
||||
--useSelectedItem crid w = (worldEventFlags . at InventoryChange ?~ ()) . fromMaybe w $ do
|
||||
-- cr <- w ^? cWorld . lWorld . creatures . ix crid
|
||||
-- invid <- cr ^? crManipulation . manObject . imSelectedItem
|
||||
-- itmloc <- allInvLocs (_crInv cr) ^? ix invid . _2
|
||||
-- let usedloc = case useLocation itmloc of
|
||||
-- UseFromLocation -> itmloc ^. locLDT
|
||||
-- UseFromRoot -> locToTop itmloc ^. locLDT
|
||||
-- let itm = usedloc ^. ldtValue . _1
|
||||
-- case usedloc ^. ldtValue . _2 of
|
||||
-- HeldPlatformSF ->
|
||||
-- return $
|
||||
-- heldEffect (bimap _iatType fst3 usedloc) cr w
|
||||
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
-- GadgetPlatformSF ->
|
||||
-- return $
|
||||
-- heldEffect (bimap _iatType fst3 usedloc) cr w
|
||||
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
-- RemoteDetonatorSF -> do
|
||||
-- return $ activateDetonator usedloc w
|
||||
-- & pointerToItem itm . itUse . heldHammer .~ HammerDown
|
||||
-- _ | isJust $ itm ^? itUse . uequipEffect -> do
|
||||
---- guard (_crHammerPosition cr == HammerUp)
|
||||
-- invid' <- itm ^? itLocation . ilInvID
|
||||
-- return $ toggleEquipmentAt invid' cr w
|
||||
-- _ -> Nothing
|
||||
-- where
|
||||
-- fst3 (x, _, _) = x
|
||||
|
||||
activateDetonator ::
|
||||
LabelDoubleTree ItemLink ComposedItem ->
|
||||
@@ -94,15 +94,6 @@ activateDetonator det = fromMaybe id $ do
|
||||
pjid <- det ^? ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0
|
||||
return $ cWorld . lWorld . projectiles . ix pjid . pjTimer .~ 0
|
||||
|
||||
useLocation :: LocationLDT ItemLink ComposedItem -> UseFocus
|
||||
useLocation loc
|
||||
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uequipEffect = UseFromLocation
|
||||
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apLinkedProjectile . _Just =
|
||||
UseFromLocation
|
||||
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0 =
|
||||
UseFromLocation
|
||||
| otherwise = UseFromRoot
|
||||
|
||||
toggleEquipmentAt :: Int -> Creature -> World -> World
|
||||
toggleEquipmentAt invid cr w = case getEquipmentAllocation w of
|
||||
DoNotMoveEquipment -> w
|
||||
|
||||
@@ -21,7 +21,6 @@ import Dodge.Data.DoubleTree
|
||||
import Dodge.Data.World
|
||||
import Dodge.DoubleTree
|
||||
import Dodge.Euse
|
||||
import Dodge.Hammer
|
||||
import Dodge.ItEffect
|
||||
import Dodge.Item.Grammar
|
||||
import Dodge.Item.HeldOffset
|
||||
@@ -123,9 +122,7 @@ poisonSPic = over _1 $ overColSH (mixColors 0.5 0.5 green . normalizeColor)
|
||||
internalCreatureUpdate :: Creature -> World -> World
|
||||
internalCreatureUpdate cr =
|
||||
cWorld . lWorld . creatures . ix (_crID cr)
|
||||
%~ ( --(crHammerPosition %~ moveHammerUp).
|
||||
updateMovement
|
||||
)
|
||||
%~ updateMovement
|
||||
|
||||
{- | Drop items according to the creature state.
|
||||
TODO make sure this doesn't mess up any ItemPosition
|
||||
@@ -432,10 +429,10 @@ itemUpdate = itUse %~ useUpdate
|
||||
|
||||
useUpdate :: ItemUse -> ItemUse
|
||||
useUpdate =
|
||||
(heldHammer %~ moveHammerUp)
|
||||
-- (heldHammer %~ moveHammerUp)
|
||||
-- . (leftHammer %~ moveHammerUp)
|
||||
-- . (leftDelay . rateTime %~ decreaseToZero)
|
||||
. (heldDelay . warmTime %~ decreaseToZero)
|
||||
(heldDelay . warmTime %~ decreaseToZero)
|
||||
. (heldDelay . rateTime %~ decreaseToZero)
|
||||
|
||||
--updateAutoRecharge :: Item -> Item
|
||||
|
||||
@@ -43,19 +43,20 @@ handleHotkeys w
|
||||
|| SDL.ScancodeRShift `M.member` _pressedKeys (_input w) =
|
||||
foldl' tryAssignHotkey w allHotkeys
|
||||
| otherwise =
|
||||
foldl'
|
||||
M.foldl'
|
||||
useHotkey
|
||||
w
|
||||
(M.intersection thehotkeys (M.filter (== InitialPress) (w ^. input . pressedKeys)))
|
||||
(M.intersectionWith (,) thehotkeys (w ^. input . pressedKeys))
|
||||
where
|
||||
thehotkeys = M.mapKeys hotkeyToScancode $ w ^. cWorld . lWorld . hotkeys
|
||||
|
||||
useHotkey :: World -> NewInt ItmInt -> World
|
||||
useHotkey w (NInt itid) = fromMaybe w $ do
|
||||
useHotkey :: World -> (NewInt ItmInt,PressType) -> World
|
||||
useHotkey w (NInt itid,pt) = fromMaybe w $ do
|
||||
invid <- w ^? cWorld . lWorld . itemLocations . ix itid . ilInvID
|
||||
cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
itmloc <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
|
||||
return $ heldEffectNoHammerCheck (bimap (^. iatType) (^. _1) itmloc) cr w
|
||||
return $ useItem invid pt w
|
||||
-- cr <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
-- itmloc <- allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
|
||||
-- return $ heldEffectNoHammerCheck (bimap (^. iatType) (^. _1) itmloc) cr w
|
||||
|
||||
allHotkeys :: [SDL.Scancode]
|
||||
allHotkeys = map hotkeyToScancode [minBound .. maxBound]
|
||||
@@ -176,8 +177,6 @@ pressedMBEffectsTopInventory pkeys w
|
||||
| Just ltime <- pkeys ^? ix SDL.ButtonLeft
|
||||
, Just rtime <- pkeys ^? ix SDL.ButtonRight
|
||||
, ltime <= rtime && inTopInv =
|
||||
--youhammerdown $
|
||||
--useSelectedItem 0 w
|
||||
fromMaybe w $ do
|
||||
invid <- w ^? cWorld . lWorld . creatures . ix 0
|
||||
. crManipulation . manObject . imSelectedItem
|
||||
|
||||
@@ -11,7 +11,6 @@ module Dodge.Data (
|
||||
module Dodge.Data.Material,
|
||||
module Dodge.Data.GenWorld,
|
||||
module Dodge.Data.Universe,
|
||||
module Dodge.Data.Hammer,
|
||||
module MaybeHelp,
|
||||
module Dodge.Data.RoomCluster,
|
||||
module Dodge.Data.Room,
|
||||
@@ -32,7 +31,6 @@ import Dodge.Data.CrWlID
|
||||
import Dodge.Data.CreatureEffect
|
||||
import Dodge.Data.Distortion
|
||||
import Dodge.Data.GenWorld
|
||||
import Dodge.Data.Hammer
|
||||
import Dodge.Data.Material
|
||||
import Dodge.Data.MountedObject
|
||||
import Dodge.Data.ObjectType
|
||||
|
||||
@@ -14,7 +14,6 @@ module Dodge.Data.Creature (
|
||||
module Dodge.Data.ActionPlan,
|
||||
module Dodge.Data.Item,
|
||||
module Dodge.Data.Material,
|
||||
module Dodge.Data.Hammer,
|
||||
) where
|
||||
|
||||
import Control.Lens
|
||||
@@ -27,7 +26,6 @@ import Dodge.Data.Creature.Misc
|
||||
import Dodge.Data.Creature.Perception
|
||||
import Dodge.Data.Creature.Stance
|
||||
import Dodge.Data.Creature.State
|
||||
import Dodge.Data.Hammer
|
||||
import Dodge.Data.Item
|
||||
import Dodge.Data.Material
|
||||
import Geometry.Data
|
||||
@@ -66,7 +64,6 @@ data Creature = Creature
|
||||
, _crGroup :: CrGroup
|
||||
, _crIntention :: Intention
|
||||
, _crMvType :: CrMvType
|
||||
-- , _crHammerPosition :: HammerPosition
|
||||
, _crName :: String
|
||||
, _crStatistics :: CreatureStatistics
|
||||
, _crDeathTimer :: Int
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
{-# LANGUAGE DeriveGeneric #-}
|
||||
{-# LANGUAGE DeriveAnyClass #-}
|
||||
{-# LANGUAGE StrictData #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
|
||||
module Dodge.Data.Hammer where
|
||||
|
||||
import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
|
||||
data HammerType
|
||||
= NoHammer
|
||||
| HasHammer {_hammerPosition :: HammerPosition}
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
data HammerPosition
|
||||
= HammerDown
|
||||
| HammerReleased
|
||||
| HammerUp
|
||||
deriving (Eq, Ord, Show, Read) --Generic, Flat)
|
||||
|
||||
makeLenses ''HammerType
|
||||
deriveJSON defaultOptions ''HammerPosition
|
||||
deriveJSON defaultOptions ''HammerType
|
||||
@@ -9,7 +9,6 @@ module Dodge.Data.Item.Use (
|
||||
module Dodge.Data.Item.HeldUse,
|
||||
module Dodge.Data.Item.HeldDelay,
|
||||
module Dodge.Data.Item.Use.Consumption,
|
||||
module Dodge.Data.Hammer,
|
||||
module Dodge.Data.Item.Targeting,
|
||||
module Dodge.Data.GenFloat,
|
||||
module Dodge.Data.Item.Scope,
|
||||
@@ -22,7 +21,6 @@ import Control.Lens
|
||||
import Data.Aeson
|
||||
import Data.Aeson.TH
|
||||
import Dodge.Data.GenFloat
|
||||
import Dodge.Data.Hammer
|
||||
import Dodge.Data.Item.HeldDelay
|
||||
import Dodge.Data.Item.HeldUse
|
||||
import Dodge.Data.Item.Targeting
|
||||
@@ -34,7 +32,6 @@ import Sound.Data
|
||||
data ItemUse
|
||||
= UseHeld
|
||||
{ _heldDelay :: UseDelay
|
||||
, _heldHammer :: HammerPosition
|
||||
, _heldAim :: AimParams
|
||||
, _heldParams :: HeldParams
|
||||
, _heldTriggerType :: TriggerType
|
||||
@@ -43,7 +40,6 @@ data ItemUse
|
||||
}
|
||||
| UseEquip { _uequipEffect :: EquipEffect }
|
||||
| UseAttach {_uaParams :: AttachParams}
|
||||
| UseHammer {_heldHammer :: HammerPosition}
|
||||
| UseNothing
|
||||
| UseScope { _uScope :: Scope }
|
||||
| UseBulletMod { _ubMod :: BulletMod }
|
||||
|
||||
@@ -9,7 +9,6 @@ module Dodge.Data.World (
|
||||
module Dodge.Data.CWorld,
|
||||
module Dodge.Data.RightButtonOptions,
|
||||
module Dodge.Data.SoundOrigin,
|
||||
module Dodge.Data.Hammer,
|
||||
module Dodge.Data.Input,
|
||||
) where
|
||||
|
||||
@@ -20,7 +19,6 @@ import Data.IntSet (IntSet)
|
||||
import qualified Data.Map.Strict as M
|
||||
import Data.Set (Set)
|
||||
import Dodge.Data.CWorld
|
||||
import Dodge.Data.Hammer
|
||||
import Dodge.Data.Input
|
||||
import Dodge.Data.RightButtonOptions
|
||||
import Dodge.Data.SaveSlot
|
||||
|
||||
@@ -73,8 +73,8 @@ defaultPP =
|
||||
, _ppText = "Pressure plate"
|
||||
}
|
||||
|
||||
upHammer :: HammerType
|
||||
upHammer = HasHammer HammerUp
|
||||
--upHammer :: HammerType
|
||||
--upHammer = HasHammer HammerUp
|
||||
|
||||
defaultProximitySensor :: Sensor
|
||||
defaultProximitySensor =
|
||||
|
||||
@@ -26,7 +26,7 @@ defaultEquipUse = UseEquip
|
||||
defaultHeldUse :: ItemUse
|
||||
defaultHeldUse = UseHeld
|
||||
{ _heldDelay = FixedRate{_rateMax = 8, _rateTime = 0}
|
||||
, _heldHammer = HammerUp
|
||||
-- , _heldHammer = HammerUp
|
||||
, _heldAim = defaultAimParams
|
||||
, _heldParams = BulletShooterParams
|
||||
{ _muzVel = ConstFloat 0.8
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
module Dodge.Hammer where
|
||||
|
||||
import Dodge.Data.Hammer
|
||||
|
||||
moveHammerUp :: HammerPosition -> HammerPosition
|
||||
{-# INLINE moveHammerUp #-}
|
||||
moveHammerUp HammerDown = HammerReleased
|
||||
moveHammerUp _ = HammerUp
|
||||
+91
-55
@@ -7,9 +7,8 @@ module Dodge.HeldUse (
|
||||
mcUseHeld,
|
||||
) where
|
||||
|
||||
import Control.Applicative
|
||||
import Dodge.Item.Weapon.Bullet
|
||||
import Color
|
||||
import Control.Applicative
|
||||
import Control.Monad
|
||||
import Data.Maybe
|
||||
import Dodge.Base.Collide
|
||||
@@ -22,6 +21,7 @@ import Dodge.Data.World
|
||||
import Dodge.Gas
|
||||
import Dodge.Inventory.Lock
|
||||
import Dodge.Item.HeldOffset
|
||||
import Dodge.Item.Weapon.Bullet
|
||||
import Dodge.Item.Weapon.Shatter
|
||||
import Dodge.Projectile.Create
|
||||
import Dodge.RadarSweep
|
||||
@@ -35,8 +35,13 @@ import Picture.Base
|
||||
import RandomHelp
|
||||
import qualified SDL
|
||||
|
||||
heldEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
heldEffect = hammerCheck heldEffectNoHammerCheck
|
||||
heldEffect ::
|
||||
PressType ->
|
||||
LabelDoubleTree ComposeLinkType Item ->
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
heldEffect pt = hammerCheck pt heldEffectNoHammerCheck
|
||||
|
||||
heldEffectNoHammerCheck ::
|
||||
LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
@@ -49,12 +54,18 @@ type ChainEffect =
|
||||
World ->
|
||||
World
|
||||
|
||||
hammerCheck :: ChainEffect
|
||||
hammerCheck f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
|
||||
Just HammerTrigger | nomakeauto
|
||||
-> case w ^? input . mouseButtons . ix SDL.ButtonLeft of
|
||||
Just 0 -> f it cr w
|
||||
_ -> w
|
||||
hammerCheck ::
|
||||
PressType ->
|
||||
(LabelDoubleTree ComposeLinkType Item -> t1 -> t2 -> t2) ->
|
||||
LabelDoubleTree ComposeLinkType Item ->
|
||||
t1 ->
|
||||
t2 ->
|
||||
t2
|
||||
hammerCheck pt f it cr w = case it ^? ldtValue . itUse . heldTriggerType of
|
||||
Just HammerTrigger | nomakeauto ->
|
||||
case pt of
|
||||
InitialPress -> f it cr w
|
||||
_ -> w
|
||||
_ -> f it cr w
|
||||
where
|
||||
nomakeauto = isNothing $ lookup MakeAutoLink (it ^. ldtRight)
|
||||
@@ -88,26 +99,34 @@ useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
|
||||
heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
heldEffectMuzzles t cr w =
|
||||
doHeldUseEffect t cr $
|
||||
uncurry (applyCME (_ldtValue t) cr) cmew
|
||||
-- & cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles
|
||||
& doWeaponRepetitions upitm cr
|
||||
uncurry (applyCME (_ldtValue t) cr) cmew
|
||||
-- & cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles
|
||||
& doWeaponRepetitions upitm cr
|
||||
where
|
||||
muzzles = t ^. ldtValue . itUse . heldAim . aimMuzzles
|
||||
(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
|
||||
cmew = foldl' (useLoadedAmmo t cr) (CME 0 0 False, w) $ zip [0 ..] loadedmuzzles
|
||||
|
||||
doHeldUseEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
|
||||
doHeldUseEffect t cr w = case t ^? ldtValue . itUse . heldUseEffect of
|
||||
Just (RandomiseMuzzleFrames x) -> fromMaybe w $ do
|
||||
i <- t ^? ldtValue . itLocation . ilInvID
|
||||
let g = w ^. randGen
|
||||
(is,g') = runState (shuffle [0..x-1]) g
|
||||
return $ w & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i . itUse . heldAim . aimMuzzles %~ zipWith (\j mz -> mz & mzFrame .~ j) is
|
||||
& randGen .~ g'
|
||||
(is, g') = runState (shuffle [0 .. x -1]) g
|
||||
return $
|
||||
w & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i . itUse . heldAim . aimMuzzles %~ zipWith (\j mz -> mz & mzFrame .~ j) is
|
||||
& randGen .~ g'
|
||||
Just SwitchAlteRifle -> fromMaybe w $ do
|
||||
i <- t ^? ldtValue . itLocation . ilInvID
|
||||
return $ w & cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
|
||||
. itUse . heldAim . aimMuzzles . ix 0 . mzAmmoSlot %~ ((`mod` 2) . (+1))
|
||||
return $
|
||||
w
|
||||
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
|
||||
. itUse
|
||||
. heldAim
|
||||
. aimMuzzles
|
||||
. ix 0
|
||||
. mzAmmoSlot
|
||||
%~ ((`mod` 2) . (+ 1))
|
||||
Just NoHeldUseEffect -> w
|
||||
Nothing -> w
|
||||
|
||||
@@ -117,7 +136,7 @@ doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponR
|
||||
Just xs -> cWorld . lWorld . delayedEvents .++~ map f xs
|
||||
_ -> id
|
||||
where
|
||||
f x = (x,WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
|
||||
f x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffect)
|
||||
upitm x =
|
||||
itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
|
||||
& ldtValue . itUse . heldTriggerType .~ AutoTrigger
|
||||
@@ -300,8 +319,14 @@ useLoadedAmmo itmtree cr (cme, w) (mzid, Just (mz, x, magtree)) = (,) (cme & cme
|
||||
MuzzleTesla -> shootTeslaArc itm cr mz w
|
||||
MuzzleTractor -> shootTractorBeam cr w
|
||||
MuzzleRLauncher -> createProjectileR itmtree magtree mz cr w
|
||||
MuzzleGLauncher -> createProjectile (Grenade (GBounce 2)) magtree
|
||||
(getPJStabiliser itmtree) mz cr w
|
||||
MuzzleGLauncher ->
|
||||
createProjectile
|
||||
(Grenade (GBounce 2))
|
||||
magtree
|
||||
(getPJStabiliser itmtree)
|
||||
mz
|
||||
cr
|
||||
w
|
||||
MuzzleNozzle{} -> useGasParams mid mz itm cr $ walkNozzle mzid mz itm cr w
|
||||
MuzzleShatter -> shootShatter itm cr w
|
||||
MuzzleDetector -> itemDetectorEffect itm cr w
|
||||
@@ -409,25 +434,25 @@ removeAmmoFromMag x mid cr = fromMaybe id $ do
|
||||
-~ x
|
||||
|
||||
getBulletType ::
|
||||
-- LabelDoubleTree ComposeLinkType Item ->
|
||||
-- LabelDoubleTree ComposeLinkType Item ->
|
||||
LabelDoubleTree ComposeLinkType Item ->
|
||||
-- Muzzle ->
|
||||
-- Creature ->
|
||||
-- World ->
|
||||
-- Muzzle ->
|
||||
-- Creature ->
|
||||
-- World ->
|
||||
Maybe Bullet
|
||||
--getBulletType itmtree magtree mz cr w =
|
||||
getBulletType magtree =
|
||||
magtree ^? ldtValue . itConsumables . magParams . ampBullet
|
||||
-- <&> buTrajectory .~ btraj
|
||||
-- <&> buTrajectory .~ btraj
|
||||
<&> buPayload .~ bpayload
|
||||
<&> buEffect .~ beffect
|
||||
where
|
||||
-- btraj = fromMaybe BasicBulletTrajectory $ do
|
||||
-- targetingtree <- lookup WeaponTargetingLink (itmtree ^. ldtRight) -- left or right for these?
|
||||
-- tp <- targetingtree ^? ldtValue . itTargeting . itTgPos . _Just
|
||||
-- attree <- lookup AmmoTargetingLink (magtree ^. ldtLeft)
|
||||
-- bt <- attree ^? ldtValue . itUse . ubMod . bmTrajectory
|
||||
-- return $ getBulletTrajectory mz (itmtree ^. ldtValue) bt tp cr w
|
||||
-- btraj = fromMaybe BasicBulletTrajectory $ do
|
||||
-- targetingtree <- lookup WeaponTargetingLink (itmtree ^. ldtRight) -- left or right for these?
|
||||
-- tp <- targetingtree ^? ldtValue . itTargeting . itTgPos . _Just
|
||||
-- attree <- lookup AmmoTargetingLink (magtree ^. ldtLeft)
|
||||
-- bt <- attree ^? ldtValue . itUse . ubMod . bmTrajectory
|
||||
-- return $ getBulletTrajectory mz (itmtree ^. ldtValue) bt tp cr w
|
||||
bpayload = fromMaybe BulSpark $ do
|
||||
attree <- lookup AmmoPayloadLink (magtree ^. ldtLeft)
|
||||
attree ^? ldtValue . itUse . ubMod . bmPayload
|
||||
@@ -462,7 +487,7 @@ shootBullet ::
|
||||
World ->
|
||||
World
|
||||
shootBullet itmtree cr (mz, x, magtree) w = fromMaybe w $ do
|
||||
-- thebullet <- getBulletType itmtree magtree mz cr w
|
||||
-- thebullet <- getBulletType itmtree magtree mz cr w
|
||||
thebullet <- getBulletType magtree
|
||||
return $ foldl' (&) w (replicate x (makeBullet' thebullet (itmtree ^. ldtValue) cr mz))
|
||||
|
||||
@@ -566,17 +591,24 @@ mcShootLaser _ mc = cWorld . lWorld . lasers .:~ lasRayAt yellow dam phasev pos
|
||||
|
||||
mcShootAuto :: Item -> Machine -> World -> World
|
||||
mcShootAuto itm mc w
|
||||
| Just (FixedRate x 0) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay
|
||||
= w & cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
|
||||
. itUse . heldDelay . rateTime .~ x
|
||||
| Just (FixedRate x 0) <- mc ^? mcType . mctTurret . tuWeapon . itUse . heldDelay =
|
||||
w
|
||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
|
||||
. itUse
|
||||
. heldDelay
|
||||
. rateTime
|
||||
.~ x
|
||||
& makeBullet defaultBullet itm pos dir
|
||||
| otherwise
|
||||
= w & cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
|
||||
. itUse . heldDelay . rateTime -~ 1
|
||||
| otherwise =
|
||||
w
|
||||
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
|
||||
. itUse
|
||||
. heldDelay
|
||||
. rateTime
|
||||
-~ 1
|
||||
where
|
||||
pos = _mcPos mc +.+ 20 *.* unitVectorAtAngle dir
|
||||
dir = mc ^?! mcType . _McTurret . tuDir
|
||||
|
||||
|
||||
-- | assumes that the item is held
|
||||
shootTeslaArc :: Item -> Creature -> Muzzle -> World -> World
|
||||
@@ -595,8 +627,9 @@ determineProjectileTracking ::
|
||||
LabelDoubleTree ComposeLinkType Item ->
|
||||
LabelDoubleTree ComposeLinkType Item ->
|
||||
RocketHoming
|
||||
determineProjectileTracking magtree itmtree = fromMaybe NoHoming $
|
||||
finddronecontrols <|> findexternaltracking
|
||||
determineProjectileTracking magtree itmtree =
|
||||
fromMaybe NoHoming $
|
||||
finddronecontrols <|> findexternaltracking
|
||||
where
|
||||
finddronecontrols = do
|
||||
screen <- lookup RemoteScreenLink (magtree ^. ldtLeft)
|
||||
@@ -615,23 +648,23 @@ createProjectileR ::
|
||||
World ->
|
||||
World
|
||||
createProjectileR itmtree magtree =
|
||||
createProjectile
|
||||
(Rocket
|
||||
createProjectile
|
||||
( Rocket
|
||||
(determineProjectileTracking magtree itmtree)
|
||||
smoke
|
||||
) magtree
|
||||
)
|
||||
magtree
|
||||
(getPJStabiliser itmtree)
|
||||
where
|
||||
smoke
|
||||
smoke
|
||||
| isJust $ lookup SmokeReducerLink (magtree ^. ldtLeft) = Just ReducedRocketSmoke
|
||||
| otherwise = Nothing
|
||||
|
||||
|
||||
getPJStabiliser :: LabelDoubleTree ComposeLinkType Item -> Maybe PJStabiliser
|
||||
getPJStabiliser ldt = case lookup ProjectileStabiliserLink (ldt ^. ldtRight) of
|
||||
Just ldt' -> case ldt' ^? ldtValue . itType . ibtAttach of
|
||||
Just GIMBAL -> Just StabOrthReduce
|
||||
Just GYROSCOPE -> Just StabSpinIncrease
|
||||
Just GYROSCOPE -> Just StabSpinIncrease
|
||||
_ -> Nothing
|
||||
_ -> Nothing
|
||||
|
||||
@@ -646,12 +679,15 @@ createProjectile ::
|
||||
createProjectile pjtype magtree stab muz cr = fromMaybe failsound $ do
|
||||
magid <- magtree ^? ldtValue . itLocation . ilInvID
|
||||
ammoitem <- cr ^? crInv . ix magid
|
||||
let rdetonate = (^. ldtValue . itID) <$>
|
||||
lookup RemoteDetonatorLink (magtree ^. ldtLeft)
|
||||
rscreen = (^. ldtValue . itID) <$>
|
||||
lookup RemoteScreenLink (magtree ^. ldtLeft)
|
||||
aparams <- ((magtree ^? ldtLeft) >>= lookup AmmoPayloadLink >>= (^? ldtValue . itType . ibtAttach . shellPayload))
|
||||
<|> ammoitem ^? itConsumables . magParams . ampPayload
|
||||
let rdetonate =
|
||||
(^. ldtValue . itID)
|
||||
<$> lookup RemoteDetonatorLink (magtree ^. ldtLeft)
|
||||
rscreen =
|
||||
(^. ldtValue . itID)
|
||||
<$> lookup RemoteScreenLink (magtree ^. ldtLeft)
|
||||
aparams <-
|
||||
((magtree ^? ldtLeft) >>= lookup AmmoPayloadLink >>= (^? ldtValue . itType . ibtAttach . shellPayload))
|
||||
<|> ammoitem ^? itConsumables . magParams . ampPayload
|
||||
return $
|
||||
createShell rdetonate rscreen stab pjtype aparams muz cr
|
||||
. startthesound
|
||||
|
||||
@@ -73,7 +73,7 @@ remoteScreen = makeAttach REMOTESCREEN
|
||||
|
||||
remoteDetonator :: Item
|
||||
remoteDetonator = makeAttach REMOTEDETONATOR
|
||||
& itUse .~ UseHammer HammerUp
|
||||
-- & itUse .~ UseHammer HammerUp
|
||||
& itUse . uaParams .~ APProjectiles []
|
||||
|
||||
joystick :: Item
|
||||
|
||||
@@ -5,6 +5,7 @@ module Dodge.WorldEffect (
|
||||
lineOutputTerminal,
|
||||
) where
|
||||
|
||||
import Dodge.Data.Input
|
||||
import Dodge.HeldUse
|
||||
import Dodge.Data.ComposedItem
|
||||
import Dodge.Data.DoubleTree
|
||||
@@ -43,7 +44,7 @@ doWdWd we = case we of
|
||||
|
||||
doItCrWdWd :: ItCrWdWd -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
|
||||
doItCrWdWd icww = case icww of
|
||||
ItCrWdItemHeldEffect -> heldEffect
|
||||
ItCrWdItemHeldEffect -> heldEffect InitialPress
|
||||
|
||||
accessTerminal :: Maybe Int -> World -> World
|
||||
accessTerminal mtmid w = fromMaybe w $ do
|
||||
|
||||
Reference in New Issue
Block a user