module Dodge.Creature.ChaseCrit
    (smallChaseCrit
    ,chaseCrit
    ) where
import Dodge.Data
import Dodge.Default
import Dodge.Creature.Picture
import Dodge.Creature.ReaderUpdate
import Dodge.Creature.Impulse
import Dodge.Creature.Action
import Dodge.Creature.Perception
import Dodge.Creature.State
import Dodge.Creature.State.Data
import Dodge.Item.Consumable
import Dodge.Picture.Layer
--import Geometry
import Picture
--import Dodge.RandomHelp

--import Data.Maybe
import qualified Data.IntMap.Strict as IM
import Control.Lens
import Control.Monad
--import System.Random

smallChaseCrit :: Creature
smallChaseCrit = chaseCrit
    { _crHP = 1
    , _crRad = 4
    , _crPict = basicCrPict green
    , _crInv = IM.fromList [(0,medkit 200)]
    , _crCorpse = onLayer CorpseLayer $ color (greyN 0.5) $ circleSolid 4
    }
chaseCrit :: Creature
chaseCrit = defaultCreature
    { _crUpdate = stateUpdate $ --dummyUpdate
        impulsiveAIR $ 
        doStrategyActionsR >=>
        performActionsR >=>
        overrideMeleeCloseTargetR >=>
        setViewPos >=>
        setMvPos >=>
--        setTargetMv (pure . _crTarget) >=>
        goToTarget >=>
        perceptionUpdate [0] >=>
        targetYouWhenCognizantR >=>
        return . (crMeleeCooldown %~ max 0 . subtract 1)
    , _crHP = 300
    , _crPict = basicCrPict green
    , _crInv = IM.fromList [(0,medkit 200)]
    , _crMeleeCooldown = 0
    , _crFaction = ColorFaction green
    , _crMvType = ChaseMvType
        { _mvSpeed = 3
        , _mvTurnRad = f
        , _mvTurnJit = 0.2
        }
    }
  where
    f x | x > pi / 4 = 0.2
        | otherwise  = 0.05
