Move creature speed parameters into explicit data

This commit is contained in:
2021-09-05 11:24:15 +01:00
parent 215a3dda36
commit c16c09a9ce
6 changed files with 45 additions and 19 deletions
+8
View File
@@ -42,7 +42,15 @@ armourChaseCrit = defaultCreature
] ]
, _crMeleeCooldown = 0 , _crMeleeCooldown = 0
, _crGroup = ShieldGroup , _crGroup = ShieldGroup
, _crMvType = ChaseMvType
{ _chaseSpeed = 2.5
, _chaseTurnRad = f
, _chaseTurnJit = 0.2
}
} }
where
f x | x > pi / 4 = 0.2
| otherwise = 0.05
flockACCR :: Creature -> Reader World Creature flockACCR :: Creature -> Reader World Creature
flockACCR = reader . flockACC flockACCR = reader . flockACC
+8
View File
@@ -48,4 +48,12 @@ chaseCrit = defaultCreature
, _crInv = IM.fromList [(0,medkit 200)] , _crInv = IM.fromList [(0,medkit 200)]
, _crMeleeCooldown = 0 , _crMeleeCooldown = 0
, _crFaction = ColorFaction green , _crFaction = ColorFaction green
, _crMvType = ChaseMvType
{ _chaseSpeed = 2.5
, _chaseTurnRad = f
, _chaseTurnJit = 0.2
}
} }
where
f x | x > pi / 4 = 0.2
| otherwise = 0.05
+10 -10
View File
@@ -145,16 +145,16 @@ upperBody col cr = color (light4 col) $ pictures
, shoulderH $ torso cr , shoulderH $ torso cr
] ]
naked :: Color -> Creature -> Picture --naked :: Color -> Creature -> Picture
naked _ cr --naked _ cr
| strikeMelee = shoulderH . color white $ circleSolid $ _crRad cr -- | strikeMelee = shoulderH . color white $ circleSolid $ _crRad cr
| pdam > 200 = shoulderH . color red $ circleSolid $ _crRad cr -- | pdam > 200 = shoulderH . color red $ circleSolid $ _crRad cr
| pdam > 99 = shoulderH . color white $ circleSolid $ _crRad cr -- | pdam > 99 = shoulderH . color white $ circleSolid $ _crRad cr
| otherwise = [] -- | otherwise = []
where -- where
strikeMelee = _crMeleeCooldown cr > 5 -- strikeMelee = _crMeleeCooldown cr > 5
pdam = sum $ concatMap (map _dmAmount) pastDams -- pdam = sum $ concatMap (map _dmAmount) pastDams
pastDams = _crPastDamage $ _crState cr -- pastDams = _crPastDamage $ _crState cr
shoulderH :: Picture -> Picture shoulderH :: Picture -> Picture
shoulderH = setDepth 20 shoulderH = setDepth 20
+9 -8
View File
@@ -41,17 +41,18 @@ chaseTargetR targFunc cr = reader $ \w -> case targFunc cr w of
Just crTarg -> cr & crActionPlan . crImpulse .~ chaseTarg cr crTarg Just crTarg -> cr & crActionPlan . crImpulse .~ chaseTarg cr crTarg
chaseTarg :: Creature -> Creature -> [Impulse] chaseTarg :: Creature -> Creature -> [Impulse]
chaseTarg cr crT chaseTarg cr crT = [MoveForward speed, TurnToward tpos (trad dirOffset), RandomTurn jit]
| dist tpos cpos < combinedRad + 5
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
= [ TurnToward tpos 0.05 ]
| abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
= [MoveForward 2.5 , TurnToward tpos 0.2, RandomTurn 0.2 ]
| otherwise = [MoveForward 2.5 , TurnToward tpos 0.05, RandomTurn 0.2 ]
where where
cpos = _crPos cr cpos = _crPos cr
tpos = _crPos crT tpos = _crPos crT
combinedRad = _crRad cr + _crRad crT mvType = _crMvType cr
speed = _chaseSpeed mvType
trad = _chaseTurnRad mvType
jit = _chaseTurnJit mvType
dirOffset = abs (_crDir cr - argV (tpos -.- cpos))
-- | abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
-- = [MoveForward 2.5 , TurnToward tpos 0.2, RandomTurn 0.2 ]
-- | otherwise = [MoveForward 2.5 , TurnToward tpos 0.05, RandomTurn 0.2 ]
doStrategyActionsR doStrategyActionsR
:: Creature :: Creature
+8
View File
@@ -220,7 +220,15 @@ data Creature = Creature
, _crFaction :: Faction , _crFaction :: Faction
, _crGroup :: CrGroup , _crGroup :: CrGroup
, _crTarget :: Maybe Creature , _crTarget :: Maybe Creature
, _crMvType :: CrMvType
} }
data CrMvType
= DefCrMvType
| ChaseMvType
{ _chaseSpeed :: Float
, _chaseTurnRad :: Float -> Float
, _chaseTurnJit :: Float
}
data WorldState data WorldState
= DoorNumOpen Int = DoorNumOpen Int
| CrNumAlive Int | CrNumAlive Int
+1
View File
@@ -56,6 +56,7 @@ defaultCreature = Creature
, _crFaction = NoFaction , _crFaction = NoFaction
, _crTarget = Nothing , _crTarget = Nothing
, _crGroup = LoneWolf , _crGroup = LoneWolf
, _crMvType = DefCrMvType
} }
defaultState :: CreatureState defaultState :: CreatureState
defaultState = CrSt defaultState = CrSt