Fix burst rifle rate delay bug, various cleanups

This commit is contained in:
2025-06-25 23:47:41 +01:00
parent 1bdf426c42
commit 5b35b4c6c8
19 changed files with 440 additions and 469 deletions
+4 -8
View File
@@ -24,9 +24,8 @@ useItem invid pt w = fmap (worldEventFlags . at InventoryChange ?~ ()) $ do
let usedloc = useLocation itmloc
useItemLoc cr usedloc pt w
useItemLoc ::
Creature ->
LocationLDT ItemLink ComposedItem ->
useItemLoc :: Creature ->
LocationLDT ItemLink CItem ->
PressType ->
World ->
Maybe World
@@ -63,7 +62,7 @@ useItemLoc cr loc pt w
ldt = loc ^. locLDT
itm = ldt ^. ldtValue . _1
useLocation :: LocationLDT ItemLink ComposedItem -> LocationLDT ItemLink ComposedItem
useLocation :: LocationLDT ItemLink CItem -> LocationLDT ItemLink CItem
useLocation loc
| isJust $ loc ^? locLDT . ldtValue . _1 . itType . ibtEquip = loc
| isJust $ loc ^? locLDT . ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0 =
@@ -81,10 +80,7 @@ structureUseAtLoc = \case
MapperSF -> True
_ -> False
activateDetonator ::
LabelDoubleTree ItemLink ComposedItem ->
World ->
World
activateDetonator :: LabelDoubleTree ItemLink CItem -> World -> World
activateDetonator det = fromMaybe id $ do
pjid <- det ^? ldtValue . _1 . itUse . uaParams . apProjectiles . ix 0
return $ cWorld . lWorld . projectiles . ix pjid . pjTimer .~ 0
+11 -11
View File
@@ -149,7 +149,7 @@ invRootItemEffs cr =
(reduceLocLDT (Endo . invItemLocUpdate cr) . LocLDT TopLDT)
(invLDT (_crInv cr))
invItemLocUpdate :: Creature -> LocationLDT ItemLink ComposedItem -> World -> World
invItemLocUpdate :: Creature -> LocationLDT ItemLink CItem -> World -> World
invItemLocUpdate cr loc w = doAnyEquipmentEffect loc cr $ case itm ^. itType of
ATTACH BULLETSYNTH -> trySynthBullet loc w
EQUIP WRIST_ECG | haspulse -> tryUseParent loc w
@@ -175,21 +175,21 @@ copierItemUpdate itm cr w = fromMaybe w $ do
v <- getItemValue itm' w cr
return $ w & pointerToItem itm . itUse . uValue .~ v
doAnyEquipmentEffect :: LocationLDT ItemLink ComposedItem -> Creature -> World -> World
doAnyEquipmentEffect :: LocationLDT ItemLink CItem -> Creature -> World -> World
doAnyEquipmentEffect loc cr = case itm ^? itLocation . ilEquipSite . _Just of
Just _ -> equipBackgroundEffect loc cr
_ -> id
where
itm = loc ^. locLDT . ldtValue . _1
tryUseParent :: LocationLDT ItemLink ComposedItem -> World -> World
tryUseParent :: LocationLDT ItemLink CItem -> World -> World
tryUseParent loc w = fromMaybe w $ do
t <- locUp loc
let t' = bimap (^. iatType) (^. _1) $ t ^. locLDT
cr <- w ^? cWorld . lWorld . creatures . ix 0
return $ heldEffectNoHammerCheck t' cr w
trySynthBullet :: LocationLDT ItemLink ComposedItem -> World -> World
trySynthBullet :: LocationLDT ItemLink CItem -> World -> World
trySynthBullet loc w = fromMaybe w $ do
i <- itm ^? itLocation . ilInvID
x <- itm ^? itUse . uaParams . apInt
@@ -248,7 +248,7 @@ updateHeldRootItem cr = fromMaybe id $ do
itmtree <- invRootTrees (_crInv cr) ^? ix invid
return $ updateAttachedItems itmtree cr
updateAttachedItems :: LabelDoubleTree ItemLink ComposedItem -> Creature -> World -> World
updateAttachedItems :: LabelDoubleTree ItemLink CItem -> Creature -> World -> World
updateAttachedItems itmtree cr =
cldtPropagateFold
chainLinkOrientation
@@ -260,9 +260,9 @@ updateAttachedItems itmtree cr =
-- need to check rotation
chainLinkOrientation ::
(Point3, Q.Quaternion Float) ->
ComposedItem ->
CItem ->
ItemLink ->
ComposedItem ->
CItem ->
(Point3, Q.Quaternion Float)
chainLinkOrientation (p, q) par (ILink lt f) child = (p + Q.rotate q p1, q * q1)
where
@@ -271,7 +271,7 @@ chainLinkOrientation (p, q) par (ILink lt f) child = (p + Q.rotate q p1, q * q1)
updateItemWithOrientation ::
Creature ->
(Point3, Q.Quaternion Float) ->
LocationLDT ItemLink ComposedItem ->
LocationLDT ItemLink CItem ->
World ->
World
updateItemWithOrientation cr m loc@(LocLDT _ itmtree) w =
@@ -285,7 +285,7 @@ updateItemWithOrientation cr m loc@(LocLDT _ itmtree) w =
ci = itmtree ^. ldtValue
itm = ci ^. _1
drawARHUD :: LocationLDT ItemLink ComposedItem -> World -> World
drawARHUD :: LocationLDT ItemLink CItem -> World -> World
drawARHUD (LocLDT con _) w = fromMaybe w $ do
itm <- con ^? cldtParent . _1
return $
@@ -295,7 +295,7 @@ drawARHUD (LocLDT con _) w = fromMaybe w $ do
shineTargetLaser ::
Creature ->
LabelDoubleTree ItemLink ComposedItem ->
LabelDoubleTree ItemLink CItem ->
(Point3, Q.Quaternion Float) ->
World ->
World
@@ -336,7 +336,7 @@ shineTargetLaser cr itmtree (p, q) w = fromMaybe (w & pointittarg . itTgPos .~ N
shineTorch ::
Creature ->
LabelDoubleTree ItemLink ComposedItem ->
LabelDoubleTree ItemLink CItem ->
(Point3, Q.Quaternion Float) ->
World ->
World
+10 -10
View File
@@ -12,7 +12,7 @@ import Dodge.Data.Item
import Geometry.Data
import Linear.Quaternion (Quaternion (..))
data ComposeLinkType
data CLinkType
= AmmoInLink Int AmmoType
| TriggerLink
| AmmoModLink
@@ -65,29 +65,29 @@ data ItemStructuralFunction
| MapperSF
deriving (Eq, Ord, Show, Read)
type ComposedItem = (Item, ItemStructuralFunction, LinkTest)
type CItem = (Item, ItemStructuralFunction, LinkTest)
data ItemLink = ILink
{ _iatType :: ComposeLinkType
, _iatOrient :: Item -> ComposeLinkType -> Item -> (Point3, Quaternion Float)
{ _iatType :: CLinkType
, _iatOrient :: Item -> CLinkType -> Item -> (Point3, Quaternion Float)
}
-- this should possibly use a full item structure tree rather than a
-- ComposedItem as arguments
-- CItem as arguments
data LinkTest = LTest
{ _tryLeftLink :: LabelDoubleTree ItemLink ComposedItem -> Maybe LinkUpdate
, _tryRightLink :: LabelDoubleTree ItemLink ComposedItem -> Maybe LinkUpdate
{ _tryLeftLink :: LabelDoubleTree ItemLink CItem -> Maybe LinkUpdate
, _tryRightLink :: LabelDoubleTree ItemLink CItem -> Maybe LinkUpdate
}
data LinkUpdate = LUpdate
{ _luLinkType :: ItemLink
, _luParentUpdate :: ComposedItem -> ComposedItem
, _luChildUpdate :: ComposedItem -> ComposedItem
, _luParentUpdate :: CItem -> CItem
, _luChildUpdate :: CItem -> CItem
}
makeLenses ''ItemLink
makeLenses ''LinkTest
makeLenses ''LinkUpdate
makeLenses ''ComposeLinkType
makeLenses ''CLinkType
--deriveJSON defaultOptions ''ItemStructuralFunction
--deriveJSON defaultOptions ''ComposeLinkType
-2
View File
@@ -25,7 +25,6 @@ import Dodge.Data.Item.BulletMod
import Dodge.Data.Item.Scope
import Dodge.Data.Item.Targeting
import Dodge.Data.Payload
--import Dodge.Data.Item.Use.Consumption
import Geometry.Data
data ItemUse
@@ -54,7 +53,6 @@ data AmmoParams
= BulletParams {_ampBullet :: Bullet}
| ProjectileParams {_ampPayload :: Payload}
| GasParams {_ampCreateGas :: GasFuel}
| NoAmmoParams
deriving (Eq, Show, Read) --Generic, Flat)
makeLenses ''ItemUse
+1 -1
View File
@@ -14,7 +14,7 @@ data Muzzle = Muzzle
, _mzFlareType :: FlareType
, _mzEffect :: MuzzleEffect
, _mzAmmoPerShot :: AmmoPerShot
, _mzFrame :: Int
-- , _mzFrame :: Int
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
+1 -1
View File
@@ -12,7 +12,7 @@ import Dodge.Wall.Move
import Geometry
import LensHelp
equipBackgroundEffect :: LocationLDT ItemLink ComposedItem -> Creature -> World -> World
equipBackgroundEffect :: LocationLDT ItemLink CItem -> Creature -> World -> World
equipBackgroundEffect loc cr = case eo of
EQUIP (MAGSHIELD mt) -> useMagShield mt itm cr
EQUIP WRISTARMOUR -> setWristShieldPos itm cr
+2
View File
@@ -21,6 +21,8 @@ updateFlame w pt
| _flTimer pt <= 0 = (makeCloudAt Smoke 200 (addZ 20 ep) w, Nothing)
| Just (_, Right wl) <- thit = (doupdate, Just $ reflame wl)
-- might want to move differently if we hit a creature?
| _flTimer pt <= 1 = (makeCloudAt Smoke 200 (addZ 20 ep) $ flFlicker pt doupdate
, Just mvflame)
| otherwise = (flFlicker pt doupdate, Just mvflame)
where
reflame wl = pt & flTimer -~ 1 & flVel %~ reflVelWallDamp 0.9 wl
+201 -207
View File
@@ -10,26 +10,26 @@ module Dodge.HeldUse (
heldEffectMuzzles,
) where
import Dodge.Creature.Radius
import Dodge.Creature.Mass
import Dodge.Data.Muzzle
import Dodge.Data.UseDelay
import Dodge.Item.UseDelay
import Dodge.Base
import Color
import Control.Applicative
import Control.Monad
import qualified Data.IntMap.Strict as IM
import Data.Maybe
import Dodge.Base
import Dodge.BaseTriggerType
import Dodge.Creature.Action
import Dodge.Creature.Mass
import Dodge.Creature.Radius
import Dodge.Data.ComposedItem
import Dodge.Data.DoubleTree
import Dodge.Data.Muzzle
import Dodge.Data.UseDelay
import Dodge.Data.World
import Dodge.Gas
import Dodge.Inventory.Lock
import Dodge.Inventory.Path
import Dodge.Item.HeldOffset
import Dodge.Item.UseDelay
import Dodge.Item.Weapon.Bullet
import Dodge.Item.Weapon.Shatter
import Dodge.Projectile.Create
@@ -45,12 +45,7 @@ import RandomHelp
import qualified SDL
import Sound.Data
gadgetEffect ::
PressType ->
LocationLDT ItemLink ComposedItem ->
Creature ->
World ->
World
gadgetEffect :: PressType -> LocationLDT ItemLink CItem -> Creature -> World -> World
gadgetEffect pt loc
| UseHeld{} <- loc ^. locLDT . ldtValue . _1 . itUse =
heldEffect
@@ -65,29 +60,23 @@ gadgetEffect pt loc
useInventoryPath pt i x loc
| otherwise = const id
heldEffect ::
PressType ->
LabelDoubleTree ComposeLinkType Item ->
Creature ->
World ->
World
heldEffect = hammerCheck heldEffectNoHammerCheck
heldEffect :: PressType -> LabelDoubleTree CLinkType Item -> Creature -> World -> World
heldEffect = useTimeCheck . hammerCheck heldEffectMuzzles
heldEffectNoHammerCheck ::
LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
heldEffectNoHammerCheck :: LabelDoubleTree CLinkType Item -> Creature -> World -> World
heldEffectNoHammerCheck = useTimeCheck heldEffectMuzzles
type ChainEffect =
(LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World) ->
LabelDoubleTree ComposeLinkType Item ->
(LabelDoubleTree CLinkType Item -> Creature -> World -> World) ->
LabelDoubleTree CLinkType Item ->
Creature ->
World ->
World
hammerCheck ::
(LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World) ->
(LabelDoubleTree CLinkType Item -> Creature -> World -> World) ->
PressType ->
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree CLinkType Item ->
Creature ->
World ->
World
@@ -106,11 +95,6 @@ hammerCheck f pt it cr
id
| otherwise = f it cr
where
-- g x = (x, WdWdFromItCrixWdWd (upitm x) (_crID cr) ItCrWdItemHeldEffectNoHammer)
-- upitm x =
-- it -- & ldtValue . itUse . heldParams . weaponRepeat .~ []
-- & ldtValue . itUse . heldFrame .~ x
g x = (x, WdWdBurstFireRepetition (_crID cr) (it ^?! ldtValue . itLocation . ilInvID))
-- | Applies a world effect after an item use cooldown check.
@@ -123,151 +107,163 @@ useTimeCheck f item cr w = case useDelay $ item ^. ldtValue of
| _wTime (_itParams $ _ldtValue item) < wm ->
w
& soundContinue (CrWeaponSound cid 0) (_crPos cr) ws (Just 2)
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime +~ 2
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime +~ 2
WarmUpNoDelay wm _ ->
f item cr w
-- & cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime .~ (wm + 1)
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itParams . wTime .~ (wm + 1)
NoDelay -> f item cr w
--Nothing -> w
where
lastused = item ^. ldtValue . itTimeLastUsed
cid = _crID cr
setUseRate =
--cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . rateTimeLastUsed
cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itTimeLastUsed
.~ w ^. cWorld . lWorld . lClock
-- the following is unsafe, but if ilInvID isn't correctly set we probably
-- will have problems elsewhere also
itRef = item ^?! ldtValue . itLocation . ilInvID
heldEffectMuzzles :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
heldEffectMuzzles :: LabelDoubleTree CLinkType Item -> Creature -> World -> World
heldEffectMuzzles t cr w =
doHeldUseEffect t cr
. uncurry (applyCME (_ldtValue t) cr)
. foldl' (useLoadedAmmo t cr) (False, w)
$ loadedmuzzles
where
-- & doWeaponRepetitions upitm cr
(_, loadedmuzzles) = mapAccumR loadMuzzle t . itemMuzzles $ t ^. ldtValue
--muzzles = t ^. ldtValue . itUse . heldMuzzles
muzzles = itemMuzzles $ t ^. ldtValue
--(upitm, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
(_, loadedmuzzles) = mapAccumR loadMuzzle t muzzles
itemMuzzles :: Item -> [Muzzle]
itemMuzzles itm = case itm ^. itType of
HELD ALTERIFLE -> dbwMuzzles & ix 0 . mzPos .~ V2 25 0
& ix 0 . mzAmmoSlot .~ _alteRifleSwitch (_itParams itm)
HELD ALTERIFLE ->
dbwMuzzles & ix 0 . mzPos .~ V2 25 0
& ix 0 . mzAmmoSlot .~ _alteRifleSwitch (_itParams itm)
HELD hit -> heldItemMuzzles hit
DETECTOR {} -> dbwMuzzles & ix 0 . mzEffect .~ MuzzleDetector
& ix 0 . mzAmmoPerShot .~ UseExactly 100
DETECTOR{} ->
dbwMuzzles & ix 0 . mzEffect .~ MuzzleDetector
& ix 0 . mzAmmoPerShot .~ UseExactly 100
_ -> []
heldItemMuzzles :: HeldItemType -> [Muzzle]
heldItemMuzzles = \case
BANGSTICK i -> [ Muzzle
(V2 10 0)
a
0.01
0
NoFlare
MuzzleShootBullet
(UseExactly 1)
0
| a <- spreadAroundCenter i baseStickSpread
]
& ix 0 . mzFlareType .~ NoLightFlare
& ix (i `div` 2) . mzFlareType .~ MiniGunFlare
& ix (i-1) . mzFlareType .~ NoLightFlare
PISTOL -> [Muzzle (V2 10 0) 0 0.05 0 BasicFlare MuzzleShootBullet (UseExactly 1) 0]
AUTOPISTOL -> [Muzzle (V2 20 0) 0 0 0 BasicFlare MuzzleShootBullet (UseExactly 1) 0]
SMG -> [Muzzle (V2 10 0) 0 0.05 0 BasicFlare MuzzleShootBullet (UseExactly 1) 0]
BANGSTICK i ->
[ Muzzle
(V2 10 0)
a
0.01
0
NoFlare
MuzzleShootBullet
(UseExactly 1)
-- 0
| a <- spreadAroundCenter i baseStickSpread
]
& ix 0 . mzFlareType .~ NoLightFlare
& ix (i `div` 2) . mzFlareType .~ BasicFlare
& ix (i -1) . mzFlareType .~ NoLightFlare
PISTOL -> [Muzzle (V2 10 0) 0 0.05 0 BasicFlare MuzzleShootBullet (UseExactly 1)]
AUTOPISTOL -> [Muzzle (V2 20 0) 0 0 0 BasicFlare MuzzleShootBullet (UseExactly 1)]
SMG -> [Muzzle (V2 10 0) 0 0.05 0 BasicFlare MuzzleShootBullet (UseExactly 1)]
RIFLE -> dbwMuzzles & ix 0 . mzPos .~ V2 25 0
BURSTRIFLE -> dbwMuzzles & ix 0 . mzPos .~ V2 25 0
& ix 0 . mzInaccuracy .~ 0.05
MINIGUNX i ->
replicate i
(Muzzle (V2 30 0) 0 0.05 0 MiniGunFlare MuzzleShootBullet (UseExactly 1) 0)
BANGROD -> dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
ELEPHANTGUN -> dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
& ix 0 . mzInaccuracy .~ 0.05
AMR -> dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
& ix 0 . mzInaccuracy .~ 0.05
AUTOAMR -> dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
& ix 0 . mzInaccuracy .~ 0.05
SNIPERRIFLE -> dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
& ix 0 . mzInaccuracy .~ 0
BANGCONE -> [Muzzle (V2 15 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15) 0]
BLUNDERBUSS -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15) 0]
GRAPECANNON _ -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15) 0]
BURSTRIFLE -> dbwMuzzles & ix 0 . mzPos .~ V2 25 0 & ix 0 . mzInaccuracy .~ 0.05
MINIGUNX i ->
replicate
i
(Muzzle (V2 30 0) 0 0.05 0 NoFlare MuzzleShootBullet (UseExactly 1))
& ix 0 . mzFlareType .~ MiniGunFlare
BANGROD ->
dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
ELEPHANTGUN ->
dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
& ix 0 . mzInaccuracy .~ 0.05
AMR ->
dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
& ix 0 . mzInaccuracy .~ 0.05
AUTOAMR ->
dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
& ix 0 . mzInaccuracy .~ 0.05
SNIPERRIFLE ->
dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzFlareType .~ HeavySmokeFlare
& ix 0 . mzInaccuracy .~ 0
BANGCONE -> [Muzzle (V2 15 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15)]
BLUNDERBUSS -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15)]
GRAPECANNON _ -> [Muzzle (V2 30 0) 0 0.5 0 BasicFlare MuzzleShootBullet (UseUpTo 15)]
TORCH -> dbwMuzzles & ix 0 . mzPos .~ V2 10 0
VOLLEYGUN i -> vgunMuzzles i
FLAMETHROWER -> flameMuzzles
FLAMESPITTER -> flameMuzzles & ix 0 . mzEffect . nzPressure .~ UniRandFloat 3 4
RLAUNCHER -> dbwMuzzles
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzEffect .~ MuzzleRLauncher
& ix 0 . mzPos .~ V2 20 0
GLAUNCHER -> dbwMuzzles
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzEffect .~ MuzzleGLauncher
& ix 0 . mzPos .~ V2 20 0
RLAUNCHER ->
dbwMuzzles
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzEffect .~ MuzzleRLauncher
& ix 0 . mzPos .~ V2 20 0
GLAUNCHER ->
dbwMuzzles
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzEffect .~ MuzzleGLauncher
& ix 0 . mzPos .~ V2 20 0
RLAUNCHERX i ->
getZipList
( ZipList [Muzzle (V2 20 0) a 0 | a <- take i [0, 2 * pi / fromIntegral i ..]]
<*> ZipList [0 ..]
<*> pure NoFlare
<*> pure MuzzleRLauncher
<*> pure (UseExactly 1)
<*> pure 0
)
LASER -> dbwMuzzles
& ix 0 . mzPos .~ V2 6 0
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzFlareType .~ LasGunFlare
& ix 0 . mzEffect .~ MuzzleLaser
TESLAGUN -> dbwMuzzles
& ix 0 . mzPos .~ V2 10 0
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzFlareType .~ TeslaGunFlare
& ix 0 . mzEffect .~ MuzzleTesla
TRACTORGUN -> dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzFlareType .~ NoFlare
& ix 0 . mzEffect .~ MuzzleTractor
SHATTERGUN -> dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzEffect .~ MuzzleShatter
BLINKER -> dbwMuzzles
& ix 0 . mzEffect .~ MuzzleBlink
& ix 0 . mzAmmoPerShot .~ UseExactly 10000000
BLINKERUNSAFE -> dbwMuzzles
& ix 0 . mzEffect .~ MuzzleUnsafeBlink
& ix 0 . mzAmmoPerShot .~ UseExactly 10000000
REWINDER -> dbwMuzzles
& ix 0 . mzEffect .~ MuzzleRewind
& ix 0 . mzAmmoPerShot .~ UseExactly 100000
TIMESTOPPER -> dbwMuzzles
& ix 0 . mzEffect .~ MuzzleStopper
& ix 0 . mzAmmoPerShot .~ UseExactly 100000
TIMESCROLLER -> dbwMuzzles
& ix 0 . mzEffect .~ MuzzleScroller
& ix 0 . mzAmmoPerShot .~ UseExactly 100000
_ -> [ Muzzle
getZipList
( ZipList [Muzzle (V2 20 0) a 0 | a <- take i [0, 2 * pi / fromIntegral i ..]]
<*> ZipList [0 ..]
<*> pure NoFlare
<*> pure MuzzleRLauncher
<*> pure (UseExactly 1)
)
LASER ->
dbwMuzzles
& ix 0 . mzPos .~ V2 6 0
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzFlareType .~ LasGunFlare
& ix 0 . mzEffect .~ MuzzleLaser
TESLAGUN ->
dbwMuzzles
& ix 0 . mzPos .~ V2 10 0
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzFlareType .~ TeslaGunFlare
& ix 0 . mzEffect .~ MuzzleTesla
TRACTORGUN ->
dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzFlareType .~ NoFlare
& ix 0 . mzEffect .~ MuzzleTractor
SHATTERGUN ->
dbwMuzzles
& ix 0 . mzPos .~ V2 30 0
& ix 0 . mzInaccuracy .~ 0
& ix 0 . mzEffect .~ MuzzleShatter
BLINKER ->
dbwMuzzles
& ix 0 . mzEffect .~ MuzzleBlink
& ix 0 . mzAmmoPerShot .~ UseExactly 10000000
BLINKERUNSAFE ->
dbwMuzzles
& ix 0 . mzEffect .~ MuzzleUnsafeBlink
& ix 0 . mzAmmoPerShot .~ UseExactly 10000000
REWINDER ->
dbwMuzzles
& ix 0 . mzEffect .~ MuzzleRewind
& ix 0 . mzAmmoPerShot .~ UseExactly 100000
TIMESTOPPER ->
dbwMuzzles
& ix 0 . mzEffect .~ MuzzleStopper
& ix 0 . mzAmmoPerShot .~ UseExactly 100000
TIMESCROLLER ->
dbwMuzzles
& ix 0 . mzEffect .~ MuzzleScroller
& ix 0 . mzAmmoPerShot .~ UseExactly 100000
_ ->
[ Muzzle
{ _mzPos = V2 20 0
, _mzRot = 0
, _mzInaccuracy = 0.05
@@ -275,7 +271,7 @@ heldItemMuzzles = \case
, _mzFlareType = NoFlare
, _mzEffect = MuzzleShootBullet
, _mzAmmoPerShot = UseExactly 1
, _mzFrame = 0
-- , _mzFrame = 0
}
]
@@ -283,49 +279,55 @@ baseStickSpread :: Float
baseStickSpread = 0.2
dbwMuzzles :: [Muzzle]
dbwMuzzles = [Muzzle (V2 15 0) 0 0.01 0 BasicFlare MuzzleShootBullet (UseExactly 1) 0]
dbwMuzzles = [Muzzle (V2 15 0) 0 0.01 0 BasicFlare MuzzleShootBullet (UseExactly 1)]
flameMuzzles :: [Muzzle]
flameMuzzles =
[ Muzzle (V2 18 0) 0 0 0 NoFlare MuzzleNozzle
[ Muzzle
(V2 18 0)
0
0
0
NoFlare
MuzzleNozzle
{ _nzPressure = ConstFloat 4
, _nzMaxWalkAngle = 0.2
, _nzWalkSpeed = 0.01
}
(UseExactly 1)
0
]
vgunMuzzles :: Int -> [Muzzle]
vgunMuzzles i =
getZipList
(ZipList [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 6]
<*> ZipList [0..i-1]
<*> pure MiniGunFlare
vgunMuzzles i =
getZipList
( ZipList [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 6]
<*> ZipList [0 .. i -1]
<*> pure BasicFlare
<*> pure MuzzleShootBullet
<*> pure (UseExactly 1)
<*> ZipList [0..i-1]
)
-- <*> ZipList [0 .. i -1]
)
doHeldUseEffect :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doHeldUseEffect :: LabelDoubleTree CLinkType Item -> Creature -> World -> World
doHeldUseEffect t cr w = case t ^. ldtValue . itType of
-- HELD (VOLLEYGUN 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 . heldMuzzles %~ zipWith (\j mz -> mz & mzFrame .~ j) is
-- & randGen .~ g'
-- HELD (VOLLEYGUN 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 . heldMuzzles %~ zipWith (\j mz -> mz & mzFrame .~ j) is
-- & randGen .~ g'
HELD ALTERIFLE -> fromMaybe w $ do
i <- t ^? ldtValue . itLocation . ilInvID
return $
w
& cWorld . lWorld . creatures . ix (_crID cr) . crInv . ix i
. itParams . alteRifleSwitch
-- . itUse
-- . heldMuzzles
-- . ix 0
-- . mzAmmoSlot
. itParams
. alteRifleSwitch
-- . itUse
-- . heldMuzzles
-- . ix 0
-- . mzAmmoSlot
%~ ((`mod` 2) . (+ 1))
_ -> w
@@ -624,11 +626,11 @@ heldTorqueAmount = \case
-- (Muzzle,Int,Int) = (muzzle, amountloaded, id of mag taken from)
loadMuzzle ::
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree CLinkType Item ->
Muzzle ->
(LabelDoubleTree ComposeLinkType Item, Maybe (Muzzle, Int, LabelDoubleTree ComposeLinkType Item))
(LabelDoubleTree CLinkType Item, Maybe (Muzzle, Int, LabelDoubleTree CLinkType Item))
loadMuzzle t@(LDT _ l _) mz = fromMaybe (t, Nothing) $ do
-- guard $ mz ^? mzFrame == t ^? ldtValue . itUse . heldFrame
-- guard $ mz ^? mzFrame == t ^? ldtValue . itUse . heldFrame
let as = _mzAmmoSlot mz
amamount = _mzAmmoPerShot mz
(i, (_, mag)) <- findWithIx (isAmmoIntLink as . fst) l
@@ -644,32 +646,29 @@ loadMuzzle t@(LDT _ l _) mz = fromMaybe (t, Nothing) $ do
, Just (mz, usedammo, mag)
)
makeMuzzleFlare :: Muzzle -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
makeMuzzleFlare :: Muzzle -> LabelDoubleTree CLinkType Item -> Creature -> World -> World
makeMuzzleFlare mz itmtree cr = case mz ^. mzFlareType of
NoFlare -> id
BasicFlare -> basicMuzFlare pos dir
NoLightFlare -> muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
MiniGunFlare ->
(cWorld . lWorld . lights .:~ LSParam (pos `v2z` 20) 100 (V3 1 1 0.5))
oddcheck (cWorld . lWorld . lights .:~ LSParam (pos `v2z` 20) 100 (V3 1 1 0.5))
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
HeavySmokeFlare -> basicMuzFlare pos dir
LasGunFlare ->
flareCircleAt (getLaserColor itmtree) 0.8 (pos `v2z` 20)
-- . ( cWorld . lWorld . tempLightSources
-- .:~ tlsTimeRadColPos 1 100 (xyzV4 $ getLaserColor itmtree) (pos `v2z` 10)
. ( cWorld . lWorld . lights
.:~ LSParam (pos `v2z` 10) 100 (xyzV4 $ getLaserColor itmtree)
)
TeslaGunFlare ->
cWorld . lWorld . lights
.:~ LSParam (pos `v2z` 10) 100 (V3 0 0 1)
TeslaGunFlare -> cWorld . lWorld . lights .:~ LSParam (pos `v2z` 10) 100 (V3 0 0 1)
where
-- .:~ tlsTimeRadColPos 1 100 (V3 0 0 1) (pos `v2z` 10)
itm = itmtree ^. ldtValue
(moff, mrot) = heldItemOrient2D itm cr (_mzPos mz) (_mzRot mz)
pos = _crPos cr + rotateV (_crDir cr) moff
dir = _crDir cr + mrot
oddcheck f w
| odd (w ^. cWorld . lWorld . lClock) = f w
| otherwise = w
--{-# OPTIONS -Wno-incomplete-uni-patterns #-}
muzFlareAt :: Color -> Point3 -> Float -> World -> World
@@ -678,13 +677,13 @@ muzFlareAt col tranv dir w =
& cWorld . lWorld . flares <>~ thepic
where
thepic =
setLayer BloomNoZWrite . translate3 tranv . color col . rotate dir . polygon $
setLayer BloomLayer . translate3 tranv . color col . rotate dir . polygon $
[ V2 0 0
, V2 a (- b)
, V2 c d
]
thestate = replicateM 4 $ state $ randomR (2, 20)
(a : b : c : d : _, g) = runState thestate $ _randGen w -- randomRs (2, 20) (_randGen w)
(a : b : c : d : _, g) = runState thestate $ _randGen w
flareCircleAt :: Color -> Float -> Point3 -> World -> World
flareCircleAt col alphax tranv =
@@ -696,13 +695,13 @@ flareCircleAt col alphax tranv =
)
-- previous phaseV parameters: 0.2, 1, 5
getLaserPhaseV :: LabelDoubleTree ComposeLinkType Item -> Float
getLaserPhaseV :: LabelDoubleTree CLinkType Item -> Float
getLaserPhaseV = const 1
getLaserDamage :: LabelDoubleTree ComposeLinkType Item -> LaserType
getLaserDamage :: LabelDoubleTree CLinkType Item -> LaserType
getLaserDamage = const (DamageLaser 11)
getLaserColor :: LabelDoubleTree ComposeLinkType Item -> Color
getLaserColor :: LabelDoubleTree CLinkType Item -> Color
getLaserColor = const yellow
basicMuzFlare :: Point2 -> Float -> World -> World
@@ -712,15 +711,15 @@ basicMuzFlare pos dir =
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
isAmmoIntLink :: Int -> ComposeLinkType -> Bool
isAmmoIntLink :: Int -> CLinkType -> Bool
isAmmoIntLink i (AmmoInLink j _) = i == j
isAmmoIntLink _ _ = False
useLoadedAmmo ::
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree CLinkType Item ->
Creature ->
(Bool, World) ->
Maybe (Muzzle, Int, LabelDoubleTree ComposeLinkType Item) ->
Maybe (Muzzle, Int, LabelDoubleTree CLinkType Item) ->
(Bool, World)
useLoadedAmmo _ _ (cme, w) Nothing = (cme, w)
useLoadedAmmo itmtree cr (_, w) (Just (mz, x, magtree)) = (,) True $
@@ -758,7 +757,7 @@ useLoadedAmmo itmtree cr (_, w) (Just (mz, x, magtree)) = (,) True $
getAttachedSFLink ::
ItemStructuralFunction ->
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree CLinkType Item ->
Maybe (NewInt ItmInt)
getAttachedSFLink sf = (^? ldtRight . folding (lookup (SFLink sf)) . ldtValue . itID)
@@ -819,7 +818,7 @@ tractorBeamAt pos outpos dir power =
d = unitVectorAtAngle dir * power
creatureShootLaser ::
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree CLinkType Item ->
Creature ->
Muzzle ->
World ->
@@ -875,7 +874,7 @@ removeAmmoFromMag x mid cr = fromMaybe id $ do
. _Just
-~ x
getBulletType :: LabelDoubleTree ComposeLinkType Item -> Maybe Bullet
getBulletType :: LabelDoubleTree CLinkType Item -> Maybe Bullet
getBulletType magtree =
--magtree ^? ldtValue . itConsumables . magParams . ampBullet
(magtree ^? ldtValue >>= magAmmoParams >>= (^? ampBullet))
@@ -898,7 +897,6 @@ getBulletType magtree =
magAmmoParams :: Item -> Maybe AmmoParams
magAmmoParams itm = case itm ^. itType of
EQUIP BATTERYPACK -> Just NoAmmoParams
EQUIP FUELPACK -> Just $ GasParams ChemFuel
AMMOMAG CHEMFUELPOUCH -> Just $ GasParams ChemFuel
EQUIP BULLETBELTPACK -> Just $ BulletParams defaultBullet
@@ -906,11 +904,7 @@ magAmmoParams itm = case itm ^. itType of
AMMOMAG TINMAG -> Just $ BulletParams defaultBullet
AMMOMAG DRUMMAG -> Just $ BulletParams defaultBullet
AMMOMAG BELTMAG -> Just $ BulletParams defaultBullet
AMMOMAG SHELLMAG -> Just $
ProjectileParams
{ _ampPayload = ExplosionPayload
}
AMMOMAG BATTERY -> Just NoAmmoParams
AMMOMAG SHELLMAG -> Just $ ProjectileParams ExplosionPayload
_ -> Nothing
--getBulletTrajectory ::
@@ -934,9 +928,9 @@ magAmmoParams itm = case itm ^. itType of
-- _ -> 0
shootBullet ::
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree CLinkType Item ->
Creature ->
(Muzzle, Int, LabelDoubleTree ComposeLinkType Item) ->
(Muzzle, Int, LabelDoubleTree CLinkType Item) ->
World ->
World
shootBullet itmtree cr (mz, x, magtree) w = fromMaybe w $ do
@@ -1196,9 +1190,9 @@ mcShootAuto itm mc w
w
& cWorld . lWorld . machines . ix (_mcID mc) . mcType . mctTurret . tuWeapon
. itTimeLastUsed
-- . itUse
-- . heldDelay
-- . rateTimeLastUsed
-- . itUse
-- . heldDelay
-- . rateTimeLastUsed
.~ w ^. cWorld . lWorld . lClock
& makeBullet defaultBullet itm pos dir
| otherwise = w
@@ -1221,8 +1215,8 @@ shootTeslaArc itm cr mz w =
dir = _crDir cr + mrot
determineProjectileTracking ::
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree CLinkType Item ->
LabelDoubleTree CLinkType Item ->
RocketHoming
determineProjectileTracking magtree itmtree =
fromMaybe NoHoming $
@@ -1238,8 +1232,8 @@ determineProjectileTracking magtree itmtree =
return $ HomeUsingTargeting (targetingtree ^. ldtValue . itID)
createProjectileR ::
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree CLinkType Item ->
LabelDoubleTree CLinkType Item ->
Muzzle ->
Creature ->
World ->
@@ -1257,7 +1251,7 @@ createProjectileR itmtree magtree =
| isJust $ lookup SmokeReducerLink (magtree ^. ldtLeft) = Just ReducedRocketSmoke
| otherwise = Nothing
getPJStabiliser :: LabelDoubleTree ComposeLinkType Item -> Maybe PJStabiliser
getPJStabiliser :: LabelDoubleTree CLinkType Item -> Maybe PJStabiliser
getPJStabiliser ldt = case lookup ProjectileStabiliserLink (ldt ^. ldtRight) of
Just ldt' -> case ldt' ^? ldtValue . itType . ibtAttach of
Just GIMBAL -> Just StabOrthReduce
@@ -1265,7 +1259,7 @@ getPJStabiliser ldt = case lookup ProjectileStabiliserLink (ldt ^. ldtRight) of
_ -> Nothing
_ -> Nothing
getGrenadeHitEffect :: LabelDoubleTree ComposeLinkType Item -> GrenadeHitEffect
getGrenadeHitEffect :: LabelDoubleTree CLinkType Item -> GrenadeHitEffect
getGrenadeHitEffect t = case lookup GrenadeHitEffectLink (t ^. ldtRight) of
Just ldt' -> case ldt' ^? ldtValue . itType of
Just STICKYMOD -> GStick
@@ -1274,7 +1268,7 @@ getGrenadeHitEffect t = case lookup GrenadeHitEffectLink (t ^. ldtRight) of
createProjectile ::
ProjectileType ->
LabelDoubleTree ComposeLinkType Item ->
LabelDoubleTree CLinkType Item ->
Maybe PJStabiliser ->
Muzzle ->
Creature ->
@@ -1291,7 +1285,7 @@ createProjectile pjtype magtree stab muz cr = fromMaybe failsound $ do
<$> lookup RemoteScreenLink (magtree ^. ldtLeft)
aparams <-
((magtree ^? ldtLeft) >>= lookup AmmoPayloadLink >>= (^? ldtValue . itType . ibtAttach . shellPayload))
-- <|> ammoitem ^? itConsumables . magParams . ampPayload
-- <|> ammoitem ^? itConsumables . magParams . ampPayload
<|> magAmmoParams ammoitem ^? _Just . ampPayload
return $
createShell rdetonate rscreen stab pjtype aparams muz cr
@@ -1354,7 +1348,7 @@ useRewindGun i =
dropInventoryPath ::
Int ->
InventoryPathing ->
LocationLDT ItemLink ComposedItem ->
LocationLDT ItemLink CItem ->
Creature ->
World ->
World
@@ -1380,7 +1374,7 @@ useInventoryPath ::
PressType ->
Int ->
InventoryPathing ->
LocationLDT ItemLink ComposedItem ->
LocationLDT ItemLink CItem ->
Creature ->
World ->
World
+3 -3
View File
@@ -29,7 +29,7 @@ import NewInt
import Padding
import Picture.Base
invSelectionItem :: World -> Int -> LocationLDT ItemLink ComposedItem -> SelectionItem ()
invSelectionItem :: World -> Int -> LocationLDT ItemLink CItem -> SelectionItem ()
invSelectionItem w indent loc =
SelectionItem
{ _siPictures = itemDisplay w cr ci
@@ -46,7 +46,7 @@ invSelectionItem w indent loc =
-- note the convoluted display of the hotkey/equipment, this was done to avoid a
-- space leak
itemDisplay :: World -> Creature -> ComposedItem -> [String]
itemDisplay :: World -> Creature -> CItem -> [String]
itemDisplay w cr ci = -- f
basicItemDisplay itm
-- (itemNumberDisplay w cr ci)
@@ -152,7 +152,7 @@ itemScrollValue itm = Left <$> itm ^? itScroll . failing itsInt itsRangeInt
-- | rs == "" = ls
-- | otherwise = midPadL 15 ' ' ls (' ' : rs)
--itemNumberDisplay :: World -> Creature -> ComposedItem -> [String]
--itemNumberDisplay :: World -> Creature -> CItem -> [String]
--itemNumberDisplay w cr ci
-- | Just x <- ci ^? _1 . itUse . uInt = [show x]
-- | Just x <- ci ^? _1 . itUse . useToggle = [show x]
+1 -1
View File
@@ -15,7 +15,7 @@ import Dodge.Item.Draw.SPic
import Dodge.Item.HeldOffset
import ShapePicture
itemEquipPict :: Creature -> LabelDoubleTree ItemLink ComposedItem -> SPic
itemEquipPict :: Creature -> LabelDoubleTree ItemLink CItem -> SPic
itemEquipPict cr itmtree
| Just i <- itm ^? itLocation . ilInvID
, Just esite <- cr ^? crInv . ix i . itLocation . ilEquipSite . _Just
+2 -3
View File
@@ -20,13 +20,12 @@ import Picture
import Shape
import ShapePicture
itemTreeSPic :: LabelDoubleTree ItemLink ComposedItem -> SPic
itemTreeSPic :: LabelDoubleTree ItemLink CItem -> SPic
itemTreeSPic (LDT (itm,_,_) l r) =
itemSPic itm
<> foldMap (itemRotTreeSPic itm) (l <> r)
itemRotTreeSPic :: Item -> (ItemLink, LabelDoubleTree ItemLink ComposedItem)
-> SPic
itemRotTreeSPic :: Item -> (ItemLink, LabelDoubleTree ItemLink CItem) -> SPic
itemRotTreeSPic par (il, t) = translateSP p . overPosSP (Q.rotate q) $ itemTreeSPic t
where
(p, q) = _iatOrient il par (_iatType il) itm
+27 -27
View File
@@ -29,14 +29,14 @@ import LensHelp
import ListHelp
tryAttachItems ::
LabelDoubleTree ItemLink ComposedItem ->
LabelDoubleTree ItemLink ComposedItem ->
Maybe (LabelDoubleTree ItemLink ComposedItem)
LabelDoubleTree ItemLink CItem ->
LabelDoubleTree ItemLink CItem ->
Maybe (LabelDoubleTree ItemLink CItem)
tryAttachItems = leftRightCombine leftIsParentCombine rightIsParentCombine
useBreakL ::
[(ItemStructuralFunction, ComposeLinkType)] ->
[(ItemStructuralFunction, ComposeLinkType)] ->
[(ItemStructuralFunction, CLinkType)] ->
[(ItemStructuralFunction, CLinkType)] ->
LinkTest
useBreakL x y = useBreakListsLinkTest (map (uncurry noa) x) (map (uncurry noa) y)
where
@@ -68,7 +68,7 @@ useBreakListsLinkTest llist rlist = LTest ltest rtest
itemToBreakLists ::
Item ->
ItemStructuralFunction ->
([(ItemStructuralFunction, ComposeLinkType)], [(ItemStructuralFunction, ComposeLinkType)])
([(ItemStructuralFunction, CLinkType)], [(ItemStructuralFunction, CLinkType)])
itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
(HELD TORCH, _) -> (getAmmoLinks itm, [])
(ATTACH UNDERBARRELSLOT, _) -> ([(UnderBarrelPlatformSF, UnderBarrelPlatformLink)], [])
@@ -118,12 +118,12 @@ itemToBreakLists itm itmf = case (itm ^. itType, itmf) of
([(AmmoMagSF ElectricalAmmo, AmmoInLink 0 ElectricalAmmo)], [])
_ -> ([], [])
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
getAutoSpringLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
getAutoSpringLinks itm = case baseTriggerType itm of
HammerTrigger -> [(MakeAutoSF, MakeAutoLink)]
_ -> []
extraWeaponLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
extraWeaponLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
extraWeaponLinks itm = case itm ^. itType of
HELD GLAUNCHER -> launcherlinks <> [(GrenadeHitEffectSF,GrenadeHitEffectLink)]
HELD RLAUNCHER -> launcherlinks
@@ -132,14 +132,14 @@ extraWeaponLinks itm = case itm ^. itType of
where
launcherlinks = [(ProjectileStabiliserSF,ProjectileStabiliserLink)]
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
extraWeaponLinksBelow :: Item -> [(ItemStructuralFunction, CLinkType)]
extraWeaponLinksBelow itm
-- | Just TwoHandUnder <- itm ^? itUse . heldAim . aimStance
| TwoHandUnder <- aStance itm
= [(UnderBarrelSlotSF,UnderBarrelSlotLink)]
| otherwise = []
getAmmoLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
getAmmoLinks :: Item -> [(ItemStructuralFunction, CLinkType)]
getAmmoLinks itm =
map
(\(i, a) -> (AmmoMagSF a, AmmoInLink i a))
@@ -181,7 +181,7 @@ itemToFunction itm = case itm ^. itType of
_ -> NoSF
structureToPotentialFunction ::
LabelDoubleTree ItemLink ComposedItem ->
LabelDoubleTree ItemLink CItem ->
S.Set ItemStructuralFunction
structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
STICKYMOD -> S.singleton GrenadeHitEffectSF
@@ -190,7 +190,7 @@ structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
HELD GLAUNCHER -> S.singleton UnderBarrelPlatformSF
_ -> S.singleton (ldt ^. ldtValue . _2)
baseCI :: Item -> ComposedItem
baseCI :: Item -> CItem
baseCI itm = (itm, itemToFunction itm, itemBaseConnections itm)
itemBaseConnections :: Item -> LinkTest
@@ -202,13 +202,13 @@ itemBaseConnections itm = case _itType itm of
laserLinkTest :: Item -> LinkTest
laserLinkTest itm = LTest (llleft itm) (llright itm)
llleft :: Item -> LabelDoubleTree ItemLink ComposedItem -> Maybe LinkUpdate
llleft :: Item -> LabelDoubleTree ItemLink CItem -> Maybe LinkUpdate
llleft itm =
_tryLeftLink
. uncurry useBreakL
$ itemToBreakLists itm WeaponTargetingSF
llright :: Item -> LabelDoubleTree ItemLink ComposedItem -> Maybe LinkUpdate
llright :: Item -> LabelDoubleTree ItemLink CItem -> Maybe LinkUpdate
llright itm pci = case pci ^. ldtValue . _1 . itType of
CRAFT TRANSFORMER -> Just (toLasgunUpdate itm)
_ -> _tryRightLink (uncurry useBreakL $ itemToBreakLists itm WeaponTargetingSF) pci
@@ -232,20 +232,20 @@ springLinkTest = LTest (const Nothing) $
)
_ -> Nothing
--itemLinkTestLeft :: Item -> PartiallyComposedItem -> Maybe LinkUpdate
--itemLinkTestLeft :: Item -> PartiallyCItem -> Maybe LinkUpdate
--itemLinkTestLeft itm = _tryLeftLink $
-- uncurry useBreakL $ itemToBreakLists itm
type LDTComb a b = LabelDoubleTree b a -> LabelDoubleTree b a -> Maybe (LabelDoubleTree b a)
leftIsParentCombine :: LDTComb ComposedItem ItemLink
leftIsParentCombine :: LDTComb CItem ItemLink
leftIsParentCombine ltree rtree = do
lu <- (ltree ^. ldtValue . _3 . tryRightLink) rtree --(rtree ^. ldtValue)
return $
ltree & ldtValue %~ (lu ^. luParentUpdate)
& ldtRight %~ (++ [(lu ^. luLinkType, rtree & ldtValue %~ (lu ^. luChildUpdate))])
rightIsParentCombine :: LDTComb ComposedItem ItemLink
rightIsParentCombine :: LDTComb CItem ItemLink
rightIsParentCombine ltree rtree = do
lu <- (rtree ^. ldtValue . _3 . tryLeftLink) ltree -- (ltree ^. ldtValue)
return $
@@ -276,7 +276,7 @@ joinItemsInList f xs = snd $ h (xs, [])
Just w -> h (w : ys, zs)
-- this puts the first elements in the intmap at the end of the list
invLDT :: IM.IntMap Item -> [LabelDoubleTree ItemLink ComposedItem]
invLDT :: IM.IntMap Item -> [LabelDoubleTree ItemLink CItem]
invLDT =
joinItemsInList tryAttachItems . IM.elems
. fmap (singleLDT . baseCI)
@@ -306,28 +306,28 @@ invAdj = IM.unions . map g . invLDT
$ itm ^? itLocation . ilInvID
-- returns an intmap with trees for (only!) root items, indexed by inventory position
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink ComposedItem)
invRootTrees :: IM.IntMap Item -> IM.IntMap (LabelDoubleTree ItemLink CItem)
invRootTrees = IM.fromDistinctAscList . reverse . map getid . invLDT
where
getid ::
LabelDoubleTree ItemLink ComposedItem ->
(Int, LabelDoubleTree ItemLink ComposedItem)
LabelDoubleTree ItemLink CItem ->
(Int, LabelDoubleTree ItemLink CItem)
getid t = (t ^?! ldtValue . _1 . itLocation . ilInvID, t)
-- returns an intmap with indents and locations for all items
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
allInvLocs :: IM.IntMap Item -> IM.IntMap (Int, LocationLDT ItemLink CItem)
allInvLocs inv = foldMap (f . LocLDT TopLDT) (IM.elems (invRootTrees inv)) mempty
where
f t = cldtPropagateFold h h g 0 t id
h x _ _ _ = x + 1
g ::
Int ->
LocationLDT ItemLink ComposedItem ->
( IM.IntMap (Int, LocationLDT ItemLink ComposedItem) ->
IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
LocationLDT ItemLink CItem ->
( IM.IntMap (Int, LocationLDT ItemLink CItem) ->
IM.IntMap (Int, LocationLDT ItemLink CItem)
) ->
IM.IntMap (Int, LocationLDT ItemLink ComposedItem) ->
IM.IntMap (Int, LocationLDT ItemLink ComposedItem)
IM.IntMap (Int, LocationLDT ItemLink CItem) ->
IM.IntMap (Int, LocationLDT ItemLink CItem)
g x ldt =
(.)
( IM.insert
+1 -5
View File
@@ -43,11 +43,7 @@ autoRifle =
& itType .~ HELD AUTORIFLE
burstRifle :: Item
burstRifle =
rifle
& itType .~ HELD BURSTRIFLE
-- & itUse . heldMuzzles . ix 0 . mzInaccuracy .~ 0.05
-- & itUse . heldDelay . rateMax .~ 6
burstRifle = rifle & itType .~ HELD BURSTRIFLE
miniGunX :: Int -> Item
miniGunX i =
+1 -1
View File
@@ -6,7 +6,7 @@ import Color
import Control.Lens
import Dodge.Data.ComposedItem
itemInvColor :: ComposedItem -> Color
itemInvColor :: CItem -> Color
itemInvColor ci = case ci ^. _2 of
MapperSF -> white
GrenadeHitEffectSF -> yellow
+2 -2
View File
@@ -13,14 +13,14 @@ orientChild itm = case _itType itm of
HELD LASER -> (V3 15 (-5) 0, Q.qID)
_ -> (0, Q.qID)
orientByLink :: Item -> ComposeLinkType -> (Point3, Q.Quaternion Float)
orientByLink :: Item -> CLinkType -> (Point3, Q.Quaternion Float)
orientByLink itm lt = case (_itType itm, lt) of
(HELD FLAMETHROWER, AmmoInLink{}) -> (V3 4 (-6) 0, Q.qID)
(HELD _, AmmoInLink{}) -> (V3 7 (-2) 0, Q.qID)
(HELD _, WeaponScopeLink) -> (V3 5 0 5, Q.qID)
_ -> (0, Q.qID)
orientAttachment :: Item -> ComposeLinkType -> Item -> (Point3, Q.Quaternion Float)
orientAttachment :: Item -> CLinkType -> Item -> (Point3, Q.Quaternion Float)
orientAttachment par lnk ch = case (_itType par, lnk, _itType ch) of
-- (HELD BURSTRIFLE, _, HELD TORCH) -> (V3 20 0 0, Q.axisAngle (V3 0 0 1) (pi/2))
-- (HELD LAUNCHER, _, HELD TORCH) -> (V3 0 20 0, Q.axisAngle (V3 0 0 1) (pi/4))
+5 -11
View File
@@ -1,6 +1,7 @@
{-# OPTIONS_GHC -Wno-unused-imports #-}
module Dodge.TestString where
import Dodge.Item.UseDelay
import qualified SDL
import Linear
import Dodge.ListDisplayParams
@@ -26,17 +27,10 @@ import qualified IntMapHelp as IM
import qualified Data.Map.Strict as M
testStringInit :: Universe -> [String]
testStringInit u = fmap show $ u ^.. uvWorld . cWorld . lWorld . terminals . each . tmID
-- foldMap prettyShort $ u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crTwist
-- prettyShort $ u ^.. uvWorld . cWorld . lWorld . teslaArcs . ix 0 . taArcSteps . each . asObject
--testStringInit u = foldMap prettyShort $ u ^. uvWorld . cWorld . lWorld . projectiles
-- (map (show . _ebPos) $ u ^. uvWorld . cWorld . lWorld . energyBalls)
-- <>
-- (foldMap prettyShort $ u ^. uvWorld . cWorld . lWorld . bullets)
-- fromMaybe mempty $ do
-- cr <- u ^? uvWorld . cWorld . lWorld . creatures . ix 0
-- let itms = IM.elems $ cr ^. crInv
-- return $ map (show . (^? itLocation . ilIsSelected)) itms
testStringInit u = prettyShort (u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crInv
. ix 0 . itTimeLastUsed)
<> prettyShort (u ^? uvWorld . cWorld . lWorld . creatures . ix 0 . crInv
. ix 0 >>= ((^? rateMax) .useDelay))
--return . foldMap (prettyLDT (show . (^. _1 . itType))) . invLDT $ _crInv cr
-- where
-- idp = invDisplayParams $ u ^. uvWorld
-1
View File
@@ -58,7 +58,6 @@ itemScroll yi invid itm w
| HELD ALTERIFLE <- itm ^. itType
, yi /= 0 =
w
-- & itmlens . itUse . heldMuzzles . ix 0 . mzAmmoSlot
& itmlens . itParams . alteRifleSwitch
%~ ((`mod` 2) . (+ 1))
| isJust $ itm ^? itScroll . itsInt = w & itmlens . itScroll . itsInt +~ yi
-5
View File
@@ -51,11 +51,6 @@ doWdWd we = case we of
allInvLocs (cr ^. crInv) ^? ix invid . _2 . locLDT
return $ heldEffectMuzzles itree cr w
--doItCrWdWd :: ItCrWdWd -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
--doItCrWdWd icww = case icww of
-- ItCrWdItemHeldEffect -> heldEffect InitialPress
-- ItCrWdItemHeldEffectNoHammer -> heldEffectNoHammerCheck
accessTerminal :: Maybe Int -> World -> World
accessTerminal mtmid w = fromMaybe w $ do
tmid <- mtmid