Continue weapon effect chain work

Start work on using muzzles to determine the effect of the ammo when
loaded
This commit is contained in:
2024-09-18 00:36:28 +01:00
parent 791003ebb9
commit 2c96a514ea
22 changed files with 502 additions and 404 deletions
+38 -1
View File
@@ -1 +1,38 @@
All good (617 modules, at 11:03:32)
/home/justin/Haskell/loop/src/Dodge/HeldUse.hs:(44,25)-(322,30): warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative: Patterns not matched: MachineGunMod
|
44 | heldEffect effecttype = case effecttype of
| ^^^^^^^^^^^^^^^^^^...
/home/justin/Haskell/loop/src/Dodge/HeldUse.hs:(487,43)-(500,9): warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative:
Patterns not matched:
MuzzleLaser
MuzzleTesla
MuzzleTractor
MuzzleLauncher
...
|
487 | useLoadedAmmo itm cr (cme,w) (mz,x,mid) = case _mzEffect mz of
| ^^^^^^^^^^^^^^^^^^^^...
/home/justin/Haskell/loop/src/Dodge/Bullet.hs:6:1-30: warning: [-Wunused-imports]
The import of Dodge.Data.ComposedItem is redundant
|
6 | import Dodge.Data.ComposedItem
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Bullet.hs:7:1-28: warning: [-Wunused-imports]
The import of Dodge.Data.DoubleTree is redundant
|
7 | import Dodge.Data.DoubleTree
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Bullet.hs:13:1-28: warning: [-Wunused-imports]
The import of Dodge.Base.Coordinate is redundant
|
13 | import Dodge.Base.Coordinate
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/justin/Haskell/loop/src/Dodge/Bullet.hs:14:1-29: warning: [-Wunused-imports]
The import of Dodge.Creature.HandPos is redundant
|
14 | import Dodge.Creature.HandPos
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+1 -1
View File
File diff suppressed because one or more lines are too long
+39 -38
View File
@@ -1,6 +1,6 @@
module Dodge.Bullet (
updateBullet,
shootBullet,
-- shootBullet,
) where
import Dodge.Data.ComposedItem
@@ -58,43 +58,44 @@ updateBulVel bt = case _buTrajectory bt of
where
t = _buTimer bt
shootBullet :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
shootBullet itm cr w = fromMaybe (error "cannot find bullet ammo when expected to") $ do
atype <- itm ^? ldtValue . itUse . heldAmmoTypes . ix 0
leftitms <- itm ^? ldtLeft
mag <- lookup (AmmoInLink 0 atype) leftitms
thebullet <- mag ^? ldtValue . itUse . amagParams . ampBullet
return $ w
& randGen .~ g'
& cWorld . lWorld . instantBullets
.:~ ( thebullet
& buPos .~ _crPos cr
& buTrajectory %~ settrajectory
& buVel %~ (rotateV dir . (muzvel *.*))
& buDrag *~ drag
)
where
it = itm ^. ldtValue
sp = _crPos cr +.+ (muzlength ^?! _head . _x) *.* unitVectorAtAngle dir
dir = _crDir cr
(drag,g) = case _rifling (_heldParams $ _itUse it) of
ConstFloat x -> (x, _randGen w)
UniRandFloat x y -> randomR (x,y) $ _randGen w
(muzvel,g') = case _muzVel $ _heldParams $ _itUse it of
ConstFloat x -> (x,g)
UniRandFloat x y -> randomR (x,y) $ _randGen w
muzlength = aimingMuzzlePos cr it
settrajectory traj = case traj of
BasicBulletTrajectory -> BasicBulletTrajectory
MagnetTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
tpos <- cr ^? crTargeting . ctPos . _Just
return $ MagnetTrajectory tpos
FlechetteTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
tpos <- cr ^? crTargeting . ctPos . _Just
return $ FlechetteTrajectory tpos
BezierTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
tpos <- cr ^? crTargeting . ctPos . _Just
return $ BezierTrajectory sp tpos (mouseWorldPos (w ^. input) (w ^. wCam))
-- NOTE THE FOLLOWING HAS BEZIER CURE/FLECHETTE STUFF THAT MIGHT BE USEFUL
--shootBullet :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
--shootBullet itm cr w = fromMaybe (error "cannot find bullet ammo when expected to") $ do
-- atype <- itm ^? ldtValue . itUse . heldAmmoTypes . ix 0
-- leftitms <- itm ^? ldtLeft
-- mag <- lookup (AmmoInLink 0 atype) leftitms
-- thebullet <- mag ^? ldtValue . itUse . amagParams . ampBullet
-- return $ w
-- & randGen .~ g'
-- & cWorld . lWorld . instantBullets
-- .:~ ( thebullet
-- & buPos .~ _crPos cr
-- & buTrajectory %~ settrajectory
-- & buVel %~ (rotateV dir . (muzvel *.*))
-- & buDrag *~ drag
-- )
-- where
-- it = itm ^. ldtValue
-- sp = _crPos cr +.+ (muzlength ^?! _head . _x) *.* unitVectorAtAngle dir
-- dir = _crDir cr
-- (drag,g) = case _rifling (_heldParams $ _itUse it) of
-- ConstFloat x -> (x, _randGen w)
-- UniRandFloat x y -> randomR (x,y) $ _randGen w
-- (muzvel,g') = case _muzVel $ _heldParams $ _itUse it of
-- ConstFloat x -> (x,g)
-- UniRandFloat x y -> randomR (x,y) $ _randGen w
-- muzlength = aimingMuzzlePos cr it
-- settrajectory traj = case traj of
-- BasicBulletTrajectory -> BasicBulletTrajectory
-- MagnetTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
-- tpos <- cr ^? crTargeting . ctPos . _Just
-- return $ MagnetTrajectory tpos
-- FlechetteTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
-- tpos <- cr ^? crTargeting . ctPos . _Just
-- return $ FlechetteTrajectory tpos
-- BezierTrajectory{} -> fromMaybe BasicBulletTrajectory $ do
-- tpos <- cr ^? crTargeting . ctPos . _Just
-- return $ BezierTrajectory sp tpos (mouseWorldPos (w ^. input) (w ^. wCam))
bounceDir :: (Point2, Either Creature Wall) -> Maybe Point2
bounceDir (_, Right wl) | _wlBouncy wl = Just $ uncurry (-.-) (_wlLine wl)
+2
View File
@@ -5,6 +5,7 @@
module Dodge.Data.Item.HeldDelay where
import Sound.Data
import Control.Lens
import Data.Aeson
import Data.Aeson.TH
@@ -24,6 +25,7 @@ data UseDelay -- should just be Delay
| WarmUpNoDelay
{ _warmTime :: Int
, _warmMax :: Int
, _warmSound :: SoundID
}
deriving (Eq, Ord, Show, Read) --Generic, Flat)
+4 -4
View File
@@ -14,7 +14,7 @@ import Control.Lens
data Huse
= HeldDoNothing
| HeldUseAmmoParams
-- | HeldUseAmmoParams
| HeldOverNozzlesUseGasParams
| HeldPJCreation
| HeldPJCreationX Int
@@ -94,9 +94,9 @@ data HeldMod
| PistolMod
-- | AutoPistolMod
-- | MachinePistolMod
| BurstRifleMod
| BurstRifleRepeatMod
| MiniGunMod Int
-- | BurstRifleMod
-- | BurstRifleRepeatMod
-- | MiniGunMod Int
-- | SmgMod
-- | BangConeMod
| TractorMod --apply with AmmoCheckMod
+20 -1
View File
@@ -75,6 +75,10 @@ data HeldParams
= DefaultHeldParams
| GasSprayParams
{_gasCreation :: GasCreate}
| BeamShooterParams
{ _bulGunSound :: (SoundID, Int) -- if the int is 0, play sound on new channel
-- TODO remove duplicate
}
| BulletShooterParams
{ _muzVel :: GenFloat
, _rifling :: GenFloat
@@ -82,7 +86,9 @@ data HeldParams
, _torqueAfter :: Float
, _randomOffset :: Float
, _sidePush :: Float
, _bulGunSound :: SoundID
, _bulGunSound :: (SoundID, Int) -- if the int is 0, play sound on new channel
-- if >0, continue playing sound for
-- given time
, _weaponInvLock :: Int
, _weaponRepeat :: [Int]
}
@@ -130,7 +136,18 @@ data AimParams = AimParams
data FlareType = DefaultFlareType
| PistolFlare
| MiniGunFlare
| HeavySmokeFlare
| LasGunFlare
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data MuzzleEffect
= MuzzleShootBullet
| MuzzleLaser
| MuzzleTesla
| MuzzleTractor
| MuzzleLauncher
| MuzzleFlame
| MuzzleGas
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Muzzle = Muzzle
@@ -139,6 +156,7 @@ data Muzzle = Muzzle
, _mzInaccuracy :: Float
, _mzAmmoSlot :: Int
, _mzFlareType :: FlareType
, _mzEffect :: MuzzleEffect
-- , _mzRecoil :: Float
-- , _mzTorque :: Float
-- , _mzSidePush :: Float
@@ -175,6 +193,7 @@ makeLenses ''HeldParams
makeLenses ''AttachParams
makeLenses ''ScrollAttachParams
makeLenses ''AmmoParams
deriveJSON defaultOptions ''MuzzleEffect
deriveJSON defaultOptions ''FlareType
deriveJSON defaultOptions ''TriggerType
deriveJSON defaultOptions ''AmmoParams
+1
View File
@@ -144,6 +144,7 @@ data LWorld = LWorld
, _distortions :: [Distortion]
, _lClock :: Int
, _lTestString :: [String]
, _lTestInt :: Int
}
data WorldBeams = WorldBeams
{ _blockingBeams :: [Beam]
+1
View File
@@ -52,6 +52,7 @@ defaultBulletWeapon =
& itUse . heldAmmoTypes .~ singleAmmo BulletAmmo
-- & itUse . heldUse .~ HeldUseAmmoParams -- useAmmoParams
& itType . iyModules . at ModBulletCollision ?~ EMPTYMODULE
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.01 0 PistolFlare MuzzleShootBullet]
-- & itType . iyModules . at ModBulletPayload ?~ EMPTYMODULE
-- & itType . iyModules . at ModBulletTrajectory ?~ EMPTYMODULE
+1 -1
View File
@@ -42,7 +42,7 @@ defaultHeldUse =
, _torqueAfter = 0.2
, _randomOffset = 0
, _sidePush = 0
, _bulGunSound = tap3S
, _bulGunSound = (tap3S, 0)
, _weaponInvLock = 0
, _weaponRepeat = []
}
+1
View File
@@ -24,6 +24,7 @@ defaultMuzzle = Muzzle
, _mzInaccuracy = 0.05
, _mzAmmoSlot = 0
, _mzFlareType = DefaultFlareType
, _mzEffect = MuzzleShootBullet
}
+1
View File
@@ -144,6 +144,7 @@ defaultLWorld =
, _distortions = []
, _lClock = 0
, _lTestString = []
, _lTestInt = 0
}
defaultHUD :: HUD
+122 -110
View File
@@ -18,7 +18,7 @@ import Color
import Data.Maybe
--import Data.Traversable
import Dodge.Base.Coordinate
import Dodge.Bullet
--import Dodge.Bullet
import Dodge.Creature.HandPos
import Dodge.Data.World
import Dodge.Gas
@@ -209,13 +209,13 @@ heldEffect effecttype = case effecttype of
-- , useTimeCheck
-- , ammoCheckI -- cf ElephantGun
-- ]
MachineGunMod -> bulletGunEffect
[ withFlare
, withThinSmokeI
, withSoundStart bangEchoS
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
, ammoCheckI
]
-- MachineGunMod -> bulletGunEffect
-- [ withFlare
-- , withThinSmokeI
-- , withSoundStart bangEchoS
-- , rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
-- , ammoCheckI
-- ]
-- BangStickMod -> bulletGunEffect
-- [ withRecoil
-- , useAllAmmo
@@ -250,44 +250,44 @@ heldEffect effecttype = case effecttype of
-- , useTimeCheck
-- , ammoCheckI
-- ]
BurstRifleMod -> bulletGunEffect
[ withRecoil
, withFlare
, duplicateLoadedBarrels
, useAmmoAmount 1
, withSoundStart tap3S
, repeatOnFrames [3, 6] BurstRifleRepeatMod
, lockInvFor 7
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, useTimeCheck
, ammoCheckI
, blCheck
]
BurstRifleRepeatMod -> bulletGunEffect
[ withRecoil
, withFlare
, duplicateLoadedBarrels
, useAmmoAmount 1
, withSoundStart tap3S
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, ammoCheckI
]
MiniGunMod i -> bulletGunEffect
[ duplicateNumBarrels 1
, repeatTransformed
[ (id, modcrpos x)
| x <- map ((/ (fromIntegral i - 1)) . fromIntegral) [0 .. i -1]
]
, afterRecoil (fromIntegral i * 5)
, torqueBefore (fromIntegral i * 0.05)
, withSidePushI (fromIntegral i * 25)
, withMuzFlare
, withSmoke 1 black 20 200 5
, useAmmoAmount i
, withSoundForI mini1S 2
, withWarmUp crankSlowS
, ammoCheckI
]
-- BurstRifleMod -> bulletGunEffect
-- [ withRecoil
-- , withFlare
-- , duplicateLoadedBarrels
-- , useAmmoAmount 1
-- , withSoundStart tap3S
-- , repeatOnFrames [3, 6] BurstRifleRepeatMod
-- , lockInvFor 7
-- , sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
-- , useTimeCheck
-- , ammoCheckI
-- , blCheck
-- ]
-- BurstRifleRepeatMod -> bulletGunEffect
-- [ withRecoil
-- , withFlare
-- , duplicateLoadedBarrels
-- , useAmmoAmount 1
-- , withSoundStart tap3S
-- , sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
-- , ammoCheckI
-- ]
-- MiniGunMod i -> bulletGunEffect
-- [ duplicateNumBarrels 1
-- , repeatTransformed
-- [ (id, modcrpos x)
-- | x <- map ((/ (fromIntegral i - 1)) . fromIntegral) [0 .. i -1]
-- ]
-- , afterRecoil (fromIntegral i * 5)
-- , torqueBefore (fromIntegral i * 0.05)
-- , withSidePushI (fromIntegral i * 25)
-- , withMuzFlare
-- , withSmoke 1 black 20 200 5
-- , useAmmoAmount i
-- , withSoundForI mini1S 2
-- , withWarmUp crankSlowS
-- , ammoCheckI
-- ]
-- SmgMod -> bulletGunEffect
-- [ withFlare
-- , withSidePushI 30
@@ -332,11 +332,11 @@ heldEffect effecttype = case effecttype of
-- where
-- p = fromMaybe (_crPos cr) $ cr ^? crTargeting . ctPos . _Just
-- a = argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- p)
modcrpos x cr = fromMaybe cr $ do
invid <- cr ^? crManipulation . manObject . inInventory . ispItem
return $ cr & crDir %~ tweenAngles x (_crOldDir cr)
& crPos %~ alongSegBy x (_crOldPos cr)
& crInv . ix (invid + 1) . itUse . amagParams . ampBullet . buDelayFraction .~ x
-- modcrpos x cr = fromMaybe cr $ do
-- invid <- cr ^? crManipulation . manObject . inInventory . ispItem
-- return $ cr & crDir %~ tweenAngles x (_crOldDir cr)
-- & crPos %~ alongSegBy x (_crOldPos cr)
-- & crInv . ix (invid + 1) . itUse . amagParams . ampBullet . buDelayFraction .~ x
gasEffect :: [(LabelDoubleTree ComposeLinkType Item
-> Creature -> World -> World)
@@ -361,6 +361,7 @@ bulGunEffect' t cr w = fromMaybe (error "error in bulGunEffect") $ do
return $ uncurry (applyCME (_ldtValue t) cr) cmew
& cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles
& doWeaponRepetitions upitm cr
-- & cWorld . lWorld . lTestInt +~ 1
doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
@@ -390,8 +391,10 @@ applyInvLock itm cr = case itm ^? itUse . heldParams . weaponInvLock of
applySoundCME :: Item -> Creature -> World -> World
applySoundCME itm cr = fromMaybe id $ do
soundid <- itm ^? itUse . heldParams . bulGunSound
return $ soundMultiFrom [CrWeaponSound cid j | j <- [0..3]] (_crPos cr) soundid Nothing
(soundid,x) <- itm ^? itUse . heldParams . bulGunSound
if x > 0
then return $ soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) soundid (Just x)
else return $ soundMultiFrom [CrWeaponSound cid j | j <- [0..5]] (_crPos cr) soundid Nothing
where
cid = _crID cr
@@ -447,7 +450,10 @@ makeMuzzleFlare :: Muzzle -> Item -> Creature -> World -> World
makeMuzzleFlare mz itm cr = case mz ^. mzFlareType of
DefaultFlareType -> id
PistolFlare -> basicMuzFlare pos dir
MiniGunFlare -> makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (pos `v2z` 20)
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
HeavySmokeFlare -> basicMuzFlare pos dir
LasGunFlare -> flareCircleAt (_lasColor $ _itParams itm) 0.8 (pos `v2z` 20)
where
pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
dir = _crDir cr + _mzRot mz
@@ -461,8 +467,10 @@ basicMuzFlare pos dir = makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (pos `v2z` 20)
makeMuzzleSmoke :: Muzzle -> Item -> Creature -> World -> World
makeMuzzleSmoke mz itm cr w = case mz ^. mzFlareType of
DefaultFlareType -> w
PistolFlare -> foldl' (flip $ smokeCloudAt (greyN 0.5) 20 400 5 . (+.+.+ pos) . (* 8)) w ps
PistolFlare -> foldl' (flip $ smokeCloudAt (greyN 0.5) 5 400 5 . (+.+.+ pos) . (* 8)) w ps
MiniGunFlare -> smokeCloudAt (greyN 0.5) 5 400 5 pos w
HeavySmokeFlare -> foldl' (flip $ smokeCloudAt black 20 400 5 . (+.+.+ pos) . (* 8)) w ps'
LasGunFlare -> w
where
ps = replicateM 2 randOnUnitSphere & evalState $ _randGen w
ps' = replicateM 4 randOnUnitSphere & evalState $ _randGen w
@@ -476,7 +484,11 @@ isAmmoIntLink _ _ = False
useLoadedAmmo :: Item -> Creature -> (CumulativeMuzzleEffect,World) -> (Muzzle,Int,Maybe Int)
-> (CumulativeMuzzleEffect,World)
useLoadedAmmo _ _ (cme,w) (_,0,_) = (cme, w)
useLoadedAmmo itm cr (cme,w) (mz,x,mid) = fromMaybe (cme,w) $ do
useLoadedAmmo itm cr (cme,w) (mz,x,mid) = case _mzEffect mz of
MuzzleShootBullet ->
fromMaybe (cme,w) $ do
magid <- mid
-- should be able to pass the magazine in from elsewhere?
thebullet <- cr ^? crInv . ix magid . itUse . amagParams . ampBullet
@@ -515,17 +527,17 @@ makeBullet thebullet itm cr mz w =
Just x | x /= 0 -> fst . randomR (-x,x) $ _randGen w
_ -> 0
bulletGunEffect :: [(LabelDoubleTree ComposeLinkType Item
-> Creature -> World -> World)
-> LabelDoubleTree ComposeLinkType Item
-> Creature
-> World
-> World]
-> LabelDoubleTree ComposeLinkType Item
-> Creature
-> World
-> World
bulletGunEffect = foldl' (&) shootBullet
--bulletGunEffect :: [(LabelDoubleTree ComposeLinkType Item
-- -> Creature -> World -> World)
-- -> LabelDoubleTree ComposeLinkType Item
-- -> Creature
-- -> World
-- -> World]
-- -> LabelDoubleTree ComposeLinkType Item
-- -> Creature
-- -> World
-- -> World
--bulletGunEffect = foldl' (&) shootBullet
useMod :: HeldMod ->
[(LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World)
@@ -764,44 +776,44 @@ useMod hm = case hm of
-- , useTimeCheck
-- , ammoCheckI
-- ]
BurstRifleMod ->
[ withRecoil
, withFlare
, duplicateLoadedBarrels
, useAmmoAmount 1
, withSoundStart tap3S
, repeatOnFrames [3, 6] BurstRifleRepeatMod
, lockInvFor 7
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, useTimeCheck
, ammoCheckI
, blCheck
]
BurstRifleRepeatMod ->
[ withRecoil
, withFlare
, duplicateLoadedBarrels
, useAmmoAmount 1
, withSoundStart tap3S
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, ammoCheckI
]
MiniGunMod i ->
[ duplicateNumBarrels 1
, repeatTransformed
[ (id, modcrpos x)
| x <- map ((/ (fromIntegral i - 1)) . fromIntegral) [0 .. i -1]
]
, afterRecoil (fromIntegral i * 5)
, torqueBefore (fromIntegral i * 0.05)
, withSidePushI (fromIntegral i * 25)
, withMuzFlare
, withSmoke 1 black 20 200 5
, useAmmoAmount i
, withSoundForI mini1S 2
, withWarmUp crankSlowS
, ammoCheckI
]
-- BurstRifleMod ->
-- [ withRecoil
-- , withFlare
-- , duplicateLoadedBarrels
-- , useAmmoAmount 1
-- , withSoundStart tap3S
-- , repeatOnFrames [3, 6] BurstRifleRepeatMod
-- , lockInvFor 7
-- , sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
-- , useTimeCheck
-- , ammoCheckI
-- , blCheck
-- ]
-- BurstRifleRepeatMod ->
-- [ withRecoil
-- , withFlare
-- , duplicateLoadedBarrels
-- , useAmmoAmount 1
-- , withSoundStart tap3S
-- , sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
-- , ammoCheckI
-- ]
-- MiniGunMod i ->
-- [ duplicateNumBarrels 1
-- , repeatTransformed
-- [ (id, modcrpos x)
-- | x <- map ((/ (fromIntegral i - 1)) . fromIntegral) [0 .. i -1]
-- ]
-- , afterRecoil (fromIntegral i * 5)
-- , torqueBefore (fromIntegral i * 0.05)
-- , withSidePushI (fromIntegral i * 25)
-- , withMuzFlare
-- , withSmoke 1 black 20 200 5
-- , useAmmoAmount i
-- , withSoundForI mini1S 2
-- , withWarmUp crankSlowS
-- , ammoCheckI
-- ]
-- SmgMod ->
-- [ withFlare
-- , withSidePushI 30
@@ -843,11 +855,11 @@ useMod hm = case hm of
-- where
-- p = fromMaybe (_crPos cr) $ cr ^? crTargeting . ctPos . _Just
-- a = argV (mouseWorldPos (w ^. input) (w ^. wCam) -.- p)
modcrpos x cr = fromMaybe cr $ do
invid <- cr ^? crManipulation . manObject . inInventory . ispItem
return $ cr & crDir %~ tweenAngles x (_crOldDir cr)
& crPos %~ alongSegBy x (_crOldPos cr)
& crInv . ix (invid + 1) . itUse . amagParams . ampBullet . buDelayFraction .~ x
-- modcrpos x cr = fromMaybe cr $ do
-- invid <- cr ^? crManipulation . manObject . inInventory . ispItem
-- return $ cr & crDir %~ tweenAngles x (_crOldDir cr)
-- & crPos %~ alongSegBy x (_crOldPos cr)
-- & crInv . ix (invid + 1) . itUse . amagParams . ampBullet . buDelayFraction .~ x
lasWideRate :: Int
lasWideRate = 2
@@ -860,7 +872,7 @@ mcUseHeld hit = case hit of
useHeld :: Huse -> LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
useHeld hu = case hu of
HeldDoNothing -> const $ const id
HeldUseAmmoParams -> shootBullet
-- HeldUseAmmoParams -> shootBullet
HeldOverNozzlesUseGasParams -> overNozzles useGasParams
HeldPJCreation -> usePjCreation
HeldPJCreationX _ -> usePjCreationX
+14 -14
View File
@@ -1,8 +1,9 @@
module Dodge.Item.Held.BatteryGuns where
import Dodge.SoundLogic.ExternallyGeneratedSounds
import Dodge.Default.Item
import Dodge.Base
import Dodge.Data.Beam
import Dodge.Default.Item
import Color
import Control.Lens
import qualified Data.Map.Strict as M
@@ -30,13 +31,19 @@ teslaGun =
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimStance .~ TwoHandFlat
-- & itUse . heldAim . aimMuzPos .~ 4
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 4 0) 0 0 0 DefaultFlareType]
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 4 0) 0 0 0 DefaultFlareType MuzzleTesla]
& itType . iyBase .~ HELD TESLAGUN
lasGun :: Item
lasGun =
defaultAutoBatteryGun
defaultHeldItem
& itType . iyModules .~ batteryModules
& itUse . heldMods .~ PistolMod
& itUse . heldParams .~ BeamShooterParams (tone440sawtoothquietS,2)
& itUse . heldAmmoTypes .~ singleAmmo ElectricalAmmo
& itUse . heldDelay .~ NoDelay
& itUse . heldTriggerType .~ AutoTrigger
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0 LasGunFlare MuzzleLaser]
& itParams
.~ Refracting
{ _phaseV = 1
@@ -52,14 +59,11 @@ lasGun =
& itDimension . dimRad .~ 10
& itDimension . dimCenter .~ V3 15 0 0
-- & itUse . heldUse .~ HeldLaser --shootLaser
& itUse . heldDelay .~ NoDelay
& itUse . heldMods .~ LasMod
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandUnder
-- & itUse . heldAim . aimHandlePos .~ 5
-- & itUse . heldAim . aimMuzPos .~ 30
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0 DefaultFlareType]
& itType . iyBase .~ HELD LASGUN
lasGunTweak :: TweakParam
@@ -84,7 +88,7 @@ tractorGun =
& itUse . heldMods .~ TractorMod
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0 DefaultFlareType]
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0 DefaultFlareType MuzzleTractor]
& itType . iyBase .~ HELD TRACTORGUN
tractorGunTweak :: TweakParam
@@ -102,7 +106,8 @@ lasWide n =
& itParams . lasColor .~ yellow
& itParams . lasDamage .~ 2
& itUse . heldMods .~ LasWideMod n
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 y) 0 0 0 DefaultFlareType | y <- spreadFromCenter n 1]
& itUse . heldAim . aimMuzzles
.~ [Muzzle (V2 30 y) 0 0 0 DefaultFlareType MuzzleLaser | y <- spreadFromCenter n 1]
defaultBatteryGun :: Item
defaultBatteryGun =
@@ -116,11 +121,6 @@ batteryModules =
, (ModTeleport, EMPTYMODULE)
]
defaultAutoBatteryGun :: Item
defaultAutoBatteryGun =
defaultHeldItem
& itType . iyModules .~ batteryModules
--lasCircle :: Item
--lasCircle =
-- lasGun
@@ -137,7 +137,7 @@ dualBeam :: Item
dualBeam =
lasGun
& itType . iyBase .~ HELD DUALBEAM
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0 DefaultFlareType]
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0 0 DefaultFlareType MuzzleLaser]
& itParams
.~ DualBeam
{ _phaseV = 1
+17 -19
View File
@@ -6,6 +6,7 @@ module Dodge.Item.Held.Cane (
miniGunX,
) where
import Dodge.SoundLogic.ExternallyGeneratedSounds
import Dodge.Base
import Dodge.Data.Item
import Dodge.Default
@@ -27,7 +28,7 @@ defaultBangCane =
-- & itUse . heldMods .~ BangCaneMod
& itUse . heldAim . aimStance .~ OneHand
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.01 0 PistolFlare]
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 15 0) 0 0.01 0 PistolFlare MuzzleShootBullet]
volleyGun :: Int -> Item
volleyGun i =
@@ -41,9 +42,10 @@ volleyGun i =
(ZipList [Muzzle (V2 15 x) 0 0.01 | x <- spreadAroundCenter i 6]
<*> ZipList [0..i-1]
<*> pure PistolFlare
<*> pure MuzzleShootBullet
)
& itUse . heldParams . torqueAfter .~ 0.15 + 0.05 * fromIntegral i
& itUse . heldParams . recoil .~ 10 + 5 * fromIntegral i
& itUse . heldParams . recoil .~ 20 + 10 * fromIntegral i
& itType . iyBase .~ HELD (VOLLEYGUN i)
& itUse . heldAmmoTypes .~ IM.fromList (zip [0..i-1] $ repeat BulletAmmo)
@@ -55,7 +57,7 @@ rifle =
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 25 0) 0 0.01 0 PistolFlare]
& itUse . heldAim . aimMuzzles . ix 0 . mzPos .~ V2 25 0
& itType . iyModules . at ModHeldAttach ?~ EMPTYMODULE
--repeater :: Item
@@ -84,27 +86,23 @@ burstRifle =
& itUse . heldParams . weaponInvLock .~ 7
& itUse . heldParams . weaponRepeat .~ [3,6]
miniGunUse :: Int -> ItemUse
miniGunUse i =
defaultHeldUse
-- & heldUse .~ HeldUseAmmoParams
& heldMods .~ MiniGunMod i
& heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100}
& heldAim . aimWeight .~ 6
& heldAim . aimRange .~ 1
& heldAim . aimStance .~ TwoHandUnder
& heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& heldAmmoTypes .~ singleAmmo BeltBulletAmmo
miniGunX :: Int -> Item
miniGunX i =
autoRifle
& itUse .~ miniGunUse i
& itUse . heldDelay .~ WarmUpNoDelay{_warmTime = 0, _warmMax = 100, _warmSound = crankSlowS}
& itUse . heldAim . aimWeight .~ 6
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldAmmoTypes .~ singleAmmo BeltBulletAmmo
& itUse . heldParams . bulGunSound .~ (mini1S,2)
& itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 30 0) 0 0.05 0 DefaultFlareType)
& itUse . heldParams . recoil .~ 10
& itUse . heldParams . torqueAfter .~ 0.01
& itUse . heldAim . aimMuzzles
.~ replicate i (Muzzle (V2 30 0) 0 0.05 0 MiniGunFlare MuzzleShootBullet)
& itUse . heldParams . recoil .~ 10 * fromIntegral i
& itUse . heldParams . torqueAfter .~ 0.04 + 0.02 * fromIntegral i
& itUse . heldParams . sidePush .~ 10 * fromIntegral i
& itUse . heldParams . randomOffset .~ 10
& itUse . heldParams . rifling .~ UniRandFloat 0.8 0.9
& itInvSize .~ fromIntegral i + 1
& itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0
+3 -2
View File
@@ -16,13 +16,14 @@ bangCone =
& itUse . heldDelay . rateMax .~ 20
& itUse . heldMods .~ PistolMod
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ replicate 15 (Muzzle (V2 15 0) 0 0.5 0 DefaultFlareType)
& itUse . heldAim . aimMuzzles
.~ replicate 15 (Muzzle (V2 15 0) 0 0.5 0 DefaultFlareType MuzzleShootBullet)
& itUse . heldParams . muzVel .~ UniRandFloat 0.5 0.8
& itUse . heldParams . rifling .~ UniRandFloat 0.3 0.8
& itUse . heldParams . recoil .~ 150
& itUse . heldParams . torqueAfter .~ 0.1
& itUse . heldParams . randomOffset .~ 12
& itUse . heldParams . bulGunSound .~ bangEchoS
& itUse . heldParams . bulGunSound .~ (bangEchoS,0)
& itType . iyBase .~ HELD BANGCONE
blunderbuss :: Item
+8 -2
View File
@@ -1,5 +1,6 @@
module Dodge.Item.Held.Launcher where
import Control.Applicative
import Dodge.Default.Item
--import Dodge.Reloading.Action
import Control.Lens
@@ -31,7 +32,7 @@ launcher =
& itUse . heldAim . aimStance .~ TwoHandOver
-- & itUse . heldAim . aimHandlePos .~ V2 3 0
-- & itUse . heldAim . aimMuzPos .~ 20
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0 0 DefaultFlareType]
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 20 0) 0 0 0 DefaultFlareType MuzzleLauncher]
& itUse . heldAmmoTypes .~ singleAmmo ProjectileAmmo
& itType . iyBase .~ HELD LAUNCHER
& itType . iyModules . at ModLauncherHoming ?~ EMPTYMODULE
@@ -42,7 +43,12 @@ launcherX i =
& itType . iyBase .~ HELD (LAUNCHERX i)
-- & itUse . heldUse .~ HeldPJCreationX i
& itUse . heldMods .~ LauncherXMod i
& itUse . heldAim . aimMuzzles .~ ([Muzzle (V2 20 0) a 0 | a <- angles] <*> [0..] <*> [DefaultFlareType])
& itUse . heldAim . aimMuzzles .~ getZipList
(ZipList [Muzzle (V2 20 0) a 0 | a <- angles]
<*> ZipList [0..]
<*> pure DefaultFlareType
<*> pure MuzzleLauncher
)
where
angles = take i [0,2*pi/ fromIntegral i ..]
--angles = take i [1,2 ..]
+7 -5
View File
@@ -21,7 +21,7 @@ bangRod =
& itUse . heldParams . rifling .~ ConstFloat 1
& itUse . heldParams . recoil .~ 50
& itUse . heldParams . torqueAfter .~ 0.3
& itUse . heldParams . bulGunSound .~ bangEchoS
& itUse . heldParams . bulGunSound .~ (bangEchoS,0)
& itUse . heldDelay . rateMax .~ 12
& itDimension . dimRad .~ 12
& itDimension . dimCenter .~ V3 5 0 0
@@ -31,7 +31,7 @@ bangRod =
& itUse . heldAim . aimStance .~ OneHand
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0.1 0 HeavySmokeFlare]
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0.1 0 HeavySmokeFlare MuzzleShootBullet]
-- & itUse . heldConsumption . laAmmoType .~ hvBulletAmmo
elephantGun :: Item
@@ -63,12 +63,14 @@ machineGun :: Item
machineGun =
bangRod
& itType . iyBase .~ HELD MACHINEGUN
& itUse . heldDelay . rateMax .~ 25
& itUse . heldMods .~ MachineGunMod
-- & itUse . heldMods .~ MachineGunMod
& itUse . heldMods .~ PistolMod
& itUse . heldAim . aimWeight .~ 8
& itUse . heldAim . aimRange .~ 1
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimZoom .~ defaultItZoom{_izFac = 1.5}
& itUse . heldDelay .~ VariableRate{_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
& itUse . heldDelay .~ VariableRate
{_rateMax = 25, _rateMaxMax = 24, _rateMinMax = 7, _rateTime = 0}
& itInvSize .~ 3
& itUse . heldParams . torqueAfter .~ 0.2 -- not sure if this is necessary?
& itUse . heldTriggerType .~ AutoTrigger
+1 -1
View File
@@ -88,7 +88,7 @@ flameThrower =
& itUse . heldAim . aimZoom .~ defaultItZoom{_izMax = 5, _izMin = 1.5}
& itUse . heldAim . aimStance .~ TwoHandUnder
-- & itUse . heldAim . aimHandlePos .~ 0
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 18 0) 0 0 0 DefaultFlareType]
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 18 0) 0 0 0 DefaultFlareType MuzzleFlame]
& itUse . heldAmmoTypes .~ singleAmmo GasAmmo
& itType . iyBase .~ HELD FLAMETHROWER
& itUse . heldParams .~ GasSprayParams CreateFlame --aGasCloud
+4 -3
View File
@@ -27,7 +27,7 @@ bangStick i =
-- & itUse . heldMods .~ BangStickMod
& itUse . heldMods .~ PistolMod
& itUse . heldAim . aimMuzzles
.~ [Muzzle (V2 10 0) a 0.01 0 DefaultFlareType | a <- spreadAroundCenter i baseStickSpread]
.~ [Muzzle (V2 10 0) a 0.01 0 DefaultFlareType MuzzleShootBullet | a <- spreadAroundCenter i baseStickSpread]
baseStickSpread :: Float
baseStickSpread = 0.2
@@ -55,14 +55,15 @@ autoPistol =
pistol
& itUse . heldMods .~ PistolMod
& itUse . heldTriggerType .~ AutoTrigger
& itUse . heldParams . bulGunSound .~ tap1S
& itUse . heldParams . bulGunSound .~ (tap1S,0)
& itType . iyBase .~ HELD AUTOPISTOL
& itType . iyModules . at ModAutoMag ?~ EMPTYMODULE
machinePistol :: Item
machinePistol =
autoPistol
& itUse . heldDelay . rateMax .~ 2
& itUse . heldDelay .~ WarmUpNoDelay {_warmTime = 0, _warmMax = 50, _warmSound = crankSlowS}
--rateMax .~ 2
& itUse . heldMods .~ PistolMod -- (ammoCheckI : machinePistolAfterHamMods)
& itType . iyBase .~ HELD MACHINEPISTOL
& itType . iyModules . at ModAutoMag .~ Nothing
+10 -3
View File
@@ -214,7 +214,7 @@ withWarmUp soundID f item cr w
& soundContinue (CrWeaponSound cid 0) (_crPos cr) soundID (Just 2)
| otherwise =
w
& pointertoitem . itUse . heldDelay . warmTime .~ maxWarmUp
& pointertoitem . itUse . heldDelay . warmTime .~ (maxWarmUp + 1)
& f item cr
where
item' = _ldtValue item
@@ -376,8 +376,15 @@ useAmmoAmount amAmount eff item cr = fromMaybe id $ do
Applies a world effect after an item use cooldown check.
-}
useTimeCheck :: ChainEffect
useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay . rateTime of
Just 0 -> f item cr $ setUseTime w
useTimeCheck f item cr w = case item ^? ldtValue . itUse . heldDelay of
Just (FixedRate _ 0) -> f item cr $ setUseTime w
Just (FixedRate _ _) -> w
Just (WarmUpNoDelay wt wm ws) | wt < wm -> w
& soundContinue (CrWeaponSound cid 0) (_crPos cr) ws (Just 2)
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime +~2
Just (WarmUpNoDelay _ wm _) -> f item cr w
& cWorld . lWorld . creatures . ix cid . crInv . ix itRef . itUse . heldDelay . warmTime .~ (wm+1)
Just NoDelay -> f item cr w
_ -> w
where
cid = _crID cr
+6 -2
View File
@@ -20,8 +20,12 @@ fixedCoordPictures u =
<> drawConcurrentMessage u
<> customMouseCursor u
<> toTopLeft cfig (translate (halfWidth cfig) 0 $ drawList (map text (_uvTestString u u)))
<> toTopLeft cfig (translate (0.5 * halfWidth cfig) (- halfHeight cfig)
$ drawList (map text (u ^. uvWorld . cWorld . lWorld . lTestString)))
<> toTopLeft cfig
(translate (0.5 * halfWidth cfig) (- halfHeight cfig)
$ drawList $ map text $
show (u ^. uvWorld . cWorld . lWorld . lTestInt)
: (u ^. uvWorld . cWorld . lWorld . lTestString)
)
<> displayFrameTicks u
where
cfig = _uvConfig u
+201 -197
View File
File diff suppressed because it is too large Load Diff