Add pistolCrit file, tweak shell spin params
This commit is contained in:
+1
-2
@@ -1,6 +1,5 @@
|
||||
module Dodge.AIs
|
||||
( launcherAI
|
||||
, chargeAI
|
||||
( chargeAI
|
||||
, dodgeAI
|
||||
, spawnerAI
|
||||
) where
|
||||
|
||||
+2
-10
@@ -2,6 +2,7 @@ module Dodge.Creature
|
||||
( module Dodge.Creature
|
||||
, module Dodge.Creature.Inanimate
|
||||
, launcherCrit
|
||||
, pistolCrit
|
||||
)
|
||||
where
|
||||
import Dodge.Creature.Stance.Data
|
||||
@@ -14,6 +15,7 @@ import Dodge.Creature.AlertLevel
|
||||
import Dodge.Creature.SetTarget
|
||||
import Dodge.Creature.Test
|
||||
import Dodge.Creature.LauncherCrit
|
||||
import Dodge.Creature.PistolCrit
|
||||
import Dodge.Data
|
||||
import Dodge.AIs
|
||||
import Dodge.Default
|
||||
@@ -179,16 +181,6 @@ spreadGunCrit = defaultCreature
|
||||
, _crState = defaultState {_goals = [[Init]]}
|
||||
, _crHP = 300
|
||||
}
|
||||
pistolCrit :: Creature
|
||||
pistolCrit = defaultCreature
|
||||
{ _crPict = basicCrPict red
|
||||
, _crUpdate = stateUpdate (dodgeAI 150 200)
|
||||
, _crInv = IM.fromList [(0,pistol),(1,medkit 100)]
|
||||
, _crInvSel = 0
|
||||
, _crRad = 10
|
||||
, _crState = defaultState {_goals = [[InitGuard]]}
|
||||
, _crHP = 500
|
||||
}
|
||||
autoCrit :: Creature
|
||||
autoCrit = defaultCreature
|
||||
{ _crPict = basicCrPict red
|
||||
|
||||
@@ -78,18 +78,22 @@ shootFirstMiss tcid w cr = StrategyActions (ShootAt tcid) acs
|
||||
`DoActionThen`
|
||||
LeadTarget (0,0)
|
||||
`DoActionThen`
|
||||
(advanceShoot `DoActionWhileThen` lostest
|
||||
$ DoReplicateThen advanceShoot 75
|
||||
$ DoImpulses [ChangeStrategy WatchAndWait]
|
||||
)
|
||||
lostest `DoActionWhile`
|
||||
advanceShoot `DoActionThen`
|
||||
75 `DoReplicate`
|
||||
advanceShoot `DoActionThen`
|
||||
DoImpulses [ChangeStrategy WatchAndWait]
|
||||
|
||||
]
|
||||
lostest (w,cr') = canSee (_crID cr') tcid w
|
||||
advanceShoot = ImpulsesList [[UseItem, MoveForward 3]]
|
||||
|
||||
fleeTime :: Int -> World -> Creature -> Strategy
|
||||
fleeTime t w cr = StrategyActions Flee
|
||||
[ UseTargetCID FleeFrom `DoReplicateThen` t
|
||||
$ DoImpulses [ChangeStrategy WatchAndWait]
|
||||
[ t `DoReplicate`
|
||||
UseTargetCID FleeFrom
|
||||
`DoActionThen`
|
||||
DoImpulses [ChangeStrategy WatchAndWait]
|
||||
]
|
||||
|
||||
aimThenShootStrat :: Int -> World -> Creature -> Strategy
|
||||
@@ -115,10 +119,10 @@ shootMoveStrat :: Point2 -> Int -> World -> Creature -> Strategy
|
||||
shootMoveStrat moveV tcid _ _ = StrategyActions (ShootAt tcid)
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen DrawWeapon (WaitThen 50 NoAction))
|
||||
`DoActionThen`
|
||||
(DoActionWhileThen advanceShoot lostest
|
||||
. DoReplicateThen advanceShoot 75
|
||||
$ DoImpulses [ChangeStrategy WatchAndWait]
|
||||
)
|
||||
lostest `DoActionWhile`
|
||||
75 `DoReplicate`
|
||||
advanceShoot `DoActionThen`
|
||||
DoImpulses [ChangeStrategy WatchAndWait]
|
||||
, AimAtCloseSlow
|
||||
{ _targetID = tcid
|
||||
, _targetSeenAt = (0,0) -- hack
|
||||
@@ -135,10 +139,11 @@ shootAdvanceStrat :: Int -> World -> Creature -> Strategy
|
||||
shootAdvanceStrat tcid _ _ = StrategyActions (ShootAt tcid)
|
||||
[ DoActionIfElse NoAction crIsAiming (DoActionThen DrawWeapon (WaitThen 50 NoAction))
|
||||
`DoActionThen`
|
||||
(DoActionWhileThen advanceShoot lostest
|
||||
. DoReplicateThen advanceShoot 75
|
||||
$ DoImpulses [ChangeStrategy WatchAndWait]
|
||||
)
|
||||
lostest `DoActionWhile`
|
||||
advanceShoot `DoActionThen`
|
||||
75 `DoReplicate`
|
||||
advanceShoot `DoActionThen`
|
||||
DoImpulses [ChangeStrategy WatchAndWait]
|
||||
, AimAtCloseSlow
|
||||
{ _targetID = tcid
|
||||
, _targetSeenAt = (0,0) -- hack
|
||||
@@ -183,10 +188,12 @@ shootAdvance w cr tcr as
|
||||
&& cr ^? crInv . ix (_crInvSel cr) . wpReloadState == Just 0 =
|
||||
[ DrawWeapon
|
||||
, DoImpulses [ChangeStrategy $ ShootAt $ _crID tcr]
|
||||
, WaitThen 50
|
||||
. DoActionWhileThen advanceShoot lostest
|
||||
. DoReplicateThen advanceShoot 50
|
||||
$ DoImpulses [ChangeStrategy WatchAndWait]
|
||||
, 50 `WaitThen`
|
||||
lostest `DoActionWhile`
|
||||
advanceShoot `DoActionThen`
|
||||
50 `DoReplicate`
|
||||
advanceShoot `DoActionThen`
|
||||
DoImpulses [ChangeStrategy WatchAndWait]
|
||||
, AimAtCloseSlow
|
||||
{ _targetID = _crID tcr
|
||||
, _targetSeenAt = _crPos cr
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
module Dodge.Creature.PistolCrit
|
||||
( pistolCrit
|
||||
) where
|
||||
import Dodge.Data
|
||||
import Dodge.Default
|
||||
import Dodge.Creature.Picture
|
||||
import Dodge.Creature.Test
|
||||
import Dodge.Creature.ActionRat
|
||||
import Dodge.Creature.ChooseTarget
|
||||
import Dodge.Creature.SetTarget
|
||||
import Dodge.Creature.Rationality
|
||||
import Dodge.Creature.AlertLevel
|
||||
import Dodge.Creature.State
|
||||
import Dodge.Creature.State.Data
|
||||
import Dodge.Item.Weapon
|
||||
import Dodge.Item.Consumable
|
||||
import Geometry
|
||||
import Picture
|
||||
|
||||
import Data.Maybe
|
||||
import qualified Data.IntMap.Strict as IM
|
||||
import Control.Lens
|
||||
|
||||
pistolCrit :: Creature
|
||||
pistolCrit = defaultCreature
|
||||
{ _crPict = basicCrPict red
|
||||
, _crUpdate = stateUpdate $ impulsiveAI $ composeInternalAIs
|
||||
[ performActions
|
||||
, watchUpdateStrat
|
||||
[ (crHasTargetLOS, \w cr -> StrategyActions (ShootAt 0) [chooseMovement cr w])
|
||||
, (crAwayFromPost, goToPostStrat)
|
||||
]
|
||||
, basicPerceptionUpdate [0]
|
||||
, doStrategyActions
|
||||
, reloadOverride
|
||||
, targetYouWhenCognizant
|
||||
, overrideInternal (onBoth (&&) crHasTarget (crStratConMatches (GetTo (0,0))))
|
||||
$ \ _ -> crActionPlan . crStrategy .~ WatchAndWait
|
||||
]
|
||||
, _crActionPlan = ActionPlan
|
||||
{ _crImpulse = []
|
||||
, _crAction = []
|
||||
, _crStrategy = StrategyActions WatchAndWait [StartSentinelPost]
|
||||
, _crGoal = []
|
||||
}
|
||||
, _crInv = IM.fromList [(0,pistol),(1,medkit 100)]
|
||||
, _crInvSel = 0
|
||||
, _crRad = 10
|
||||
, _crHP = 500
|
||||
}
|
||||
|
||||
chooseMovement :: Creature -> World -> Action
|
||||
chooseMovement cr w = undefined
|
||||
|
||||
retreatAction :: Creature -> Creature -> Action
|
||||
retreatAction tcr cr =
|
||||
[TurnToward retreatOffset 0.2]
|
||||
`DoImpulsesAlongside`
|
||||
NoAction
|
||||
where
|
||||
cpos = _crPos cr
|
||||
tpos = _crPos tcr
|
||||
retreatOffset =
|
||||
let a | dist cpos tpos < 50 = 0
|
||||
| isLeftOfA (_crDir cr) (argV $ tpos -.- cpos)
|
||||
= -0.7
|
||||
| otherwise = 0.7
|
||||
in fromMaybe tpos $ intersectLineLine' cpos
|
||||
(cpos +.+ rotateV a (tpos -.- cpos))
|
||||
tpos
|
||||
(tpos +.+ vNormal (cpos -.- tpos))
|
||||
|
||||
@@ -68,7 +68,8 @@ followImpulse cr w imp = case imp of
|
||||
DropItem -> undefined
|
||||
ChangeStrategy strat -> (id, cr & crActionPlan . crStrategy .~ strat)
|
||||
AddGoal gl -> (id, cr & crActionPlan . crGoal %~ (gl :) )
|
||||
ArbitraryCreatureImpulse f -> (id, f w cr)
|
||||
ArbitraryImpulseFunction f -> (id, f w cr)
|
||||
ArbitraryImpulse f -> followImpulse cr w (f cr w)
|
||||
ImpulseUseTargetCID f -> case cr ^? crTarget . _Just of
|
||||
Just tcid -> followImpulse cr w (f tcid)
|
||||
_ -> (id,cr)
|
||||
@@ -130,17 +131,18 @@ performAction cr w ac = case ac of
|
||||
DoActionThen ac ac' -> case performAction cr w ac of
|
||||
(imps , Just ac'') -> (imps, Just (DoActionThen ac'' ac'))
|
||||
(imps , Nothing ) -> (imps, Just ac')
|
||||
DoActionWhile ac f
|
||||
| f (w,cr) -> (fst $ performAction cr w ac, Just $ DoActionWhile ac f)
|
||||
| otherwise -> ([], Nothing)
|
||||
DoActionWhile f ac -> performAction cr w $ DoActionWhilePartial ac f ac
|
||||
DoActionWhilePartial partAc f resetAc
|
||||
| f (w,cr) -> case performAction cr w partAc of
|
||||
(imps, Just ac) -> (imps, Just $ DoActionWhilePartial ac f resetAc)
|
||||
(imps, _) -> (imps, Just $ DoActionWhilePartial resetAc f resetAc)
|
||||
| otherwise -> performAction cr w partAc
|
||||
DoActionIfElse ac f ac'
|
||||
| f (w,cr) -> performAction cr w ac
|
||||
| otherwise -> performAction cr w ac'
|
||||
DoActionWhileThen ac f ac'
|
||||
| f (w,cr) -> (fst $ performAction cr w ac, Just $ DoActionWhileThen ac f ac')
|
||||
| otherwise -> performAction cr w ac'
|
||||
DoReplicateThen ac 0 ac' -> performAction cr w ac'
|
||||
DoReplicateThen ac t ac' -> (fst $ performAction cr w ac, Just $ DoReplicateThen ac (t-1) ac')
|
||||
DoActions [] -> ([], Nothing)
|
||||
DoActions acs ->
|
||||
let (imps, newAcs) = unzip $ map (performAction cr w) acs
|
||||
@@ -161,6 +163,13 @@ performAction cr w ac = case ac of
|
||||
Just tcid -> performAction cr w (f tcid)
|
||||
_ -> ([],Nothing)
|
||||
UseAheadPos f -> performAction cr w (f (_crPos cr +.+ 20 *.* unitVectorAtAngle (_crDir cr)))
|
||||
ArbitraryAction f -> performAction cr w (f cr w)
|
||||
DoImpulsesAlongside sideImpulses mainAc -> undefined
|
||||
DoReplicate t ac -> performAction cr w $ DoReplicatePartial ac t ac
|
||||
DoReplicatePartial _ 0 ac' -> performAction cr w ac'
|
||||
DoReplicatePartial ac t ac' -> case performAction cr w ac' of
|
||||
(imps , Just ac'') -> (imps, Just $ DoReplicatePartial ac t ac'')
|
||||
(imps , _) -> (imps, Just $ DoReplicatePartial ac (t-1) ac)
|
||||
_ -> ([], Nothing)
|
||||
where
|
||||
cpos = _crPos cr
|
||||
|
||||
+28
-6
@@ -476,7 +476,8 @@ data Impulse
|
||||
| MakeSound Int
|
||||
| ChangeStrategy Strategy
|
||||
| AddGoal Goal
|
||||
| ArbitraryCreatureImpulse (World -> Creature -> Creature)
|
||||
| ArbitraryImpulseFunction (World -> Creature -> Creature)
|
||||
| ArbitraryImpulse (Creature -> World -> Impulse)
|
||||
| ImpulseUseTargetCID
|
||||
{_impulseUseTargetCID :: Int -> Impulse
|
||||
}
|
||||
@@ -489,6 +490,8 @@ data Impulse
|
||||
-- deriving (Eq,Ord,Show)
|
||||
infixr 9 `WaitThen`
|
||||
infixr 9 `DoActionThen`
|
||||
infixr 9 `DoActionWhile`
|
||||
infixr 9 `DoReplicate`
|
||||
data Action
|
||||
= Attack
|
||||
{_attackTargetID :: Int}
|
||||
@@ -535,8 +538,13 @@ data Action
|
||||
,_waitThenAction :: Action
|
||||
}
|
||||
| DoActionWhile
|
||||
{_doActionWhileAction :: Action
|
||||
{_doActionWhileCondition :: ( (World, Creature) -> Bool)
|
||||
,_doActionWhileAction :: Action
|
||||
}
|
||||
| DoActionWhilePartial
|
||||
{_doActionWhilePartial :: Action
|
||||
,_doActionWhileCondition :: ( (World, Creature) -> Bool)
|
||||
,_doActionWhileAction :: Action
|
||||
}
|
||||
| DoActionIfElse
|
||||
{_doActionIfElseIfAction :: Action
|
||||
@@ -561,10 +569,14 @@ data Action
|
||||
| DoGuardActions
|
||||
{_doGuardActionsList :: [( (World, Creature) -> Bool, Action, Maybe Action)]
|
||||
}
|
||||
| DoReplicateThen
|
||||
{_doReplicateThenDo :: Action
|
||||
,_doReplicateThenTimes :: Int
|
||||
,_doReplicateThenAfter :: Action
|
||||
| DoReplicate
|
||||
{_doReplicateTimes :: Int
|
||||
,_doReplicateAction :: Action
|
||||
}
|
||||
| DoReplicatePartial
|
||||
{_partialAction :: Action
|
||||
,_doReplicateTimes :: Int
|
||||
,_doReplicateAction :: Action
|
||||
}
|
||||
| LeadTarget
|
||||
{_leadTargetBy :: Point2
|
||||
@@ -577,6 +589,16 @@ data Action
|
||||
| UseAheadPos
|
||||
{_useAheadPos :: Point2 -> Action
|
||||
}
|
||||
| ArbitraryAction
|
||||
{ _arbitraryAction :: Creature -> World -> Action }
|
||||
| DoActionAlongside -- ^ Repeatedly perform a side action alongside a main action until the main action terminates
|
||||
{_sideAction :: Action
|
||||
,_mainAction :: Action
|
||||
}
|
||||
| DoImpulsesAlongside -- ^ Repeatedly perform impulses alongside a main action until the main action terminates
|
||||
{_sideImpulses :: [Impulse]
|
||||
,_mainAction :: Action
|
||||
}
|
||||
deriving (Generic)
|
||||
-- deriving (Eq,Ord,Show)
|
||||
data Strategy
|
||||
|
||||
@@ -676,12 +676,12 @@ moveShell time i cid rot accel w
|
||||
| time >= 20 = w
|
||||
& projectiles . ix i . pjPos %~ (+.+ vel)
|
||||
& projectiles . ix i . pjPict .~ pic
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid rot (rotateV rot accel)
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid rot' (rotateV rot accel)
|
||||
| time > -99 = w
|
||||
& projectiles . ix i . pjPos %~ (+.+ vel)
|
||||
& randGen .~ g
|
||||
& projectiles . ix i . pjPict .~ pic
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid rot (rotateV rot accel)
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid rot' (rotateV rot accel)
|
||||
& projectiles . ix i . pjVel %~ (\v -> accel +.+ frict *.* v)
|
||||
& soundFromPos (ShellSound i) newPos (fromIntegral smokeTrailSound) 1 250
|
||||
& makeFlameletTimed (oldPos -.- vel) (vel +.+ rotateV (pi+sparkD) accel) Nothing 3 10
|
||||
@@ -689,7 +689,7 @@ moveShell time i cid rot accel w
|
||||
| time > -200 = w
|
||||
& projectiles . ix i . pjPos %~ (+.+ vel)
|
||||
& projectiles . ix i . pjPict .~ pic
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid rot (rotateV rot accel)
|
||||
& projectiles . ix i . pjUpdate .~ moveShell (time-1) i cid rot' (rotateV rot accel)
|
||||
| otherwise = doExplode
|
||||
where
|
||||
doExplode = w
|
||||
@@ -715,6 +715,7 @@ moveShell time i cid rot accel w
|
||||
_ -> 0
|
||||
r1 = randInCirc 10 & evalState $ _randGen w
|
||||
smokeGen = makeSmokeCloudAt (oldPos +.+ r1 +.+ 30 *.* normalizeV (oldPos -.- newPos))
|
||||
rot' = rot * 0.995
|
||||
|
||||
normalizeAnglePi angle
|
||||
| normalizeAngle angle > pi = normalizeAngle angle - 2*pi
|
||||
|
||||
Reference in New Issue
Block a user