Remove reified impulses from creature record

This commit is contained in:
2025-10-18 15:42:35 +01:00
parent b43168ae33
commit 4ee389efb1
16 changed files with 155 additions and 191 deletions
+4 -6
View File
@@ -33,11 +33,9 @@ import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import LensHelp import LensHelp
performActions :: World -> Creature -> Creature performActions :: World -> Creature -> ([Impulse],Creature)
performActions w cr = performActions w cr = (concat iss
cr , cr & crActionPlan . apAction .~ catMaybes mayas)
& crActionPlan . apImpulse .~ concat iss
& crActionPlan . apAction .~ catMaybes mayas
where where
(iss, mayas) = unzip $ map (performAction cr w) $ cr ^. crActionPlan . apAction (iss, mayas) = unzip $ map (performAction cr w) $ cr ^. crActionPlan . apAction
@@ -125,7 +123,7 @@ performAction cr w ac = case ac of
LeadTarget p -> fromMaybe ([],Nothing) $ do LeadTarget p -> fromMaybe ([],Nothing) $ do
i <- cr ^? crIntention . targetCr . _Just i <- cr ^? crIntention . targetCr . _Just
tcr <- w ^? cWorld . lWorld . creatures . ix i tcr <- w ^? cWorld . lWorld . creatures . ix i
return $ ([TurnTo (tcr ^. crPos . _xy +.+ rotateV (_crDir tcr) p)], Nothing) return ([TurnTo (tcr ^. crPos . _xy +.+ rotateV (_crDir tcr) p)], Nothing)
UseSelf f -> performAction cr w $ doCrAc f cr UseSelf f -> performAction cr w $ doCrAc f cr
ArbitraryAction f -> performAction cr w (doCrWdAc f cr w) ArbitraryAction f -> performAction cr w (doCrWdAc f cr w)
DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of DoImpulsesAlongside sideImp mainAc -> case performAction cr w mainAc of
+1 -2
View File
@@ -22,8 +22,7 @@ flockArmourChaseCrit =
-- ] -- ]
, _crActionPlan = , _crActionPlan =
ActionPlan ActionPlan
{ _apImpulse = [] { _apAction = []
, _apAction = []
, _apStrategy = FollowImpulses , _apStrategy = FollowImpulses
, _apGoal = [Kill 0] , _apGoal = [Kill 0]
} }
+5 -5
View File
@@ -210,7 +210,7 @@ flockPointTarget ::
Creature Creature
flockPointTarget f targFunc w cr = case targFunc cr w of flockPointTarget f targFunc w cr = case targFunc cr w of
Nothing -> cr Nothing -> cr
Just crTarg -> cr & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
where where
is = _swarm $ _crGroup cr is = _swarm $ _crGroup cr
crs = IM.restrictKeys (w ^. cWorld . lWorld . creatures) is crs = IM.restrictKeys (w ^. cWorld . lWorld . creatures) is
@@ -239,7 +239,7 @@ flockToPointUsing' pf mvf w cr = fromMaybe cr $ do
i <- _targetCr $ _crIntention cr i <- _targetCr $ _crIntention cr
tcr <- w ^? cWorld . lWorld . creatures . ix i tcr <- w ^? cWorld . lWorld . creatures . ix i
let ptarg = pf tcr cenp cr let ptarg = pf tcr cenp cr
return $ cr & crActionPlan . apImpulse .~ mvf ptarg cr tcr return $ cr -- & crActionPlan . apImpulse .~ mvf ptarg cr tcr
where where
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
@@ -251,7 +251,7 @@ flockFunc ::
Reader World Creature Reader World Creature
flockFunc f targFunc cr = reader $ \w -> case targFunc cr w of flockFunc f targFunc cr = reader $ \w -> case targFunc cr w of
Nothing -> cr Nothing -> cr
Just crTarg -> cr & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
where where
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
p = f crTarg cenp cr p = f crTarg cenp cr
@@ -264,7 +264,7 @@ flockCenterFunc ::
Reader World Creature Reader World Creature
flockCenterFunc f targFunc cr = reader $ \w -> case targFunc cr w of flockCenterFunc f targFunc cr = reader $ \w -> case targFunc cr w of
Nothing -> cr Nothing -> cr
Just crTarg -> cr & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
where where
cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter cenp = w ^?! cWorld . lWorld . creatureGroups . ix (cr ^?! crGroup . crGroupID) . crGroupCenter
p = f crTarg cenp cr p = f crTarg cenp cr
@@ -277,7 +277,7 @@ flockPointTargetR ::
Reader World Creature Reader World Creature
flockPointTargetR f targFunc cr = reader $ \w -> case targFunc cr w of flockPointTargetR f targFunc cr = reader $ \w -> case targFunc cr w of
Nothing -> cr Nothing -> cr
Just crTarg -> cr & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg Just crTarg -> cr -- & crActionPlan . apImpulse .~ mvPointMeleeTarg p cr crTarg
where where
is = _swarm $ _crGroup cr is = _swarm $ _crGroup cr
--crs = IM.restrictKeys (_creatures (_cWorld w)) is --crs = IM.restrictKeys (_creatures (_cWorld w)) is
+5 -8
View File
@@ -1,7 +1,8 @@
{-# LANGUAGE TupleSections #-} --{-# LANGUAGE TupleSections #-}
module Dodge.Creature.Impulse (followImpulses) where module Dodge.Creature.Impulse (followImpulses) where
import Dodge.Creature.Action
import Data.Maybe import Data.Maybe
import NewInt import NewInt
import Linear import Linear
@@ -20,14 +21,10 @@ import Geometry
import LensHelp import LensHelp
import System.Random import System.Random
--followImpulses :: World -> Creature -> (World -> World, Creature)
--followImpulses w cr = foldl' (flip f) (id, cr) (reverse $ _apImpulse $ _crActionPlan cr)
-- where
-- f imp (theupdate, cr') = first (. theupdate) $ followImpulse cr' w imp
followImpulses :: Int -> World -> World followImpulses :: Int -> World -> World
followImpulses cid w = foldl' (followImpulse cid) w followImpulses cid w = let (is,cr) = performActions w (w ^?! cWorld . lWorld . creatures . ix cid)
(reverse $ w ^?! cWorld . lWorld . creatures . ix cid . crActionPlan . apImpulse) in foldl' (followImpulse cid) (w & cWorld . lWorld . creatures . ix cid .~ cr)
(reverse is)
-- note SwitchToItem doesn't necessarily update the root item correctly -- note SwitchToItem doesn't necessarily update the root item correctly
followImpulse :: Int -> World -> Impulse -> World followImpulse :: Int -> World -> Impulse -> World
+1 -1
View File
@@ -82,7 +82,7 @@ chaseCritAwarenessUpdate w cr = case _cpAttention $ _crPerception cr of
IM.unionWith cogRaised oldAwareness newAwareness IM.unionWith cogRaised oldAwareness newAwareness
thejitter = [RandomImpulse $ RandImpulseCircMove 3] thejitter = [RandomImpulse $ RandImpulseCircMove 3]
maybeBark = fromMaybe id $ do maybeBark = fromMaybe id $ do
guard $ becomesCognizant guard becomesCognizant
guard $ cr ^? crVocalization . vcCoolDown == Just 0 guard $ cr ^? crVocalization . vcCoolDown == Just 0
let soundid = evalState (takeOne (crWarningSounds cr)) (_randGen w) let soundid = evalState (takeOne (crWarningSounds cr)) (_randGen w)
numjits = fst $ randomR (15, 25) (_randGen w) numjits = fst $ randomR (15, 25) (_randGen w)
+3 -3
View File
@@ -43,9 +43,9 @@ tryMeleeAttack cr tcr
&& Just (_crID tcr) == cr ^? crActionPlan . apStrategy . meleeTarget && Just (_crID tcr) == cr ^? crActionPlan . apStrategy . meleeTarget
&& dist tpos cpos < crRad (cr ^. crType) + crRad (tcr ^. crType) + 5 && dist tpos cpos < crRad (cr ^. crType) + crRad (tcr ^. crType) + 5
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 = && abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 =
cr & crActionPlan . apImpulse .~ [Melee $ _crID tcr] cr & crActionPlan . apAction
& crActionPlan . apAction .~ [ DoImpulses [Melee $ _crID tcr] `DoActionThen`
.~ [ DoReplicate 10 NoAction DoReplicate 10 NoAction
`DoActionThen` DoImpulses `DoActionThen` DoImpulses
[ChangeStrategy (CloseToMelee $ _crID tcr)] [ChangeStrategy (CloseToMelee $ _crID tcr)]
] ]
+2 -4
View File
@@ -49,8 +49,7 @@ sentinelAI =
sentinelFireType :: (Int -> Action) -> World -> Creature -> Creature sentinelFireType :: (Int -> Action) -> World -> Creature -> Creature
sentinelFireType f = sentinelFireType f =
chainCreatureUpdates chainCreatureUpdates
[ performActions [ watchUpdateStrat
, watchUpdateStrat
[ [
( crHasTargetLOS ( crHasTargetLOS
, \_ _ -> , \_ _ ->
@@ -86,8 +85,7 @@ sentinelExtraWatchUpdate ::
Creature Creature
sentinelExtraWatchUpdate xs = sentinelExtraWatchUpdate xs =
chainCreatureUpdates chainCreatureUpdates
[ performActions [ watchUpdateStrat
, watchUpdateStrat
(xs ++ [(const crAwayFromPost, const goToPostStrat)]) (xs ++ [(const crAwayFromPost, const goToPostStrat)])
, perceptionUpdate [0] , perceptionUpdate [0]
, const doStrategyActions , const doStrategyActions
+4 -2
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.Update (updateCreature) where module Dodge.Creature.Update (updateCreature) where
import Dodge.Creature.Impulse
import Linear import Linear
import NewInt import NewInt
import Color import Color
@@ -47,8 +48,9 @@ updateCreature' cr =
LampCrit{} -> updateLampoid cr LampCrit{} -> updateLampoid cr
BarrelCrit bt -> updateBarreloid bt cr BarrelCrit bt -> updateBarreloid bt cr
AvatarDead -> id AvatarDead -> id
ChaseCrit {} -> crUpdate cid . updateHumanoid cr ChaseCrit {} -> \w -> crUpdate cid . followImpulses cid
_ -> crUpdate cid . updateHumanoid cr $ over (cWorld . lWorld . creatures . ix cid) (chaseCritInternal w) w
_ -> crUpdate cid
where where
cid = cr ^. crID cid = cr ^. crID
+2 -9
View File
@@ -16,8 +16,8 @@ import Sound.Data
data ActionPlan data ActionPlan
= Inanimate = Inanimate
| ActionPlan | ActionPlan
{ _apImpulse :: [Impulse] -- done per frame { -- _apImpulse :: [Impulse] -- done per frame
, _apAction :: [Action] -- updated per frame, likely persist across frames _apAction :: [Action] -- updated per frame, likely persist across frames
, _apStrategy :: Strategy -- current strategy , _apStrategy :: Strategy -- current strategy
, _apGoal :: [Goal] -- particular ordered goals , _apGoal :: [Goal] -- particular ordered goals
} }
@@ -187,13 +187,6 @@ concat <$> mapM (deriveJSON defaultOptions)
, ''Goal , ''Goal
] ]
--deriveJSON defaultOptions ''Impulse
--deriveJSON defaultOptions ''RandImpulse
--deriveJSON defaultOptions ''Action
--deriveJSON defaultOptions ''Strategy
--deriveJSON defaultOptions ''ActionPlan
--deriveJSON defaultOptions ''Goal
makeLenses ''ActionPlan makeLenses ''ActionPlan
makeLenses ''Impulse makeLenses ''Impulse
makeLenses ''Action makeLenses ''Action
+2 -2
View File
@@ -84,7 +84,7 @@ succB x
debugWritableValues :: Universe -> Maybe [DebugItem] debugWritableValues :: Universe -> Maybe [DebugItem]
debugWritableValues u = debugWritableValues u =
Just $ Just $
mapMaybe f $ mapMaybe f
[ (uvDebugV2_1, uvDebugV2_1) [ (uvDebugV2_1, uvDebugV2_1)
, (uvDebugV2_2, uvDebugV2_2) , (uvDebugV2_2, uvDebugV2_2)
] ]
@@ -151,7 +151,7 @@ drawCrInfo u = foldMap f . IM.elems $ w ^. cWorld . lWorld . creatures
, g "crPos" $ cr ^? crPos . _xy , g "crPos" $ cr ^? crPos . _xy
, g "cpVigilance" $ cr ^? crPerception . cpVigilance , g "cpVigilance" $ cr ^? crPerception . cpVigilance
, g "crAction" $ cr ^? crActionPlan . apAction , g "crAction" $ cr ^? crActionPlan . apAction
, g "crImpulse" $ cr ^? crActionPlan . apImpulse -- , g "crImpulse" $ cr ^? crActionPlan . apImpulse
, g "crName" $ cr ^? crName , g "crName" $ cr ^? crName
, g "crIntention" $ cr ^? crIntention , g "crIntention" $ cr ^? crIntention
] ]
+1 -1
View File
@@ -43,7 +43,7 @@ defaultCreature =
, _strideLength = yourDefaultStrideLength , _strideLength = yourDefaultStrideLength
} }
, _crVocalization = Mute , _crVocalization = Mute
, _crActionPlan = ActionPlan [] [] (StrategyActions WatchAndWait [StartSentinelPost]) [LiveLongAndProsper] , _crActionPlan = ActionPlan [] (StrategyActions WatchAndWait [StartSentinelPost]) [LiveLongAndProsper]
, _crPerception = defaultPerceptionState , _crPerception = defaultPerceptionState
, _crMemory = defaultCreatureMemory , _crMemory = defaultCreatureMemory
, _crFaction = NoFaction , _crFaction = NoFaction
+93 -109
View File
@@ -1,22 +1,13 @@
module Dodge.Humanoid where module Dodge.Humanoid (chaseCritInternal) where
import Dodge.Creature.Impulse
import Linear
import Data.Maybe
import Dodge.Creature.Action
import Dodge.Creature import Dodge.Creature
import Dodge.Data.CreatureEffect
import Dodge.Data.World import Dodge.Data.World
import Geometry
import LensHelp import LensHelp
import RandomHelp
updateHumanoid :: Creature -> World -> World chaseCritInternal :: World -> Creature -> Creature
updateHumanoid cr = case cr ^?! crType of chaseCritInternal =
ChaseCrit {} -> chainCreatureUpdates
humanoidAIList
[ const doStrategyActions [ const doStrategyActions
, performActions
, overrideMeleeCloseTarget , overrideMeleeCloseTarget
, setViewPos , setViewPos
, setMvPos , setMvPos
@@ -27,8 +18,7 @@ updateHumanoid cr = case cr ^?! crType of
, const (crType . meleeCooldown %~ max 0 . subtract 1) , const (crType . meleeCooldown %~ max 0 . subtract 1)
, const (crVocalization . vcCoolDown %~ max 0 . subtract 1) , const (crVocalization . vcCoolDown %~ max 0 . subtract 1)
] ]
cr
_ -> id
-- SpreadGunAI -> -- SpreadGunAI ->
-- defaultImpulsive -- defaultImpulsive
-- [ performActions -- [ performActions
@@ -180,97 +170,91 @@ updateHumanoid cr = case cr ^?! crType of
-- , WaitThen 1 $ (DoImpulses [ChangeStrategy WatchAndWait]) -- , WaitThen 1 $ (DoImpulses [ChangeStrategy WatchAndWait])
-- ] -- ]
humanoidAIList :: [World -> Creature -> Creature] -> Creature -> World -> World --chooseMovementPistol :: Creature -> World -> Action
humanoidAIList l cr w = followImpulses cid $ --chooseMovementPistol cr w =
w & cWorld . lWorld . creatures . ix cid %~ chainCreatureUpdates l w -- chooseMovementPistol' cr w
where -- `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
cid = cr ^. crID --
--chooseMovementPistol' :: Creature -> World -> Action
chooseMovementPistol :: Creature -> World -> Action --chooseMovementPistol' cr w =
chooseMovementPistol cr w = -- takeOneWeighted
chooseMovementPistol' cr w -- [chargeProb, retreatProb, strafeProb, strafeProb]
`DoActionThen` DoImpulses [ChangeStrategy WatchAndWait] -- [ chargeActions
-- , retreatActionsPistol ycr cr
chooseMovementPistol' :: Creature -> World -> Action -- , strafeLeftActions
chooseMovementPistol' cr w = -- , strafeRightActions
takeOneWeighted -- ]
[chargeProb, retreatProb, strafeProb, strafeProb] -- & evalState
[ chargeActions -- $ g
, retreatActionsPistol ycr cr -- where
, strafeLeftActions -- g = _randGen w
, strafeRightActions -- cpos = cr ^. crPos . _xy
] -- ycr = w ^?! cWorld . lWorld . creatures . ix 0
& evalState -- ypos = ycr ^. crPos . _xy
$ g -- chargeProb
where -- | dist cpos ypos > 300 = 5
g = _randGen w -- | dist cpos ypos > 150 = 1
cpos = cr ^. crPos . _xy -- | otherwise = 0
ycr = w ^?! cWorld . lWorld . creatures . ix 0 -- strafeProb
ypos = ycr ^. crPos . _xy -- | dist cpos ypos > 150 = 1
chargeProb -- | otherwise = 0
| dist cpos ypos > 300 = 5 -- retreatProb
| dist cpos ypos > 150 = 1 -- | dist cpos ypos < 200 = 1 :: Float
| otherwise = 0 -- | otherwise = 0
strafeProb -- chargeActions =
| dist cpos ypos > 150 = 1 -- [TurnToward ypos 0.1]
| otherwise = 0 -- `DoImpulsesAlongside` 3
retreatProb -- `DoReplicate` ImpulsesList (replicate 9 [Move (V2 3 0)] ++ [[Move (V2 3 0), UseItem]])
| dist cpos ypos < 200 = 1 :: Float -- strafeLeftActions =
| otherwise = 0 -- DoImpulses [TurnToward yposr (2 * pi)]
chargeActions = -- `DoActionThen` 3
[TurnToward ypos 0.1] -- `DoReplicate` ImpulsesList (replicate 9 [Move (V2 0 3)] ++ [[Move (V2 0 3), UseItem]])
`DoImpulsesAlongside` 3 -- strafeRightActions =
`DoReplicate` ImpulsesList (replicate 9 [Move (V2 3 0)] ++ [[Move (V2 3 0), UseItem]]) -- DoImpulses [TurnToward yposl (2 * pi)]
strafeLeftActions = -- `DoActionThen` 3
DoImpulses [TurnToward yposr (2 * pi)] -- `DoReplicate` ImpulsesList (replicate 9 [Move (V2 0 (-3))] ++ [[Move (V2 0 (-3)), UseItem]])
`DoActionThen` 3 -- yposl = ypos -.- 100 *.* vNormal (normalizeV $ ypos -.- cpos)
`DoReplicate` ImpulsesList (replicate 9 [Move (V2 0 3)] ++ [[Move (V2 0 3), UseItem]]) -- yposr = ypos +.+ 100 *.* vNormal (normalizeV $ ypos -.- cpos)
strafeRightActions = --
DoImpulses [TurnToward yposl (2 * pi)] --retreatActionsPistol :: Creature -> Creature -> Action
`DoActionThen` 3 --retreatActionsPistol tcr cr =
`DoReplicate` ImpulsesList (replicate 9 [Move (V2 0 (-3))] ++ [[Move (V2 0 (-3)), UseItem]]) -- [TurnToward retreatOffset 0.2]
yposl = ypos -.- 100 *.* vNormal (normalizeV $ ypos -.- cpos) -- `DoImpulsesAlongside` 3
yposr = ypos +.+ 100 *.* vNormal (normalizeV $ ypos -.- cpos) -- `DoReplicate` ImpulsesList (replicate 9 [Move (V2 (-3) 0)] ++ [[UseItem]])
-- where
retreatActionsPistol :: Creature -> Creature -> Action -- cpos = cr ^. crPos . _xy
retreatActionsPistol tcr cr = -- tpos = tcr ^. crPos . _xy
[TurnToward retreatOffset 0.2] -- retreatOffset =
`DoImpulsesAlongside` 3 -- let a
`DoReplicate` ImpulsesList (replicate 9 [Move (V2 (-3) 0)] ++ [[UseItem]]) -- | dist cpos tpos < 50 = 0
where -- | isLeftOfA (_crDir cr) (argV $ tpos -.- cpos) =
cpos = cr ^. crPos . _xy -- -0.7
tpos = tcr ^. crPos . _xy -- | otherwise = 0.7
retreatOffset = -- in fromMaybe tpos $
let a -- intersectLineLine
| dist cpos tpos < 50 = 0 -- cpos
| isLeftOfA (_crDir cr) (argV $ tpos -.- cpos) = -- (cpos +.+ rotateV a (tpos -.- cpos))
-0.7 -- tpos
| otherwise = 0.7 -- (tpos +.+ vNormal (cpos -.- tpos))
in fromMaybe tpos $ --
intersectLineLine --retreatFireLauncher :: Action
cpos --retreatFireLauncher =
(cpos +.+ rotateV a (tpos -.- cpos)) -- ImpulsesList ([UseItem] : replicate 20 [Turn 0.16])
tpos -- `DoActionThen` holsterWeapon
(tpos +.+ vNormal (cpos -.- tpos)) -- `DoActionThen` ImpulsesList (replicate 30 [MoveForward 3])
-- `DoActionThen` drawWeapon
retreatFireLauncher :: Action -- `DoActionThen` ImpulsesList ([UseItem] : replicate 20 [Turn $ negate 0.16])
retreatFireLauncher = -- `DoActionThen` holsterWeapon
ImpulsesList ([UseItem] : replicate 20 [Turn 0.16]) -- `DoActionThen` ImpulsesList (replicate 15 [MoveForward 3])
`DoActionThen` holsterWeapon -- `DoActionThen` drawWeapon
`DoActionThen` ImpulsesList (replicate 30 [MoveForward 3]) -- `DoActionThen` ImpulsesList
`DoActionThen` drawWeapon -- ( replicate
`DoActionThen` ImpulsesList ([UseItem] : replicate 20 [Turn $ negate 0.16]) -- 100
`DoActionThen` holsterWeapon -- [ UseItem
`DoActionThen` ImpulsesList (replicate 15 [MoveForward 3]) -- , ImpulseUseTarget (TurnTowardCr (pi / 16))
`DoActionThen` drawWeapon -- ]
`DoActionThen` ImpulsesList -- )
( replicate -- `DoActionThen` 20
100 -- `WaitThen` holsterWeapon
[ UseItem -- `DoActionThen` ImpulsesList (replicate 15 [MoveForward 3])
, ImpulseUseTarget (TurnTowardCr (pi / 16)) -- `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
]
)
`DoActionThen` 20
`WaitThen` holsterWeapon
`DoActionThen` ImpulsesList (replicate 15 [MoveForward 3])
`DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
+1 -1
View File
@@ -57,7 +57,7 @@ walkableNodeNear w p = fmap fst . find (flip (isWalkable p) w . snd) $ nodesNear
nodesNear = zonesExtract (w ^. pnZoning) . snailAround $ zoneOfPoint pnZoneSize p nodesNear = zonesExtract (w ^. pnZoning) . snailAround $ zoneOfPoint pnZoneSize p
snailAround :: Int2 -> [Int2] snailAround :: Int2 -> [Int2]
snailAround x = fmap (x+) $ smallSnailInt2 snailAround x = (x+) <$> smallSnailInt2
smallSnailInt2 :: [Int2] smallSnailInt2 :: [Int2]
smallSnailInt2 = sortOn (distance (V2 0 (0::Float)) . fmap fromIntegral) smallSnailInt2 = sortOn (distance (V2 0 (0::Float)) . fmap fromIntegral)
+1 -1
View File
@@ -97,7 +97,7 @@ shellHitFloor p pj =
. (topj . pjVel . _z %~ bouncez) . (topj . pjVel . _z %~ bouncez)
. (topj . pjVel . _xy %~ decvel) . (topj . pjVel . _xy %~ decvel)
. (topj . pjSpin *~ 0.9) . (topj . pjSpin *~ 0.9)
. (bounceSound pj) . bounceSound pj
where where
bouncez x = max 0 (-0.5 * x) bouncez x = max 0 (-0.5 * x)
topj = cWorld . lWorld . projectiles . ix (pj ^. pjID) topj = cWorld . lWorld . projectiles . ix (pj ^. pjID)
+1 -1
View File
@@ -1,4 +1,4 @@
{-# LANGUAGE LambdaCase #-} --{-# LANGUAGE LambdaCase #-}
module Dodge.Render.ShapePicture (worldSPic) where module Dodge.Render.ShapePicture (worldSPic) where
import Dodge.Debug import Dodge.Debug
+18 -25
View File
@@ -932,7 +932,7 @@ Opaque src/Dodge/Data/Wall.hs 44;" C
OpticScope src/Dodge/Data/Item/Scope.hs 14;" C OpticScope src/Dodge/Data/Item/Scope.hs 14;" C
OptionScreen src/Dodge/Data/Universe.hs 82;" C OptionScreen src/Dodge/Data/Universe.hs 82;" C
OptionScreenFlag src/Dodge/Data/Universe.hs 72;" t OptionScreenFlag src/Dodge/Data/Universe.hs 72;" t
OutAction src/Dodge/Creature/Action.hs 44;" t OutAction src/Dodge/Creature/Action.hs 42;" t
OutLink src/Dodge/Data/Room.hs 44;" C OutLink src/Dodge/Data/Room.hs 44;" C
OutsideTerminal src/Dodge/Data/Input.hs 30;" C OutsideTerminal src/Dodge/Data/Input.hs 30;" C
OutwardShockwave src/Dodge/Data/Shockwave.hs 14;" C OutwardShockwave src/Dodge/Data/Shockwave.hs 14;" C
@@ -1526,7 +1526,6 @@ _amsfLink src/Dodge/Data/ComposedItem.hs 24;" f
_amsfType src/Dodge/Data/ComposedItem.hs 24;" f _amsfType src/Dodge/Data/ComposedItem.hs 24;" f
_apAction src/Dodge/Data/ActionPlan.hs 20;" f _apAction src/Dodge/Data/ActionPlan.hs 20;" f
_apGoal src/Dodge/Data/ActionPlan.hs 22;" f _apGoal src/Dodge/Data/ActionPlan.hs 22;" f
_apImpulse src/Dodge/Data/ActionPlan.hs 19;" f
_apInt src/Dodge/Data/Item/Use.hs 47;" f _apInt src/Dodge/Data/Item/Use.hs 47;" f
_apProjectiles src/Dodge/Data/Item/Use.hs 46;" f _apProjectiles src/Dodge/Data/Item/Use.hs 46;" f
_apStrategy src/Dodge/Data/ActionPlan.hs 21;" f _apStrategy src/Dodge/Data/ActionPlan.hs 21;" f
@@ -2628,7 +2627,7 @@ arcStepwisePositive src/Geometry.hs 340;" f
arcTest src/Picture/Test.hs 9;" f arcTest src/Picture/Test.hs 9;" f
arcTest' src/Picture/Test.hs 21;" f arcTest' src/Picture/Test.hs 21;" f
argV src/Geometry/Vector.hs 81;" f argV src/Geometry/Vector.hs 81;" f
armourChaseCrit src/Dodge/Creature/ArmourChase.hs 35;" f armourChaseCrit src/Dodge/Creature/ArmourChase.hs 34;" f
armouredChasers src/Dodge/Room/Boss.hs 64;" f armouredChasers src/Dodge/Room/Boss.hs 64;" f
armouredCorridor src/Dodge/Room/RoadBlock.hs 20;" f armouredCorridor src/Dodge/Room/RoadBlock.hs 20;" f
arms src/Dodge/Creature/Picture.hs 72;" f arms src/Dodge/Creature/Picture.hs 72;" f
@@ -2802,9 +2801,10 @@ charToTupleGrad src/Picture/Text.hs 18;" f
chartreuse src/Color.hs 24;" f chartreuse src/Color.hs 24;" f
chaseCrit src/Dodge/Creature/ChaseCrit.hs 27;" f chaseCrit src/Dodge/Creature/ChaseCrit.hs 27;" f
chaseCritAwarenessUpdate src/Dodge/Creature/Perception.hs 65;" f chaseCritAwarenessUpdate src/Dodge/Creature/Perception.hs 65;" f
chaseCritInternal src/Dodge/Humanoid.hs 7;" f
chaseCritMv src/Dodge/Creature/ReaderUpdate.hs 120;" f chaseCritMv src/Dodge/Creature/ReaderUpdate.hs 120;" f
chaseCritPerceptionUpdate src/Dodge/Creature/Perception.hs 32;" f chaseCritPerceptionUpdate src/Dodge/Creature/Perception.hs 32;" f
chaseCritVocalization src/Dodge/Creature/ChaseCrit.hs 37;" f chaseCritVocalization src/Dodge/Creature/ChaseCrit.hs 36;" f
chasmSimpleMaze src/Dodge/Room/Tutorial.hs 180;" f chasmSimpleMaze src/Dodge/Room/Tutorial.hs 180;" f
chasmTest src/Dodge/Creature/Update.hs 133;" f chasmTest src/Dodge/Creature/Update.hs 133;" f
chasmWallToSurface src/Dodge/Base/Collide.hs 120;" f chasmWallToSurface src/Dodge/Base/Collide.hs 120;" f
@@ -2829,8 +2829,6 @@ chooseEquipPosition src/Dodge/Inventory/RBList.hs 41;" f
chooseFootSound src/Dodge/Creature/State/WalkCycle.hs 35;" f chooseFootSound src/Dodge/Creature/State/WalkCycle.hs 35;" f
chooseFreeSite src/Dodge/Inventory/RBList.hs 47;" f chooseFreeSite src/Dodge/Inventory/RBList.hs 47;" f
chooseMovementLtAuto src/Dodge/CreatureEffect.hs 76;" f chooseMovementLtAuto src/Dodge/CreatureEffect.hs 76;" f
chooseMovementPistol src/Dodge/Humanoid.hs 185;" f
chooseMovementPistol' src/Dodge/Humanoid.hs 190;" f
chooseMovementSpreadGun src/Dodge/CreatureEffect.hs 59;" f chooseMovementSpreadGun src/Dodge/CreatureEffect.hs 59;" f
circHitWall src/Dodge/Base/Collide.hs 242;" f circHitWall src/Dodge/Base/Collide.hs 242;" f
circInPolygon src/Geometry/Polygon.hs 102;" f circInPolygon src/Geometry/Polygon.hs 102;" f
@@ -2982,7 +2980,7 @@ crShape src/Dodge/Creature/Shape.hs 8;" f
crSpring src/Dodge/Update.hs 867;" f crSpring src/Dodge/Update.hs 867;" f
crStratConMatches src/Dodge/Creature/Test.hs 80;" f crStratConMatches src/Dodge/Creature/Test.hs 80;" f
crStrength src/Dodge/Creature/Statistics.hs 29;" f crStrength src/Dodge/Creature/Statistics.hs 29;" f
crUpdate src/Dodge/Creature/Update.hs 60;" f crUpdate src/Dodge/Creature/Update.hs 64;" f
crUpdateInvidLocations src/Dodge/Inventory/Location.hs 66;" f crUpdateInvidLocations src/Dodge/Inventory/Location.hs 66;" f
crUpdateItemLocations src/Dodge/Inventory/Location.hs 48;" f crUpdateItemLocations src/Dodge/Inventory/Location.hs 48;" f
crVocalizationSound src/Dodge/Creature/Vocalization.hs 13;" f crVocalizationSound src/Dodge/Creature/Vocalization.hs 13;" f
@@ -3421,9 +3419,9 @@ drawZoneCirc src/Dodge/Debug/Picture.hs 301;" f
drawZoneCol src/Dodge/Debug/Picture.hs 149;" f drawZoneCol src/Dodge/Debug/Picture.hs 149;" f
drawZoneNearPointCursor src/Dodge/Debug/Picture.hs 294;" f drawZoneNearPointCursor src/Dodge/Debug/Picture.hs 294;" f
dropAll src/Dodge/Creature/Update.hs 130;" f dropAll src/Dodge/Creature/Update.hs 130;" f
dropExcept src/Dodge/Creature/Action.hs 163;" f dropExcept src/Dodge/Creature/Action.hs 161;" f
dropInventoryPath src/Dodge/HeldUse.hs 1351;" f dropInventoryPath src/Dodge/HeldUse.hs 1351;" f
dropItem src/Dodge/Creature/Action.hs 170;" f dropItem src/Dodge/Creature/Action.hs 168;" f
dropper src/Dodge/Item/Scope.hs 76;" f dropper src/Dodge/Item/Scope.hs 76;" f
drumMag src/Dodge/Item/Ammo.hs 34;" f drumMag src/Dodge/Item/Ammo.hs 34;" f
dsZoneSize src/Dodge/Zoning/Cloud.hs 42;" f dsZoneSize src/Dodge/Zoning/Cloud.hs 42;" f
@@ -3568,8 +3566,8 @@ foamSprayLoopS src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 554;" f
foldMTRS src/Dodge/Room/Tutorial.hs 58;" f foldMTRS src/Dodge/Room/Tutorial.hs 58;" f
foldPairs src/ListHelp.hs 37;" f foldPairs src/ListHelp.hs 37;" f
foldrWhileArb src/ListHelp.hs 110;" f foldrWhileArb src/ListHelp.hs 110;" f
followImpulse src/Dodge/Creature/Impulse.hs 39;" f followImpulse src/Dodge/Creature/Impulse.hs 30;" f
followImpulses src/Dodge/Creature/Impulse.hs 33;" f followImpulses src/Dodge/Creature/Impulse.hs 24;" f
foot1S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 486;" f foot1S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 486;" f
foot2S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 510;" f foot2S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 510;" f
foot3S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 622;" f foot3S src/Dodge/SoundLogic/ExternallyGeneratedSounds.hs 622;" f
@@ -3764,12 +3762,10 @@ horPipe src/Dodge/Placement/Instance/Pipe.hs 9;" f
hotkeyToChar src/Dodge/Inventory/SelectionList.hs 188;" f hotkeyToChar src/Dodge/Inventory/SelectionList.hs 188;" f
hotkeyToScancode src/Dodge/Creature/YourControl.hs 82;" f hotkeyToScancode src/Dodge/Creature/YourControl.hs 82;" f
hotkeyToString src/Dodge/Inventory/SelectionList.hs 185;" f hotkeyToString src/Dodge/Inventory/SelectionList.hs 185;" f
humanoidAIList src/Dodge/Humanoid.hs 182;" f
iShape src/Dodge/Placement/Instance/LightSource.hs 87;" f iShape src/Dodge/Placement/Instance/LightSource.hs 87;" f
icosahedronPoints src/Polyhedra/Geodesic.hs 12;" f icosahedronPoints src/Polyhedra/Geodesic.hs 12;" f
icosohedronFaces src/Polyhedra/Geodesic.hs 19;" f icosohedronFaces src/Polyhedra/Geodesic.hs 19;" f
ildtPropagate src/Dodge/DoubleTree.hs 111;" f ildtPropagate src/Dodge/DoubleTree.hs 111;" f
impulsiveAIBefore src/Dodge/Creature/Impulse.hs 24;" f
inLink src/Dodge/RoomLink.hs 128;" f inLink src/Dodge/RoomLink.hs 128;" f
inSegArea src/Geometry/Intersect.hs 319;" f inSegArea src/Geometry/Intersect.hs 319;" f
inSimplePoly src/Geometry/Polygon.hs 90;" f inSimplePoly src/Geometry/Polygon.hs 90;" f
@@ -4400,11 +4396,11 @@ pedestalRoom src/Dodge/Room/Containing.hs 50;" f
penThing src/Dodge/Bullet.hs 210;" f penThing src/Dodge/Bullet.hs 210;" f
perMat src/MatrixHelper.hs 49;" f perMat src/MatrixHelper.hs 49;" f
perceptionUpdate src/Dodge/Creature/Perception.hs 24;" f perceptionUpdate src/Dodge/Creature/Perception.hs 24;" f
performAction src/Dodge/Creature/Action.hs 90;" f performAction src/Dodge/Creature/Action.hs 88;" f
performActions src/Dodge/Creature/Action.hs 36;" f performActions src/Dodge/Creature/Action.hs 36;" f
performAimAt src/Dodge/Creature/Action.hs 46;" f performAimAt src/Dodge/Creature/Action.hs 44;" f
performPathTo src/Dodge/Creature/Action.hs 59;" f performPathTo src/Dodge/Creature/Action.hs 57;" f
performTurnToA src/Dodge/Creature/Action.hs 77;" f performTurnToA src/Dodge/Creature/Action.hs 75;" f
perspectiveMatrixb src/MatrixHelper.hs 11;" f perspectiveMatrixb src/MatrixHelper.hs 11;" f
pesNearCirc src/Dodge/Zoning/Pathing.hs 43;" f pesNearCirc src/Dodge/Zoning/Pathing.hs 43;" f
pesNearPoint src/Dodge/Zoning/Pathing.hs 33;" f pesNearPoint src/Dodge/Zoning/Pathing.hs 33;" f
@@ -4732,8 +4728,6 @@ restrictLinkType src/Dodge/RoomLink.hs 34;" f
restrictOutLinks src/Dodge/RoomLink.hs 47;" f restrictOutLinks src/Dodge/RoomLink.hs 47;" f
restrictRMInLinksPD src/Dodge/Room/Link.hs 25;" f restrictRMInLinksPD src/Dodge/Room/Link.hs 25;" f
resumeSound src/Dodge/SoundLogic.hs 48;" f resumeSound src/Dodge/SoundLogic.hs 48;" f
retreatActionsPistol src/Dodge/Humanoid.hs 231;" f
retreatFireLauncher src/Dodge/Humanoid.hs 252;" f
retreatPointForFrom src/Dodge/Creature/Impulse/Flee.hs 9;" f retreatPointForFrom src/Dodge/Creature/Impulse/Flee.hs 9;" f
reversePair src/Dodge/LevelGen.hs 85;" f reversePair src/Dodge/LevelGen.hs 85;" f
rewinder src/Dodge/Item/Held/Utility.hs 36;" f rewinder src/Dodge/Item/Held/Utility.hs 36;" f
@@ -4890,7 +4884,7 @@ sensorSPic src/Dodge/Machine/Draw.hs 81;" f
sensorTut src/Dodge/Room/Tutorial.hs 338;" f sensorTut src/Dodge/Room/Tutorial.hs 338;" f
sensorTypeDamages src/Dodge/Machine/Update.hs 234;" f sensorTypeDamages src/Dodge/Machine/Update.hs 234;" f
sentinelAI src/Dodge/Creature/SentinelAI.hs 20;" f sentinelAI src/Dodge/Creature/SentinelAI.hs 20;" f
sentinelExtraWatchUpdate src/Dodge/Creature/SentinelAI.hs 82;" f sentinelExtraWatchUpdate src/Dodge/Creature/SentinelAI.hs 81;" f
sentinelFireType src/Dodge/Creature/SentinelAI.hs 49;" f sentinelFireType src/Dodge/Creature/SentinelAI.hs 49;" f
setAimPosture src/Dodge/Creature/YourControl.hs 145;" f setAimPosture src/Dodge/Creature/YourControl.hs 145;" f
setChannelPos src/Sound.hs 150;" f setChannelPos src/Sound.hs 150;" f
@@ -5243,7 +5237,7 @@ thingsHit src/Dodge/WorldEvent/ThingsHit.hs 36;" f
thingsHitExceptCr src/Dodge/WorldEvent/ThingsHit.hs 119;" f thingsHitExceptCr src/Dodge/WorldEvent/ThingsHit.hs 119;" f
thingsHitZ src/Dodge/WorldEvent/ThingsHit.hs 44;" f thingsHitZ src/Dodge/WorldEvent/ThingsHit.hs 44;" f
threeLineDecoration src/Dodge/Placement/TopDecoration.hs 61;" f threeLineDecoration src/Dodge/Placement/TopDecoration.hs 61;" f
throwItem src/Dodge/Creature/Action.hs 206;" f throwItem src/Dodge/Creature/Action.hs 204;" f
tileTexCoords src/Tile.hs 11;" f tileTexCoords src/Tile.hs 11;" f
tilesFromRooms src/Dodge/Layout.hs 192;" f tilesFromRooms src/Dodge/Layout.hs 192;" f
tilesToLine src/Shader/AuxAddition.hs 66;" f tilesToLine src/Shader/AuxAddition.hs 66;" f
@@ -5416,8 +5410,8 @@ updateCloud src/Dodge/Update.hs 798;" f
updateClouds src/Dodge/Update.hs 669;" f updateClouds src/Dodge/Update.hs 669;" f
updateCombinePositioning src/Dodge/DisplayInventory.hs 40;" f updateCombinePositioning src/Dodge/DisplayInventory.hs 40;" f
updateCombineSections src/Dodge/DisplayInventory.hs 47;" f updateCombineSections src/Dodge/DisplayInventory.hs 47;" f
updateCreature src/Dodge/Creature/Update.hs 32;" f updateCreature src/Dodge/Creature/Update.hs 33;" f
updateCreature' src/Dodge/Creature/Update.hs 41;" f updateCreature' src/Dodge/Creature/Update.hs 42;" f
updateCreatureGroups src/Dodge/Update.hs 537;" f updateCreatureGroups src/Dodge/Update.hs 537;" f
updateCreatureSoundPositions src/Dodge/Update.hs 516;" f updateCreatureSoundPositions src/Dodge/Update.hs 516;" f
updateDebris src/Dodge/Update.hs 572;" f updateDebris src/Dodge/Update.hs 572;" f
@@ -5442,7 +5436,6 @@ updateFloatingCamera src/Dodge/Update/Camera.hs 35;" f
updateFunctionKey src/Dodge/Update/Input/InGame.hs 363;" f updateFunctionKey src/Dodge/Update/Input/InGame.hs 363;" f
updateFunctionKeys src/Dodge/Update/Input/InGame.hs 359;" f updateFunctionKeys src/Dodge/Update/Input/InGame.hs 359;" f
updateGusts src/Dodge/Update.hs 781;" f updateGusts src/Dodge/Update.hs 781;" f
updateHumanoid src/Dodge/Humanoid.hs 13;" f
updateIMl src/Dodge/Update.hs 531;" f updateIMl src/Dodge/Update.hs 531;" f
updateIMl' src/Dodge/Update.hs 534;" f updateIMl' src/Dodge/Update.hs 534;" f
updateInGameCamera src/Dodge/Update/Camera.hs 79;" f updateInGameCamera src/Dodge/Update/Camera.hs 79;" f
@@ -5670,7 +5663,7 @@ yIntercepts' src/Dodge/Zoning/Base.hs 76;" f
yV2 src/Geometry/Vector.hs 205;" f yV2 src/Geometry/Vector.hs 205;" f
yellow src/Color.hs 17;" f yellow src/Color.hs 17;" f
you src/Dodge/Base/You.hs 13;" f you src/Dodge/Base/You.hs 13;" f
youDropItem src/Dodge/Creature/Action.hs 192;" f youDropItem src/Dodge/Creature/Action.hs 190;" f
yourAugmentedItem src/Dodge/Render/HUD.hs 238;" f yourAugmentedItem src/Dodge/Render/HUD.hs 238;" f
yourControl src/Dodge/Creature/YourControl.hs 28;" f yourControl src/Dodge/Creature/YourControl.hs 28;" f
yourDefaultStrideLength src/Dodge/Default/Creature.hs 110;" f yourDefaultStrideLength src/Dodge/Default/Creature.hs 110;" f