Fix worldEvent reset space leak
This commit is contained in:
@@ -33,14 +33,14 @@ armourChaseCrit = defaultCreature
|
||||
targetYouWhenCognizantR >=>
|
||||
flockACCR >=>
|
||||
overrideMeleeCloseTargetR >=>
|
||||
return . (crMeleeCooldown . _Just %~ max 0 . subtract 1)
|
||||
return . (crMeleeCooldown %~ max 0 . subtract 1)
|
||||
, _crHP = 300
|
||||
, _crPict = basicCrPict green
|
||||
, _crInv = IM.fromList
|
||||
[(0,frontArmour)
|
||||
,(1,medkit 200)
|
||||
]
|
||||
, _crMeleeCooldown = Just 0
|
||||
, _crMeleeCooldown = 0
|
||||
, _crGroup = ShieldGroup
|
||||
}
|
||||
|
||||
|
||||
@@ -36,16 +36,16 @@ chaseCrit :: Creature
|
||||
chaseCrit = defaultCreature
|
||||
{ _crUpdate = stateUpdate $ --dummyUpdate
|
||||
impulsiveAIR $
|
||||
--doStrategyActionsR >=>
|
||||
--performActionsR >=>
|
||||
--overrideMeleeCloseTargetR >=>
|
||||
--chaseTargetR targetYouLOS >=>
|
||||
--basicPerceptionUpdateR [0] >=>
|
||||
--targetYouWhenCognizantR >=>
|
||||
return . (crMeleeCooldown . _Just %~ max 0 . subtract 1)
|
||||
doStrategyActionsR >=>
|
||||
performActionsR >=>
|
||||
overrideMeleeCloseTargetR >=>
|
||||
chaseTargetR targetYouLOS >=>
|
||||
basicPerceptionUpdateR [0] >=>
|
||||
targetYouWhenCognizantR >=>
|
||||
return . (crMeleeCooldown %~ max 0 . subtract 1)
|
||||
, _crHP = 300
|
||||
, _crPict = basicCrPict green
|
||||
, _crInv = IM.fromList [(0,medkit 200)]
|
||||
, _crMeleeCooldown = Just 0
|
||||
, _crMeleeCooldown = 0
|
||||
, _crFaction = ColorFaction green
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ meleeHeadingMove
|
||||
meleeHeadingMove maxta minta tacutoff speed tp cr tcr
|
||||
| dist tpos cpos < combinedRad + 5
|
||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff
|
||||
&& _crMeleeCooldown cr == Just 0
|
||||
&& _crMeleeCooldown cr == 0
|
||||
= [Melee (_crID tcr), Turn pi]
|
||||
| dist tpos cpos < combinedRad + 5
|
||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < tacutoff
|
||||
@@ -50,7 +50,7 @@ mvPointMeleeTarg :: Point2 -> Creature -> Creature -> [Impulse]
|
||||
mvPointMeleeTarg p cr crT
|
||||
| dist tpos cpos < combinedRad + 5
|
||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
|
||||
&& _crMeleeCooldown cr == Just 0
|
||||
&& _crMeleeCooldown cr == 0
|
||||
= [Melee (_crID crT)]
|
||||
| dist tpos cpos < combinedRad + 5
|
||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
|
||||
@@ -89,7 +89,7 @@ impulseShootAtTarg :: Creature -> Creature -> [Impulse]
|
||||
impulseShootAtTarg cr crT
|
||||
| dist tpos cpos < combinedRad + 5
|
||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
|
||||
&& _crMeleeCooldown cr == Just 0
|
||||
&& _crMeleeCooldown cr == 0
|
||||
= [Melee (_crID crT)]
|
||||
| dist tpos cpos < combinedRad + 5
|
||||
&& abs (_crDir cr - argV (tpos -.- cpos)) < pi/4
|
||||
|
||||
@@ -142,9 +142,7 @@ naked col cr
|
||||
aimingOneHand = crIsAiming' cr && crIt ^? itAimStance == Just OneHand
|
||||
aimingTwist = crIsAiming' cr && crIt ^? itAimStance == Just TwoHandTwist
|
||||
crIt = _crInv cr IM.! _crInvSel cr
|
||||
strikeMelee = case _crMeleeCooldown cr of
|
||||
Nothing -> False
|
||||
Just x -> x > 5
|
||||
strikeMelee = _crMeleeCooldown cr > 5
|
||||
pdam = sum $ concatMap (map _dmAmount) pastDams
|
||||
crad = _crRad cr
|
||||
pastDams = _crPastDamage $ _crState cr
|
||||
|
||||
@@ -29,7 +29,7 @@ impulsiveAIR
|
||||
-> Creature
|
||||
-> World
|
||||
-> (Endo World , Maybe Creature)
|
||||
impulsiveAIR impf cr w = followImpulses w . ($ w) . runReader $ impf cr
|
||||
impulsiveAIR impf cr w = bimap Endo Just $ followImpulses w . ($ w) . runReader $ impf cr
|
||||
|
||||
--impulsiveAI
|
||||
-- :: (World -> Creature -> Creature) -- ^ Internal AI update, should determine impulses
|
||||
@@ -43,10 +43,9 @@ impulsiveAIR impf cr w = followImpulses w . ($ w) . runReader $ impf cr
|
||||
followImpulses
|
||||
:: World
|
||||
-> Creature
|
||||
-> (Endo World, Maybe Creature)
|
||||
-> (World -> World, Creature)
|
||||
followImpulses w cr
|
||||
= (\(f''' ,cr') -> (Endo f''',Just cr'))
|
||||
$ foldr
|
||||
= foldr
|
||||
(\imp (f , cr') -> let (f'', cr'') = followImpulse cr' w imp in (f'' . f , cr''))
|
||||
(id, cr)
|
||||
(_crImpulse $ _crActionPlan cr)
|
||||
@@ -67,7 +66,7 @@ followImpulse cr w imp = case imp of
|
||||
SwitchToItem i -> (id, cr & crInvSel .~ i)
|
||||
Melee cid ->
|
||||
(hitCr cid
|
||||
, crMvBy (10 *.* normalizeV (posFromID cid -.- cpos)) $ cr & crMeleeCooldown ?~ 20) -- randomise cooldown?
|
||||
, crMvBy (10 *.* normalizeV (posFromID cid -.- cpos)) $ cr & crMeleeCooldown .~ 20) -- randomise cooldown?
|
||||
RandomTurn a -> (id, creatureTurn (rr a) cr)
|
||||
MakeSound sid -> ( soundOnceOrigin sid (CrSound (_crID cr)) (_crPos cr) , cr )
|
||||
DropItem -> undefined
|
||||
|
||||
@@ -19,7 +19,7 @@ overrideMeleeCloseTargetR cr = return $ maybe cr (tryMeleeAttack cr) (_crTarget
|
||||
|
||||
tryMeleeAttack :: Creature -> Creature -> Creature
|
||||
tryMeleeAttack cr tcr
|
||||
| _crMeleeCooldown cr == Just 0
|
||||
| _crMeleeCooldown cr == 0
|
||||
&& dist (_crPos tcr) cpos < _crRad cr + _crRad tcr + 5
|
||||
&& abs (_crDir cr - argV (_crPos tcr -.- cpos)) < pi/4
|
||||
-- = cr & crActionPlan . crStrategy .~ StrategyActions MeleeStrike meleeActions
|
||||
|
||||
@@ -75,8 +75,8 @@ velocity to carry across frames.
|
||||
crFriction :: Creature -> Point2 -> Point2
|
||||
crFriction _ _ = V2 0 0
|
||||
|
||||
meleeCooldown :: CRUpdate -> CRUpdate
|
||||
meleeCooldown u cr = u $ cr & crMeleeCooldown . _Just %~ (max 0 . (\x -> x - 1))
|
||||
--meleeCooldown :: CRUpdate -> CRUpdate
|
||||
--meleeCooldown u cr = u $ cr & crMeleeCooldown . _Just %~ (max 0 . (\x -> x - 1))
|
||||
|
||||
doDamage :: Creature -> Creature
|
||||
doDamage cr = set (crState . crDamage) []
|
||||
|
||||
@@ -32,7 +32,7 @@ swarmCrit :: Creature
|
||||
swarmCrit = defaultCreature
|
||||
{ _crUpdate = stateUpdate $ impulsiveAIR $
|
||||
flockToPointUsing (encircleDistP 100) (meleeHeadingMove 0.1 0.1 (pi/4) 3.9)
|
||||
>=> return . (crMeleeCooldown . _Just %~ max 0 . subtract 1)
|
||||
>=> return . (crMeleeCooldown %~ max 0 . subtract 1)
|
||||
>=> basicPerceptionUpdateR [0]
|
||||
>=> doStrategyActionsR
|
||||
>=> targetYouWhenCognizantR
|
||||
@@ -45,7 +45,7 @@ swarmCrit = defaultCreature
|
||||
, _crPict = basicCrPict yellow
|
||||
, _crCorpse = onLayer CorpseLayer $ color (greyN 0.5) $ circleSolid 2
|
||||
, _crFaction = ColorFaction yellow
|
||||
, _crMeleeCooldown = Just 0
|
||||
, _crMeleeCooldown = 0
|
||||
}
|
||||
|
||||
--swarmCritMoveFunc :: Creature -> Point2 -> Creature -> Point2
|
||||
|
||||
Reference in New Issue
Block a user