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
+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