Fix blink bug

This commit is contained in:
2022-10-19 23:17:26 +01:00
parent 4ad19aa19d
commit 21dc670c9f
13 changed files with 353 additions and 312 deletions
+11
View File
@@ -101,6 +101,17 @@ mvPointTowardAtSpeed
mvPointTowardAtSpeed !speed !ep !p mvPointTowardAtSpeed !speed !ep !p
| dist p ep < speed = ep | dist p ep < speed = ep
| otherwise = p +.+ speed *.* normalizeV (ep -.- p) | otherwise = p +.+ speed *.* normalizeV (ep -.- p)
{- | given a target and a start point, shift toward the end point by a given
amount.
If close enough, go past the end point -}
mvPointAlongAtSpeed
:: Float -- ^ Speed.
-> Point2 -- ^ End point.
-> Point2 -- ^ Start point.
-> Point2
mvPointAlongAtSpeed !speed !ep !p
| dist p ep == 0 = ep
| otherwise = p +.+ speed *.* normalizeV (ep -.- p)
{- | given a target and a start point, shift toward the end point by 1. {- | given a target and a start point, shift toward the end point by 1.
If close enough, end up on the end point -} If close enough, end up on the end point -}
mvPointToward mvPointToward
+2
View File
@@ -15,6 +15,7 @@ module Dodge.Base.Collide (
collidePoint, collidePoint,
collidePointWallsFilter, collidePointWallsFilter,
collidePointTestFilter, collidePointTestFilter,
collideCircWalls,
overlapSegWalls, overlapSegWalls,
overlapSegCrs, overlapSegCrs,
bounceBall, bounceBall,
@@ -69,6 +70,7 @@ doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2,
{-# INLINE doBounce #-} {-# INLINE doBounce #-}
doBounce x sp ep (p, mwl) = doBounce x sp ep (p, mwl) =
mwl <&> \wl -> mwl <&> \wl ->
--( p +.+ normalizeV (vNormal (uncurry (-.-) (_wlLine wl)))
( p +.+ normalizeV (vNormal (uncurry (-.-) (_wlLine wl))) ( p +.+ normalizeV (vNormal (uncurry (-.-) (_wlLine wl)))
, reflVelWallDamp x wl (ep -.- sp) , reflVelWallDamp x wl (ep -.- sp)
) )
+2 -85
View File
@@ -8,7 +8,7 @@ module Dodge.Creature.Action (
dropUnselected, dropUnselected,
dropExcept, dropExcept,
dropItem, dropItem,
blinkAction, blinkActionMousePos,
blinkActionFail, blinkActionFail,
unsafeBlinkAction, unsafeBlinkAction,
sizeSelf, sizeSelf,
@@ -22,6 +22,7 @@ import Data.Bifunctor
import Data.List (findIndex) import Data.List (findIndex)
import Data.Maybe import Data.Maybe
import Dodge.Base import Dodge.Base
import Dodge.Creature.Action.Blink
import Dodge.CreatureEffect import Dodge.CreatureEffect
import Dodge.Data.World import Dodge.Data.World
import Dodge.Default import Dodge.Default
@@ -32,11 +33,9 @@ import Dodge.Inventory.Add
import Dodge.Path import Dodge.Path
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.WallCreatureCollisions import Dodge.WallCreatureCollisions
import Dodge.WorldEvent.Shockwave
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import LensHelp import LensHelp
import Picture
performActions :: World -> Creature -> Creature performActions :: World -> Creature -> Creature
performActions w cr = performActions w cr =
@@ -145,88 +144,6 @@ performAction cr w ac = case ac of
(imps, _) -> (imps, Just $ DoReplicatePartial startac (t -1) startac) (imps, _) -> (imps, Just $ DoReplicatePartial startac (t -1) startac)
NoAction -> ([], Nothing) 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 :: Int -> Creature -> World -> World
setMinInvSize n cr = cWorld . creatures . ix (_crID cr) . crInvCapacity .~ n setMinInvSize n cr = cWorld . creatures . ix (_crID cr) . crInvCapacity .~ n
+103
View File
@@ -0,0 +1,103 @@
{-# LANGUAGE TupleSections #-}
module Dodge.Creature.Action.Blink (
blinkActionMousePos,
blinkActionFail,
unsafeBlinkAction,
) where
import Dodge.Zoning.Wall
import Data.Maybe
import Dodge.Base
import Dodge.Data.World
import Dodge.SoundLogic
import Dodge.WorldEvent.Shockwave
import Geometry
import LensHelp
import Picture
-- | Teleport a creature to the mouse position
blinkActionMousePos :: Creature -> World -> World
blinkActionMousePos cr w =
w
& soundMultiFrom [TeleSound 0, TeleSound 1] p3 teleS Nothing
& blinkDistortions cpos p3
& cWorld . creatures . ix cid . crPos .~ p3
& blinkShockwave cid p3
& inverseShockwaveAt cpos 40 2 2
where
cid = _crID cr
p1 = mouseWorldPos w
cpos = _crPos cr
--p2 = bouncePoint (const True) 1 cpos p1 w
p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w)
r = _crRad cr
p3 = maybe p1 ((+.+ squashNormalizeV (cpos -.- p1)) . fst) p2
--p3 = maybe p1 (const 0) p2
--p3 = maybe p1 fst p2
pushIntoMaybe :: (a, Maybe b) -> Maybe (a,b)
pushIntoMaybe (x,my) = (x,) <$> my
blinkDistortions :: Point2 -> Point2 -> World -> World
blinkDistortions sp ep = cWorld . distortions .++~ distortionBulge
where
distR = 120
distortionBulge =
[ RadialDistortion ep (ep +.+ V2 distR 0) (ep +.+ V2 0 distR) 0.1
, RadialDistortion sp (sp +.+ V2 distR 0) (sp +.+ V2 0 distR) 1.9
]
{- | 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
. blinkDistortions cpos mwp
. 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)
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
-- | 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
+2 -3
View File
@@ -30,7 +30,7 @@ useItem cr' w = fromMaybe (f w) $ do
itemEffect :: Creature -> Item -> World -> World itemEffect :: Creature -> Item -> World -> World
itemEffect cr it w = case it ^. itUse of itemEffect cr it w = case it ^. itUse of
HeldUse{_heldUse = eff, _heldMods = usemods} -> HeldUse{_heldUse = eff, _heldMods = usemods} ->
hammerTest $ tryReload cr it w $ foldl' (flip ($)) (useHeld eff) (reverse $ useMod usemods) it cr hammerTest $ tryReload cr it w $ foldl' (&) (useHeld eff) (reverse $ useMod usemods) it cr
LeftUse{} -> doequipmentchange LeftUse{} -> doequipmentchange
EquipUse{} -> doequipmentchange EquipUse{} -> doequipmentchange
-- ConsumeUse will cause problems if the item is not selected -- ConsumeUse will cause problems if the item is not selected
@@ -125,8 +125,7 @@ useLeftItem cid w
itmIsConsumable = itmIsConsumable =
isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse) isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse)
itmIsEquipable = itmIsEquipable =
( isJust (cr ^? crInv . ix (crSel cr) . itUse . equipEffect . eeUse) isJust (cr ^? crInv . ix (crSel cr) . itUse . equipEffect . eeUse)
&& _crLeftInvSel cr /= Just (crSel cr) && _crLeftInvSel cr /= Just (crSel cr)
)
-- TODO determine itmShouldBeUsed with reference to config options -- TODO determine itmShouldBeUsed with reference to config options
+2 -2
View File
@@ -202,7 +202,7 @@ movementSideEff cr w
useUpdate :: ItemUse -> ItemUse useUpdate :: ItemUse -> ItemUse
useUpdate = useUpdate =
(heldHammer %~ moveHammerUp) (heldHammer %~ moveHammerUp)
. (leftHammer %~ moveHammerUp) . (leftHammer %~ moveHammerUp)
. (leftDelay . rateTime %~ decreaseToZero) . (leftDelay . rateTime %~ decreaseToZero)
. (heldDelay . warmTime %~ decreaseToZero) . (heldDelay . warmTime %~ decreaseToZero)
. (heldDelay . rateTime %~ decreaseToZero) . (heldDelay . rateTime %~ decreaseToZero)
@@ -246,7 +246,7 @@ itemUpdate cr i
| otherwise = baseupdate False | otherwise = baseupdate False
where where
baseupdate bool = baseupdate bool =
updateAutoRecharge updateAutoRecharge
. (itUse %~ useUpdate) . (itUse %~ useUpdate)
. (itLocation .~ InInv (_crID cr) i) . (itLocation .~ InInv (_crID cr) i)
. (itIsHeld .~ bool) . (itIsHeld .~ bool)
+207 -209
View File
@@ -28,309 +28,307 @@ useMod :: HeldMod -> [(Item -> Creature -> World -> World) -> Item -> Creature -
useMod hm = case hm of useMod hm = case hm of
HeldModNothing -> [] HeldModNothing -> []
PoisonSprayerMod -> PoisonSprayerMod ->
[ ammoCheckI [ useAmmoAmount 1
, withSoundForI foamSprayLoopS 5 , withSoundForI foamSprayLoopS 5
, useAmmoAmount 1 , ammoCheckI
] ]
FlameSpitterMod -> FlameSpitterMod ->
[ ammoCheckI [ withSidePushAfterI 20
, useTimeCheck
, lockInvFor 10
, repeatOnFrames [1 .. 9] FlameSpitterRepeatMod
, withRandomItemParams f
, useAmmoAmount 1
, withSidePushI 5 , withSidePushI 5
, withSidePushAfterI 20 , useAmmoAmount 1
, withRandomItemParams f
, repeatOnFrames [1 .. 9] FlameSpitterRepeatMod
, lockInvFor 10
, useTimeCheck
, ammoCheckI
] ]
FlameSpitterRepeatMod -> FlameSpitterRepeatMod ->
[ ammoCheckI [ withSidePushAfterI 20
, withRandomItemParams f
, useAmmoAmount 1
, withSidePushI 5 , withSidePushI 5
, withSidePushAfterI 20 , useAmmoAmount 1
, withRandomItemParams f
, ammoCheckI
] ]
FlameThrowerMod -> FlameThrowerMod ->
[ ammoCheckI [ withSidePushAfterI 20
, useAmmoAmount 1 --, withTempLight 1 100 (V3 1 0 0)
, withSidePushI 5 , withSidePushI 5
, --, withTempLight 1 100 (V3 1 0 0) , useAmmoAmount 1
withSidePushAfterI 20 , ammoCheckI
] ]
LauncherMod -> LauncherMod ->
[ hammerCheckI [ useAmmoAmount 1
, ammoCheckI
, useTimeCheck
, withSoundStart tap4S , withSoundStart tap4S
, useAmmoAmount 1 , useTimeCheck
, ammoCheckI
, hammerCheckI
] ]
TeslaMod -> TeslaMod ->
[ ammoCheckI [ useAmmoAmount 1
, withTempLight 1 100 (V3 0 0 1)
, withSoundForI elecCrackleS 1 , withSoundForI elecCrackleS 1
, useAmmoAmount 1 , withTempLight 1 100 (V3 0 0 1)
, ammoCheckI
] ]
CircleLaserMod -> CircleLaserMod ->
[ ammoCheckI [ duplicateItem fLasCircle
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
, withItemUpdate' increasecycleLasCircle , withItemUpdate' increasecycleLasCircle
, duplicateItem fLasCircle , useAmmoAmount 1
, withSoundForI tone440sawtoothquietS 2
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, ammoCheckI
] ]
LasWideMod n -> LasWideMod n ->
[ ammoCheckI [ withItem $ \it -> duplicateOffsetsV2 (xsLasWide it)
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1
, crAtMuzPos
, withItemUpdate' (increasecycleLasWide n) , withItemUpdate' (increasecycleLasWide n)
, withItem $ \it -> duplicateOffsetsV2 (xsLasWide it) , crAtMuzPos
, useAmmoAmount 1
, withSoundForI tone440sawtoothquietS 2
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, ammoCheckI
] ]
DualBeamMod -> DualBeamMod ->
[ ammoCheckI [ useAmmoAmount 1
, withItem $ \it -> withMuzPosShift (V2 0 (thegapDualBeam it)) $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withItem $ \it -> withMuzPosShift (V2 0 (- thegapDualBeam it)) $ flareCircleAt (_lasColor2 $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2 , withSoundForI tone440sawtoothquietS 2
, useAmmoAmount 1 , withItem $ \it -> withMuzPosShift (V2 0 (- thegapDualBeam it)) $ flareCircleAt (_lasColor2 $ _itParams it) 0.8
, withItem $ \it -> withMuzPosShift (V2 0 (thegapDualBeam it)) $ flareCircleAt (_lasColor $ _itParams it) 0.8
, ammoCheckI
] ]
LasMod -> LasMod ->
[ ammoCheckI [ crAtMuzPos
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, withSoundForI tone440sawtoothquietS 2
, withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, useAmmoAmount 1 , useAmmoAmount 1
, crAtMuzPos , withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8
, withSoundForI tone440sawtoothquietS 2
, withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it))
, ammoCheckI
] ]
LauncherXMod i -> LauncherXMod i ->
[ hammerCheckI [ useAmmoAmount i
, ammoCheckI
, useTimeCheck
, withSoundStart tap4S , withSoundStart tap4S
, useAmmoAmount i , useTimeCheck
, ammoCheckI
, hammerCheckI
] ]
ShatterMod -> ShatterMod ->
[ ammoHammerCheck [ useAmmoAmount 1
-- , withSoundStart tap3S
, useTimeCheck , useTimeCheck
, -- , withSoundStart tap3S , ammoHammerCheck
useAmmoAmount 1
] ]
AmmoCheckMod -> [ammoCheckI] AmmoCheckMod -> [ammoCheckI]
AmmoUseCheckMod -> [ammoUseCheck] AmmoUseCheckMod -> [ammoUseCheck]
AmmoHammerTimeUseOneMod -> AmmoHammerTimeUseOneMod ->
[ ammoHammerCheck [ useAmmoAmount 1
, useTimeCheck , useTimeCheck
, useAmmoAmount 1 , ammoHammerCheck
] ]
BangCaneMod -> BangCaneMod ->
[ ammoHammerCheck [ withMuzFlareI
, useTimeCheck
, withSoundStart tap3S
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withRecoil
, withSmoke 1 black 20 200 5 , withSmoke 1 black 20 200 5
, withMuzFlareI , withRecoil
, applyInaccuracy
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart tap3S
, useTimeCheck
, ammoHammerCheck
] ]
VolleyGunMod -> VolleyGunMod ->
[ ammoHammerCheck [ withRecoil
, useTimeCheck
, withSoundItemChoiceStart caneStickSoundChoice
, useAllAmmo
, withTorqueAfter
, duplicateLoadedBarrels
, applyInaccuracy
, withMuzFlareI , withMuzFlareI
, withRecoil , applyInaccuracy
, duplicateLoadedBarrels
, withTorqueAfter
, useAllAmmo
, withSoundItemChoiceStart caneStickSoundChoice
, useTimeCheck
, ammoHammerCheck
] ]
AutoRifleMod -> AutoRifleMod ->
-- note this is the same as BangCanemMod with the first changed -- note this is the same as BangCanemMod with the first changed
[ ammoCheckI [ withMuzFlareI
, useTimeCheck
, withSoundStart tap3S
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withRecoil
, withSmoke 1 black 20 200 5 , withSmoke 1 black 20 200 5
, withMuzFlareI , withRecoil
, applyInaccuracy
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart tap3S
, useTimeCheck
, ammoCheckI
] ]
BangRodMod -> BangRodMod ->
[ ammoHammerCheck [ withRecoil
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withThickSmokeI
, withMuzFlareI , withMuzFlareI
, withRecoil , withThickSmokeI
, applyInaccuracy
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoHammerCheck
] ]
ElephantGunMod -> ElephantGunMod ->
[ ammoHammerCheck [ withRecoil
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withThickSmokeI
, withMuzFlareI , withMuzFlareI
, withRecoil , withThickSmokeI
, applyInaccuracy
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoHammerCheck
] ]
AutoAmrMod -> AutoAmrMod ->
[ ammoCheckI -- cf ElephantGun [ withRecoil
, useTimeCheck
, withSoundStart bangEchoS
, useAmmoAmount 1
, withTorqueAfter
, applyInaccuracy
, withThickSmokeI
, withMuzFlareI , withMuzFlareI
, withRecoil , withThickSmokeI
, applyInaccuracy
, withTorqueAfter
, useAmmoAmount 1
, withSoundStart bangEchoS
, useTimeCheck
, ammoCheckI -- cf ElephantGun
] ]
MachineGunMod -> MachineGunMod ->
[ ammoCheckI [ withMuzFlareI
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
, withSoundStart bangEchoS
, withThinSmokeI , withThinSmokeI
, withMuzFlareI , withSoundStart bangEchoS
, rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter
, ammoCheckI
] ]
ModWithDirectedTeleport hm' -> ModWithDirectedTeleport hm' ->
withPosDirWallCheck directedTelPos : useMod hm' reverse $ withPosDirWallCheck directedTelPos : useMod hm'
BangStickMod -> BangStickMod ->
[ ammoHammerCheck [ withRecoil
, useTimeCheck -- , applyInaccuracy
, withSoundItemChoiceStart bangStickSoundChoice
, useAllAmmo
, withMuzFlareI
, withTorqueAfter
, spreadLoaded , spreadLoaded
, -- , applyInaccuracy , withTorqueAfter
withRecoil , withMuzFlareI
, useAllAmmo
, withSoundItemChoiceStart bangStickSoundChoice
, useTimeCheck
, ammoHammerCheck
] ]
PistolMod -> PistolMod ->
[ ammoHammerCheck [ withMuzFlareI
, useTimeCheck
, useAmmoAmount 1
, withSoundStart tap3S
, applyInaccuracy
, withTorqueAfter
, withRecoil
, withSidePushI 50 , withSidePushI 50
, withMuzFlareI , withRecoil
, withTorqueAfter
, applyInaccuracy
, withSoundStart tap3S
, useAmmoAmount 1
, useTimeCheck
, ammoHammerCheck
] ]
AutoPistolMod -> AutoPistolMod ->
[ ammoCheckI [ withMuzFlareI
, useTimeCheck
, useAmmoAmount 1
, withSoundStart tap3S
, applyInaccuracy
, withTorqueAfter
, withRecoil
, withSidePushI 50 , withSidePushI 50
, withMuzFlareI , withRecoil
, withTorqueAfter
, applyInaccuracy
, withSoundStart tap3S
, useAmmoAmount 1
, useTimeCheck
, ammoCheckI
] ]
MachinePistolMod -> MachinePistolMod ->
[ ammoCheckI [ withMuzFlareI
, useTimeCheck
, useAmmoAmount 1
, withSoundStart tap1S
, applyInaccuracy
, withTorqueAfter
, withSidePushI 50
, withRecoil , withRecoil
, withMuzFlareI , withSidePushI 50
, withTorqueAfter
, applyInaccuracy
, withSoundStart tap1S
, useAmmoAmount 1
, useTimeCheck
, ammoCheckI
] ]
BurstRifleMod -> BurstRifleMod ->
[ ammoHammerCheck [ withRecoil
, useTimeCheck
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, lockInvFor 7
, repeatOnFrames [3, 6] BurstRifleRepeatMod
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
, withMuzFlareI , withMuzFlareI
, withRecoil , applyInaccuracy
, useAmmoAmount 1
, withSoundStart tap3S
, repeatOnFrames [3, 6] BurstRifleRepeatMod
, lockInvFor 7
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, useTimeCheck
, ammoHammerCheck
] ]
BurstRifleRepeatMod -> BurstRifleRepeatMod ->
[ ammoCheckI [ withRecoil
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, withSoundStart tap3S
, useAmmoAmount 1
, applyInaccuracy
, withMuzFlareI , withMuzFlareI
, withRecoil , applyInaccuracy
, useAmmoAmount 1
, withSoundStart tap3S
, sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2)
, ammoCheckI
] ]
MiniGunMod i -> MiniGunMod i ->
[ ammoCheckI reverse [ trigDoAlso' (moddelay x) (modcrpos x) useAmmoParams
, withWarmUp crankSlowS
, withSoundForI mini1S 2
, --, withThinSmokeI
withSmoke 1 black 20 200 5
, withMuzFlareI
, useAmmoAmount i
, withSidePushI (fromIntegral i * 50)
, torqueBefore (fromIntegral i * 0.05)
, afterRecoil (fromIntegral i * 5)
]
<> [ trigDoAlso' (moddelay x) (modcrpos x) useAmmoParams
| x <- map ((/ fromIntegral i) . fromIntegral) [1 .. i -1] | x <- map ((/ fromIntegral i) . fromIntegral) [1 .. i -1]
] ]
SmgMod -> <>
[ ammoCheckI [ afterRecoil (fromIntegral i * 5)
, useTimeCheck , torqueBefore (fromIntegral i * 0.05)
, useAmmoAmount 1 , withSidePushI (fromIntegral i * 50)
, withSoundStart tap3S , useAmmoAmount i
, applyInaccuracy
, withTorqueAfter
, withRecoil
, withSidePushI 30
, withMuzFlareI , withMuzFlareI
, withSmoke 1 black 20 200 5
--, withThinSmokeI
, withSoundForI mini1S 2
, withWarmUp crankSlowS
, ammoCheckI
]
SmgMod ->
[ withMuzFlareI
, withSidePushI 30
, withRecoil
, withTorqueAfter
, applyInaccuracy
, withSoundStart tap3S
, useAmmoAmount 1
, useTimeCheck
, ammoCheckI
] ]
RevolverXMod -> RevolverXMod ->
[ ammoHammerCheck [ withRecoil
, useTimeCheck , withTorqueAfter
, -- rather than locking the inventory, a better solution may be to check -- , spreadLoaded
-- that the weapon is still in your hands in the repeated frames
lockInvFor 10
, repeatOnFrames [2, 4, 6, 8, 10] RevolverXRepeatMod
, withSoundStart tap3S
, useAmmoUpTo 1
, applyInaccuracy
, withMuzFlareI , withMuzFlareI
, -- , spreadLoaded , applyInaccuracy
withTorqueAfter , useAmmoUpTo 1
, withRecoil , withSoundStart tap3S
, repeatOnFrames [2, 4, 6, 8, 10] RevolverXRepeatMod
, lockInvFor 10
-- rather than locking the inventory, a better solution may be to check
-- that the weapon is still in your hands in the repeated frames
, useTimeCheck
, ammoHammerCheck
] ]
RevolverXRepeatMod -> RevolverXRepeatMod ->
[ ammoCheckI [ withRecoil
, -- rather than locking the inventory, a better solution may be to check , withTorqueAfter
-- that the weapon is still in your hands in the repeated frames
withSoundStart tap3S
, useAmmoUpTo 1
, applyInaccuracy
, withMuzFlareI , withMuzFlareI
, -- , spreadLoaded , applyInaccuracy
withTorqueAfter , useAmmoUpTo 1
, withRecoil , withSoundStart tap3S
, ammoCheckI
] ]
BangConeMod -> BangConeMod ->
[ ammoCheckI [ withRandomItemParams coneRandItemParams
, hammerCheckI
, useTimeCheck
, withSoundStart bangEchoS
, useAllAmmo
, withTorqueAfter
, withRecoil
, duplicateLoaded
, withMuzFlareI
, applyInaccuracy
, withRandomOffset
, withRandomItemUpdate coneRandItemUpdate , withRandomItemUpdate coneRandItemUpdate
, withRandomItemParams coneRandItemParams , withRandomOffset
, applyInaccuracy
, withMuzFlareI
, duplicateLoaded
, withRecoil
, withTorqueAfter
, useAllAmmo
, withSoundStart bangEchoS
, useTimeCheck
, hammerCheckI
, ammoCheckI
] ]
where where
f = do f = do
+9 -1
View File
@@ -13,7 +13,7 @@ import RandomHelp
updateHumanoid :: Creature -> World -> World updateHumanoid :: Creature -> World -> World
updateHumanoid cr = case cr ^?! crType . humanoidAI of updateHumanoid cr = case cr ^?! crType . humanoidAI of
ChaseAI -> ChaseAI ->
defaultImpulsive humanoidAIList
[ const doStrategyActions [ const doStrategyActions
, performActions , performActions
, const overrideMeleeCloseTarget , const overrideMeleeCloseTarget
@@ -181,6 +181,14 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
, WaitThen 1 $ DoActionWhileInterrupt NoAction (WdCrBlfromCrBl CrIsReloading) (DoImpulses [ChangeStrategy WatchAndWait]) , WaitThen 1 $ DoActionWhileInterrupt NoAction (WdCrBlfromCrBl CrIsReloading) (DoImpulses [ChangeStrategy WatchAndWait])
] ]
humanoidAIList ::
[World -> Creature -> Creature] ->
Creature ->
World ->
World
humanoidAIList
= stateUpdate . impulsiveAIBefore . chainCreatureUpdates
-- bit of a hack to get new random generators after each creature's update -- bit of a hack to get new random generators after each creature's update
defaultImpulsive :: defaultImpulsive ::
[World -> Creature -> Creature] -> [World -> Creature -> Creature] ->
+1 -1
View File
@@ -21,7 +21,7 @@ rewindGun =
, _itUse = , _itUse =
defaultLeftUse defaultLeftUse
& leftUse .~ LRewind --useRewindGun & leftUse .~ LRewind --useRewindGun
& equipEffect . eeSite .~ GoesOnChest & equipEffect . eeSite .~ GoesOnWrist
} }
& itEffect . ieInv .~ RewindEffect & itEffect . ieInv .~ RewindEffect
& itType . iyBase .~ LEFT REWINDER & itType . iyBase .~ LEFT REWINDER
+1 -1
View File
@@ -15,7 +15,7 @@ useL lu = case lu of
LDoNothing -> const $ const id LDoNothing -> const $ const id
LRewind -> useRewindGun LRewind -> useRewindGun
LShrink -> hammerCheckL useShrinkGun LShrink -> hammerCheckL useShrinkGun
LBlink -> hammerCheckL (shootL $ const blinkAction) LBlink -> hammerCheckL (shootL $ const blinkActionMousePos)
LUnsafeBlink -> hammerCheckL (shootL $ const unsafeBlinkAction) LUnsafeBlink -> hammerCheckL (shootL $ const unsafeBlinkAction)
LBoost -> boostSelfL 10 LBoost -> boostSelfL 10
+10 -7
View File
@@ -2,15 +2,18 @@ module Dodge.TestString where
import Dodge.Data.Universe import Dodge.Data.Universe
import Control.Lens import Control.Lens
import Data.Maybe --import Data.Maybe
import ShortShow
testStringInit :: Universe -> [String] testStringInit :: Universe -> [String]
testStringInit u = [ testStringInit u = [
show $ u ^? uvWorld . hammers . ix DoubleMouseHam shortShow $ u ^?! uvWorld . cWorld . creatures . ix 0 . crPos
, show $ u ^? uvWorld . cWorld . creatures . ix 0 . crLeftInvSel . _Just
, fromMaybe "" $ do
i <- u ^? uvWorld . cWorld . creatures . ix 0 . crLeftInvSel . _Just
h <- u ^? uvWorld . cWorld . creatures . ix 0 . crInv . ix i . itUse . leftHammer
return $ show h
] ]
-- [ show $ u ^? uvWorld . hammers . ix DoubleMouseHam
-- , show $ u ^? uvWorld . cWorld . creatures . ix 0 . crLeftInvSel . _Just
-- , fromMaybe "" $ do
-- i <- u ^? uvWorld . cWorld . creatures . ix 0 . crLeftInvSel . _Just
-- h <- u ^? uvWorld . cWorld . creatures . ix 0 . crInv . ix i . itUse . leftHammer
-- return $ show h
-- ]
+2 -2
View File
@@ -45,10 +45,10 @@ pesNearCirc p r = pesNearRect (p +.+ V2 r r) (p -.- V2 r r)
peZoneSize :: Float peZoneSize :: Float
peZoneSize = 50 peZoneSize = 50
zoneOfPe :: (PathEdgeNodes) -> [Int2] zoneOfPe :: PathEdgeNodes -> [Int2]
zoneOfPe (PathEdgeNodes _ _ pe) = zoneOfSeg peZoneSize (_peStart pe) (_peEnd pe) zoneOfPe (PathEdgeNodes _ _ pe) = zoneOfSeg peZoneSize (_peStart pe) (_peEnd pe)
zonePe :: PathEdgeNodes -> IM.IntMap (IM.IntMap (Set PathEdgeNodes)) -> IM.IntMap (IM.IntMap (Set (PathEdgeNodes))) zonePe :: PathEdgeNodes -> IM.IntMap (IM.IntMap (Set PathEdgeNodes)) -> IM.IntMap (IM.IntMap (Set PathEdgeNodes))
zonePe pe im = foldl' f im (zoneOfPe pe) zonePe pe im = foldl' f im (zoneOfPe pe)
where where
f im' i2 = zoneMonoid i2 (Set.singleton pe) im' f im' i2 = zoneMonoid i2 (Set.singleton pe) im'
+1 -1
View File
@@ -1,5 +1,5 @@
{-# LANGUAGE StrictData #-} {-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-} --{-# LANGUAGE TemplateHaskell #-}
module Loop.Data where module Loop.Data where