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
+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
chaseTarg :: Creature -> Creature -> [Impulse]
chaseTarg cr crT
| 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 ]
chaseTarg cr crT = [MoveForward speed, TurnToward tpos (trad dirOffset), RandomTurn jit]
where
cpos = _crPos cr
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
:: Creature