This commit is contained in:
2026-03-26 23:35:12 +00:00
parent 8b088425a9
commit fed607681b
6 changed files with 27 additions and 26 deletions
+1
View File
@@ -106,6 +106,7 @@ flockACC w cr = fromMaybe cr $ do
macr =
safeMinimumOn (dist cpos . (^. crPos . _xy))
. filter isFarACC
. IM.elems
$ crsNearCirc cpos 50 w
return $ case macr of
Nothing -> cr
+2
View File
@@ -4,6 +4,7 @@ module Dodge.Creature.State (
invItemEffs,
) where
import qualified Data.IntMap.Strict as IM
import Linear
import NewInt
import Control.Applicative
@@ -296,6 +297,7 @@ setRBCreatureTargeting cr w ituse
newtarg =
safeMinimumOn (dist mwp . (^. crPos . _xy))
. filter (canseepos . (^. crPos . _xy))
. IM.elems
$ crsNearCirc mwp 40 w
canseepos p = hasLOS ((^. crPos . _xy) cr) p w
mwp = w ^. cWorld . lWorld . lAimPos
+18 -21
View File
@@ -966,43 +966,40 @@ radiusSpring r a b
simpleCrSprings :: World -> World
simpleCrSprings w =
IM.foldl' (flip crSpring) (w & cWorld . lWorld . lTestString .~ mempty) $
IM.filter (\cr -> cr ^. crPos . _z >= 0) $ w ^. cWorld . lWorld . creatures
IM.foldl' (flip crSpring) w $
IM.filter (canSpring) $ w ^. cWorld . lWorld . creatures
-- note that this may in rare cases not push creatures away from each other
crSpring :: Creature -> World -> World
crSpring c w =
foldl' (flip $ crCrSpring c) w $
crsNearCirc
(c ^. crPos . _xy)
(crRad $ c ^. crType)
w
IM.foldl' (flip $ crCrSpring c) w . IM.filter canSpring $
crsNearCirc (c ^. crPos . _xy) (crRad $ c ^. crType) w
canSpring :: Creature -> Bool
canSpring cr = cr ^. crPos . _z >= 0 && case cr ^. crHP of
HP{} -> True
CrIsCorpse{} -> True
CrIsGibs -> False
CrIsPitted -> False
crCrSpring :: Creature -> Creature -> World -> World
crCrSpring c1 c2
| id1 == id2 = id
| vec == V2 0 0 = id
| diff >= comRad || nopush c1 || nopush c2
= id
| diff >= comRad = id
| otherwise =
(cWorld . lWorld . creatures
%~ ( (ix id1 . crPos . _xy +~ overlap1)
. (ix id2 . crPos . _xy -~ overlap2)
))
. (cWorld . lWorld . lTestString .:~ show id1 <> " " <> show id2 )
( cWorld . lWorld . creatures
%~ ( (ix id1 . crPos . _xy +~ overlap c2)
. (ix id2 . crPos . _xy -~ overlap c1)
)
)
where
nopush cr = case cr ^. crHP of
HP {} -> False
CrIsCorpse {} -> False
CrIsGibs -> True
CrIsPitted -> True
id1 = _crID c1
id2 = _crID c2
vec = c1 ^. crPos . _xy - c2 ^. crPos . _xy
diff = magV vec
comRad = crRad (c1 ^. crType) + crRad (c2 ^. crType)
overlap1 = ((comRad - diff) * crMass (_crType c2) * 0.5 / massT) *^ signorm vec
overlap2 = ((comRad - diff) * crMass (_crType c1) * 0.5 / massT) *^ signorm vec
overlap c = ((comRad - diff) * crMass (_crType c) * 0.5 / massT) *^ signorm vec
massT = crMass (_crType c1) + crMass (_crType c2)
updateDelayedEvents :: World -> World
+1 -1
View File
@@ -181,7 +181,7 @@ wlsHitRadial p r = IM.mapMaybe f . wlsNearCirc p r
-- v = normalizeV . vNormal . uncurry (-) $ _wlLine wl
crsHitRadial :: Point2 -> Float -> World -> [(Point2, Creature)]
crsHitRadial p r = mapMaybe f . crsNearCirc p r
crsHitRadial p r = mapMaybe f . IM.elems . crsNearCirc p r
where
f cr = do
let cp = cr ^. crPos . _xy
+2 -2
View File
@@ -33,8 +33,8 @@ crixsNearSeg = nearSeg crZoneSize _crZoning
crIXsNearCirc :: Point2 -> Float -> World -> IS.IntSet
crIXsNearCirc p r = crsNearRect (p + V2 r r) (p - V2 r r)
crsNearCirc :: Point2 -> Float -> World -> [Creature]
crsNearCirc p r w = mapMaybe (\cid -> w ^? cWorld . lWorld . creatures . ix cid) . IS.toList
crsNearCirc :: Point2 -> Float -> World -> IM.IntMap Creature
crsNearCirc p r w = IM.restrictKeys (w ^. cWorld . lWorld . creatures)
$ crIXsNearCirc p r w
crsNearRect :: Point2 -> Point2 -> World -> IS.IntSet
+3 -2
View File
@@ -2779,6 +2779,7 @@ calcSmoothScroll src/Dodge/SmoothScroll.hs 11;" f
calcTexCoord src/Tile.hs 19;" f
canSee src/Dodge/Base/Collide.hs 321;" f
canSeeIndirect src/Dodge/Base/Collide.hs 328;" f
canSpring src/Dodge/Update.hs 978;" f
cancelExamineInventory src/Dodge/Item/BackgroundEffect.hs 23;" f
capacitor src/Dodge/Item/Ammo.hs 67;" f
card8Vec src/Dodge/Base/CardinalPoint.hs 17;" f
@@ -2947,7 +2948,7 @@ crAwayFromPost src/Dodge/Creature/Test.hs 86;" f
crBlips src/Dodge/RadarSweep.hs 88;" f
crCamouflage src/Dodge/Creature/Picture.hs 33;" f
crCanSeeCr src/Dodge/Creature/Test.hs 53;" f
crCrSpring src/Dodge/Update.hs 982;" f
crCrSpring src/Dodge/Update.hs 985;" f
crCurrentEquipment src/Dodge/Creature/Statistics.hs 62;" f
crDeathSounds src/Dodge/Creature/Vocalization.hs 45;" f
crDexterity src/Dodge/Creature/Statistics.hs 19;" f
@@ -5402,7 +5403,7 @@ updateCreatureStrides src/Dodge/Update.hs 370;" f
updateDebris src/Dodge/Update.hs 665;" f
updateDebrisChunk src/Dodge/Prop/Moving.hs 16;" f
updateDebugMessageOffset src/Dodge/Update.hs 102;" f
updateDelayedEvents src/Dodge/Update.hs 1003;" f
updateDelayedEvents src/Dodge/Update.hs 1005;" f
updateDisplaySections src/Dodge/DisplayInventory.hs 116;" f
updateDistortion src/Dodge/Distortion.hs 8;" f
updateDistortions src/Dodge/Update.hs 644;" f