Fix unsafe blink bugs

This commit is contained in:
2022-06-05 09:53:16 +01:00
parent 65fcea0f50
commit e84e5bad01
2 changed files with 29 additions and 6 deletions
+25 -2
View File
@@ -10,6 +10,7 @@ module Dodge.Creature.Action
, dropItem
-- , startReloadingWeapon
, blinkAction
, blinkActionFail
, unsafeBlinkAction
, sizeSelf
-- , crAutoReload
@@ -155,6 +156,26 @@ performAction cr w ac = case ac of
(imps , _) -> (imps, Just $ DoReplicatePartial sac (t-1) sac)
NoAction -> ([],Nothing)
{- | Like a blink action, but no ingoing distortion -}
blinkActionFail
:: Creature
-> World
-> World
blinkActionFail cr w = w
& soundMultiFrom [TeleSound 0,TeleSound 1] p3 teleS Nothing
& distortions .:~ distortionBulge
& creatures . ix cid . crPos .~ p3
& inverseShockwaveAt cpos 40 2 2
where
distR = 120
distortionBulge = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
cid = _crID cr
p1 = mouseWorldPos w
cpos = _crPos cr
p2 = reflectPointWalls cpos p1 $ wallsAlongLine cpos p1 w
r = 1.5 * _crRad cr
p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2
{- | Teleport a creature to the mouse position -}
blinkAction
:: Creature
@@ -191,8 +212,10 @@ unsafeBlinkAction cr w
. set (creatures . ix cid . crPos) mwp
. blinkShockwave cid mwp
$ inverseShockwaveAt cpos 40 2 2 w
| otherwise = blinkAction cr w & creatures . ix cid . crState . crDamage .:~
Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect
| otherwise = w
& blinkActionFail cr
& creatures . ix cid . crState . crDamage .:~
Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect
where
success = fromMaybe True $ do
(_,wl) <- collidePointWallsWall mwp cpos $ wallsAlongLine mwp cpos w
+4 -4
View File
@@ -59,15 +59,15 @@ foldCr xs cr w = foldr f w xs
-- may affect whether the shield moves correctly
stateUpdate :: (Creature -> World -> World) -> Creature -> World -> World
stateUpdate f = foldCr
[ clearDamage
, equipmentEffects
[ equipmentEffects
, invSideEff
, upInv -- upInv must be called before invSideEff 22.05.23
, movementSideEff
, f
, internalUpdate
, checkDeath
, doDamage
, clearDamage -- these three
, checkDeath -- must be in
, doDamage -- this order 22/06/05
]
checkDeath :: Creature -> World -> World