Fix blink bug
This commit is contained in:
@@ -8,7 +8,7 @@ module Dodge.Creature.Action (
|
||||
dropUnselected,
|
||||
dropExcept,
|
||||
dropItem,
|
||||
blinkAction,
|
||||
blinkActionMousePos,
|
||||
blinkActionFail,
|
||||
unsafeBlinkAction,
|
||||
sizeSelf,
|
||||
@@ -22,6 +22,7 @@ import Data.Bifunctor
|
||||
import Data.List (findIndex)
|
||||
import Data.Maybe
|
||||
import Dodge.Base
|
||||
import Dodge.Creature.Action.Blink
|
||||
import Dodge.CreatureEffect
|
||||
import Dodge.Data.World
|
||||
import Dodge.Default
|
||||
@@ -32,11 +33,9 @@ import Dodge.Inventory.Add
|
||||
import Dodge.Path
|
||||
import Dodge.SoundLogic
|
||||
import Dodge.WallCreatureCollisions
|
||||
import Dodge.WorldEvent.Shockwave
|
||||
import Geometry
|
||||
import qualified IntMapHelp as IM
|
||||
import LensHelp
|
||||
import Picture
|
||||
|
||||
performActions :: World -> Creature -> Creature
|
||||
performActions w cr =
|
||||
@@ -145,88 +144,6 @@ performAction cr w ac = case ac of
|
||||
(imps, _) -> (imps, Just $ DoReplicatePartial startac (t -1) startac)
|
||||
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
|
||||
& cWorld . distortions .:~ distortionBulge
|
||||
& cWorld . 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 = bouncePoint (const True) 1 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 -> World -> World
|
||||
blinkAction cr w =
|
||||
w
|
||||
& soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
|
||||
& cWorld . distortions .++~ distortionBulge
|
||||
& cWorld . creatures . ix cid . crPos .~ p3
|
||||
& blinkShockwave cid p3
|
||||
& inverseShockwaveAt cpos 40 2 2
|
||||
where
|
||||
distR = 120
|
||||
distortionBulge =
|
||||
[ RadialDistortion p3 (p3 +.+ V2 distR 0) (p3 +.+ V2 0 distR) 0.1
|
||||
, RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
|
||||
]
|
||||
cid = _crID cr
|
||||
p1 = mouseWorldPos w
|
||||
cpos = _crPos cr
|
||||
p2 = bouncePoint (const True) 1 cpos p1 w
|
||||
r = 1.5 * _crRad cr
|
||||
p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2
|
||||
|
||||
{- | Teleport a creature to the mouse position.
|
||||
Can go through walls, if ending up in wall does big damage.
|
||||
-}
|
||||
unsafeBlinkAction ::
|
||||
Creature ->
|
||||
World ->
|
||||
World
|
||||
unsafeBlinkAction cr w
|
||||
| success =
|
||||
soundMultiFrom [TeleSound 0, TeleSound 1] mwp teleS Nothing
|
||||
. (cWorld . distortions .++~ distortionBulge)
|
||||
. set (cWorld . creatures . ix cid . crPos) mwp
|
||||
. blinkShockwave cid mwp
|
||||
$ inverseShockwaveAt cpos 40 2 2 w
|
||||
| otherwise =
|
||||
w
|
||||
& blinkActionFail cr
|
||||
& cWorld . creatures . ix cid . crState . csDamage
|
||||
.:~ Damage ENTERREMENT 10000 mwp mwp mwp NoDamageEffect
|
||||
where
|
||||
success = fromMaybe True $ do
|
||||
wl <- snd $ collidePointWallsFilter (const True) mwp cpos w
|
||||
return (isLHS mwp `uncurry` _wlLine wl)
|
||||
distR = 120
|
||||
distortionBulge =
|
||||
[ RadialDistortion mwp (mwp +.+ V2 distR 0) (mwp +.+ V2 0 distR) 0.1
|
||||
, RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) 1.9
|
||||
]
|
||||
cid = _crID cr
|
||||
mwp = mouseWorldPos w
|
||||
cpos = _crPos cr
|
||||
|
||||
blinkShockwave ::
|
||||
-- | Blinking creature ID.
|
||||
Int ->
|
||||
Point2 ->
|
||||
World ->
|
||||
World
|
||||
blinkShockwave i p = makeShockwaveAt [i] p 60 1 2 cyan
|
||||
|
||||
setMinInvSize :: Int -> Creature -> World -> World
|
||||
setMinInvSize n cr = cWorld . creatures . ix (_crID cr) . crInvCapacity .~ n
|
||||
|
||||
Reference in New Issue
Block a user