Implement burstRifle using attachment weapon chain

This commit is contained in:
2024-09-17 11:05:34 +01:00
parent ecc63a70cc
commit 791003ebb9
11 changed files with 324 additions and 319 deletions
+4 -4
View File
@@ -85,12 +85,12 @@ data HeldMod
-- | VolleyGunMod
-- | MultiGunMod
-- | AutoRifleMod
| BangRodMod
| ElephantGunMod
| AutoAmrMod
-- | BangRodMod
-- | ElephantGunMod
-- | AutoAmrMod
| MachineGunMod
-- | ModWithDirectedTeleport HeldMod
| BangStickMod
-- | BangStickMod
| PistolMod
-- | AutoPistolMod
-- | MachinePistolMod
+3
View File
@@ -83,6 +83,8 @@ data HeldParams
, _randomOffset :: Float
, _sidePush :: Float
, _bulGunSound :: SoundID
, _weaponInvLock :: Int
, _weaponRepeat :: [Int]
}
deriving (Eq, Show, Read) --Generic, Flat)
@@ -128,6 +130,7 @@ data AimParams = AimParams
data FlareType = DefaultFlareType
| PistolFlare
| HeavySmokeFlare
deriving (Eq, Ord, Show, Read) --Generic, Flat)
data Muzzle = Muzzle
+2
View File
@@ -43,6 +43,8 @@ defaultHeldUse =
, _randomOffset = 0
, _sidePush = 0
, _bulGunSound = tap3S
, _weaponInvLock = 0
, _weaponRepeat = []
}
, _heldTriggerType = HammerTrigger
}
+123 -99
View File
@@ -1,9 +1,11 @@
{-# LANGUAGE TupleSections #-}
module Dodge.HeldUse
-- ( heldEffect
-- , mcUseHeld
-- )
where
import Dodge.Inventory.Lock
import Dodge.WorldEvent.Cloud
import Dodge.LightSource
import qualified SDL
@@ -172,41 +174,41 @@ heldEffect effecttype = case effecttype of
-- , useTimeCheck
-- , ammoCheckI
-- ]
BangRodMod -> bulletGunEffect
[ withRecoil
, withFlare
, withThickSmokeI
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoCheckI
, blCheck
]
ElephantGunMod -> bulletGunEffect
[ withRecoil
, withFlare
, withThickSmokeI
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoCheckI
, blCheck
]
AutoAmrMod -> bulletGunEffect
[ withRecoil
, withFlare
, withThickSmokeI
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoCheckI -- cf ElephantGun
]
-- BangRodMod -> bulletGunEffect
-- [ withRecoil
-- , withFlare
-- , withThickSmokeI
-- , duplicateLoadedBarrels
-- , withTorqueAfter
-- , useAmmoAmount 1
-- , withSoundStart bangEchoS
-- , useTimeCheck
-- , ammoCheckI
-- , blCheck
-- ]
-- ElephantGunMod -> bulletGunEffect
-- [ withRecoil
-- , withFlare
-- , withThickSmokeI
-- , duplicateLoadedBarrels
-- , withTorqueAfter
-- , useAmmoAmount 1
-- , withSoundStart bangEchoS
-- , useTimeCheck
-- , ammoCheckI
-- , blCheck
-- ]
-- AutoAmrMod -> bulletGunEffect
-- [ withRecoil
-- , withFlare
-- , withThickSmokeI
-- , duplicateLoadedBarrels
-- , withTorqueAfter
-- , useAmmoAmount 1
-- , withSoundStart bangEchoS
-- , useTimeCheck
-- , ammoCheckI -- cf ElephantGun
-- ]
MachineGunMod -> bulletGunEffect
[ withFlare
, withThinSmokeI
@@ -214,17 +216,17 @@ heldEffect effecttype = case effecttype of
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
, ammoCheckI
]
BangStickMod -> bulletGunEffect
[ withRecoil
, useAllAmmo
, withSoundItemChoiceStart bangStickSoundChoice
, duplicateLoadedBarrels
, withTorqueAfter
, withFlare
, useTimeCheck
, ammoCheckI
, blCheck
]
-- BangStickMod -> bulletGunEffect
-- [ withRecoil
-- , useAllAmmo
-- , withSoundItemChoiceStart bangStickSoundChoice
-- , duplicateLoadedBarrels
-- , withTorqueAfter
-- , withFlare
-- , useTimeCheck
-- , ammoCheckI
-- , blCheck
-- ]
PistolMod -> bulGunEffect
-- AutoPistolMod -> bulletGunEffect
-- [ withFlare
@@ -354,14 +356,23 @@ bulGunEffect = hammerCheck $ useTimeCheck bulGunEffect'
bulGunEffect' :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
bulGunEffect' t cr w = fromMaybe (error "error in bulGunEffect") $ do
muzzles <- t ^? ldtValue . itUse . heldAim . aimMuzzles
let (_,loadedmuzzles) = mapAccumR loadMuzzle t muzzles
let (upitm,loadedmuzzles) = mapAccumR loadMuzzle t muzzles
cmew = foldl' (useLoadedAmmo (_ldtValue t) cr) (CME 0 0 False,w) $ loadedmuzzles
return $ uncurry (applyCME (_ldtValue t) cr) cmew
& cWorld . lWorld . lTestString .~ map (show . _mzAmmoSlot) muzzles
& doWeaponRepetitions upitm cr
doWeaponRepetitions :: LabelDoubleTree ComposeLinkType Item -> Creature -> World -> World
doWeaponRepetitions itm cr = case itm ^? ldtValue . itUse . heldParams . weaponRepeat of
Just (x:xs) -> cWorld . lWorld . delayedEvents .++~ ((x:xs) <&> (,WdWdFromItCrixWdWd upitm (_crID cr) ItCrWdItemEffect))
_ -> id
where
upitm = itm & ldtValue . itUse . heldParams . weaponRepeat .~ []
& ldtValue . itUse . heldTriggerType .~ AutoTrigger
applyCME :: Item -> Creature -> CumulativeMuzzleEffect -> World -> World
applyCME itm cr cme
| _cmeSound cme = applySoundCME itm cr . applySidePush spush cr . applyTorqueCME itm cr . applyRecoil itm cr
| _cmeSound cme = applyInvLock itm cr . applySoundCME itm cr . applySidePush spush cr . applyTorqueCME itm cr . applyRecoil itm cr
| otherwise = failsound
where
spush = fromMaybe 0 $ itm ^? itUse . heldParams . sidePush
@@ -369,6 +380,14 @@ applyCME itm cr cme
Just 0 -> soundStart (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w
_ -> soundContinue (CrWeaponSound (_crID cr) 0) (_crPos cr) click1S Nothing w
applyInvLock :: Item -> Creature -> World -> World
applyInvLock itm cr = case itm ^? itUse . heldParams . weaponInvLock of
Just i | i > 0 -> (cWorld . lWorld . delayedEvents .:~ (i, UnlockInv cid))
. lockInv cid
_ -> id
where
cid = _crID cr
applySoundCME :: Item -> Creature -> World -> World
applySoundCME itm cr = fromMaybe id $ do
soundid <- itm ^? itUse . heldParams . bulGunSound
@@ -427,21 +446,26 @@ loadMuzzle t@(LDT _ l _) mz = fromMaybe (t,(mz, 0,Nothing)) $ do
makeMuzzleFlare :: Muzzle -> Item -> Creature -> World -> World
makeMuzzleFlare mz itm cr = case mz ^. mzFlareType of
DefaultFlareType -> id
PistolFlare -> makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (pos `v2z` 20)
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
PistolFlare -> basicMuzFlare pos dir
HeavySmokeFlare -> basicMuzFlare pos dir
where
pos = _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
dir = _crDir cr + _mzRot mz
basicMuzFlare :: Point2 -> Float -> World -> World
basicMuzFlare pos dir = makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (pos `v2z` 20)
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
. muzFlareAt (V4 10 10 1 3) (pos `v2z` 20) dir
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
HeavySmokeFlare -> foldl' (flip $ smokeCloudAt black 20 400 5 . (+.+.+ pos) . (* 8)) w ps'
where
ps = replicateM 2 randOnUnitSphere & evalState $ _randGen w
ps' = replicateM 4 randOnUnitSphere & evalState $ _randGen w
pos = addZ 10 $ _crPos cr + rotateV (_crDir cr) (_mzPos mz + aimingWeaponZeroPos cr itm)
-- , withSmoke 1 black 20 200 5
@@ -662,41 +686,41 @@ useMod hm = case hm of
-- , useTimeCheck
-- , ammoCheckI
-- ]
BangRodMod ->
[ withRecoil
, withFlare
, withThickSmokeI
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoCheckI
, blCheck
]
ElephantGunMod ->
[ withRecoil
, withFlare
, withThickSmokeI
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoCheckI
, blCheck
]
AutoAmrMod ->
[ withRecoil
, withFlare
, withThickSmokeI
, duplicateLoadedBarrels
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoCheckI -- cf ElephantGun
]
-- BangRodMod ->
-- [ withRecoil
-- , withFlare
-- , withThickSmokeI
-- , duplicateLoadedBarrels
-- , withTorqueAfter
-- , useAmmoAmount 1
-- , withSoundStart bangEchoS
-- , useTimeCheck
-- , ammoCheckI
-- , blCheck
-- ]
-- ElephantGunMod ->
-- [ withRecoil
-- , withFlare
-- , withThickSmokeI
-- , duplicateLoadedBarrels
-- , withTorqueAfter
-- , useAmmoAmount 1
-- , withSoundStart bangEchoS
-- , useTimeCheck
-- , ammoCheckI
-- , blCheck
-- ]
-- AutoAmrMod ->
-- [ withRecoil
-- , withFlare
-- , withThickSmokeI
-- , duplicateLoadedBarrels
-- , withTorqueAfter
-- , useAmmoAmount 1
-- , withSoundStart bangEchoS
-- , useTimeCheck
-- , ammoCheckI -- cf ElephantGun
-- ]
MachineGunMod ->
[ withFlare
, withThinSmokeI
@@ -706,17 +730,17 @@ useMod hm = case hm of
]
-- ModWithDirectedTeleport hm' ->
-- reverse $ withPosDirWallCheck directedTelPos : useMod hm'
BangStickMod ->
[ withRecoil
, useAllAmmo
, withSoundItemChoiceStart bangStickSoundChoice
, duplicateLoadedBarrels
, withTorqueAfter
, withFlare
, useTimeCheck
, ammoCheckI
, blCheck
]
-- BangStickMod ->
-- [ withRecoil
-- , useAllAmmo
-- , withSoundItemChoiceStart bangStickSoundChoice
-- , duplicateLoadedBarrels
-- , withTorqueAfter
-- , withFlare
-- , useTimeCheck
-- , ammoCheckI
-- , blCheck
-- ]
PistolMod ->
[ withSidePushI 50
, withRecoil
+8 -13
View File
@@ -6,7 +6,6 @@ module Dodge.Item.Held.Cane (
miniGunX,
) where
import Dodge.SoundLogic.ExternallyGeneratedSounds
import Dodge.Base
import Dodge.Data.Item
import Dodge.Default
@@ -19,16 +18,9 @@ import Control.Applicative
defaultBangCane :: Item
defaultBangCane =
defaultBulletWeapon
& itUse . heldParams
.~ BulletShooterParams
{ _muzVel = ConstFloat 0.8
, _rifling = ConstFloat 0.9
, _recoil = 50
, _torqueAfter = 0.1
, _randomOffset = 0
, _sidePush = 0
, _bulGunSound = tap3S
}
& itUse . heldParams . rifling .~ ConstFloat 0.9
& itUse . heldParams . recoil .~ 50
& itUse . heldParams . torqueAfter .~ 0.1
& itDimension . dimRad .~ 8
& itDimension . dimCenter .~ V3 5 0 0
& itUse . heldDelay . rateMax .~ 6
@@ -86,8 +78,11 @@ burstRifle =
rifle
& itType . iyBase .~ HELD BURSTRIFLE
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldDelay . rateMax .~ 18
& itUse . heldMods .~ BurstRifleMod
-- & itUse . heldDelay . rateMax .~ 18
& itUse . heldDelay . rateMax .~ 6
-- & itUse . heldMods .~ BurstRifleMod
& itUse . heldParams . weaponInvLock .~ 7
& itUse . heldParams . weaponRepeat .~ [3,6]
miniGunUse :: Int -> ItemUse
miniGunUse i =
+6 -9
View File
@@ -17,15 +17,12 @@ bangCone =
& itUse . heldMods .~ PistolMod
-- & itUse . heldAim . aimHandlePos .~ 5
& itUse . heldAim . aimMuzzles .~ replicate 15 (Muzzle (V2 15 0) 0 0.5 0 DefaultFlareType)
& itUse . heldParams .~ BulletShooterParams
{ _muzVel = UniRandFloat 0.5 0.8
, _rifling = UniRandFloat 0.3 0.9
, _recoil = 150
, _torqueAfter = 0.1
, _randomOffset = 12
, _sidePush = 0
, _bulGunSound = bangEchoS
}
& 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
& itType . iyBase .~ HELD BANGCONE
blunderbuss :: Item
+5 -14
View File
@@ -18,18 +18,11 @@ import LensHelp
bangRod :: Item
bangRod =
defaultBulletWeapon
& itUse . heldParams
.~ BulletShooterParams
{ _muzVel = ConstFloat 0.8
, _rifling = ConstFloat 1
, _recoil = 50
, _torqueAfter = 0.3
, _randomOffset = 0
, _sidePush = 0
, _bulGunSound = bangEchoS
}
& itUse . heldParams . rifling .~ ConstFloat 1
& itUse . heldParams . recoil .~ 50
& itUse . heldParams . torqueAfter .~ 0.3
& itUse . heldParams . bulGunSound .~ bangEchoS
& itUse . heldDelay . rateMax .~ 12
& itUse . heldMods .~ BangRodMod
& itDimension . dimRad .~ 12
& itDimension . dimCenter .~ V3 5 0 0
& itType . iyBase .~ HELD BANGROD
@@ -38,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 DefaultFlareType]
& itUse . heldAim . aimMuzzles .~ [Muzzle (V2 30 0) 0 0.1 0 HeavySmokeFlare]
-- & itUse . heldConsumption . laAmmoType .~ hvBulletAmmo
elephantGun :: Item
@@ -47,7 +40,6 @@ elephantGun =
& itType . iyBase .~ HELD ELEPHANTGUN
& itUse . heldAim . aimStance .~ TwoHandUnder
& itUse . heldAim . aimMuzzles . ix 0 . mzInaccuracy .~ 0.05
& itUse . heldMods .~ ElephantGunMod
& itUse . heldParams . recoil .~ 50
amr :: Item
@@ -59,7 +51,6 @@ autoAmr :: Item
autoAmr =
amr
& itType . iyBase .~ HELD AUTOAMR
& itUse . heldMods .~ AutoAmrMod
sniperRifle :: Item
sniperRifle =
+4 -11
View File
@@ -17,22 +17,15 @@ import LensHelp
bangStick :: Int -> Item
bangStick i =
defaultBulletWeapon
& itUse . heldParams
.~ BulletShooterParams
{ _muzVel = ConstFloat 0.8
, _rifling = ConstFloat 0.8
, _recoil = 25
, _torqueAfter = 0.18 + 0.02 * fromIntegral i
, _randomOffset = 0
, _sidePush = 0
, _bulGunSound = tap3S
}
& itUse . heldParams . recoil .~ 25
& itUse . heldParams . torqueAfter .~ 0.18 + 0.02 * fromIntegral i
& itType . iyBase .~ HELD (BANGSTICK i)
& itInvSize .~ fromIntegral i / 3
& itDimension . dimRad .~ 5
& itDimension . dimCenter .~ V3 5 0 0
& itUse . heldDelay . rateMax .~ 8
& itUse . heldMods .~ BangStickMod
-- & itUse . heldMods .~ BangStickMod
& itUse . heldMods .~ PistolMod
& itUse . heldAim . aimMuzzles
.~ [Muzzle (V2 10 0) a 0.01 0 DefaultFlareType | a <- spreadAroundCenter i baseStickSpread]