Remove creature records

This commit is contained in:
2025-06-06 13:36:18 +01:00
parent 73c79f2f4d
commit 0f55257bff
48 changed files with 621 additions and 610 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -3
View File
@@ -36,6 +36,7 @@ module Dodge.Base.Collide (
) where ) where
--import qualified Data.IntMap.Strict as IM --import qualified Data.IntMap.Strict as IM
import Dodge.Creature.Radius
import Control.Lens import Control.Lens
import qualified Data.IntSet as IS import qualified Data.IntSet as IS
import Data.List (sortOn) import Data.List (sortOn)
@@ -64,7 +65,7 @@ overlapSegCrs ::
{-# INLINE overlapSegCrs #-} {-# INLINE overlapSegCrs #-}
overlapSegCrs sp ep = overlapSegCrs sp ep =
mapMaybe mapMaybe
(\cr -> (,cr) <$> listToMaybe (intersectCircSeg (_crPos cr) (_crRad cr) sp ep)) (\cr -> (,cr) <$> listToMaybe (intersectCircSeg (_crPos cr) (crRad $ cr ^. crType) sp ep))
doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, Point2) doBounce :: Float -> Point2 -> Point2 -> (Point2, Maybe Wall) -> Maybe (Point2, Point2)
{-# INLINE doBounce #-} {-# INLINE doBounce #-}
@@ -197,7 +198,7 @@ circOnAnyCr :: Point2 -> Float -> World -> Bool
{-# INLINE circOnAnyCr #-} {-# INLINE circOnAnyCr #-}
circOnAnyCr p r w = IS.foldr f False $ crIXsNearPoint p w circOnAnyCr p r w = IS.foldr f False $ crIXsNearPoint p w
where where
f cid bl = maybe False (\cr -> dist p (_crPos cr) < r + _crRad cr) (w ^? cWorld . lWorld . creatures . ix cid) || bl f cid bl = maybe False (\cr -> dist p (_crPos cr) < r + crRad (cr ^. crType)) (w ^? cWorld . lWorld . creatures . ix cid) || bl
-- | More general collision tests follow -- | More general collision tests follow
hasLOS :: Point2 -> Point2 -> World -> Bool hasLOS :: Point2 -> Point2 -> World -> Bool
@@ -253,7 +254,7 @@ anythingHitCirc rad sp ep w = hitCr || circHitWall sp ep rad w
f cid bl = f cid bl =
maybe maybe
False False
(\cr -> intersectCircSegTest (_crPos cr) (rad + _crRad cr) sp ep) (\cr -> intersectCircSegTest (_crPos cr) (rad + crRad (cr ^. crType)) sp ep)
(w ^? cWorld . lWorld . creatures . ix cid) (w ^? cWorld . lWorld . creatures . ix cid)
|| bl || bl
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Corpse.Make (makeCorpse) where module Dodge.Corpse.Make (makeCorpse) where
import Dodge.Creature.Radius
import Dodge.Creature.Shape import Dodge.Creature.Shape
import Control.Lens import Control.Lens
import Dodge.Creature.Picture import Dodge.Creature.Picture
@@ -28,7 +29,7 @@ makeDefaultCorpse cr =
) )
where where
cskin = crShape $ _crType cr -- this should be fixed cskin = crShape $ _crType cr -- this should be fixed
crsize = 0.1 * _crRad cr crsize = 0.1 * crRad (cr ^. crType)
rotmdir = rotateSH (_crMvDir cr - _crDir cr) rotmdir = rotateSH (_crMvDir cr - _crDir cr)
defaultCorpse :: Corpse defaultCorpse :: Corpse
+1 -2
View File
@@ -98,11 +98,10 @@ startCr =
& crMvDir .~ pi / 2 & crMvDir .~ pi / 2
& crID .~ 0 & crID .~ 0
& crHP .~ 10000 & crHP .~ 10000
& crMaxHP .~ 15000
& crInv .~ startInventory & crInv .~ startInventory
& crFaction .~ PlayerFaction & crFaction .~ PlayerFaction
& crMvType .~ MvWalking yourDefaultSpeed & crMvType .~ MvWalking yourDefaultSpeed
& crType .~ Avatar (PulseStatus 55 0) & crType .~ Avatar (PulseStatus 55 0) Flesh
-- | Items you start with. -- | Items you start with.
startInvList :: [Item] startInvList :: [Item]
+25 -26
View File
@@ -9,10 +9,11 @@ module Dodge.Creature.Action (
blinkActionMousePos, blinkActionMousePos,
blinkActionFail, blinkActionFail,
unsafeBlinkAction, unsafeBlinkAction,
sizeSelf, -- sizeSelf,
youDropItem, youDropItem,
) where ) where
import Dodge.Creature.Radius
import Dodge.Item.BackgroundEffect import Dodge.Item.BackgroundEffect
import Control.Applicative import Control.Applicative
import Control.Monad import Control.Monad
@@ -23,13 +24,11 @@ import Dodge.Creature.Action.Blink
import Dodge.CreatureEffect import Dodge.CreatureEffect
--import Dodge.Data.SelectionList --import Dodge.Data.SelectionList
import Dodge.Data.World import Dodge.Data.World
import Dodge.Default
import Dodge.FloatFunction import Dodge.FloatFunction
import Dodge.FloorItem import Dodge.FloorItem
import Dodge.Inventory import Dodge.Inventory
import Dodge.Path import Dodge.Path
import Dodge.SoundLogic import Dodge.SoundLogic
import Dodge.WallCreatureCollisions
import Geometry import Geometry
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import LensHelp import LensHelp
@@ -59,7 +58,7 @@ performAimAt cr w tcid p = ([TurnToward tpos aimSp], Just $ AimAt tcid tpos)
performPathTo :: Creature -> World -> Point2 -> OutAction performPathTo :: Creature -> World -> Point2 -> OutAction
performPathTo cr w p performPathTo cr w p
| dist cpos p <= _crRad cr = ([], Nothing) | dist cpos p <= crRad (cr ^. crType) = ([], Nothing)
| isWalkable cpos p w = ([MvTurnToward p, MvForward, RandomTurn jit], Just (PathTo p)) | isWalkable cpos p w = ([MvTurnToward p, MvForward, RandomTurn jit], Just (PathTo p))
| otherwise = case pointTowardsImpulse p cpos w of | otherwise = case pointTowardsImpulse p cpos w of
Just q -> Just q ->
@@ -204,25 +203,25 @@ youDropItem w = fromMaybe w $ do
throwItem :: World -> World throwItem :: World -> World
throwItem = id throwItem = id
sizeSelf :: Float -> Creature -> World -> Maybe World --sizeSelf :: Float -> Creature -> World -> Maybe World
sizeSelf x cr w --sizeSelf x cr w
| not (crOnWall cr1 w) = -- | not (crOnWall cr1 w) =
Just $ -- Just $
w -- w
& soundMultiFrom [TeleSound 0, TeleSound 1] cpos teleS Nothing -- & soundMultiFrom [TeleSound 0, TeleSound 1] cpos teleS Nothing
& cWorld . lWorld . distortions .:~ distortionBulge -- & cWorld . lWorld . distortions .:~ distortionBulge
& cWorld . lWorld . creatures . ix cid -- & cWorld . lWorld . creatures . ix cid
%~ ( (crRad .~ 10 * x) -- %~ ( (crRad .~ 10 * x)
. (crMvType . mvSpeed .~ yourDefaultSpeed * x) -- . (crMvType . mvSpeed .~ yourDefaultSpeed * x)
. (crStance . strideLength .~ ceiling (fromIntegral yourDefaultStrideLength * x)) -- . (crStance . strideLength .~ ceiling (fromIntegral yourDefaultStrideLength * x))
) -- )
| otherwise = Nothing -- | otherwise = Nothing
where -- where
cr1 = colCrWall w (cr{_crRad = 10 * x}) -- cr1 = colCrWall w (cr{_crRad = 10 * x})
distR = 120 -- distR = 120
distortionBulge -- distortionBulge
| _crRad cr < 10 * x = raddist 1.9 -- | _crRad cr < 10 * x = raddist 1.9
| otherwise = raddist 0.1 -- | otherwise = raddist 0.1
raddist = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR) -- raddist = RadialDistortion cpos (cpos +.+ V2 distR 0) (cpos +.+ V2 0 distR)
cid = _crID cr -- cid = _crID cr
cpos = _crPos cr -- cpos = _crPos cr
+3 -2
View File
@@ -5,6 +5,7 @@ module Dodge.Creature.Action.Blink (
unsafeBlinkAction, unsafeBlinkAction,
) where ) where
import Dodge.Creature.Radius
import Dodge.Zoning.Wall import Dodge.Zoning.Wall
import Data.Maybe import Data.Maybe
import Dodge.Base import Dodge.Base
@@ -33,7 +34,7 @@ blinkActionMousePos cr w =
cpos = _crPos cr cpos = _crPos cr
--p2 = bouncePoint (const True) 1 cpos p1 w --p2 = bouncePoint (const True) 1 cpos p1 w
p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w) p2 = pushIntoMaybe $ collideCircWalls cpos p1 r (wlsNearSeg cpos p1 w)
r = _crRad cr r = crRad $ cr ^. crType
p3 = maybe p1 ((+.+ squashNormalizeV (cpos -.- p1)) . fst) p2 p3 = maybe p1 ((+.+ squashNormalizeV (cpos -.- p1)) . fst) p2
--p3 = maybe p1 (const 0) p2 --p3 = maybe p1 (const 0) p2
--p3 = maybe p1 fst p2 --p3 = maybe p1 fst p2
@@ -102,5 +103,5 @@ blinkActionFail cr w =
p1 = w ^. cWorld . lWorld . lAimPos p1 = w ^. cWorld . lWorld . lAimPos
cpos = _crPos cr cpos = _crPos cr
p2 = bouncePoint (const True) 1 cpos p1 w p2 = bouncePoint (const True) 1 cpos p1 w
r = 1.5 * _crRad cr r = 1.5 * crRad (cr ^. crType)
p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2 p3 = maybe p1 (mvPointTowardAtSpeed r cpos . fst) p2
-1
View File
@@ -28,7 +28,6 @@ flockArmourChaseCrit =
, _apStrategy = FollowImpulses , _apStrategy = FollowImpulses
, _apGoal = [Kill 0] , _apGoal = [Kill 0]
} }
, _crMeleeCooldown = 0
, _crGroup = ShieldGroup , _crGroup = ShieldGroup
, _crMvType = defaultChaseMvType , _crMvType = defaultChaseMvType
} }
-1
View File
@@ -13,7 +13,6 @@ autoCrit :: Creature
autoCrit = autoCrit =
defaultCreature defaultCreature
{ _crInv = IM.fromList [(0, autoRifle)] { _crInv = IM.fromList [(0, autoRifle)]
, _crRad = 10
, _crHP = 300 , _crHP = 300
, _crMvType = defaultAimMvType , _crMvType = defaultAimMvType
} }
+5 -4
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.Boid where module Dodge.Creature.Boid where
import Dodge.Creature.Radius
import Control.Lens import Control.Lens
import Control.Monad.Reader import Control.Monad.Reader
import Dodge.Base import Dodge.Base
@@ -297,7 +298,7 @@ meleeHeadingMove ::
meleeHeadingMove maxta minta tacutoff speed tp cr tcr meleeHeadingMove maxta minta tacutoff speed tp cr tcr
| dist tpos cpos < combinedRad + 5 | dist tpos cpos < combinedRad + 5
&& abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff && abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff
&& _crMeleeCooldown cr == 0 = && _meleeCooldown (_crType cr) == 0 =
[Melee (_crID tcr), Turn pi] [Melee (_crID tcr), Turn pi]
| dist tpos cpos < combinedRad + 5 | dist tpos cpos < combinedRad + 5
&& abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff = && abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff =
@@ -308,13 +309,13 @@ meleeHeadingMove maxta minta tacutoff speed tp cr tcr
where where
cpos = _crPos cr cpos = _crPos cr
tpos = _crPos tcr tpos = _crPos tcr
combinedRad = _crRad cr + _crRad tcr combinedRad = crRad (cr ^. crType) + crRad (tcr ^. crType)
mvPointMeleeTarg :: Point2 -> Creature -> Creature -> [Impulse] mvPointMeleeTarg :: Point2 -> Creature -> Creature -> [Impulse]
mvPointMeleeTarg p cr crT mvPointMeleeTarg p cr crT
| dist tpos cpos < combinedRad + 5 | dist tpos cpos < combinedRad + 5
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 && abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4
&& _crMeleeCooldown cr == 0 = && _meleeCooldown (_crType cr) == 0 =
[Melee (_crID crT)] [Melee (_crID crT)]
| dist tpos cpos < combinedRad + 5 | dist tpos cpos < combinedRad + 5
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 = && abs (_crDir cr - argV (tpos -.- cpos)) < pi / 4 =
@@ -325,4 +326,4 @@ mvPointMeleeTarg p cr crT
where where
cpos = _crPos cr cpos = _crPos cr
tpos = _crPos crT tpos = _crPos crT
combinedRad = _crRad cr + _crRad crT combinedRad = crRad (cr ^. crType) + crRad (crT ^. crType)
-2
View File
@@ -16,7 +16,6 @@ smallChaseCrit :: Creature
smallChaseCrit = smallChaseCrit =
chaseCrit chaseCrit
{ _crHP = 1 { _crHP = 1
, _crRad = 4
, _crInv = mempty , _crInv = mempty
-- , _crCorpse = MakeDefaultCorpse -- , _crCorpse = MakeDefaultCorpse
} }
@@ -34,7 +33,6 @@ chaseCrit =
{ _crName = "chaseCrit" { _crName = "chaseCrit"
, _crHP = 150 , _crHP = 150
, _crInv = mempty , _crInv = mempty
, _crMeleeCooldown = 0
, _crFaction = ColorFaction green , _crFaction = ColorFaction green
, _crVocalization = chaseCritVocalization , _crVocalization = chaseCritVocalization
, _crMvType = defaultChaseMvType , _crMvType = defaultChaseMvType
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.Damage where module Dodge.Creature.Damage where
import Dodge.Creature.Material
import Dodge.Creature.Mass import Dodge.Creature.Mass
import Color import Color
import Data.List import Data.List
@@ -13,7 +14,7 @@ applyNoDamage :: [Damage] -> Creature -> World -> World
applyNoDamage _ _ = id applyNoDamage _ _ = id
applyCreatureDamage :: [Damage] -> Creature -> World -> World applyCreatureDamage :: [Damage] -> Creature -> World -> World
applyCreatureDamage dms cr = case _crMaterial cr of applyCreatureDamage dms cr = case crMaterial (cr ^. crType) of
Flesh -> defaultApplyDamage dms cr Flesh -> defaultApplyDamage dms cr
Crystal -> id Crystal -> id
_ -> defaultApplyDamage dms cr _ -> defaultApplyDamage dms cr
+1 -1
View File
@@ -53,7 +53,7 @@ followImpulse cr w imp = case imp of
SwitchToItem i -> crup $ cr & crManipulation . manObject .~ SelectedItem i i mempty SwitchToItem i -> crup $ cr & crManipulation . manObject .~ SelectedItem i i mempty
Melee cid' -> Melee cid' ->
( hitCr cid' ( hitCr cid'
, crMvAbsolute (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20 , crMvAbsolute (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crType . meleeCooldown .~ 20
) )
RandomTurn a -> (randGen .~ snd (rr a), cr & crDir +~ fst (rr a)) RandomTurn a -> (randGen .~ snd (rr a), cr & crDir +~ fst (rr a))
MakeSound sid -> (soundStart (CrSound (_crID cr)) (_crPos cr) sid Nothing, cr) MakeSound sid -> (soundStart (CrSound (_crID cr)) (_crPos cr) sid Nothing, cr)
+2 -2
View File
@@ -12,7 +12,7 @@ import Dodge.Creature.Lamp
import Dodge.Data.Creature import Dodge.Data.Creature
import Dodge.Default import Dodge.Default
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
import LensHelp --import LensHelp
barrel :: Creature barrel :: Creature
barrel = barrel =
@@ -37,4 +37,4 @@ explosiveBarrel =
} }
, _crInv = IM.empty -- IM.fromList [(0,frontArmour)] , _crInv = IM.empty -- IM.fromList [(0,frontArmour)]
} }
& crMaterial .~ Crystal -- & crMaterial .~ Crystal
+1 -1
View File
@@ -15,7 +15,7 @@ colorLamp col h =
defaultInanimate defaultInanimate
{ _crHP = 100 { _crHP = 100
, _crType = LampCrit h col Nothing , _crType = LampCrit h col Nothing
, _crRad = 3 -- , _crRad = 3
} }
lamp :: Float -> Creature lamp :: Float -> Creature
-1
View File
@@ -13,7 +13,6 @@ launcherCrit :: Creature
launcherCrit = launcherCrit =
defaultCreature defaultCreature
{ _crInv = IM.fromList [(0, rLauncher)] { _crInv = IM.fromList [(0, rLauncher)]
, _crRad = 10
, _crState = defaultState , _crState = defaultState
, _crHP = 300 , _crHP = 300
} }
-1
View File
@@ -13,7 +13,6 @@ ltAutoCrit :: Creature
ltAutoCrit = ltAutoCrit =
defaultCreature defaultCreature
{ _crInv = IM.fromList [(0, autoPistol)] { _crInv = IM.fromList [(0, autoPistol)]
, _crRad = 10
, _crHP = 500 , _crHP = 500
} }
-- & crType .~ LtAutoCrit -- & crType .~ LtAutoCrit
+1 -1
View File
@@ -6,7 +6,7 @@ crMass :: CreatureType -> Float
crMass = \case crMass = \case
Avatar {} -> 10 Avatar {} -> 10
AvatarDead -> 10 AvatarDead -> 10
ChaseCrit -> 10 ChaseCrit {} -> 10
SwarmCrit -> 2 SwarmCrit -> 2
AutoCrit -> 10 AutoCrit -> 10
BarrelCrit{} -> 10 BarrelCrit{} -> 10
+2 -1
View File
@@ -5,6 +5,7 @@ module Dodge.Creature.Perception (
visionCheck, visionCheck,
) where ) where
import Dodge.Creature.Radius
import Linear import Linear
import Control.Lens import Control.Lens
import qualified Data.Map.Strict as M import qualified Data.Map.Strict as M
@@ -155,7 +156,7 @@ visionCheck cr tpos = doFloatFloat (_viFOV vi) ang * doFloatFloat (_viDist vi) d
vi = _cpVision $ _crPerception cr vi = _cpVision $ _crPerception cr
cpos = _crPos cr cpos = _crPos cr
dirvec = unitVectorAtAngle (_crDir cr) dirvec = unitVectorAtAngle (_crDir cr)
ang = angleVV dirvec (tpos - (cpos - _crRad cr *^ dirvec)) ang = angleVV dirvec (tpos - (cpos - crRad (cr ^. crType) *^ dirvec))
d = dist tpos cpos d = dist tpos cpos
+2 -1
View File
@@ -9,6 +9,7 @@ module Dodge.Creature.Picture (
deadFeet, deadFeet,
) where ) where
import Dodge.Creature.Radius
import Dodge.Creature.Shape import Dodge.Creature.Shape
import Control.Lens import Control.Lens
import Dodge.Creature.HandPos (translateToLeftHand, translateToRightHand) import Dodge.Creature.HandPos (translateToLeftHand, translateToRightHand)
@@ -46,7 +47,7 @@ basicCrShape cr
] ]
where where
cskin = crShape $ _crType cr cskin = crShape $ _crType cr
crsize = 0.1 * _crRad cr crsize = 0.1 * crRad (cr ^. crType)
tr = uncurryV translateSHxy (_crPos cr) tr = uncurryV translateSHxy (_crPos cr)
rotdir = rotateSH (_crDir cr) rotdir = rotateSH (_crDir cr)
rotmdir = rotateSH (_crMvDir cr) rotmdir = rotateSH (_crMvDir cr)
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Creature.Picture.Awareness where module Dodge.Creature.Picture.Awareness where
import Dodge.Creature.Radius
import qualified Data.Vector as V import qualified Data.Vector as V
import Dodge.Clock import Dodge.Clock
import Dodge.Data.World import Dodge.Data.World
@@ -32,7 +33,7 @@ creatureDisplayText w cr =
theScale = 0.15 / (w ^. wCam . camZoom) theScale = 0.15 / (w ^. wCam . camZoom)
cpos = _crPos cr cpos = _crPos cr
v = cpos -.- campos v = cpos -.- campos
(V2 x y) = campos +.+ v +.+ _crRad cr *.* normalizeV v (V2 x y) = campos +.+ v +.+ crRad (cr ^. crType) *.* normalizeV v
crDisplayAwareness :: Creature -> String crDisplayAwareness :: Creature -> String
crDisplayAwareness cr crDisplayAwareness cr
-1
View File
@@ -13,7 +13,6 @@ pistolCrit :: Creature
pistolCrit = pistolCrit =
defaultCreature defaultCreature
{ _crInv = IM.fromList [(0, pistol)] { _crInv = IM.fromList [(0, pistol)]
, _crRad = 10
, _crHP = 500 , _crHP = 500
} }
-- & crType . humanoidAI .~ PistolAI -- & crType . humanoidAI .~ PistolAI
+5 -4
View File
@@ -13,6 +13,7 @@ module Dodge.Creature.ReaderUpdate (
setViewPos, setViewPos,
) where ) where
import Dodge.Creature.Radius
import RandomHelp import RandomHelp
import Dodge.Creature.Perception import Dodge.Creature.Perception
import qualified IntMapHelp as IM import qualified IntMapHelp as IM
@@ -35,9 +36,9 @@ overrideMeleeCloseTarget cr = maybe cr (tryMeleeAttack cr) (_targetCr $ _crInten
tryMeleeAttack :: Creature -> Creature -> Creature tryMeleeAttack :: Creature -> Creature -> Creature
tryMeleeAttack cr tcr tryMeleeAttack cr tcr
| _crMeleeCooldown cr == 0 | _meleeCooldown (_crType cr) == 0
&& Just (_crID tcr) == cr ^? crActionPlan . apStrategy . meleeTarget && Just (_crID tcr) == cr ^? crActionPlan . apStrategy . meleeTarget
&& dist tpos cpos < _crRad cr + _crRad tcr + 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 . apImpulse .~ [Melee $ _crID tcr]
& crActionPlan . apAction .~ [DoReplicate 10 NoAction `DoActionThen` DoImpulses & crActionPlan . apAction .~ [DoReplicate 10 NoAction `DoActionThen` DoImpulses
@@ -101,7 +102,7 @@ flockACC w cr = case cr ^? crIntention . targetCr . _Just of
in case macr of in case macr of
Nothing -> cr Nothing -> cr
Just acr -> Just acr ->
let r = _crRad acr + _crRad cr + 10 let r = crRad (acr ^. crType) + crRad (cr ^. crType) + 10
horDir = normalizeV (vNormal (cpos -.- tpos)) horDir = normalizeV (vNormal (cpos -.- tpos))
horShift = horShift =
if isLHS tpos cpos (_crPos acr) if isLHS tpos cpos (_crPos acr)
@@ -126,7 +127,7 @@ chaseCritMv w cr = case _apStrategy (_crActionPlan cr) of
numjits = fst $ randomR (15, 25) (_randGen w) numjits = fst $ randomR (15, 25) (_randGen w)
_ -> case cr ^? crIntention . mvToPoint . _Just of _ -> case cr ^? crIntention . mvToPoint . _Just of
Just p Just p
| dist (_crPos cr) p > _crRad cr -> cr & crActionPlan . apAction .~ [PathTo p] | dist (_crPos cr) p > crRad (cr ^. crType) -> cr & crActionPlan . apAction .~ [PathTo p]
| otherwise -> | otherwise ->
cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]] cr & crActionPlan . apAction .~ [bfsThenReturn 500 `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]]
& crActionPlan . apStrategy .~ WatchAndWait & crActionPlan . apStrategy .~ WatchAndWait
+1 -1
View File
@@ -8,7 +8,7 @@ import Dodge.Data.Creature.Misc
crShape :: CreatureType -> CreatureShape crShape :: CreatureType -> CreatureShape
crShape = \case crShape = \case
Avatar{} -> Humanoid (greyN 0.9) (lightx4 black) (greyN 0.3) InanimateAI Avatar{} -> Humanoid (greyN 0.9) (lightx4 black) (greyN 0.3) InanimateAI
ChaseCrit -> Humanoid (greyN 0.9) (lightx4 green) (greyN 0.3) ChaseAI ChaseCrit {} -> Humanoid (greyN 0.9) (lightx4 green) (greyN 0.3) ChaseAI
SwarmCrit -> Humanoid (greyN 0.9) (lightx4 yellow) (greyN 0.3) SwarmAI SwarmCrit -> Humanoid (greyN 0.9) (lightx4 yellow) (greyN 0.3) SwarmAI
AutoCrit -> Humanoid (greyN 0.9) (lightx4 red) (greyN 0.3) AutoAI AutoCrit -> Humanoid (greyN 0.9) (lightx4 red) (greyN 0.3) AutoAI
AvatarDead -> Humanoid (greyN 0.9) (lightx4 black) (greyN 0.3) InanimateAI AvatarDead -> Humanoid (greyN 0.9) (lightx4 black) (greyN 0.3) InanimateAI
-1
View File
@@ -13,7 +13,6 @@ spreadGunCrit :: Creature
spreadGunCrit = spreadGunCrit =
defaultCreature defaultCreature
{ _crInv = IM.fromList [(0, bangStick 6)] { _crInv = IM.fromList [(0, bangStick 6)]
, _crRad = 10
, _crHP = 500 , _crHP = 500
} }
-- & crType . humanoidAI .~ SpreadGunAI -- & crType . humanoidAI .~ SpreadGunAI
+5 -4
View File
@@ -129,10 +129,11 @@ internalCreatureUpdate cr = cWorld . lWorld . creatures . ix (_crID cr) %~ updat
TODO make sure this doesn't mess up any ItemPosition TODO make sure this doesn't mess up any ItemPosition
-} -}
dropByState :: Creature -> World -> World dropByState :: Creature -> World -> World
dropByState cr w = foldl' (flip (dropItem cr)) w $ case cr ^. crState . csDropsOnDeath of dropByState cr w = foldl' (flip (dropItem cr)) w $ IM.keys $ _crInv cr
DropAll -> IM.keys $ _crInv cr -- case cr ^. crState . csDropsOnDeath of
DropSpecific xs -> xs -- DropAll -> IM.keys $ _crInv cr
DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w) -- DropSpecific xs -> xs
-- DropAmount n -> take n $ evalState (shuffle $ IM.keys $ _crInv cr) (_randGen w)
doDamage :: Creature -> World -> World doDamage :: Creature -> World -> World
doDamage cr = applyPastDamages cr . applyCreatureDamage dams cr doDamage cr = applyPastDamages cr . applyCreatureDamage dams cr
+1 -2
View File
@@ -11,9 +11,8 @@ swarmCrit :: Creature
swarmCrit = swarmCrit =
defaultCreature defaultCreature
{ _crHP = 1 { _crHP = 1
, _crRad = 2 -- , _crRad = 2
, _crFaction = ColorFaction yellow , _crFaction = ColorFaction yellow
, _crMeleeCooldown = 0
} }
& crType .~ SwarmCrit & crType .~ SwarmCrit
-- & crType . skinUpper .~ lightx4 yellow -- & crType . skinUpper .~ lightx4 yellow
+2 -1
View File
@@ -24,6 +24,7 @@ module Dodge.Creature.Test (
crSafeDistFromTarg, crSafeDistFromTarg,
) where ) where
import Dodge.Creature.Radius
import Dodge.Data.Equipment.Misc import Dodge.Data.Equipment.Misc
import Dodge.Data.AimStance import Dodge.Data.AimStance
import Dodge.Item.AimStance import Dodge.Item.AimStance
@@ -136,7 +137,7 @@ hasFrontArmour p cr = fromMaybe False $ do
--crNearSeg d p1 p2 cr = circOnSeg p1 p2 (_crPos cr) (_crRad cr + d) --crNearSeg d p1 p2 cr = circOnSeg p1 p2 (_crPos cr) (_crRad cr + d)
crNearPoint :: Float -> Point2 -> Creature -> Bool crNearPoint :: Float -> Point2 -> Creature -> Bool
crNearPoint d p cr = dist (_crPos cr) p < d + _crRad cr crNearPoint d p cr = dist (_crPos cr) p < d + crRad (cr ^. crType)
isAnimate :: Creature -> Bool isAnimate :: Creature -> Bool
{-# INLINE isAnimate #-} {-# INLINE isAnimate #-}
+1 -5
View File
@@ -40,21 +40,17 @@ data Creature = Creature
, _crMvAim :: Float , _crMvAim :: Float
, _crType :: CreatureType , _crType :: CreatureType
, _crID :: Int , _crID :: Int
, _crRad :: Float
-- , _crMass :: Float
, _crHP :: Int , _crHP :: Int
, _crMaxHP :: Int
, _crInv :: IM.IntMap Item , _crInv :: IM.IntMap Item
, _crManipulation :: Manipulation , _crManipulation :: Manipulation
, _crInvCapacity :: Int , _crInvCapacity :: Int
, _crInvLock :: Bool , _crInvLock :: Bool
, _crEquipment :: M.Map EquipSite Int , _crEquipment :: M.Map EquipSite Int
, _crState :: CreatureState , _crState :: CreatureState
, _crMaterial :: Material
, _crPastDamage :: Int , _crPastDamage :: Int
, _crStance :: Stance , _crStance :: Stance
, _crActionPlan :: ActionPlan , _crActionPlan :: ActionPlan
, _crMeleeCooldown :: Int -- , _crMeleeCooldown :: Int
, _crPerception :: Perception , _crPerception :: Perception
, _crMemory :: Memory , _crMemory :: Memory
, _crVocalization :: Vocalization , _crVocalization :: Vocalization
+3 -2
View File
@@ -8,6 +8,7 @@ module Dodge.Data.Creature.Misc (
module Dodge.Data.CamouflageStatus, module Dodge.Data.CamouflageStatus,
) where ) where
import Dodge.Data.Material
import Color import Color
import Control.Lens import Control.Lens
import Data.Aeson import Data.Aeson
@@ -67,9 +68,9 @@ data Pulse = PulseStatus
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
data CreatureType data CreatureType
= Avatar { _avatarPulse :: Pulse } = Avatar { _avatarPulse :: Pulse , _avatarMaterial :: Material}
| AvatarDead | AvatarDead
| ChaseCrit | ChaseCrit {_meleeCooldown :: Int}
| SwarmCrit | SwarmCrit
| AutoCrit | AutoCrit
| BarrelCrit{_barrelType :: BarrelType} | BarrelCrit{_barrelType :: BarrelType}
+1 -1
View File
@@ -16,7 +16,7 @@ import Geometry.Data
data CreatureState = CrSt data CreatureState = CrSt
{ _csDamage :: [Damage] { _csDamage :: [Damage]
, _csSpState :: CrSpState , _csSpState :: CrSpState
, _csDropsOnDeath :: CreatureDropType -- , _csDropsOnDeath :: CreatureDropType
} }
deriving (Eq, Ord, Show, Read) --Generic, Flat) deriving (Eq, Ord, Show, Read) --Generic, Flat)
+2 -2
View File
@@ -33,8 +33,8 @@ applyTerminalCommand s = case s of
. (uvWorld . cWorld . lWorld . creatures . ix 0 . crInv .~ IM.fromList (zip [0 ..] $ inventoryX x)) . (uvWorld . cWorld . lWorld . creatures . ix 0 . crInv .~ IM.fromList (zip [0 ..] $ inventoryX x))
. (uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ 50) . (uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ 50)
['I','S',x,y] -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ read [x,y] ['I','S',x,y] -> uvWorld . cWorld . lWorld . creatures . ix 0 . crInvCapacity .~ read [x,y]
"GODON" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMaterial .~ Crystal "GODON" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial .~ Crystal
"GODOFF" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crMaterial .~ Flesh "GODOFF" -> uvWorld . cWorld . lWorld . creatures . ix 0 . crType . avatarMaterial .~ Flesh
x -> fromMaybe id $ do x -> fromMaybe id $ do
(ibt, n) <- parseItem [x] (ibt, n) <- parseItem [x]
return $ uvWorld %~ flip (foldl' (&)) (replicate n (snd . createItemYou (itemFromBase ibt))) return $ uvWorld %~ flip (foldl' (&)) (replicate n (snd . createItemYou (itemFromBase ibt)))
+5 -6
View File
@@ -19,17 +19,17 @@ defaultCreature =
, _crMvAim = 0 , _crMvAim = 0
-- , _crTwist = 0 -- , _crTwist = 0
, _crID = 1 , _crID = 1
, _crType = ChaseCrit , _crType = ChaseCrit {_meleeCooldown = 0}
, _crRad = 10 -- , _crRad = 10
, _crHP = 100 , _crHP = 100
, _crMaxHP = 150 -- , _crMaxHP = 150
, _crInv = IM.empty , _crInv = IM.empty
, _crManipulation = Manipulator SelNothing , _crManipulation = Manipulator SelNothing
, _crInvCapacity = 25 , _crInvCapacity = 25
, _crInvLock = False , _crInvLock = False
, _crState = defaultState , _crState = defaultState
-- , _crCorpse = MakeDefaultCorpse -- , _crCorpse = MakeDefaultCorpse
, _crMaterial = Flesh -- , _crMaterial = Flesh
, _crPastDamage = 0 , _crPastDamage = 0
-- , _crInvEquipped = mempty -- , _crInvEquipped = mempty
, _crEquipment = M.empty , _crEquipment = M.empty
@@ -45,7 +45,6 @@ defaultCreature =
, _crActionPlan = ActionPlan [] [] (StrategyActions WatchAndWait [StartSentinelPost]) [LiveLongAndProsper] , _crActionPlan = ActionPlan [] [] (StrategyActions WatchAndWait [StartSentinelPost]) [LiveLongAndProsper]
, _crPerception = defaultPerceptionState , _crPerception = defaultPerceptionState
, _crMemory = defaultCreatureMemory , _crMemory = defaultCreatureMemory
, _crMeleeCooldown = 0
, _crFaction = NoFaction , _crFaction = NoFaction
, _crIntention = defaultIntention , _crIntention = defaultIntention
, _crGroup = LoneWolf , _crGroup = LoneWolf
@@ -135,5 +134,5 @@ defaultState =
CrSt CrSt
{ _csDamage = [] { _csDamage = []
, _csSpState = GenCr , _csSpState = GenCr
, _csDropsOnDeath = DropAll -- , _csDropsOnDeath = DropAll
} }
+2 -1
View File
@@ -4,6 +4,7 @@ module Dodge.Flame (
updateFlame, updateFlame,
) where ) where
import Dodge.Creature.Radius
import Dodge.Data.World import Dodge.Data.World
import Data.Foldable import Data.Foldable
import Data.Tuple import Data.Tuple
@@ -91,7 +92,7 @@ updateFlame w pt
closeWls wl = uncurry segOnCirc (_wlLine wl) ep 5 closeWls wl = uncurry segOnCirc (_wlLine wl) ep 5
closeCrs cr = closeCrs cr =
dist ep (_crPos cr) dist ep (_crPos cr)
< _crRad cr + 10 - min 9 (max 0 (fromIntegral time - 80)) < crRad (cr ^. crType) + 10 - min 9 (max 0 (fromIntegral time - 80))
+ 5 * angleCoeff (angleVV (ep -.- _crPos cr) rotd) + 5 * angleCoeff (angleVV (ep -.- _crPos cr) rotd)
angleCoeff x' = abs $ 1 - abs ((x' * 2 - pi) / pi) angleCoeff x' = abs $ 1 - abs ((x' * 2 - pi) / pi)
rfl wl p = rfl wl p =
+2 -1
View File
@@ -10,6 +10,7 @@ module Dodge.HeldUse (
heldEffectMuzzles, heldEffectMuzzles,
) where ) where
import Dodge.Creature.Radius
import Dodge.Creature.Mass import Dodge.Creature.Mass
import Dodge.Data.Muzzle import Dodge.Data.Muzzle
import Dodge.Data.UseDelay import Dodge.Data.UseDelay
@@ -802,7 +803,7 @@ shootTractorBeam cr w =
& soundContinue (CrWeaponSound (_crID cr) 0) cpos tone440sawtoothquietS (Just 2) & soundContinue (CrWeaponSound (_crID cr) 0) cpos tone440sawtoothquietS (Just 2)
where where
cpos = _crPos cr cpos = _crPos cr
spos = cpos +.+ (_crRad cr + 10) *.* unitVectorAtAngle dir spos = cpos +.+ (crRad (cr ^. crType) + 10) *.* unitVectorAtAngle dir
xpos = cpos +.+ 400 *.* unitVectorAtAngle dir xpos = cpos +.+ 400 *.* unitVectorAtAngle dir
dir = _crDir cr dir = _crDir cr
outpos = fst $ collidePointWallsFilter (const True) cpos xpos w outpos = fst $ collidePointWallsFilter (const True) cpos xpos w
+2 -2
View File
@@ -12,7 +12,7 @@ import RandomHelp
updateHumanoid :: Creature -> World -> World updateHumanoid :: Creature -> World -> World
updateHumanoid cr = case cr ^?! crType of updateHumanoid cr = case cr ^?! crType of
ChaseCrit -> ChaseCrit {} ->
humanoidAIList humanoidAIList
[ const doStrategyActions [ const doStrategyActions
, performActions , performActions
@@ -23,7 +23,7 @@ updateHumanoid cr = case cr ^?! crType of
, chaseCritPerceptionUpdate [0] , chaseCritPerceptionUpdate [0]
, targetYouWhenCognizant , targetYouWhenCognizant
, const searchIfDamaged , const searchIfDamaged
, const (crMeleeCooldown %~ 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 cr
+2 -1
View File
@@ -8,6 +8,7 @@ module Dodge.Inventory.SelectionList (
getItemValue, getItemValue,
) where ) where
import Dodge.Creature.MaxHP
import Dodge.Data.Equipment.Misc import Dodge.Data.Equipment.Misc
import Numeric import Numeric
import Dodge.Inventory.Path import Dodge.Inventory.Path
@@ -78,7 +79,7 @@ epText Nothing = " @NOT.EQP"
introScanValue :: Creature -> IntroScanType -> Either Int String introScanValue :: Creature -> IntroScanType -> Either Int String
introScanValue cr = \case introScanValue cr = \case
HEALTH -> Left $ cr ^. crHP HEALTH -> Left $ cr ^. crHP
MAXHEALTH -> Left $ cr ^. crMaxHP MAXHEALTH -> Left $ crMaxHP $ cr ^. crType
itemExternalValue :: Item -> World -> Creature -> Maybe (Either Int String) itemExternalValue :: Item -> World -> Creature -> Maybe (Either Int String)
itemExternalValue itm w cr itemExternalValue itm w cr
+2 -1
View File
@@ -4,6 +4,7 @@ module Dodge.Item.BackgroundEffect (
itEffectOnDrop, itEffectOnDrop,
) where ) where
import Dodge.Creature.Radius
import Dodge.Inventory.SelectionList import Dodge.Inventory.SelectionList
--import Dodge.Inventory.Path --import Dodge.Inventory.Path
import Data.Maybe import Data.Maybe
@@ -67,7 +68,7 @@ createShieldWall' it cr w = case it ^? itParams . flatShieldWlMIX . _Just of
wlline = (a, b) wlline = (a, b)
crdirv = unitVectorAtAngle $ _crDir cr crdirv = unitVectorAtAngle $ _crDir cr
crpos = _crPos cr crpos = _crPos cr
rad = _crRad cr + 2 rad = crRad (cr ^. crType) + 2
a = crpos +.+ rad *.* crdirv -.- 10 *.* therot crdirv a = crpos +.+ rad *.* crdirv -.- 10 *.* therot crdirv
b = crpos +.+ rad *.* crdirv +.+ 10 *.* therot crdirv b = crpos +.+ rad *.* crdirv +.+ 10 *.* therot crdirv
therot therot
+4 -3
View File
@@ -7,6 +7,7 @@ module Dodge.Item.HeldOffset (
heldItemOrient2D, heldItemOrient2D,
) where ) where
import Dodge.Creature.Radius
import Dodge.Data.AimStance import Dodge.Data.AimStance
import Dodge.Item.AimStance import Dodge.Item.AimStance
import qualified Quaternion as Q import qualified Quaternion as Q
@@ -36,16 +37,16 @@ heldItemRelativeOrient itm cr (p,q)
| Aiming {} <- _posture (_crStance cr) = | Aiming {} <- _posture (_crStance cr) =
(p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q) (p + aimingWeaponZeroPos cr itm `v2z` shoulderHeight, Q.qID * q)
| TwoHandFlat <- aStance itm = | TwoHandFlat <- aStance itm =
( V3 (_crRad cr) 0 handD + rotate3 (twoFlatHRot cr) (transToHandle itm p) ( V3 (crRad $ cr ^. crType) 0 handD + rotate3 (twoFlatHRot cr) (transToHandle itm p)
, Q.axisAngle (V3 0 0 1) (twoFlatHRot cr) * q , Q.axisAngle (V3 0 0 1) (twoFlatHRot cr) * q
) )
| OneHand <- aStance itm = | OneHand <- aStance itm =
( V3 (_crRad cr * 0.7 + handPos) (_crRad cr * negate 0.7) handD ( V3 (crRad (cr ^. crType) * 0.7 + handPos) (crRad (cr ^. crType) * negate 0.7) handD
+ transToHandle itm p + transToHandle itm p
, Q.qID * q , Q.qID * q
) )
| otherwise = | otherwise =
( V3 (_crRad cr) 0 handD ( V3 (crRad $ cr ^. crType) 0 handD
+ rotate3 (strideRot cr + 1.2) (V3 (-8) 0 0 + transToHandle itm p) + rotate3 (strideRot cr + 1.2) (V3 (-8) 0 0 + transToHandle itm p)
, Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2) * q , Q.axisAngle (V3 0 0 1) (strideRot cr + 1.2) * q
) )
+2 -1
View File
@@ -3,6 +3,7 @@ module Dodge.Prop.Moving (
fallSmallBounce, fallSmallBounce,
) where ) where
import Dodge.Creature.Radius
import Dodge.Base import Dodge.Base
import Dodge.Data.World import Dodge.Data.World
import Geometry import Geometry
@@ -20,7 +21,7 @@ fallSmallBounceDamage pr w =
| _prPosZ pr < 25 = cWorld . lWorld . creatures %~ fmap dodamage' | _prPosZ pr < 25 = cWorld . lWorld . creatures %~ fmap dodamage'
| otherwise = id | otherwise = id
dodamage' cr dodamage' cr
| dist (_crPos cr) p < _crRad cr + 5 = | dist (_crPos cr) p < crRad (cr ^. crType) + 5 =
cr & crState . csDamage cr & crState . csDamage
.:~ Damage CRUSHING (floor . (* 10) . max 0 . subtract 5 . abs $ _prVelZ pr) (p -.- v) p (p +.+ v) NoDamageEffect .:~ Damage CRUSHING (floor . (* 10) . max 0 . subtract 5 . abs $ _prVelZ pr) (p -.- v) p (p +.+ v) NoDamageEffect
| otherwise = cr | otherwise = cr
+2 -1
View File
@@ -68,7 +68,8 @@ armouredChasers = do
treeFromPost [corridor, corridor] <$> (randomMediumRoom <&> rmPmnts %~ (++ theCrits)) treeFromPost [corridor, corridor] <$> (randomMediumRoom <&> rmPmnts %~ (++ theCrits))
where where
cs = cs =
(armourChaseCrit & crState . csDropsOnDeath .~ DropSpecific [0]) : --(armourChaseCrit & crState . csDropsOnDeath .~ DropSpecific [0]) :
armourChaseCrit :
replicate 4 chaseCrit replicate 4 chaseCrit
randomMediumRoom :: RandomGen g => State g Room randomMediumRoom :: RandomGen g => State g Room
+1 -1
View File
@@ -26,7 +26,7 @@ centerVaultExplosiveExit = do
[ sPS (V2 0 110) 0 $ PutCrit explosiveBarrel [ sPS (V2 0 110) 0 $ PutCrit explosiveBarrel
, sPS (V2 5 115) 0 $ PutCrit explosiveBarrel , sPS (V2 5 115) 0 $ PutCrit explosiveBarrel
, sPS (V2 0 120) 0 $ PutCrit explosiveBarrel , sPS (V2 0 120) 0 $ PutCrit explosiveBarrel
, sPS (V2 0 0) 0 $ PutCrit (cr & crState . csDropsOnDeath .~ DropAll) , sPS (V2 0 0) 0 $ PutCrit cr
] ]
centerVaultRoom 120 120 50 <&> rmPmnts %~ (extraPS ++) centerVaultRoom 120 120 50 <&> rmPmnts %~ (extraPS ++)
+3 -2
View File
@@ -1,5 +1,6 @@
module Dodge.Shockwave.Update where module Dodge.Shockwave.Update where
import Dodge.Creature.Radius
import Data.Foldable import Data.Foldable
import Dodge.Base.Collide import Dodge.Base.Collide
import Dodge.Data.World import Dodge.Data.World
@@ -36,7 +37,7 @@ moveShockwave w sw
hitBlocks = map snd . overlapCircWalls p rad $ wlsNearCirc p rad w hitBlocks = map snd . overlapCircWalls p rad $ wlsNearCirc p rad w
-- this is not expansive enough -- this is not expansive enough
damCr cr damCr cr
| _crID cr `elem` is || dist (_crPos cr) p >= rad + _crRad cr = cr | _crID cr `elem` is || dist (_crPos cr) p >= rad + crRad (cr ^. crType) = cr
| otherwise = | otherwise =
cr & crState . csDamage cr & crState . csDamage
.:~ Damage .:~ Damage
@@ -65,7 +66,7 @@ moveInverseShockwave w sw
dams = over (cWorld . lWorld . creatures) (IM.map damCr) -- . flip (foldr (damageBlocksBy 1)) hitBlocks dams = over (cWorld . lWorld . creatures) (IM.map damCr) -- . flip (foldr (damageBlocksBy 1)) hitBlocks
-- hitBlocks = wallsOnCirc' p rad $ wallsNearPoint' p w -- hitBlocks = wallsOnCirc' p rad $ wallsNearPoint' p w
damCr cr damCr cr
| dist (_crPos cr) p >= rad + _crRad cr = cr | dist (_crPos cr) p >= rad + crRad (cr ^. crType) = cr
| otherwise = | otherwise =
cr & crState . csDamage cr & crState . csDamage
.:~ Damage CONCUSSIVE 1 (cpos +.+ v) cpos (cpos -.- v) (PushBackDamage 25) .:~ Damage CONCUSSIVE 1 (cpos +.+ v) cpos (cpos -.- v) (PushBackDamage 25)
+3 -2
View File
@@ -7,6 +7,7 @@ Description : Simulation update
-} -}
module Dodge.Update (updateUniverse) where module Dodge.Update (updateUniverse) where
import Dodge.Creature.Radius
import Dodge.Creature.Mass import Dodge.Creature.Mass
import Dodge.Damage import Dodge.Damage
import RandomHelp import RandomHelp
@@ -568,7 +569,7 @@ updateTeslaArc w pt
(lp, rdir) (lp, rdir)
| ArcStep lp' ld' (CrID crid) <- last thearc | ArcStep lp' ld' (CrID crid) <- last thearc
, Just cr <- w ^? cWorld . lWorld . creatures . ix crid = , Just cr <- w ^? cWorld . lWorld . creatures . ix crid =
(lp' -.- (_crRad cr + 1) *.* unitVectorAtAngle ld', rp $ ld' + pi) (lp' -.- (crRad (cr ^. crType) + 1) *.* unitVectorAtAngle ld', rp $ ld' + pi)
| ArcStep lp' ld' (WlID wlid) <- last thearc | ArcStep lp' ld' (WlID wlid) <- last thearc
, Just wl <- w ^? cWorld . lWorld . walls . ix wlid = , Just wl <- w ^? cWorld . lWorld . walls . ix wlid =
( lp' -.- 2 *.* unitVectorAtAngle ld' ( lp' -.- 2 *.* unitVectorAtAngle ld'
@@ -793,7 +794,7 @@ crCrSpring c1 c2
id2 = _crID c2 id2 = _crID c2
vec = _crPos c1 -.- _crPos c2 vec = _crPos c1 -.- _crPos c2
diff = magV vec diff = magV vec
comRad = _crRad c1 + _crRad c2 comRad = crRad (c1 ^. crType) + crRad (c2 ^. crType)
overlap1 = ((comRad - diff) * crMass (_crType c2) * 0.5 / massT) *.* errorNormalizeV 55 vec overlap1 = ((comRad - diff) * crMass (_crType c2) * 0.5 / massT) *.* errorNormalizeV 55 vec
overlap2 = ((comRad - diff) * crMass (_crType c1) * 0.5 / massT) *.* errorNormalizeV 56 vec overlap2 = ((comRad - diff) * crMass (_crType c1) * 0.5 / massT) *.* errorNormalizeV 56 vec
massT = crMass (_crType c1) + crMass (_crType c2) massT = crMass (_crType c1) + crMass (_crType c2)
+2 -1
View File
@@ -6,6 +6,7 @@ module Dodge.Update.Camera (
updateCamera, updateCamera,
) where ) where
import Dodge.Creature.Radius
import Bound import Bound
import Control.Monad import Control.Monad
import Data.Foldable import Data.Foldable
@@ -202,7 +203,7 @@ rotateToOverlappingWall w =
maybe maybe
id id
(doWallRotate . snd) (doWallRotate . snd)
(overlapCircWallsClosest p (_crRad cr + 10) (filter _wlRotateTo $ wlsNearPoint p w)) (overlapCircWallsClosest p (crRad (cr ^. crType) + 10) (filter _wlRotateTo $ wlsNearPoint p w))
w w
where where
cr = you w cr = you w
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Update.Cloud where module Dodge.Update.Cloud where
import Dodge.Creature.Radius
import Data.Foldable import Data.Foldable
import Dodge.Data.World import Dodge.Data.World
import Dodge.Zoning.Creature import Dodge.Zoning.Creature
@@ -14,5 +15,5 @@ cloudPoisonDamage c w = w & dodamagesto (filter f $ crsNearPoint clpos w)
doDam cr = doDam cr =
cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage cWorld . lWorld . creatures . ix (_crID cr) . crState . csDamage
.:~ Damage POISONDAM 1 clpos clpos clpos NoDamageEffect .:~ Damage POISONDAM 1 clpos clpos clpos NoDamageEffect
f cr = dist3 (addZ 20 $ _crPos cr) (_clPos c) < _crRad cr + _clRad c + 10 f cr = dist3 (addZ 20 $ _crPos cr) (_clPos c) < crRad (cr ^. crType) + _clRad c + 10
clpos = stripZ $ _clPos c clpos = stripZ $ _clPos c
+5 -4
View File
@@ -6,6 +6,7 @@ module Dodge.WallCreatureCollisions (
crOnWall, crOnWall,
) where ) where
import Dodge.Creature.Radius
import Control.Lens import Control.Lens
import Data.Maybe import Data.Maybe
import Data.Monoid import Data.Monoid
@@ -40,7 +41,7 @@ colCrWall w c
. fst . fst
. flip (collidePoint p1) wls -- check push throughs . flip (collidePoint p1) wls -- check push throughs
-- . flip (collidePointWalls' p1) wls -- check push throughs -- . flip (collidePointWalls' p1) wls -- check push throughs
r = _crRad c + wallBuffer r = crRad (c ^. crType) + wallBuffer
p1 = _crOldPos c p1 = _crOldPos c
p2 = _crPos c p2 = _crPos c
ls = _wlLine <$> wls ls = _wlLine <$> wls
@@ -52,7 +53,7 @@ wallBuffer :: Float
wallBuffer = 0 wallBuffer = 0
pushCreatureOutFromWalls :: [(Point2, Point2)] -> Creature -> Creature pushCreatureOutFromWalls :: [(Point2, Point2)] -> Creature -> Creature
pushCreatureOutFromWalls ls cr = cr & crPos %~ pushOutFromWalls (_crRad cr) ls pushCreatureOutFromWalls ls cr = cr & crPos %~ pushOutFromWalls (crRad (cr ^. crType)) ls
-- the following tests whether or not a point is on a wall, and if so pushes it -- the following tests whether or not a point is on a wall, and if so pushes it
-- out from the wall -- out from the wall
@@ -71,7 +72,7 @@ pushOutFromWalls rad wls p1 = case (getFirst . foldMap (First . pushOutFromWall
-- -- possible improvement: choose between the closer of p2 and "p3" to p1 -- -- possible improvement: choose between the closer of p2 and "p3" to p1
pushOrCrush :: [(Point2, Point2)] -> Creature -> Creature pushOrCrush :: [(Point2, Point2)] -> Creature -> Creature
pushOrCrush wls cr = case mapMaybe (pushOutFromWall (_crRad cr) cpos) wls of pushOrCrush wls cr = case mapMaybe (pushOutFromWall (crRad (cr ^. crType)) cpos) wls of
[] -> cr [] -> cr
(p : _) -> cr & crPos .~ p (p : _) -> cr & crPos .~ p
where where
@@ -89,7 +90,7 @@ crOnWall cr =
. wlsNearPoint p . wlsNearPoint p
where where
p = _crPos cr p = _crPos cr
r = _crRad cr r = crRad (cr ^. crType)
-- assumes that the wall is orientated -- assumes that the wall is orientated
-- assumes wall points are different -- assumes wall points are different
+2 -1
View File
@@ -1,5 +1,6 @@
module Dodge.Zoning.Creature where module Dodge.Zoning.Creature where
import Dodge.Creature.Radius
import Control.Lens import Control.Lens
import qualified Data.IntSet as IS import qualified Data.IntSet as IS
import Data.Maybe import Data.Maybe
@@ -41,7 +42,7 @@ crZoneSize :: Float
crZoneSize = 15 crZoneSize = 15
zoneOfCr :: Creature -> [Int2] zoneOfCr :: Creature -> [Int2]
zoneOfCr cr = zoneOfCirc crZoneSize (_crPos cr) (_crRad cr) zoneOfCr cr = zoneOfCirc crZoneSize (_crPos cr) (crRad $ cr ^. crType)
minCrIXOn :: Ord a => (Creature -> a) -> IS.IntSet -> World -> Maybe Creature minCrIXOn :: Ord a => (Creature -> a) -> IS.IntSet -> World -> Maybe Creature
minCrIXOn f is w = fst <$> IS.foldl' g Nothing is minCrIXOn f is w = fst <$> IS.foldl' g Nothing is
+505 -503
View File
File diff suppressed because it is too large Load Diff