Add random generator update when creature does random turn
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
module Dodge.Creature.Impulse
|
||||
( impulsiveAI'
|
||||
( impulsiveAIBefore
|
||||
, followThenClearImpulses
|
||||
) where
|
||||
import Dodge.Data
|
||||
@@ -25,9 +25,9 @@ impulsiveAIBeforeAfter startup endup cr w = w' & creatures . ix (_crID cr) .~ en
|
||||
w' = g w
|
||||
(g,cr') = impulsiveAI startup cr w
|
||||
|
||||
impulsiveAI' :: (World -> Creature -> Creature)
|
||||
impulsiveAIBefore :: (World -> Creature -> Creature)
|
||||
-> Creature -> World -> World
|
||||
impulsiveAI' f cr w = g w & creatures . ix (_crID cr) .~ cr'
|
||||
impulsiveAIBefore f cr w = g w & creatures . ix (_crID cr) .~ cr'
|
||||
where
|
||||
(g,cr') = impulsiveAI f cr w
|
||||
|
||||
@@ -60,7 +60,7 @@ followImpulse cr w imp = case imp of
|
||||
SwitchToItem i -> crup $ cr & crInvSel .~ i
|
||||
Melee cid' -> (hitCr cid'
|
||||
, crMvBy (10 *.* normalizeV (posFromID cid' -.- cpos)) $ cr & crMeleeCooldown .~ 20)
|
||||
RandomTurn a -> crup $ creatureTurn (rr a) cr
|
||||
RandomTurn a -> (randGen .~ snd (rr a), creatureTurn (fst $ rr a) cr)
|
||||
MakeSound sid -> ( soundStart (CrSound (_crID cr)) (_crPos cr) sid Nothing , cr )
|
||||
DropItem -> undefined
|
||||
ChangeStrategy strat -> crup $ cr & crActionPlan . crStrategy .~ strat
|
||||
@@ -86,7 +86,7 @@ followImpulse cr w imp = case imp of
|
||||
cdir = _crDir cr
|
||||
cid = _crID cr
|
||||
posFromID cid' = _crPos $ _creatures w IM.! cid'
|
||||
rr a = fst $ randomR (-a,a) $ _randGen w
|
||||
rr a = randomR (-a,a) $ _randGen w
|
||||
hitCr i = (creatures . ix i . crState . crDamage
|
||||
.:~ Damage Blunt 100 cpos (posFromID i) (posFromID i) NoDamageEffect
|
||||
)
|
||||
|
||||
@@ -6,4 +6,4 @@ import Dodge.Creature.ChainUpdates
|
||||
|
||||
defaultImpulsive :: [World -> Creature -> Creature]
|
||||
-> Creature -> World -> World
|
||||
defaultImpulsive = stateUpdate . impulsiveAI' . chainCreatureUpdates
|
||||
defaultImpulsive = stateUpdate . impulsiveAIBefore . chainCreatureUpdates
|
||||
|
||||
Reference in New Issue
Block a user