Add debug to copy to clipboard any clicked-on creature

This commit is contained in:
2026-05-04 21:17:22 +01:00
parent 6b3d75cbb2
commit 5d5d0a539b
13 changed files with 212 additions and 207 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ performAction cr w ac = case ac of
-- DoActions acs ->
-- let (imps, newAcs) = foldMap (performAction cr w) acs
-- in (imps, newAcs)
StartSentinelPost -> ([AddGoal $ SentinelAt (cr ^. crPos . _xy) (_crDir cr)], NoAction)
-- StartSentinelPost -> ([AddGoal $ SentinelAt (cr ^. crPos . _xy) (_crDir cr)], NoAction)
PathTo p a -> performPathTo a cr w p
EvadeAim -> tryEvadeSideways cr w
TurnToPoint p -> performTurnToA cr p
+1 -1
View File
@@ -24,7 +24,7 @@ flockArmourChaseCrit =
ActionPlan
{ _apAction = NoAction
, _apStrategy = FollowImpulses
, _apGoal = [Kill 0]
, _apGoal = Kill 0
}
, _crGroup = ShieldGroup
-- , _crMvType = defaultChaseMvType
+1 -1
View File
@@ -64,7 +64,7 @@ followImpulse cid w = \case
MakeSound sid -> soundStart (CrSound (_crID cr)) (cr ^. crPos . _xy) sid Nothing w
DropItem -> undefined
ChangeStrategy strat -> crup $ crActionPlan . apStrategy .~ strat
AddGoal gl -> crup $ crActionPlan . apGoal .:~ gl
-- AddGoal gl -> crup $ crActionPlan . apGoal .:~ gl
ImpulseUseTarget f -> fromMaybe w $ do
i <- cr ^? crIntention . targetCr . _Just
tcr <- w ^? cWorld . lWorld . creatures . ix i
+1 -15
View File
@@ -1,6 +1,5 @@
{-# LANGUAGE LambdaCase #-}
module Dodge.Creature.ReaderUpdate (
doStrategyActions,
targetYouWhenCognizant,
overrideMeleeCloseTarget,
watchUpdateStrat,
@@ -269,14 +268,6 @@ viewTarget w cr = case cr ^? crIntention . viewPoint . _Just of
--replaceNullWith x [] = [x]
--replaceNullWith _ xs = xs
doStrategyActions :: Creature -> Creature
doStrategyActions cr = case cr ^? crActionPlan . apStrategy of
Just (SetStrategyAction strat acs) ->
cr
& crActionPlan . apAction .~ acs
& crActionPlan . apStrategy .~ strat
_ -> cr
overrideInternal :: (Creature -> Bool) -> (Creature -> Creature) -> Creature -> Creature
overrideInternal test update cr
| test cr = update cr
@@ -315,12 +306,7 @@ searchIfDamaged cr
| _crPain cr > 0
&& _apStrategy (_crActionPlan cr) == WatchAndWait =
cr & crPerception . cpVigilance .~ Vigilant
& crActionPlan . apStrategy
.~ SetStrategyAction
LookAround
( TurnToPoint (cr ^. crPos . _xy -.- unitVectorAtAngle (_crDir cr))
-- `DoActionThen` 40 `WaitThen` bfsThenReturn 500
)
& crActionPlan . apStrategy .~ LookAround
| otherwise = cr
--bfsThenReturn :: Int -> Action
+2 -6
View File
@@ -29,7 +29,6 @@ import Dodge.Creature.Radius
import Dodge.Data.Equipment.Misc
import Dodge.Data.AimStance
import Control.Lens
import Data.List (find)
import Data.Maybe
import Dodge.Base.Collide
import Dodge.Data.World
@@ -81,12 +80,9 @@ crStratConMatches strat cr = strat == _apStrategy (_crActionPlan cr)
-- this equality check might be slow...
crAwayFromPost :: Creature -> Bool
crAwayFromPost cr = case find sentinelGoal . _apGoal $ _crActionPlan cr of
Just (SentinelAt p _) -> dist p (cr ^. crPos . _xy) > 15
crAwayFromPost cr = case _apGoal $ _crActionPlan cr of
SentinelAt p _ -> dist p (cr ^. crPos . _xy) > 15
_ -> False
where
sentinelGoal (SentinelAt _ _) = True
sentinelGoal _ = False
crInAimStance :: AimStance -> Creature -> Bool
crInAimStance as cr = cr ^? crStance . posture == Just Aiming
+9 -3
View File
@@ -161,8 +161,11 @@ updateCalmBee cr cid w
, x >= 0.5 = w & tocr . crType . beeSlime -~ 0.5
| Just x <- cr ^? crType . beeSlime
, x < 0.5
, Just hcr <- gethive
, distance (cr ^. crPos . _xy) (hcr ^. crPos . _xy) < 30
, Just ReturnToHive <- cr ^? crActionPlan . apStrategy
= w & tocr . crActionPlan . apStrategy .~ Search
& tocr . crActionPlan . apAction .~ NoAction
| Just hcr <- gethive
, Just _ <- cr ^? crStance . carriage . mountID
, Just x <- cr ^? crType . beeSlime
@@ -180,8 +183,10 @@ updateCalmBee cr cid w
= w & tocr . crActionPlan . apAction .~ PathTo (hcr ^. crPos . _xy) NoAction
& tocr . crActionPlan . apStrategy .~ ReturnToHive
| Nothing <- cr ^? crActionPlan . apStrategy . harvestTarget
, Just tcr <- listToMaybe . sortOn (distance cxy . (^. crPos . _xy)) . IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w =
, xs@(_:_) <- IM.elems . IM.filter istarget $ crsNearCirc cxy 100 w
, (tcr,g') <- runState (takeOne xs) (w ^. randGen) =
w & tocr . crActionPlan . apStrategy .~ HarvestFrom (tcr ^. crID)
& randGen .~ g'
| Just tid <- cr ^? crStance . carriage . mountID
, Just SlimeCrit{} <- w ^? cWorld . lWorld . creatures . ix tid . crType = w
& tocr . crType . beeSlime +~ sspeed
@@ -195,7 +200,8 @@ updateCalmBee cr cid w
& tocr . crActionPlan . apAction .~ NoAction
| Just (tcr,_) <- gettarg = w
& tocr . crActionPlan . apAction .~ PathTo (tcr ^. crPos . _xy) NoAction
| Just (SearchTimed 0) <- cr ^? crActionPlan . apStrategy = w & tocr . crActionPlan . apStrategy .~ Search
| Just (SearchTimed 0) <- cr ^? crActionPlan . apStrategy
= w & tocr . crActionPlan . apStrategy .~ ReturnToHive
| Just PathTo{} <- cr ^? crActionPlan . apAction = w
& tocr . crActionPlan . apStrategy . searchTimer %~ (max 0 . subtract 1)
| otherwise = w
@@ -203,7 +209,7 @@ updateCalmBee cr cid w
& randGen .~ g
& tocr . crActionPlan . apStrategy .~ SearchTimed 200
where
(p,g) = runState (randOnCirc 150) (w ^. randGen)
(p,g) = runState (randOnCirc 200) (w ^. randGen)
cxy = cr ^. crPos . _xy
mountshakeoff mid = fromMaybe True $ do
mcr <- w ^? cWorld . lWorld . creatures . ix mid