Remove creature records
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -28,7 +28,6 @@ flockArmourChaseCrit =
|
||||
, _apStrategy = FollowImpulses
|
||||
, _apGoal = [Kill 0]
|
||||
}
|
||||
, _crMeleeCooldown = 0
|
||||
, _crGroup = ShieldGroup
|
||||
, _crMvType = defaultChaseMvType
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ autoCrit :: Creature
|
||||
autoCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, autoRifle)]
|
||||
, _crRad = 10
|
||||
, _crHP = 300
|
||||
, _crMvType = defaultAimMvType
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -15,7 +15,7 @@ colorLamp col h =
|
||||
defaultInanimate
|
||||
{ _crHP = 100
|
||||
, _crType = LampCrit h col Nothing
|
||||
, _crRad = 3
|
||||
-- , _crRad = 3
|
||||
}
|
||||
|
||||
lamp :: Float -> Creature
|
||||
|
||||
@@ -13,7 +13,6 @@ launcherCrit :: Creature
|
||||
launcherCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, rLauncher)]
|
||||
, _crRad = 10
|
||||
, _crState = defaultState
|
||||
, _crHP = 300
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ ltAutoCrit :: Creature
|
||||
ltAutoCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, autoPistol)]
|
||||
, _crRad = 10
|
||||
, _crHP = 500
|
||||
}
|
||||
-- & crType .~ LtAutoCrit
|
||||
|
||||
@@ -6,7 +6,7 @@ crMass :: CreatureType -> Float
|
||||
crMass = \case
|
||||
Avatar {} -> 10
|
||||
AvatarDead -> 10
|
||||
ChaseCrit -> 10
|
||||
ChaseCrit {} -> 10
|
||||
SwarmCrit -> 2
|
||||
AutoCrit -> 10
|
||||
BarrelCrit{} -> 10
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -13,7 +13,6 @@ pistolCrit :: Creature
|
||||
pistolCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, pistol)]
|
||||
, _crRad = 10
|
||||
, _crHP = 500
|
||||
}
|
||||
-- & crType . humanoidAI .~ PistolAI
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -13,7 +13,6 @@ spreadGunCrit :: Creature
|
||||
spreadGunCrit =
|
||||
defaultCreature
|
||||
{ _crInv = IM.fromList [(0, bangStick 6)]
|
||||
, _crRad = 10
|
||||
, _crHP = 500
|
||||
}
|
||||
-- & crType . humanoidAI .~ SpreadGunAI
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 #-}
|
||||
|
||||
Reference in New Issue
Block a user