Start implementing sticky grenades

This commit is contained in:
2025-01-01 17:03:10 +00:00
parent 356301fb61
commit e8fe4c2d72
16 changed files with 585 additions and 536 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -30,7 +30,7 @@ import RandomHelp
splinterBlock :: Block -> World -> World
splinterBlock bl w =
foldl' unshadowBlock w (_blShadows bl) -- foldr shiftTowardCen w (_blWallIDs bl)
& originsIDsAt
& soundOriginsIDsAt
[MaterialSound bm 0, MaterialSound bm 1, MaterialSound bm 2]
(weakenMatS bm)
(_blPos bl)
+2 -2
View File
@@ -57,7 +57,7 @@ makeDebrisDirectedHeight mindist maxdist arcrad dir maxh bm col p w =
w
& flip (foldl' (flip $ plNew (cWorld . lWorld . props) prID)) thedebris
& randGen .~ newg
& originsIDsAt [MaterialSound bm i | i <- [0, 1, 2]] (destroyMatS bm) p
& soundOriginsIDsAt [MaterialSound bm i | i <- [0, 1, 2]] (destroyMatS bm) p
where
dsize = debrisSize bm
(thedebris, newg) = mapM f [10, 10 + dsize .. maxh + 5] & runState $ _randGen w
@@ -90,7 +90,7 @@ makeDebrisDirected mindist maxdist arcrad dir bm col p w =
w
& flip (foldl' (flip $ plNew (cWorld . lWorld . props) prID)) thedebris
& randGen .~ newg
& originsIDsAt [MaterialSound bm i | i <- [0, 1, 2]] (destroyMatS bm) p
& soundOriginsIDsAt [MaterialSound bm i | i <- [0, 1, 2]] (destroyMatS bm) p
where
(thedebris, newg) = mapM f [35, 55 .. 95] & runState $ _randGen w
f h = do
+1
View File
@@ -261,6 +261,7 @@ inventoryX c = case c of
, megaShellMag
, homingModule
, gLauncher
, stickyMod
]
<> [shellModule p | p <- [minBound .. maxBound]]
'V' ->
+2
View File
@@ -32,6 +32,7 @@ data ComposeLinkType
| ProjectileStabiliserLink
| UnderBarrelSlotLink
| UnderBarrelPlatformLink
| GrenadeHitEffectLink
deriving (Eq, Ord, Show, Read)
data ItemStructuralFunction
@@ -59,6 +60,7 @@ data ItemStructuralFunction
| FunctionChangeSF
| MakeAutoSF
| ProjectileStabiliserSF
| GrenadeHitEffectSF
deriving (Eq, Ord, Show, Read)
type ComposedItem = (Item, ItemStructuralFunction, LinkTest)
+2
View File
@@ -51,6 +51,8 @@ data RocketHoming
data GrenadeHitEffect
= GBounce {_bounceTolerance :: Float}
| GStick
| GStuckCreature {_stuckCrID :: Int, _stuckCrOffset :: Point2}
| GStuckWall {_stuckWlID :: Int}
deriving (Show, Eq, Ord, Read) --Generic, Flat)
data RocketSmoke
-1
View File
@@ -121,7 +121,6 @@ displaySectionsSizes 3 = 10
displaySectionsSizes _ = 3
displayIndents :: Int -> Int
--displayIndents (-3) = 2
displayIndents 0 = 2
displayIndents 3 = 2
displayIndents 5 = 2
+9 -1
View File
@@ -321,7 +321,7 @@ useLoadedAmmo itmtree cr (cme, w) (mzid, Just (mz, x, magtree)) = (,) (cme & cme
MuzzleRLauncher -> createProjectileR itmtree magtree mz cr w
MuzzleGLauncher ->
createProjectile
(Grenade (GBounce 2))
(Grenade (getGrenadeHitEffect itmtree))
magtree
(getPJStabiliser itmtree)
mz
@@ -668,6 +668,14 @@ getPJStabiliser ldt = case lookup ProjectileStabiliserLink (ldt ^. ldtRight) of
_ -> Nothing
_ -> Nothing
getGrenadeHitEffect :: LabelDoubleTree ComposeLinkType Item -> GrenadeHitEffect
getGrenadeHitEffect t = case lookup GrenadeHitEffectLink (t ^. ldtRight) of
Just ldt' -> case ldt' ^? ldtValue . itType of
Just STICKYMOD -> GStick
_ -> GBounce 2
_ -> GBounce 2
createProjectile ::
ProjectileType ->
LabelDoubleTree ComposeLinkType Item ->
+2 -1
View File
@@ -110,7 +110,7 @@ getAutoSpringLinks itm = case itm ^? itUse . heldTriggerType of
extraWeaponLinks :: Item -> [(ItemStructuralFunction, ComposeLinkType)]
extraWeaponLinks itm = case itm ^. itType of
HELD GLAUNCHER -> launcherlinks
HELD GLAUNCHER -> launcherlinks <> [(GrenadeHitEffectSF,GrenadeHitEffectLink)]
HELD RLAUNCHER -> launcherlinks
HELD RLAUNCHERX{} -> launcherlinks
_ -> []
@@ -163,6 +163,7 @@ structureToPotentialFunction ::
LabelDoubleTree ItemLink ComposedItem ->
S.Set ItemStructuralFunction
structureToPotentialFunction ldt = case ldt ^. ldtValue . _1 . itType of
STICKYMOD -> S.singleton GrenadeHitEffectSF
ATTACH GIMBAL -> S.singleton ProjectileStabiliserSF
ATTACH GYROSCOPE -> S.singleton ProjectileStabiliserSF
HELD GLAUNCHER -> S.singleton UnderBarrelPlatformSF
+1
View File
@@ -8,6 +8,7 @@ import Dodge.Data.ComposedItem
itemInvColor :: ComposedItem -> Color
itemInvColor ci = case ci ^. _2 of
GrenadeHitEffectSF -> yellow
IntroScanSF -> white
UnloadedWeaponSF -> mixColorsLinear 0.5 0.5 red white
HeldPlatformSF -> white
+1 -1
View File
@@ -21,7 +21,7 @@ updateLampoid cr w = case cr ^?! crType . lampLSID of
-- & cWorld . lWorld . tempLightSources .:~ tlsTimeRadFunPos 20 150 (TLSFade 1 10) (addZ 20 cpos)
& cWorld . lWorld . worldEvents .:~ MakeTempLight
(LSParam (addZ 20 cpos) 150 1) 20
& originsIDsAt [MaterialSound Glass n | n <- [0, 1, 2]] (destroyMatS Glass) cpos
& soundOriginsIDsAt [MaterialSound Glass n | n <- [0, 1, 2]] (destroyMatS Glass) cpos
& cWorld . lWorld . lightSources . at i .~ Nothing
& cWorld . lWorld . creatures . at cid .~ Nothing
| otherwise ->
+1 -1
View File
@@ -34,7 +34,7 @@ destroyLS lsid w =
w
& cWorld . lWorld . lightSources . at lsid .~ Nothing
& destroyLSFlashAt p3
& originsIDsAt [MaterialSound Glass n | n <- [0, 1, 2]] (destroyMatS Glass) (xyV3 p3)
& soundOriginsIDsAt [MaterialSound Glass n | n <- [0, 1, 2]] (destroyMatS Glass) (xyV3 p3)
where
ls = w ^?! cWorld . lWorld . lightSources . ix lsid -- unsafe
p3 = _lsPos $ _lsParam ls
+25 -13
View File
@@ -14,6 +14,7 @@ import Dodge.Movement.Turn
import Dodge.Payload
import Dodge.SoundLogic
import Dodge.WorldEvent.Cloud
import Dodge.WorldEvent.Sound
import Dodge.WorldEvent.ThingsHit
import Geometry
import qualified IntMapHelp as IM
@@ -23,8 +24,9 @@ import RandomHelp
updateProjectile :: Projectile -> World -> World
updateProjectile pj w =
(cWorld . lWorld . projectiles . ix (pj ^. pjID) %~
decTimMvVel)
( cWorld . lWorld . projectiles . ix (pj ^. pjID)
%~ decTimMvVel
)
. shellCollisionCheck
pj
$ foldl' (flip $ upProjectile pj) w (_pjUpdates pj)
@@ -83,10 +85,10 @@ shellCollisionCheck pj w
| RetiredProjectile <- pj ^. pjType
, time <= 0 =
destroyProjectile (pj ^. pjScreenID) (_pjID pj) w
| time <= 0 = g
| RetiredProjectile <- pj ^. pjType = w
| Just thit <- thingHit oldPos (oldPos + _pjVel pj) w = tryShellBounce thit pj w
-- | anythingHitCirc 2 oldPos (oldPos + _pjVel pj) w = g
| time <= 0 = g
| otherwise = w
where
g = explodeShell pj w
@@ -97,12 +99,20 @@ shellCollisionCheck pj w
-- bouncing in some way
tryShellBounce :: (Point2, Either Creature Wall) -> Projectile -> World -> World
tryShellBounce (p, Right wl) pj w
| Just GStick <- pj ^? pjType . gnHitEffect = w
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
| Just GStick <- pj ^? pjType . gnHitEffect =
w & cWorld . lWorld . projectiles . ix (_pjID pj) . pjType .~ Grenade
(GStuckWall (wl ^. wlID))
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos)
| Just x <- pj ^? pjType . gnHitEffect . bounceTolerance =
if abs (dotV (pj ^. pjVel) (vNormal hitline)) < x
then w & cWorld . lWorld . projectiles . ix (_pjID pj) . pjVel %~ reflectIn
hitline
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjPos .~ p
then
w
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjVel
%~ reflectIn
hitline
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjPos .~ p
& soundStart (ShellSound (pj ^. pjID)) (pj ^. pjPos) click1S Nothing
else explodeShell pj w
where
@@ -180,12 +190,14 @@ pjRemoteSetDirection ph pj w = case ph of
lw = w ^. cWorld . lWorld
decTimMvVel :: Projectile -> Projectile
decTimMvVel pj = pj
& pjSpin *~ 0.99
& pjTimer -~ 1
& pjPos +~ _pjVel pj
& pjDir +~ _pjSpin pj
decTimMvVel pj
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = pj & pjTimer -~ 1
| otherwise =
pj
& pjSpin *~ 0.99
& pjTimer -~ 1
& pjPos +~ _pjVel pj
& pjDir +~ _pjSpin pj
explodeShell ::
Projectile ->
+143 -133
View File
@@ -1,4 +1,4 @@
-- generated at 2024-11-03 10:36:18.238246608 UTC
-- generated at 2025-01-01 16:37:43.706494172 UTC
module Dodge.SoundLogic.ExternallyGeneratedSounds where
import Sound.Data
soundToVol :: SoundID -> Float
@@ -61,53 +61,55 @@ soundToVol v = case _getSoundID v of
55 -> 40
56 -> 300
57 -> 300
58 -> 2000
59 -> 1000
58 -> 100
59 -> 2000
60 -> 1000
61 -> 1000
62 -> 1000
63 -> 1000
64 -> 40
65 -> 50
66 -> 1000
67 -> 500
64 -> 1000
65 -> 40
66 -> 50
67 -> 1000
68 -> 500
69 -> 100
70 -> 1000
71 -> 20
72 -> 500
73 -> 300
74 -> 200
75 -> 500
76 -> 1000
77 -> 200
78 -> 1000
79 -> 2000
80 -> 500
81 -> 100
82 -> 1000
83 -> 2000
69 -> 500
70 -> 100
71 -> 1000
72 -> 20
73 -> 500
74 -> 300
75 -> 200
76 -> 500
77 -> 1000
78 -> 200
79 -> 1000
80 -> 2000
81 -> 500
82 -> 100
83 -> 1000
84 -> 2000
85 -> 500
86 -> 2000
87 -> 100
88 -> 300
89 -> 1000
90 -> 200
91 -> 100
92 -> 1000
93 -> 2000
85 -> 2000
86 -> 100
87 -> 500
88 -> 2000
89 -> 100
90 -> 300
91 -> 1000
92 -> 200
93 -> 100
94 -> 1000
95 -> 100
96 -> 200
97 -> 500
98 -> 100
99 -> 2000
100 -> 2000
95 -> 2000
96 -> 1000
97 -> 100
98 -> 200
99 -> 500
100 -> 100
101 -> 2000
102 -> 200
103 -> 100
102 -> 2000
103 -> 2000
104 -> 200
105 -> 100
106 -> 200
_ -> 50
soundToOnomato :: SoundID -> String
soundToOnomato v = case _getSoundID v of
@@ -169,53 +171,55 @@ soundToOnomato v = case _getSoundID v of
55 -> "TIPTAP"
56 -> "TNKTNKTNK"
57 -> "CHPCHPCHP"
58 -> "SCREE"
59 -> "DHDHL"
60 -> "BRAP"
61 -> "CRSK"
62 -> "CRNKL"
63 -> "TRNKL"
64 -> "TAPP"
65 -> "SHUHP"
66 -> "CRUMBL"
67 -> "DEDEDUM"
68 -> "TAK"
69 -> "SPLRT"
70 -> "CRISH"
71 -> "SWSH"
72 -> "BIPBIPBIP"
73 -> "BEP"
74 -> "CRSKRL"
75 -> "KRTNKL"
76 -> "CRSNK"
77 -> "SHTCK"
78 -> "TTRKL"
79 -> "UGGAUGGA"
80 -> "DUDURAH"
81 -> "KKSQWL"
82 -> "CRMPL"
83 -> "CHUGUGUG"
84 -> "BANG"
85 -> "DEDA"
86 -> "WHSSH"
87 -> "HNH"
88 -> "BWAH"
89 -> "CRUNK"
90 -> "SQWLTCH"
91 -> "DRR"
92 -> "TRNKL"
93 -> "BRAP"
94 -> "BLPCHCH"
95 -> "SKLE"
96 -> "ZMM"
97 -> "WRRR"
98 -> "FWUMP"
99 -> "BRAHCHCH"
100 -> "BRPBRPBRP"
101 -> "WE-OH"
102 -> "THCK"
103 -> "FHP"
104 -> "QWLPH"
58 -> "SLP"
59 -> "SCREE"
60 -> "DHDHL"
61 -> "BRAP"
62 -> "CRSK"
63 -> "CRNKL"
64 -> "TRNKL"
65 -> "TAPP"
66 -> "SHUHP"
67 -> "CRUMBL"
68 -> "DEDEDUM"
69 -> "TAK"
70 -> "SPLRT"
71 -> "CRISH"
72 -> "SWSH"
73 -> "BIPBIPBIP"
74 -> "BEP"
75 -> "CRSKRL"
76 -> "KRTNKL"
77 -> "CRSNK"
78 -> "SHTCK"
79 -> "TTRKL"
80 -> "UGGAUGGA"
81 -> "DUDURAH"
82 -> "KKSQWL"
83 -> "CRMPL"
84 -> "CHUGUGUG"
85 -> "BANG"
86 -> "SLPP"
87 -> "DEDA"
88 -> "WHSSH"
89 -> "HNH"
90 -> "BWAH"
91 -> "CRUNK"
92 -> "SQWLTCH"
93 -> "DRR"
94 -> "TRNKL"
95 -> "BRAP"
96 -> "BLPCHCH"
97 -> "SKLE"
98 -> "ZMM"
99 -> "WRRR"
100 -> "FWUMP"
101 -> "BRAHCHCH"
102 -> "BRPBRPBRP"
103 -> "WE-OH"
104 -> "THCK"
105 -> "FHP"
106 -> "QWLPH"
_ -> error "unitialised sound"
soundPathList :: [String]
soundPathList =
@@ -277,6 +281,7 @@ soundPathList =
, "twoStep.TIPTAP.40.wav"
, "reload.TNKTNKTNK.300.wav"
, "reload1.CHPCHPCHP.300.wav"
, "slap.SLP.100.wav"
, "tone440sawtooth.SCREE.2000.wav"
, "metal3.DHDHL.1000.wav"
, "tap3.BRAP.1000.wav"
@@ -304,6 +309,7 @@ soundPathList =
, "stone2.CRMPL.1000.wav"
, "seagullChatter1.CHUGUGUG.2000.wav"
, "bang.BANG.2000.wav"
, "slap1.SLPP.100.wav"
, "deda.DEDA.500.wav"
, "missileLaunch.WHSSH.2000.wav"
, "grunt.HNH.100.wav"
@@ -441,97 +447,101 @@ reloadS :: SoundID
reloadS = SoundID 56
reload1S :: SoundID
reload1S = SoundID 57
slapS :: SoundID
slapS = SoundID 58
tone440sawtoothS :: SoundID
tone440sawtoothS = SoundID 58
tone440sawtoothS = SoundID 59
metal3S :: SoundID
metal3S = SoundID 59
metal3S = SoundID 60
tap3S :: SoundID
tap3S = SoundID 60
tap3S = SoundID 61
glassShat4S :: SoundID
glassShat4S = SoundID 61
glassShat4S = SoundID 62
glassShat2S :: SoundID
glassShat2S = SoundID 62
glassShat2S = SoundID 63
metal1S :: SoundID
metal1S = SoundID 63
metal1S = SoundID 64
foot3S :: SoundID
foot3S = SoundID 64
foot3S = SoundID 65
pickUpS :: SoundID
pickUpS = SoundID 65
pickUpS = SoundID 66
stone5S :: SoundID
stone5S = SoundID 66
stone5S = SoundID 67
dededumS :: SoundID
dededumS = SoundID 67
dededumS = SoundID 68
tap1S :: SoundID
tap1S = SoundID 68
tap1S = SoundID 69
blood1S :: SoundID
blood1S = SoundID 69
blood1S = SoundID 70
metal4S :: SoundID
metal4S = SoundID 70
metal4S = SoundID 71
knifeS :: SoundID
knifeS = SoundID 71
knifeS = SoundID 72
computerBeepingS :: SoundID
computerBeepingS = SoundID 72
computerBeepingS = SoundID 73
tone440S :: SoundID
tone440S = SoundID 73
tone440S = SoundID 74
gut6S :: SoundID
gut6S = SoundID 74
gut6S = SoundID 75
smallGlass2S :: SoundID
smallGlass2S = SoundID 75
smallGlass2S = SoundID 76
glassShat1S :: SoundID
glassShat1S = SoundID 76
glassShat1S = SoundID 77
disconnectItemS :: SoundID
disconnectItemS = SoundID 77
disconnectItemS = SoundID 78
metal5S :: SoundID
metal5S = SoundID 78
metal5S = SoundID 79
seagullBarkTransformedS :: SoundID
seagullBarkTransformedS = SoundID 79
seagullBarkTransformedS = SoundID 80
ejectS :: SoundID
ejectS = SoundID 80
ejectS = SoundID 81
blood3S :: SoundID
blood3S = SoundID 81
blood3S = SoundID 82
stone2S :: SoundID
stone2S = SoundID 82
stone2S = SoundID 83
seagullChatter1S :: SoundID
seagullChatter1S = SoundID 83
seagullChatter1S = SoundID 84
bangS :: SoundID
bangS = SoundID 84
bangS = SoundID 85
slap1S :: SoundID
slap1S = SoundID 86
dedaS :: SoundID
dedaS = SoundID 85
dedaS = SoundID 87
missileLaunchS :: SoundID
missileLaunchS = SoundID 86
missileLaunchS = SoundID 88
gruntS :: SoundID
gruntS = SoundID 87
gruntS = SoundID 89
sineRaisePitchOneSecS :: SoundID
sineRaisePitchOneSecS = SoundID 88
sineRaisePitchOneSecS = SoundID 90
metal2S :: SoundID
metal2S = SoundID 89
metal2S = SoundID 91
gut5S :: SoundID
gut5S = SoundID 90
gut5S = SoundID 92
slideDoorS :: SoundID
slideDoorS = SoundID 91
slideDoorS = SoundID 93
metal6S :: SoundID
metal6S = SoundID 92
metal6S = SoundID 94
autoGunS :: SoundID
autoGunS = SoundID 93
autoGunS = SoundID 95
oldMachineBootS :: SoundID
oldMachineBootS = SoundID 94
oldMachineBootS = SoundID 96
blood6S :: SoundID
blood6S = SoundID 95
blood6S = SoundID 97
buzzS :: SoundID
buzzS = SoundID 96
buzzS = SoundID 98
fireLoudS :: SoundID
fireLoudS = SoundID 97
fireLoudS = SoundID 99
tap4S :: SoundID
tap4S = SoundID 98
tap4S = SoundID 100
shotgunS :: SoundID
shotgunS = SoundID 99
shotgunS = SoundID 101
miniS :: SoundID
miniS = SoundID 100
miniS = SoundID 102
seagullWhistleS :: SoundID
seagullWhistleS = SoundID 101
seagullWhistleS = SoundID 103
connectItemS :: SoundID
connectItemS = SoundID 102
connectItemS = SoundID 104
whiteNoiseFadeInS :: SoundID
whiteNoiseFadeInS = SoundID 103
whiteNoiseFadeInS = SoundID 105
gut1S :: SoundID
gut1S = SoundID 104
gut1S = SoundID 106
+6 -6
View File
@@ -1,6 +1,6 @@
module Dodge.WorldEvent.Sound (
originIDsAt,
originsIDsAt,
soundOriginIDsAt,
soundOriginsIDsAt,
) where
import Control.Lens
@@ -10,12 +10,12 @@ import Geometry.Data
import RandomHelp
import Sound.Data
originsIDsAt :: [SoundOrigin] -> [SoundID] -> Point2 -> World -> World
originsIDsAt sos sids p w = soundMultiFrom sos p sid Nothing $ set randGen g w
soundOriginsIDsAt :: [SoundOrigin] -> [SoundID] -> Point2 -> World -> World
soundOriginsIDsAt sos sids p w = soundMultiFrom sos p sid Nothing $ set randGen g w
where
(sid, g) = _randGen w & runState (takeOne sids)
originIDsAt :: SoundOrigin -> [SoundID] -> Point2 -> World -> World
originIDsAt so sids p w = soundStart so p sid Nothing $ set randGen g w
soundOriginIDsAt :: SoundOrigin -> [SoundID] -> Point2 -> World -> World
soundOriginIDsAt so sids p w = soundStart so p sid Nothing $ set randGen g w
where
(sid, g) = _randGen w & runState (takeOne sids)
+388 -375
View File
File diff suppressed because it is too large Load Diff