Fix muzzle flare

This commit is contained in:
2023-05-29 16:52:29 +01:00
parent 9283ae187f
commit 02c34f99f1
3 changed files with 79 additions and 61 deletions
+43 -41
View File
@@ -1,7 +1,5 @@
module Dodge.HeldUse where module Dodge.HeldUse where
import Dodge.Wall.Move
import Dodge.Wall.ForceField
import Color import Color
import Data.Maybe import Data.Maybe
import Data.Traversable import Data.Traversable
@@ -18,6 +16,8 @@ import Dodge.Item.Weapon.TriggerType
import Dodge.Projectile.Create import Dodge.Projectile.Create
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.Tesla.Arc import Dodge.Tesla.Arc
import Dodge.Wall.ForceField
import Dodge.Wall.Move
import Dodge.WorldEvent.Flash import Dodge.WorldEvent.Flash
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
@@ -52,8 +52,8 @@ useMod hm = case hm of
] ]
FlameThrowerMod -> FlameThrowerMod ->
[ withSidePushAfterI 20 [ withSidePushAfterI 20
--, withTempLight 1 100 (V3 1 0 0) , --, withTempLight 1 100 (V3 1 0 0)
, withSidePushI 5 withSidePushI 5
, useAmmoAmount 1 , useAmmoAmount 1
, ammoCheckI , ammoCheckI
] ]
@@ -81,9 +81,12 @@ useMod hm = case hm of
] ]
LasWideMod n -> LasWideMod n ->
[ useAmmoAmount 1 [ useAmmoAmount 1
, withItem $ \it -> duplicateNumBarrels (min , withItem $ \it ->
(it ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded) duplicateNumBarrels
(it ^?! itParams . lasCycle `div` lasWideRate)) ( min
(it ^?! itUse . heldConsumption . laSource . _InternalSource . iaLoaded)
(it ^?! itParams . lasCycle `div` lasWideRate)
)
, withItem $ \it -> withCrPos $ flareCircleAt (_lasColor $ _itParams it) 0.8 , withItem $ \it -> withCrPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it)) , withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withSoundForI tone440sawtoothquietS 2 , withSoundForI tone440sawtoothquietS 2
@@ -114,13 +117,13 @@ useMod hm = case hm of
] ]
ShatterMod -> ShatterMod ->
[ useAmmoAmount 1 [ useAmmoAmount 1
-- , withSoundStart tap3S , -- , withSoundStart tap3S
, useTimeCheck useTimeCheck
, ammoCheckI , ammoCheckI
, blCheck , blCheck
] ]
AmmoCheckMod -> [ammoCheckI] AmmoCheckMod -> [ammoCheckI]
AmmoUseCheckMod -> [useAmmoAmount 1,useTimeCheck, ammoCheckI] AmmoUseCheckMod -> [useAmmoAmount 1, useTimeCheck, ammoCheckI]
AmmoHammerTimeUseOneMod -> AmmoHammerTimeUseOneMod ->
[ useAmmoAmount 1 [ useAmmoAmount 1
, useTimeCheck , useTimeCheck
@@ -128,7 +131,7 @@ useMod hm = case hm of
, blCheck , blCheck
] ]
BangCaneMod -> BangCaneMod ->
[ withMuzFlareI [ withFlare
, withSmoke 1 black 20 200 5 , withSmoke 1 black 20 200 5
, withRecoil , withRecoil
, duplicateLoadedBarrels , duplicateLoadedBarrels
@@ -141,7 +144,7 @@ useMod hm = case hm of
] ]
VolleyGunMod -> VolleyGunMod ->
[ withRecoil [ withRecoil
, withMuzFlareI , withFlare
, duplicateLoadedBarrels , duplicateLoadedBarrels
, withTorqueAfter , withTorqueAfter
, useAllAmmo , useAllAmmo
@@ -152,7 +155,7 @@ useMod hm = case hm of
] ]
AutoRifleMod -> AutoRifleMod ->
-- note this is the same as BangCanemMod with the first changed -- note this is the same as BangCanemMod with the first changed
[ withMuzFlareI [ withFlare
, withSmoke 1 black 20 200 5 , withSmoke 1 black 20 200 5
, withRecoil , withRecoil
, duplicateLoadedBarrels , duplicateLoadedBarrels
@@ -164,7 +167,7 @@ useMod hm = case hm of
] ]
BangRodMod -> BangRodMod ->
[ withRecoil [ withRecoil
, withMuzFlareI , withFlare
, withThickSmokeI , withThickSmokeI
, duplicateLoadedBarrels , duplicateLoadedBarrels
, withTorqueAfter , withTorqueAfter
@@ -176,7 +179,7 @@ useMod hm = case hm of
] ]
ElephantGunMod -> ElephantGunMod ->
[ withRecoil [ withRecoil
, withMuzFlareI , withFlare
, withThickSmokeI , withThickSmokeI
, duplicateLoadedBarrels , duplicateLoadedBarrels
, withTorqueAfter , withTorqueAfter
@@ -188,7 +191,7 @@ useMod hm = case hm of
] ]
AutoAmrMod -> AutoAmrMod ->
[ withRecoil [ withRecoil
, withMuzFlareI , withFlare
, withThickSmokeI , withThickSmokeI
, duplicateLoadedBarrels , duplicateLoadedBarrels
, withTorqueAfter , withTorqueAfter
@@ -198,7 +201,7 @@ useMod hm = case hm of
, ammoCheckI -- cf ElephantGun , ammoCheckI -- cf ElephantGun
] ]
MachineGunMod -> MachineGunMod ->
[ withMuzFlareI [ withFlare
, withThinSmokeI , withThinSmokeI
, withSoundStart bangEchoS , withSoundStart bangEchoS
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter , rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
@@ -212,7 +215,7 @@ useMod hm = case hm of
, withSoundItemChoiceStart bangStickSoundChoice , withSoundItemChoiceStart bangStickSoundChoice
, duplicateLoadedBarrels , duplicateLoadedBarrels
, withTorqueAfter , withTorqueAfter
, withMuzFlareI , withFlare
, useTimeCheck , useTimeCheck
, ammoCheckI , ammoCheckI
, blCheck , blCheck
@@ -220,7 +223,7 @@ useMod hm = case hm of
PistolMod -> PistolMod ->
[ withSidePushI 50 [ withSidePushI 50
, withRecoil , withRecoil
, withMuzFlareI , withFlare
, withTorqueAfter , withTorqueAfter
, duplicateLoadedBarrels , duplicateLoadedBarrels
, withSoundStart tap3S , withSoundStart tap3S
@@ -230,7 +233,7 @@ useMod hm = case hm of
, blCheck , blCheck
] ]
AutoPistolMod -> AutoPistolMod ->
[ withMuzFlareI [ withFlare
, withSidePushI 50 , withSidePushI 50
, withRecoil , withRecoil
, withTorqueAfter , withTorqueAfter
@@ -241,7 +244,7 @@ useMod hm = case hm of
, ammoCheckI , ammoCheckI
] ]
MachinePistolMod -> MachinePistolMod ->
[ withMuzFlareI [ withFlare
, withRecoil , withRecoil
, withSidePushI 50 , withSidePushI 50
, withTorqueAfter , withTorqueAfter
@@ -253,7 +256,7 @@ useMod hm = case hm of
] ]
BurstRifleMod -> BurstRifleMod ->
[ withRecoil [ withRecoil
, withMuzFlareI , withFlare
, duplicateLoadedBarrels , duplicateLoadedBarrels
, useAmmoAmount 1 , useAmmoAmount 1
, withSoundStart tap3S , withSoundStart tap3S
@@ -266,7 +269,7 @@ useMod hm = case hm of
] ]
BurstRifleRepeatMod -> BurstRifleRepeatMod ->
[ withRecoil [ withRecoil
, withMuzFlareI , withFlare
, duplicateLoadedBarrels , duplicateLoadedBarrels
, useAmmoAmount 1 , useAmmoAmount 1
, withSoundStart tap3S , withSoundStart tap3S
@@ -274,23 +277,23 @@ useMod hm = case hm of
, ammoCheckI , ammoCheckI
] ]
MiniGunMod i -> MiniGunMod i ->
reverse [ trigDoAlso' (moddelay x) (modcrpos x) useAmmoParams [ duplicateNumBarrels 1
| x <- map ((/ fromIntegral i) . fromIntegral) [1 .. i -1] , repeatTransformed
] [ (moddelay x, modcrpos x)
<> | x <- map ((/ (fromIntegral i - 1)) . fromIntegral) [0 .. i -1]
[ afterRecoil (fromIntegral i * 5) ]
, afterRecoil (fromIntegral i * 5)
, torqueBefore (fromIntegral i * 0.05) , torqueBefore (fromIntegral i * 0.05)
, withSidePushI (fromIntegral i * 50) , withSidePushI (fromIntegral i * 25)
, withMuzFlare
, withSmoke 1 black 20 200 5
, useAmmoAmount i , useAmmoAmount i
, withMuzFlareI
, withSmoke 1 black 20 200 5
--, withThinSmokeI
, withSoundForI mini1S 2 , withSoundForI mini1S 2
, withWarmUp crankSlowS , withWarmUp crankSlowS
, ammoCheckI , ammoCheckI
] ]
SmgMod -> SmgMod ->
[ withMuzFlareI [ withFlare
, withSidePushI 30 , withSidePushI 30
, withRecoil , withRecoil
, withTorqueAfter , withTorqueAfter
@@ -303,26 +306,25 @@ useMod hm = case hm of
RevolverXMod -> RevolverXMod ->
[ withRecoil [ withRecoil
, withTorqueAfter , withTorqueAfter
-- , spreadLoaded , withFlare
, withMuzFlareI
, duplicateLoadedBarrels , duplicateLoadedBarrels
, useAmmoUpTo 1 , useAmmoUpTo 1
, withSoundStart tap3S , withSoundStart tap3S
, repeatOnFrames [2, 4, 6, 8, 10] RevolverXRepeatMod , repeatOnFrames [2, 4, 6, 8, 10] RevolverXRepeatMod
, lockInvFor 10 , lockInvFor 10
-- rather than locking the inventory, a better solution may be to check , -- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames -- that the weapon is still in your hands in the repeated frames
, useTimeCheck useTimeCheck
, ammoCheckI , ammoCheckI
, blCheck , blCheck
] ]
RevolverXRepeatMod -> RevolverXRepeatMod ->
[ withRecoil [ withRecoil
, withTorqueAfter , withTorqueAfter
, withMuzFlareI , withFlare
, duplicateLoadedBarrels , duplicateLoadedBarrels
, useAmmoUpTo 1 , useAmmoUpTo 1
, withSoundStart tap3S , withSoundStart tap3S
, ammoCheckI , ammoCheckI
] ]
BangConeMod -> BangConeMod ->
@@ -331,7 +333,7 @@ useMod hm = case hm of
, withRandomOffset , withRandomOffset
, duplicateLoadedBarrels , duplicateLoadedBarrels
, duplicateLoaded , duplicateLoaded
, withMuzFlareI , withMuzFlare
, withRecoil , withRecoil
, withTorqueAfter , withTorqueAfter
, useAllAmmo , useAllAmmo
+5 -10
View File
@@ -110,16 +110,11 @@ miniGunX i =
autoRifle autoRifle
& itUse .~ miniGunUse i & itUse .~ miniGunUse i
& itUse . heldAim . aimTurnSpeed .~ 0.5 & itUse . heldAim . aimTurnSpeed .~ 0.5
& itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 15 0) 0 0.05) & itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 30 0) 0 0.05)
& itParams -- & itUse . heldAim . aimMuzzles .~ replicate i (Muzzle (V2 50 0) 0 0.05)
.~ BulletShooter & itParams . recoil .~ 10
{ _muzVel = 1 & itParams . torqueAfter .~ 0.01
, _rifling = 0.9 & itParams . randomOffset .~ 10
, _bore = 2
, _recoil = 10
, _torqueAfter = 0
, _randomOffset = 10
}
& itInvSize .~ fromIntegral i + 1 & itInvSize .~ fromIntegral i + 1
& itDimension . dimRad .~ 20 & itDimension . dimRad .~ 20
& itDimension . dimCenter .~ V3 5 0 0 & itDimension . dimCenter .~ V3 5 0 0
+31 -10
View File
@@ -8,12 +8,12 @@ module Dodge.Item.Weapon.TriggerType (
useAllAmmo, useAllAmmo,
useAmmoUpTo, useAmmoUpTo,
lockInvFor, lockInvFor,
withMuzFlareI, withFlare,
withMuzFlare,
withCrPos, withCrPos,
withCrPosShift, withCrPosShift,
withOldDir, withOldDir,
trigDoAlso, trigDoAlso,
trigDoAlso',
withTempLight, withTempLight,
withItem, withItem,
withItemUpdate, withItemUpdate,
@@ -57,6 +57,7 @@ module Dodge.Item.Weapon.TriggerType (
ammoCheckI, ammoCheckI,
modClock, modClock,
blCheck, blCheck,
repeatTransformed,
) where ) where
import Dodge.Item.Location import Dodge.Item.Location
@@ -90,18 +91,25 @@ lockInvFor i f it cr =
f it cr . (cWorld . lWorld . delayedEvents .:~ (i, UnlockInv (_crID cr))) f it cr . (cWorld . lWorld . delayedEvents .:~ (i, UnlockInv (_crID cr)))
. lockInv (_crID cr) . lockInv (_crID cr)
trigDoAlso' :: repeatTransformed ::
[(Item -> Item,Creature -> Creature)] ->
ChainEffect
repeatTransformed xs f itm cr w = foldr g w xs
where
g (fit,fcr) = f (fit itm) (fcr cr)
trigDoAlso ::
(Item -> Item) -> (Item -> Item) ->
(Creature -> Creature) -> (Creature -> Creature) ->
(Item -> Creature -> World -> World) -> (Item -> Creature -> World -> World) ->
ChainEffect ChainEffect
trigDoAlso' fit fcr f g itm cr = g itm cr . f (fit itm) (fcr cr) trigDoAlso fit fcr f g itm cr = g itm cr . f (fit itm) (fcr cr)
-- Note that this uses the "base" creature and item values -- Note that this uses the "base" creature and item values
trigDoAlso :: --trigDoAlso ::
(Item -> Creature -> World -> World) -> -- (Item -> Creature -> World -> World) ->
ChainEffect -- ChainEffect
trigDoAlso afterEff eff item cr = afterEff item cr . eff item cr --trigDoAlso afterEff eff item cr = afterEff item cr . eff item cr
withSmoke :: Int -> Point4 -> Float -> Int -> Float -> ChainEffect withSmoke :: Int -> Point4 -> Float -> Int -> Float -> ChainEffect
withSmoke num col rad t alt eff item cr w = withSmoke num col rad t alt eff item cr w =
@@ -453,8 +461,8 @@ modClock n chainEff eff it cr w
| (w ^. cWorld . lWorld . lClock) `mod` n == 0 = chainEff eff it cr w | (w ^. cWorld . lWorld . lClock) `mod` n == 0 = chainEff eff it cr w
| otherwise = eff it cr w | otherwise = eff it cr w
withMuzFlareI :: ChainEffect withFlare :: ChainEffect
withMuzFlareI f it cr = withFlare f it cr =
makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (cpos `v2z` 20) makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (cpos `v2z` 20)
-- . muzFlareAt (V4 5 5 0 2) (cpos `v2z` 20) cdir -- . muzFlareAt (V4 5 5 0 2) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir . muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
@@ -465,6 +473,19 @@ withMuzFlareI f it cr =
cdir = _crDir cr cdir = _crDir cr
cpos = _crPos cr cpos = _crPos cr
withMuzFlare :: ChainEffect
withMuzFlare f itm cr =
makeTlsTimeRadColPos 2 100 (V3 1 1 0.5) (cpos `v2z` 20)
-- . muzFlareAt (V4 5 5 0 2) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. muzFlareAt (V4 10 10 1 3) (cpos `v2z` 20) cdir
. f itm cr
where
cdir = _crDir cr
cpos = _crPos cr + rotateV (_crDir cr) (_mzPos brl + aimingWeaponZeroPos cr itm)
brl = itm ^?! itUse . heldAim . aimMuzzles . ix 0
--muzzleOffset :: Creature -> Item -> Point3 --muzzleOffset :: Creature -> Item -> Point3
--muzzleOffset cr it = V3 (holdOffset + 5 + _aimMuzPos dimPort - _aimHandlePos dimPort) 0 0 --muzzleOffset cr it = V3 (holdOffset + 5 + _aimMuzPos dimPort - _aimHandlePos dimPort) 0 0
-- where -- where