Improve sticky grenades

This commit is contained in:
2025-01-01 18:03:29 +00:00
parent 511e765e3a
commit 86aba6d115
4 changed files with 34 additions and 25 deletions
+1 -1
View File
@@ -19,7 +19,7 @@ data ProjectileUpdate
= ThrustPU {_pjuStart :: Int, _pjuEnd :: Int}
| StartSpinPU {_pjuTime :: Int, _pjuCID :: Int, _pjuSpinAmound :: Int}
| RemoteDirectionPU {_pjuStart :: Int, _pjuEnd :: Int}
| ApplyGravityPU
-- | ApplyGravityPU
deriving (Show, Eq, Ord, Read) --Generic, Flat)
data AmmoType
+1 -1
View File
@@ -60,7 +60,7 @@ createShell mdetonator mscreen stab pjtype payload muz cr w = w
RetiredProjectile -> 0
lifespan = 350
thrustorgrav = case pjtype of
Grenade {}-> [ApplyGravityPU]
Grenade {}-> []
Rocket{} -> [ThrustPU (lifespan - thrustdelay) 0]
RetiredProjectile -> []
thrustdelay = 20
+20 -12
View File
@@ -28,6 +28,7 @@ updateProjectile pj w =
. pjMovement pj
. shellCollisionCheck
pj
. doGravityPU pj
$ foldl' (flip $ upProjectile pj) w (_pjUpdates pj)
upProjectile :: Projectile -> ProjectileUpdate -> World -> World
@@ -41,12 +42,17 @@ upProjectile pj pu = case pu of
RemoteDirectionPU st et
| act st et -> pjRemoteSetDirection (pj ^? pjType . rkHoming) pj
| otherwise -> id
-- ReduceSpinPU x -> reduceSpinBy x (_pjID pj)
ApplyGravityPU -> applyGravityPU pj
-- ApplyGravityPU -> applyGravityPU pj
where
time = _pjTimer pj
act st et = time <= st && time >= et
doGravityPU :: Projectile -> World -> World
doGravityPU pj
| Grenade GBounce {} <- pj ^. pjType = applyGravityPU pj
| Grenade GStick <- pj ^. pjType = applyGravityPU pj
| otherwise = id
applyGravityPU :: Projectile -> World -> World
applyGravityPU pj w
| newz <= 0 && abs (pj ^. pjZVel) < 1 =
@@ -103,7 +109,7 @@ tryShellBounce (p, Right wl) pj w
| Just GStick <- pj ^? pjType . gnHitEffect = w
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjType
.~ Grenade (GStuckWall (wl ^. wlStructure))
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
-- & 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
@@ -126,7 +132,7 @@ tryShellBounce (p, Left cr) pj w
(rotateV (- cr ^. crDir) (p - cr ^. crPos))
(pj ^. pjDir - cr ^. crDir)
)
& cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
-- & cWorld . lWorld . projectiles . ix (_pjID pj) . pjUpdates %~ delete ApplyGravityPU
& soundOriginIDsAt (ShellSound (pj ^. pjID)) [slapS, slap1S] (pj ^. pjPos)
tryShellBounce _ pj w = explodeShell pj w
@@ -203,14 +209,16 @@ pjRemoteSetDirection ph pj w = case ph of
pjMovement :: Projectile -> World -> World
pjMovement pj w
| Just GStuckWall{} <- pj ^? pjType . gnHitEffect = w
| Just (GStuckCreature crid p d) <- pj ^? pjType . gnHitEffect = fromMaybe w $ do
cpos <- w ^? cWorld . lWorld . creatures . ix crid . crPos
cdir <- w ^? cWorld . lWorld . creatures . ix crid . crDir
return $
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos
.~ cpos + rotateV cdir p
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir
.~ d + cdir
| Just (GStuckCreature crid p d) <- pj ^? pjType . gnHitEffect = fromMaybe
(w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjType .~ Grenade GStick)
$ do
cpos <- w ^? cWorld . lWorld . creatures . ix crid . crPos
cdir <- w ^? cWorld . lWorld . creatures . ix crid . crDir
return $
w & cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjPos
.~ cpos + rotateV cdir p
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjDir
.~ d + cdir
| otherwise =
w
& cWorld . lWorld . projectiles . ix (pj ^. pjID) . pjSpin *~ 0.99
+12 -11
View File
@@ -75,7 +75,6 @@ AnTree src/Dodge/Annotation/Data.hs 19;" C
Analyser src/Dodge/Placement/Instance/Analyser.hs 1;" m
Annotation src/Dodge/Annotation/Data.hs 14;" t
Annotation src/Dodge/Annotation.hs 3;" m
ApplyGravityPU src/Dodge/Data/Item/Use/Consumption/Ammo.hs 22;" C
ArbitraryAction src/Dodge/Data/ActionPlan.hs 166;" C
ArbitraryImpulse src/Dodge/Data/ActionPlan.hs 47;" C
ArbitraryImpulseEffect src/Dodge/Data/ActionPlan.hs 48;" C
@@ -3100,6 +3099,7 @@ _strideAmount src/Dodge/Data/Creature/Stance.hs 22;" f
_strideLength src/Dodge/Data/Creature/Stance.hs 16;" f
_stuckCrID src/Dodge/Data/Projectile.hs 55;" f
_stuckCrOffset src/Dodge/Data/Projectile.hs 55;" f
_stuckCrRot src/Dodge/Data/Projectile.hs 55;" f
_stuckWlID src/Dodge/Data/Projectile.hs 56;" f
_subInventory src/Dodge/Data/HUD.hs 20;" f
_swColor src/Dodge/Data/Shockwave.hs 18;" f
@@ -3384,7 +3384,7 @@ applyCME src/Dodge/HeldUse.hs 145;" f
applyCreatureDamage src/Dodge/Creature/Damage.hs 14;" f
applyDamageEffect src/Dodge/Creature/Damage.hs 31;" f
applyEventIO src/Loop.hs 89;" f
applyGravityPU src/Dodge/Projectile/Update.hs 50;" f
applyGravityPU src/Dodge/Projectile/Update.hs 56;" f
applyIndividualDamage src/Dodge/Creature/Damage.hs 49;" f
applyIndividualDamage' src/Dodge/Creature/Damage.hs 52;" f
applyInvLock src/Dodge/HeldUse.hs 160;" f
@@ -3948,7 +3948,7 @@ destroyMatS src/Dodge/Material/Sound.hs 7;" f
destroyMcType src/Dodge/Machine/Destroy.hs 21;" f
destroyMount src/Dodge/Block.hs 102;" f
destroyMounts src/Dodge/Block.hs 99;" f
destroyProjectile src/Dodge/Projectile/Update.hs 128;" f
destroyProjectile src/Dodge/Projectile/Update.hs 139;" f
detV src/Geometry/Vector.hs 93;" f
detector src/Dodge/Item/Held/Utility.hs 41;" f
detectorColor src/Dodge/Item/Draw/SPic.hs 437;" f
@@ -4021,6 +4021,7 @@ doDrawing src/Dodge/Render.hs 35;" f
doDrawing' src/Dodge/Render.hs 46;" f
doFloatFloat src/Dodge/FloatFunction.hs 5;" f
doGenFloat src/Dodge/HeldUse.hs 560;" f
doGravityPU src/Dodge/Projectile/Update.hs 50;" f
doHeldUseEffect src/Dodge/HeldUse.hs 110;" f
doInPlacements src/Dodge/Layout.hs 92;" f
doIndividualPlacements src/Dodge/Layout.hs 117;" f
@@ -4062,7 +4063,7 @@ doTerminalCommandEffect src/Dodge/Terminal.hs 135;" f
doTestDrawing src/Dodge/Render.hs 42;" f
doTextInputOver src/Dodge/Update/Input/Text.hs 15;" f
doTextInputOverUniverse src/Dodge/Update/Input/Text.hs 12;" f
doThrust src/Dodge/Projectile/Update.hs 138;" f
doThrust src/Dodge/Projectile/Update.hs 149;" f
doTimeScroll src/Dodge/Update.hs 205;" f
doTmTm src/Dodge/TmTm.hs 6;" f
doTmWdWd src/Dodge/WorldEffect.hs 102;" f
@@ -4269,7 +4270,7 @@ expandPolyCorners src/Dodge/LevelGen/StaticWalls.hs 103;" f
expandToSquare src/Dodge/LevelGen/StaticWalls/Deprecated.hs 83;" f
expireAndDamage src/Dodge/Bullet.hs 195;" f
expireAndDamageFL src/Dodge/Flame.hs 47;" f
explodeShell src/Dodge/Projectile/Update.hs 211;" f
explodeShell src/Dodge/Projectile/Update.hs 226;" f
explosionS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 416;" f
explosiveBarrel src/Dodge/Creature/Inanimate.hs 29;" f
extTrigLitPos src/Dodge/Placement/Instance/Button.hs 84;" f
@@ -5155,8 +5156,8 @@ pipe src/Dodge/Item/Craftable.hs 32;" f
pistol src/Dodge/Item/Held/Stick.hs 42;" f
pistolCrit src/Dodge/Creature/PistolCrit.hs 12;" f
pistolerRoom src/Dodge/Room/Room.hs 321;" f
pjMovement src/Dodge/Projectile/Update.hs 198;" f
pjRemoteSetDirection src/Dodge/Projectile/Update.hs 183;" f
pjMovement src/Dodge/Projectile/Update.hs 209;" f
pjRemoteSetDirection src/Dodge/Projectile/Update.hs 194;" f
plBlock src/Dodge/Placement/PlaceSpot/Block.hs 18;" f
plDoor src/Dodge/Placement/PlaceSpot/TriggerDoor.hs 22;" f
plLineBlock src/Dodge/Placement/PlaceSpot/Block.hs 50;" f
@@ -5671,7 +5672,7 @@ shardShape src/Dodge/Block/Debris.hs 181;" f
shatterGun src/Dodge/Item/Held/Weapons.hs 8;" f
shatterGunSPic src/Dodge/Item/Draw/SPic.hs 287;" f
shatterWall src/Dodge/Item/Weapon/Shatter.hs 26;" f
shellCollisionCheck src/Dodge/Projectile/Update.hs 79;" f
shellCollisionCheck src/Dodge/Projectile/Update.hs 85;" f
shellMag src/Dodge/Item/Ammo.hs 61;" f
shellModule src/Dodge/Item/Scope.hs 70;" f
shellShape src/Dodge/Projectile/Draw.hs 34;" f
@@ -6067,8 +6068,8 @@ tryPutFloorItemIDInInv src/Dodge/Inventory/Add.hs 26;" f
tryPutItemInInv src/Dodge/Inventory/Add.hs 42;" f
tryPutItemInInvAt src/Dodge/Inventory/Add.hs 32;" f
trySeedFromClipboard src/Dodge/Menu.hs 88;" f
tryShellBounce src/Dodge/Projectile/Update.hs 99;" f
trySpinByCID src/Dodge/Projectile/Update.hs 165;" f
tryShellBounce src/Dodge/Projectile/Update.hs 105;" f
trySpinByCID src/Dodge/Projectile/Update.hs 176;" f
trySynthBullet src/Dodge/Creature/State.hs 201;" f
tryUseParent src/Dodge/Creature/State.hs 194;" f
turnTo src/Dodge/Movement/Turn.hs 4;" f
@@ -6103,7 +6104,7 @@ unusedOffPathAwayFromLink src/Dodge/PlacementSpot.hs 133;" f
unusedSpotAwayFromInLink src/Dodge/PlacementSpot.hs 139;" f
unusedSpotAwayFromLink src/Dodge/PlacementSpot.hs 122;" f
unusedSpotNearInLink src/Dodge/PlacementSpot.hs 191;" f
upProjectile src/Dodge/Projectile/Update.hs 33;" f
upProjectile src/Dodge/Projectile/Update.hs 34;" f
updateAllNodes src/TreeHelp.hs 85;" f
updateArc src/Dodge/Tesla.hs 91;" f
updateArc src/Dodge/Tesla/Arc.hs 100;" f