Generalise pathing, usable with flying creatures

This commit is contained in:
2026-04-02 19:30:44 +01:00
parent c2de804fa9
commit ff903bfb3b
19 changed files with 322 additions and 215 deletions
+30 -10
View File
@@ -1,4 +1,7 @@
module Dodge.Humanoid (chaseCritInternal) where
module Dodge.Humanoid (
chaseCritInternal,
hoverCritInternal,
) where
import Data.Foldable
import Dodge.Creature
@@ -22,8 +25,25 @@ chaseCritInternal w cr =
, const (crVocalization %~ updateVocTimer)
]
hoverCritInternal :: World -> Creature -> Creature
hoverCritInternal w cr =
foldl'
(\c f -> f w c)
cr
[ const doStrategyActions
, overrideMeleeCloseTarget
, setViewPos
, setMvPos
, hoverCritMv
, perceptionUpdate [0]
, targetYouWhenCognizant
, const searchIfDamaged
, const (crType . meleeCooldown %~ max 0 . subtract 1)
, const (crVocalization %~ updateVocTimer)
]
updateVocTimer :: Vocalization -> Vocalization
updateVocTimer VocTimer {_vcTime=x,_vcMaxTime=y} | x < y = VocTimer (x+1) y
updateVocTimer VocTimer{_vcTime = x, _vcMaxTime = y} | x < y = VocTimer (x + 1) y
updateVocTimer _ = VocReady
-- SpreadGunAI ->
@@ -177,13 +197,13 @@ updateVocTimer _ = VocReady
-- , WaitThen 1 $ (DoImpulses [ChangeStrategy WatchAndWait])
-- ]
--chooseMovementPistol :: Creature -> World -> Action
--chooseMovementPistol cr w =
-- chooseMovementPistol :: Creature -> World -> Action
-- chooseMovementPistol cr w =
-- chooseMovementPistol' cr w
-- `DoActionThen` DoImpulses [ChangeStrategy WatchAndWait]
--
--chooseMovementPistol' :: Creature -> World -> Action
--chooseMovementPistol' cr w =
-- chooseMovementPistol' :: Creature -> World -> Action
-- chooseMovementPistol' cr w =
-- takeOneWeighted
-- [chargeProb, retreatProb, strafeProb, strafeProb]
-- [ chargeActions
@@ -223,8 +243,8 @@ updateVocTimer _ = VocReady
-- yposl = ypos -.- 100 *.* vNormal (normalizeV $ ypos -.- cpos)
-- yposr = ypos +.+ 100 *.* vNormal (normalizeV $ ypos -.- cpos)
--
--retreatActionsPistol :: Creature -> Creature -> Action
--retreatActionsPistol tcr cr =
-- retreatActionsPistol :: Creature -> Creature -> Action
-- retreatActionsPistol tcr cr =
-- [TurnToward retreatOffset 0.2]
-- `DoImpulsesAlongside` 3
-- `DoReplicate` ImpulsesList (replicate 9 [Move (V2 (-3) 0)] ++ [[UseItem]])
@@ -244,8 +264,8 @@ updateVocTimer _ = VocReady
-- tpos
-- (tpos +.+ vNormal (cpos -.- tpos))
--
--retreatFireLauncher :: Action
--retreatFireLauncher =
-- retreatFireLauncher :: Action
-- retreatFireLauncher =
-- ImpulsesList ([UseItem] : replicate 20 [Turn 0.16])
-- `DoActionThen` holsterWeapon
-- `DoActionThen` ImpulsesList (replicate 30 [MoveForward 3])