Fix burst rifle rate delay bug, various cleanups
This commit is contained in:
+201
-207
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user