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