Implement burstRifle using attachment weapon chain
This commit is contained in:
+123
-99
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user