Dataify impulse/action/strategy function fields

This commit is contained in:
2022-07-21 21:45:31 +01:00
parent 14f3c8bc52
commit 583027112d
7 changed files with 45 additions and 36 deletions
+10 -9
View File
@@ -37,9 +37,9 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
[performActions
,watchUpdateStrat
[ (crHasTargetLOS, \_ _ -> StrategyActions (ShootAt 0)
[DoActionIf (const $ not . crIsAiming) drawWeapon
[DoActionIf (WdCrNegate $ WdCrBlfromCrBl CrIsAiming) drawWeapon
,DoActionThen
(DoActionWhile crHasTargetLOS $ ArbitraryAction chooseMovementSpreadGun)
(DoActionWhile WdCrLOSTarget $ ArbitraryAction chooseMovementSpreadGun)
(DoImpulses [ChangeStrategy WatchAndWait])
]
)
@@ -57,7 +57,7 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
[ performActions
, watchUpdateStrat
[ (crHasTargetLOS, \w cr' -> StrategyActions (ShootAt 0)
[DoActionIf (const $ not . crIsAiming) drawWeapon,chooseMovementPistol cr' w])
[DoActionIf (WdCrNegate $ WdCrBlfromCrBl CrIsAiming) drawWeapon,chooseMovementPistol cr' w])
, (const crAwayFromPost, const goToPostStrat)
]
, perceptionUpdate [0]
@@ -72,9 +72,9 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
[ performActions
, watchUpdateStrat
[ (crHasTargetLOS, \_ _ -> StrategyActions (ShootAt 0)
[DoActionIf (const $ not . crIsAiming) drawWeapon
[DoActionIf (WdCrNegate $ WdCrBlfromCrBl CrIsAiming) drawWeapon
,DoActionThen
(DoActionWhile crHasTargetLOS $ ArbitraryAction chooseMovementLtAuto)
(DoActionWhile WdCrLOSTarget $ ArbitraryAction chooseMovementLtAuto)
(DoImpulses [ChangeStrategy WatchAndWait])
]
)
@@ -130,7 +130,7 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
)
, (const $ not . crSafeDistFromTarg 150
, \_ cr' -> StrategyActions Flee
[const (not . crSafeDistFromTarg 150) `DoActionWhile` UseTarget (fleeFrom cr')
[WdCrNegate (WdCrSafeDistFromTarget 150) `DoActionWhile` UseTarget (fleeFrom cr')
`DoActionThen` DoImpulses [ChangeStrategy WatchAndWait] ]
)
, (crHasTargetLOS, \_ _ -> StrategyActions (ShootAt 0)
@@ -141,10 +141,10 @@ updateHumanoid cr = case cr ^?! crType . humanoidAI of
YourAI -> stateUpdate yourControl cr
InanimateAI -> id
where
drawwp = DoActionIfElse NoAction (const crIsAiming) (DoActionThen drawWeapon (WaitThen 50 NoAction))
drawwp = DoActionIfElse NoAction (WdCrBlfromCrBl CrIsAiming) (DoActionThen drawWeapon (WaitThen 50 NoAction))
reloadActions =
[ holsterWeapon
, WaitThen 1 $ DoActionWhileInterrupt NoAction (const crIsReloading) (DoImpulses [ChangeStrategy WatchAndWait])
, WaitThen 1 $ DoActionWhileInterrupt NoAction (WdCrBlfromCrBl CrIsReloading) (DoImpulses [ChangeStrategy WatchAndWait])
]
-- bit of a hack to get new random generators after each creature's update
defaultImpulsive :: [World -> Creature -> Creature]
@@ -268,7 +268,8 @@ retreatFireLauncher = ImpulsesList ( [ UseItem ] : replicate 20 [ Turn 0.16 ])
drawWeapon
`DoActionThen`
ImpulsesList (
replicate 100 [UseItem, ImpulseUseTarget $ \tcr -> TurnToward (_crPos tcr) (pi/16) ] )
replicate 100 [UseItem, ImpulseUseTarget (TurnTowardCr (pi/16)) -- $ \tcr -> TurnToward (_crPos tcr) (pi/16) ] )
])
`DoActionThen`
20
`WaitThen`