Start ai cleanup
This commit is contained in:
@@ -2,22 +2,19 @@ module Dodge.Creature.ArmourChase
|
||||
( armourChaseCrit
|
||||
)
|
||||
where
|
||||
import Dodge.Base
|
||||
import Dodge.Data
|
||||
import Dodge.Default
|
||||
import Dodge.Creature.State
|
||||
import Dodge.Creature.State.Data
|
||||
import Dodge.Creature.Rationality
|
||||
import Dodge.Creature.ReaderUpdate
|
||||
import Dodge.Creature.AlertLevel
|
||||
import Dodge.Creature.Picture
|
||||
import Dodge.Creature.Impulse
|
||||
import Dodge.Creature.Action
|
||||
import Dodge.Item.Equipment
|
||||
import Dodge.Item.Consumable
|
||||
import Picture
|
||||
import Geometry
|
||||
import FoldableHelp
|
||||
|
||||
import Data.Maybe
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
import Control.Monad.Reader
|
||||
@@ -28,10 +25,11 @@ armourChaseCrit = defaultCreature
|
||||
watchUpdateStratR [] >=>
|
||||
doStrategyActionsR >=>
|
||||
performActionsR >=>
|
||||
chaseTargetR (const . _crTarget) >=>
|
||||
basicPerceptionUpdateR [0] >=>
|
||||
targetYouWhenCognizantR >=>
|
||||
setTargetMv (pure . _crTarget) >=>
|
||||
flockACCR >=>
|
||||
basicPerceptionUpdateR [0] >=>
|
||||
goToTarget >=>
|
||||
overrideMeleeCloseTargetR >=>
|
||||
return . (crMeleeCooldown %~ max 0 . subtract 1)
|
||||
, _crHP = 300
|
||||
@@ -40,37 +38,13 @@ armourChaseCrit = defaultCreature
|
||||
[(0,frontArmour)
|
||||
,(1,medkit 200)
|
||||
]
|
||||
, _crActionPlan = ActionPlan
|
||||
{_crImpulse = []
|
||||
,_crAction = []
|
||||
,_crStrategy = FollowImpulses
|
||||
,_crGoal = [Kill 0]
|
||||
}
|
||||
, _crMeleeCooldown = 0
|
||||
, _crGroup = ShieldGroup
|
||||
, _crMvType = ChaseMvType
|
||||
{ _chaseSpeed = 2.5
|
||||
, _chaseTurnRad = f
|
||||
, _chaseTurnJit = 0.2
|
||||
}
|
||||
, _crMvType = defaultChaseMvType
|
||||
}
|
||||
where
|
||||
f x | x > pi / 4 = 0.2
|
||||
| otherwise = 0.05
|
||||
|
||||
flockACCR :: Creature -> Reader World Creature
|
||||
flockACCR = reader . flockACC
|
||||
|
||||
flockACC :: Creature -> World -> Creature
|
||||
flockACC cr w = fromMaybe cr $ mFlockACC cr w
|
||||
|
||||
mFlockACC :: Creature -> World -> Maybe Creature
|
||||
mFlockACC cr w = do
|
||||
tcr <- _crTarget cr
|
||||
let tpos = _crPos tcr
|
||||
cpos = _crPos cr
|
||||
isFarACC cr' = _crGroup cr' == ShieldGroup && _crID cr' /= _crID cr
|
||||
&& dist (_crPos cr') tpos > dist cpos tpos
|
||||
-- && circOnSeg (_crPos cr') tpos cpos (_crRad cr + _crRad cr')
|
||||
nearACCs = IM.filter isFarACC $ creaturesNearPointI 3 cpos w
|
||||
acr <- safeMinimumOn (dist cpos . _crPos) nearACCs
|
||||
let r = _crRad acr + _crRad cr + 10
|
||||
horDir = normalizeV (vNormal (cpos -.- tpos))
|
||||
horShift = if isLHS tpos cpos (_crPos acr)
|
||||
then r *.* horDir
|
||||
else negate r *.* horDir
|
||||
return $ cr & crActionPlan . crImpulse .~ [MoveForward 2.5,TurnToward (tpos +.+ horShift) 0.05 ]
|
||||
|
||||
Reference in New Issue
Block a user