diff --git a/src/Dodge/Base.hs b/src/Dodge/Base.hs index b2587f9b6..5bf615339 100644 --- a/src/Dodge/Base.hs +++ b/src/Dodge/Base.hs @@ -101,6 +101,17 @@ mvPointTowardAtSpeed mvPointTowardAtSpeed !speed !ep !p | dist p ep < speed = ep | 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. If close enough, end up on the end point -} mvPointToward diff --git a/src/Dodge/Base/Collide.hs b/src/Dodge/Base/Collide.hs index 1184f9004..982664405 100644 --- a/src/Dodge/Base/Collide.hs +++ b/src/Dodge/Base/Collide.hs @@ -15,6 +15,7 @@ module Dodge.Base.Collide ( collidePoint, collidePointWallsFilter, collidePointTestFilter, + collideCircWalls, overlapSegWalls, overlapSegCrs, bounceBall, @@ -69,6 +70,7 @@ doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, {-# INLINE doBounce #-} doBounce x sp ep (p, mwl) = mwl <&> \wl -> + --( p +.+ normalizeV (vNormal (uncurry (-.-) (_wlLine wl))) ( p +.+ normalizeV (vNormal (uncurry (-.-) (_wlLine wl))) , reflVelWallDamp x wl (ep -.- sp) ) diff --git a/src/Dodge/Creature/Action.hs b/src/Dodge/Creature/Action.hs index eac196d33..8d0474b3a 100644 --- a/src/Dodge/Creature/Action.hs +++ b/src/Dodge/Creature/Action.hs @@ -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 diff --git a/src/Dodge/Creature/Action/Blink.hs b/src/Dodge/Creature/Action/Blink.hs new file mode 100644 index 000000000..300ec2c8b --- /dev/null +++ b/src/Dodge/Creature/Action/Blink.hs @@ -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 diff --git a/src/Dodge/Creature/Impulse/UseItem.hs b/src/Dodge/Creature/Impulse/UseItem.hs index e6e751fe3..21d05eecc 100644 --- a/src/Dodge/Creature/Impulse/UseItem.hs +++ b/src/Dodge/Creature/Impulse/UseItem.hs @@ -30,7 +30,7 @@ useItem cr' w = fromMaybe (f w) $ do itemEffect :: Creature -> Item -> World -> World itemEffect cr it w = case it ^. itUse of 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 EquipUse{} -> doequipmentchange -- ConsumeUse will cause problems if the item is not selected @@ -125,8 +125,7 @@ useLeftItem cid w itmIsConsumable = isJust (cr ^? crInv . ix (crSel cr) . itUse . cUse) itmIsEquipable = - ( isJust (cr ^? crInv . ix (crSel cr) . itUse . equipEffect . eeUse) + isJust (cr ^? crInv . ix (crSel cr) . itUse . equipEffect . eeUse) && _crLeftInvSel cr /= Just (crSel cr) - ) -- TODO determine itmShouldBeUsed with reference to config options diff --git a/src/Dodge/Creature/State.hs b/src/Dodge/Creature/State.hs index 49ad98c2f..8293c2686 100644 --- a/src/Dodge/Creature/State.hs +++ b/src/Dodge/Creature/State.hs @@ -202,7 +202,7 @@ movementSideEff cr w useUpdate :: ItemUse -> ItemUse useUpdate = (heldHammer %~ moveHammerUp) - . (leftHammer %~ moveHammerUp) + . (leftHammer %~ moveHammerUp) . (leftDelay . rateTime %~ decreaseToZero) . (heldDelay . warmTime %~ decreaseToZero) . (heldDelay . rateTime %~ decreaseToZero) @@ -246,7 +246,7 @@ itemUpdate cr i | otherwise = baseupdate False where baseupdate bool = - updateAutoRecharge + updateAutoRecharge . (itUse %~ useUpdate) . (itLocation .~ InInv (_crID cr) i) . (itIsHeld .~ bool) diff --git a/src/Dodge/HeldUse.hs b/src/Dodge/HeldUse.hs index a96ef92b5..52638dc37 100644 --- a/src/Dodge/HeldUse.hs +++ b/src/Dodge/HeldUse.hs @@ -28,309 +28,307 @@ useMod :: HeldMod -> [(Item -> Creature -> World -> World) -> Item -> Creature - useMod hm = case hm of HeldModNothing -> [] PoisonSprayerMod -> - [ ammoCheckI + [ useAmmoAmount 1 , withSoundForI foamSprayLoopS 5 - , useAmmoAmount 1 + , ammoCheckI ] FlameSpitterMod -> - [ ammoCheckI - , useTimeCheck - , lockInvFor 10 - , repeatOnFrames [1 .. 9] FlameSpitterRepeatMod - , withRandomItemParams f - , useAmmoAmount 1 + [ withSidePushAfterI 20 , withSidePushI 5 - , withSidePushAfterI 20 + , useAmmoAmount 1 + , withRandomItemParams f + , repeatOnFrames [1 .. 9] FlameSpitterRepeatMod + , lockInvFor 10 + , useTimeCheck + , ammoCheckI ] FlameSpitterRepeatMod -> - [ ammoCheckI - , withRandomItemParams f - , useAmmoAmount 1 + [ withSidePushAfterI 20 , withSidePushI 5 - , withSidePushAfterI 20 + , useAmmoAmount 1 + , withRandomItemParams f + , ammoCheckI ] FlameThrowerMod -> - [ ammoCheckI - , useAmmoAmount 1 + [ withSidePushAfterI 20 + --, withTempLight 1 100 (V3 1 0 0) , withSidePushI 5 - , --, withTempLight 1 100 (V3 1 0 0) - withSidePushAfterI 20 + , useAmmoAmount 1 + , ammoCheckI ] LauncherMod -> - [ hammerCheckI - , ammoCheckI - , useTimeCheck + [ useAmmoAmount 1 , withSoundStart tap4S - , useAmmoAmount 1 + , useTimeCheck + , ammoCheckI + , hammerCheckI ] TeslaMod -> - [ ammoCheckI - , withTempLight 1 100 (V3 0 0 1) + [ useAmmoAmount 1 , withSoundForI elecCrackleS 1 - , useAmmoAmount 1 + , withTempLight 1 100 (V3 0 0 1) + , ammoCheckI ] CircleLaserMod -> - [ ammoCheckI - , withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it)) - , withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8 - , withSoundForI tone440sawtoothquietS 2 - , useAmmoAmount 1 + [ duplicateItem fLasCircle , 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 -> - [ ammoCheckI - , withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it)) - , withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8 - , withSoundForI tone440sawtoothquietS 2 - , useAmmoAmount 1 - , crAtMuzPos + [ withItem $ \it -> duplicateOffsetsV2 (xsLasWide it) , 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 -> - [ ammoCheckI - , 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 + [ useAmmoAmount 1 , 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 -> - [ ammoCheckI - , withItem $ \it -> withTempLight 1 100 (xyzV4 (_lasColor $ _itParams it)) - , withSoundForI tone440sawtoothquietS 2 - , withItem $ \it -> withMuzPos $ flareCircleAt (_lasColor $ _itParams it) 0.8 + [ crAtMuzPos , 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 -> - [ hammerCheckI - , ammoCheckI - , useTimeCheck + [ useAmmoAmount i , withSoundStart tap4S - , useAmmoAmount i + , useTimeCheck + , ammoCheckI + , hammerCheckI ] ShatterMod -> - [ ammoHammerCheck + [ useAmmoAmount 1 + -- , withSoundStart tap3S , useTimeCheck - , -- , withSoundStart tap3S - useAmmoAmount 1 + , ammoHammerCheck ] AmmoCheckMod -> [ammoCheckI] AmmoUseCheckMod -> [ammoUseCheck] AmmoHammerTimeUseOneMod -> - [ ammoHammerCheck + [ useAmmoAmount 1 , useTimeCheck - , useAmmoAmount 1 + , ammoHammerCheck ] BangCaneMod -> - [ ammoHammerCheck - , useTimeCheck - , withSoundStart tap3S - , useAmmoAmount 1 - , withTorqueAfter - , applyInaccuracy - , withRecoil + [ withMuzFlareI , withSmoke 1 black 20 200 5 - , withMuzFlareI + , withRecoil + , applyInaccuracy + , withTorqueAfter + , useAmmoAmount 1 + , withSoundStart tap3S + , useTimeCheck + , ammoHammerCheck ] VolleyGunMod -> - [ ammoHammerCheck - , useTimeCheck - , withSoundItemChoiceStart caneStickSoundChoice - , useAllAmmo - , withTorqueAfter - , duplicateLoadedBarrels - , applyInaccuracy + [ withRecoil , withMuzFlareI - , withRecoil + , applyInaccuracy + , duplicateLoadedBarrels + , withTorqueAfter + , useAllAmmo + , withSoundItemChoiceStart caneStickSoundChoice + , useTimeCheck + , ammoHammerCheck ] AutoRifleMod -> -- note this is the same as BangCanemMod with the first changed - [ ammoCheckI - , useTimeCheck - , withSoundStart tap3S - , useAmmoAmount 1 - , withTorqueAfter - , applyInaccuracy - , withRecoil + [ withMuzFlareI , withSmoke 1 black 20 200 5 - , withMuzFlareI + , withRecoil + , applyInaccuracy + , withTorqueAfter + , useAmmoAmount 1 + , withSoundStart tap3S + , useTimeCheck + , ammoCheckI ] BangRodMod -> - [ ammoHammerCheck - , useTimeCheck - , withSoundStart bangEchoS - , useAmmoAmount 1 - , withTorqueAfter - , applyInaccuracy - , withThickSmokeI + [ withRecoil , withMuzFlareI - , withRecoil + , withThickSmokeI + , applyInaccuracy + , withTorqueAfter + , useAmmoAmount 1 + , withSoundStart bangEchoS + , useTimeCheck + , ammoHammerCheck ] ElephantGunMod -> - [ ammoHammerCheck - , useTimeCheck - , withSoundStart bangEchoS - , useAmmoAmount 1 - , withTorqueAfter - , applyInaccuracy - , withThickSmokeI + [ withRecoil , withMuzFlareI - , withRecoil + , withThickSmokeI + , applyInaccuracy + , withTorqueAfter + , useAmmoAmount 1 + , withSoundStart bangEchoS + , useTimeCheck + , ammoHammerCheck ] AutoAmrMod -> - [ ammoCheckI -- cf ElephantGun - , useTimeCheck - , withSoundStart bangEchoS - , useAmmoAmount 1 - , withTorqueAfter - , applyInaccuracy - , withThickSmokeI + [ withRecoil , withMuzFlareI - , withRecoil + , withThickSmokeI + , applyInaccuracy + , withTorqueAfter + , useAmmoAmount 1 + , withSoundStart bangEchoS + , useTimeCheck + , ammoCheckI -- cf ElephantGun ] MachineGunMod -> - [ ammoCheckI - , rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter - , withSoundStart bangEchoS + [ withMuzFlareI , withThinSmokeI - , withMuzFlareI + , withSoundStart bangEchoS + , rateIncAB (torqueBeforeAtLeast 0.1 0.1) withTorqueAfter + , ammoCheckI ] ModWithDirectedTeleport hm' -> - withPosDirWallCheck directedTelPos : useMod hm' + reverse $ withPosDirWallCheck directedTelPos : useMod hm' BangStickMod -> - [ ammoHammerCheck - , useTimeCheck - , withSoundItemChoiceStart bangStickSoundChoice - , useAllAmmo - , withMuzFlareI - , withTorqueAfter + [ withRecoil + -- , applyInaccuracy , spreadLoaded - , -- , applyInaccuracy - withRecoil + , withTorqueAfter + , withMuzFlareI + , useAllAmmo + , withSoundItemChoiceStart bangStickSoundChoice + , useTimeCheck + , ammoHammerCheck ] PistolMod -> - [ ammoHammerCheck - , useTimeCheck - , useAmmoAmount 1 - , withSoundStart tap3S - , applyInaccuracy - , withTorqueAfter - , withRecoil + [ withMuzFlareI , withSidePushI 50 - , withMuzFlareI + , withRecoil + , withTorqueAfter + , applyInaccuracy + , withSoundStart tap3S + , useAmmoAmount 1 + , useTimeCheck + , ammoHammerCheck ] AutoPistolMod -> - [ ammoCheckI - , useTimeCheck - , useAmmoAmount 1 - , withSoundStart tap3S - , applyInaccuracy - , withTorqueAfter - , withRecoil + [ withMuzFlareI , withSidePushI 50 - , withMuzFlareI + , withRecoil + , withTorqueAfter + , applyInaccuracy + , withSoundStart tap3S + , useAmmoAmount 1 + , useTimeCheck + , ammoCheckI ] MachinePistolMod -> - [ ammoCheckI - , useTimeCheck - , useAmmoAmount 1 - , withSoundStart tap1S - , applyInaccuracy - , withTorqueAfter - , withSidePushI 50 + [ withMuzFlareI , withRecoil - , withMuzFlareI + , withSidePushI 50 + , withTorqueAfter + , applyInaccuracy + , withSoundStart tap1S + , useAmmoAmount 1 + , useTimeCheck + , ammoCheckI ] BurstRifleMod -> - [ ammoHammerCheck - , useTimeCheck - , sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2) - , lockInvFor 7 - , repeatOnFrames [3, 6] BurstRifleRepeatMod - , withSoundStart tap3S - , useAmmoAmount 1 - , applyInaccuracy + [ withRecoil , 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 -> - [ ammoCheckI - , sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2) - , withSoundStart tap3S - , useAmmoAmount 1 - , applyInaccuracy + [ withRecoil , withMuzFlareI - , withRecoil + , applyInaccuracy + , useAmmoAmount 1 + , withSoundStart tap3S + , sideEffectOnFrame 7 (\_ cr -> TorqueCr 0.2 (_crID cr)) --(torqueSideEffect 0.2) + , ammoCheckI ] MiniGunMod i -> - [ ammoCheckI - , 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 + reverse [ trigDoAlso' (moddelay x) (modcrpos x) useAmmoParams | x <- map ((/ fromIntegral i) . fromIntegral) [1 .. i -1] ] - SmgMod -> - [ ammoCheckI - , useTimeCheck - , useAmmoAmount 1 - , withSoundStart tap3S - , applyInaccuracy - , withTorqueAfter - , withRecoil - , withSidePushI 30 + <> + [ afterRecoil (fromIntegral i * 5) + , torqueBefore (fromIntegral i * 0.05) + , withSidePushI (fromIntegral i * 50) + , useAmmoAmount i , 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 -> - [ ammoHammerCheck - , useTimeCheck - , -- rather than locking the inventory, a better solution may be to check - -- 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 + [ withRecoil + , withTorqueAfter + -- , spreadLoaded , withMuzFlareI - , -- , spreadLoaded - withTorqueAfter - , withRecoil + , applyInaccuracy + , useAmmoUpTo 1 + , 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 -> - [ ammoCheckI - , -- rather than locking the inventory, a better solution may be to check - -- that the weapon is still in your hands in the repeated frames - withSoundStart tap3S - , useAmmoUpTo 1 - , applyInaccuracy + [ withRecoil + , withTorqueAfter , withMuzFlareI - , -- , spreadLoaded - withTorqueAfter - , withRecoil + , applyInaccuracy + , useAmmoUpTo 1 + , withSoundStart tap3S + , ammoCheckI ] BangConeMod -> - [ ammoCheckI - , hammerCheckI - , useTimeCheck - , withSoundStart bangEchoS - , useAllAmmo - , withTorqueAfter - , withRecoil - , duplicateLoaded - , withMuzFlareI - , applyInaccuracy - , withRandomOffset + [ withRandomItemParams coneRandItemParams , withRandomItemUpdate coneRandItemUpdate - , withRandomItemParams coneRandItemParams + , withRandomOffset + , applyInaccuracy + , withMuzFlareI + , duplicateLoaded + , withRecoil + , withTorqueAfter + , useAllAmmo + , withSoundStart bangEchoS + , useTimeCheck + , hammerCheckI + , ammoCheckI ] where f = do diff --git a/src/Dodge/Humanoid.hs b/src/Dodge/Humanoid.hs index e24aec097..c65e1d276 100644 --- a/src/Dodge/Humanoid.hs +++ b/src/Dodge/Humanoid.hs @@ -13,7 +13,7 @@ import RandomHelp updateHumanoid :: Creature -> World -> World updateHumanoid cr = case cr ^?! crType . humanoidAI of ChaseAI -> - defaultImpulsive + humanoidAIList [ const doStrategyActions , performActions , const overrideMeleeCloseTarget @@ -181,6 +181,14 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of , 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 defaultImpulsive :: [World -> Creature -> Creature] -> diff --git a/src/Dodge/Item/Weapon/Utility.hs b/src/Dodge/Item/Weapon/Utility.hs index 52cff8ab9..3f6e4f81d 100644 --- a/src/Dodge/Item/Weapon/Utility.hs +++ b/src/Dodge/Item/Weapon/Utility.hs @@ -21,7 +21,7 @@ rewindGun = , _itUse = defaultLeftUse & leftUse .~ LRewind --useRewindGun - & equipEffect . eeSite .~ GoesOnChest + & equipEffect . eeSite .~ GoesOnWrist } & itEffect . ieInv .~ RewindEffect & itType . iyBase .~ LEFT REWINDER diff --git a/src/Dodge/Luse.hs b/src/Dodge/Luse.hs index c18ef250e..a5d14e5ab 100644 --- a/src/Dodge/Luse.hs +++ b/src/Dodge/Luse.hs @@ -15,7 +15,7 @@ useL lu = case lu of LDoNothing -> const $ const id LRewind -> useRewindGun LShrink -> hammerCheckL useShrinkGun - LBlink -> hammerCheckL (shootL $ const blinkAction) + LBlink -> hammerCheckL (shootL $ const blinkActionMousePos) LUnsafeBlink -> hammerCheckL (shootL $ const unsafeBlinkAction) LBoost -> boostSelfL 10 diff --git a/src/Dodge/TestString.hs b/src/Dodge/TestString.hs index 43a9f98bb..93beb3b91 100644 --- a/src/Dodge/TestString.hs +++ b/src/Dodge/TestString.hs @@ -2,15 +2,18 @@ module Dodge.TestString where import Dodge.Data.Universe import Control.Lens -import Data.Maybe +--import Data.Maybe +import ShortShow testStringInit :: Universe -> [String] testStringInit u = [ - 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 + shortShow $ u ^?! uvWorld . cWorld . creatures . ix 0 . crPos ] +-- [ 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 +-- ] diff --git a/src/Dodge/Zoning/Pathing.hs b/src/Dodge/Zoning/Pathing.hs index c8e301359..47a843507 100644 --- a/src/Dodge/Zoning/Pathing.hs +++ b/src/Dodge/Zoning/Pathing.hs @@ -45,10 +45,10 @@ pesNearCirc p r = pesNearRect (p +.+ V2 r r) (p -.- V2 r r) peZoneSize :: Float peZoneSize = 50 -zoneOfPe :: (PathEdgeNodes) -> [Int2] +zoneOfPe :: PathEdgeNodes -> [Int2] 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) where f im' i2 = zoneMonoid i2 (Set.singleton pe) im' diff --git a/src/Loop/Data.hs b/src/Loop/Data.hs index 8c5777aeb..9d38b1f99 100644 --- a/src/Loop/Data.hs +++ b/src/Loop/Data.hs @@ -1,5 +1,5 @@ {-# LANGUAGE StrictData #-} -{-# LANGUAGE TemplateHaskell #-} +--{-# LANGUAGE TemplateHaskell #-} module Loop.Data where