ActionPlan refactor
This commit is contained in:
+4
-33
@@ -39,7 +39,7 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
|
||||
[ (crHasTargetLOS, \_ _ -> StrategyActions (ShootAt 0)
|
||||
[DoActionIf (WdCrNegate $ WdCrBlfromCrBl CrIsAiming) drawWeapon
|
||||
,DoActionThen
|
||||
(DoActionWhile WdCrLOSTarget $ ArbitraryAction chooseMovementSpreadGun)
|
||||
(DoActionWhile WdCrLOSTarget $ ArbitraryAction ChooseMovementSpreadGun)
|
||||
(DoImpulses [ChangeStrategy WatchAndWait])
|
||||
]
|
||||
)
|
||||
@@ -74,7 +74,7 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
|
||||
[ (crHasTargetLOS, \_ _ -> StrategyActions (ShootAt 0)
|
||||
[DoActionIf (WdCrNegate $ WdCrBlfromCrBl CrIsAiming) drawWeapon
|
||||
,DoActionThen
|
||||
(DoActionWhile WdCrLOSTarget $ ArbitraryAction chooseMovementLtAuto)
|
||||
(DoActionWhile WdCrLOSTarget $ ArbitraryAction ChooseMovementLtAuto)
|
||||
(DoImpulses [ChangeStrategy WatchAndWait])
|
||||
]
|
||||
)
|
||||
@@ -129,8 +129,8 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
|
||||
, \_ _ -> StrategyActions Reload reloadActions
|
||||
)
|
||||
, (const $ not . crSafeDistFromTarg 150
|
||||
, \_ cr' -> StrategyActions Flee
|
||||
[WdCrNegate (WdCrSafeDistFromTarget 150) `DoActionWhile` UseTarget (fleeFrom cr')
|
||||
, \_ _ -> StrategyActions Flee
|
||||
[WdCrNegate (WdCrSafeDistFromTarget 150) `DoActionWhile` UseSelf CrFleeFromTarget-- (fleeFrom cr')
|
||||
`DoActionThen` DoImpulses [ChangeStrategy WatchAndWait] ]
|
||||
)
|
||||
, (crHasTargetLOS, \_ _ -> StrategyActions (ShootAt 0)
|
||||
@@ -154,21 +154,6 @@ defaultImpulsive = fmap (fmap updateRandGen) . stateUpdate . impulsiveAIBefore .
|
||||
updateRandGen w = let (_,g) = randomR (0,1::Int) (_randGen w)
|
||||
in w & randGen .~ g
|
||||
|
||||
chooseMovementSpreadGun :: Creature -> World -> Action
|
||||
chooseMovementSpreadGun cr w
|
||||
| dist cpos p < 30 && safeAngleVV (p -.- cpos) (unitVectorAtAngle (_crDir cr)) > pi
|
||||
= DoImpulses [UseItem, MoveForward (-3)]
|
||||
| d < 30 = DoImpulses [UseItem,TurnToward p 0.06]
|
||||
| d < 60 = DoImpulses [UseItem,TurnToward p 0.06,MoveForward 3]
|
||||
| d < 100 = DoImpulses [TurnToward p 0.06, MoveForward 3 ]
|
||||
| d < 200 = DoImpulses [TurnToward p (0.06 + 0.002 *(d-100)), MoveForward 3 ]
|
||||
| otherwise
|
||||
= DoImpulses [TurnToward p 0.26, MoveForward 3]
|
||||
where
|
||||
d = dist cpos p
|
||||
cpos = _crPos cr
|
||||
tcr = _creatures w IM.! 0
|
||||
p = _crPos tcr
|
||||
|
||||
chooseMovementPistol :: Creature -> World -> Action
|
||||
chooseMovementPistol cr w = chooseMovementPistol' cr w
|
||||
@@ -235,20 +220,6 @@ retreatActionsPistol tcr cr =
|
||||
tpos
|
||||
(tpos +.+ vNormal (cpos -.- tpos))
|
||||
|
||||
chooseMovementLtAuto :: Creature -> World -> Action
|
||||
chooseMovementLtAuto cr w
|
||||
| dist cpos p > 200 = DoImpulses [UseItem,TurnToward p 0.05 , MoveForward 3]
|
||||
| dist cpos p < 80 = DoImpulses [UseItem,TurnToward p 0.05, MoveForward (-3) ]
|
||||
| errorAngleVV 22 (p' -.- cpos) (unitVectorAtAngle (_crDir cr)) < 0.4
|
||||
= DoImpulses [UseItem,TurnToward p' 0.01, Move (V2 0 3)]
|
||||
| otherwise
|
||||
= DoImpulses [UseItem,TurnToward p' 0.05, Move (V2 0 3)]
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tcr = _creatures w IM.! 0
|
||||
p = _crPos tcr
|
||||
v = vNormal $ p -.- cpos
|
||||
p' = p +.+ 0.5 *.* (v -.- 20 *.* normalizeV v)
|
||||
|
||||
retreatFireLauncher :: Action
|
||||
retreatFireLauncher = ImpulsesList ( [ UseItem ] : replicate 20 [ Turn 0.16 ])
|
||||
|
||||
Reference in New Issue
Block a user