Fix bug where new sounds didn't overplay old sounds
This commit is contained in:
@@ -291,10 +291,11 @@ ltAutoGun = defaultAutoGun
|
||||
, _wpReloadState = 0
|
||||
, _itUseRate = 3
|
||||
, _itUseTime = 0
|
||||
, _itUse = \_ -> withSidePush 50 $ withVelWthHiteff (V2 30 0) 2 basicBulletEffect
|
||||
, _itUse = useAmmoParams
|
||||
, _itUseModifiers =
|
||||
[ shootWithSoundI 0
|
||||
, withRandomDirI 0.3
|
||||
, withSidePushI 50
|
||||
, withMuzFlareI
|
||||
]
|
||||
, _wpSpread = 0.5
|
||||
@@ -305,6 +306,7 @@ ltAutoGun = defaultAutoGun
|
||||
, _itZoom = defaultItZoom
|
||||
, _itEquipPict = pictureWeaponOnAim ltAutoGunPic
|
||||
, _itAimStance = OneHand
|
||||
, _wpAmmo = ltBullet
|
||||
}
|
||||
ltAutoGunPic :: Picture
|
||||
ltAutoGunPic = color green $ pictures
|
||||
@@ -319,9 +321,12 @@ miniGun = defaultAutoGun
|
||||
, _wpLoadedAmmo = 150
|
||||
, _wpReloadTime = 200
|
||||
, _wpReloadState = 0
|
||||
, _wpMaxWarmUp = 100
|
||||
, _itUseRate = 2
|
||||
, _itUseTime = 0
|
||||
, _itUse = \_ -> withWarmUp 50 . torqueBefore 0.03 . withSidePush 50 . withRecoil 15
|
||||
, _itUse = \_ -> withWarmUp 50
|
||||
. shootWithSoundFor 28 2
|
||||
. torqueBefore 0.03 . withSidePush 50 . withRecoil 15
|
||||
. withRandomDir 0.1
|
||||
. withRandomOffset 9
|
||||
. withMuzFlare
|
||||
|
||||
@@ -12,6 +12,13 @@ basicBullet = BulletAmmo
|
||||
, _amBulWth = 2
|
||||
, _amBulVel = V2 50 0
|
||||
}
|
||||
ltBullet :: Ammo
|
||||
ltBullet = BulletAmmo
|
||||
{ _amString = "LTBULLET"
|
||||
, _amBulEff = destroyOnImpact bulHitCr bulHitWall' bulHitFF'
|
||||
, _amBulWth = 2
|
||||
, _amBulVel = V2 40 0
|
||||
}
|
||||
hvBullet :: Ammo
|
||||
hvBullet = BulletAmmo
|
||||
{ _amString = "HVBULLET"
|
||||
|
||||
@@ -89,25 +89,23 @@ withWarmUp
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
withWarmUp t f cr w
|
||||
withWarmUp t f cr w
|
||||
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||
| _wpReloadState item /= 0 = w
|
||||
| fState == 0 = w
|
||||
& pointerToItem %~ ( (itUse .~ (\_ -> withWarmUp 100 f)) . (itUseTime .~ 2) )
|
||||
| t > 2 = w
|
||||
& pointerToItem %~ ( (itUse .~ (\_ -> withWarmUp (t-1) f)) . (itUseTime .~ 2) )
|
||||
| curWarmUp < maxWarmUp = w
|
||||
& pointerToItem . wpCurWarmUp +~ 2
|
||||
& soundFrom (CrWeaponSound cid) 26 2 0
|
||||
| t > 0 = w
|
||||
& pointerToItem %~ ( (itUse .~ (\_ -> withWarmUp (t-1) f)) . (itUseTime .~ 2) )
|
||||
| otherwise = w
|
||||
& pointerToItem %~ ( (itUse .~ (\_ -> withWarmUp 1 f)) . (wpLoadedAmmo -~ 1) . (itUseTime .~ 2) )
|
||||
| otherwise = w
|
||||
& pointerToItem . wpCurWarmUp .~ maxWarmUp
|
||||
& f cr
|
||||
& soundFrom (CrWeaponSound cid) 28 2 0
|
||||
-- & soundFrom (CrWeaponSound cid) 28 2 0
|
||||
where
|
||||
cid = _crID cr
|
||||
itRef = _crInvSel cr
|
||||
item = _crInv cr IM.! itRef
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
curWarmUp = _wpCurWarmUp item
|
||||
maxWarmUp = _wpMaxWarmUp item
|
||||
fState = _itUseTime item
|
||||
reloadCondition = _wpLoadedAmmo item == 0
|
||||
{- | Adds a sound to a creature based world effect.
|
||||
@@ -133,11 +131,13 @@ withRecoil recoilAmount eff cr = eff cr . over (creatures . ix cid) pushback
|
||||
Applied before the underlying effect. -}
|
||||
withSidePushI
|
||||
:: Float -- ^ Maximal possible side push amount
|
||||
-> (Creature -> World -> World)
|
||||
-- ^ Underlying world effect, takes creature id as input
|
||||
-> (Item -> Creature -> World -> World)
|
||||
-- ^ Underlying world effect
|
||||
-> Item
|
||||
-> Creature
|
||||
-> World -> World
|
||||
withSidePushI maxSide eff cr w = eff cr . over (creatures . ix cid) push $ w
|
||||
withSidePushI maxSide eff item cr w = eff item cr $
|
||||
w & creatures . ix cid %~ push
|
||||
where
|
||||
cid = _crID cr
|
||||
push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr)))
|
||||
@@ -170,6 +170,32 @@ withSidePushAfter maxSide eff cr w = over (creatures . ix cid) push . eff cr $ w
|
||||
push = over crPos (+.+ rotateV (_crDir cr) (V2 0 (pushAmount / _crMass cr)))
|
||||
(pushAmount, _) = randomR (-maxSide,maxSide) $ _randGen w
|
||||
{- | Applies a world effect and sound effect after an ammo check. -}
|
||||
shootWithSoundFor
|
||||
:: Int -- ^ Sound identifier
|
||||
-> Int -- ^ Frames to play
|
||||
-> (Creature -> World -> World)
|
||||
-- ^ Shoot effect, takes creature id as input
|
||||
-> Creature
|
||||
-> World
|
||||
-> World
|
||||
shootWithSoundFor soundid playTime f cr w
|
||||
| fireCondition = over (pointerToItem . wpLoadedAmmo) (\ammo -> ammo-1)
|
||||
$ soundFromPos (CrWeaponSound cid) cpos soundid playTime 0
|
||||
$ set (pointerToItem . itUseTime) (_itUseRate item)
|
||||
$ f cr w
|
||||
| reloadCondition = fromMaybe w $ startReloadingWeapon cr w
|
||||
| otherwise = w
|
||||
where
|
||||
cid = _crID cr
|
||||
cpos = _crPos cr
|
||||
itRef = _crInvSel cr
|
||||
item = _crInv cr IM.! itRef
|
||||
pointerToItem = creatures . ix cid . crInv . ix itRef
|
||||
fireCondition = _wpReloadState item == 0
|
||||
&& _itUseTime item == 0
|
||||
&& _wpLoadedAmmo item > 0
|
||||
reloadCondition = _wpLoadedAmmo item == 0
|
||||
{- | Applies a world effect and sound effect after an ammo check. -}
|
||||
shootWithSound
|
||||
:: Int -- ^ Sound identifier
|
||||
-> (Creature -> World -> World)
|
||||
|
||||
Reference in New Issue
Block a user