require "behaviours/chaseandattack"
require "behaviours/runaway"
require "behaviours/wander"
require "behaviours/doaction"
require "behaviours/attackwall"
require "behaviours/panic"
require "behaviours/minperiod"
require "behaviours/chaseandram"

local NO_TAGS = { "FX", "NOCLICK", "DECOR", "INLIMBO", "burnt" }

--Here we create a new brain 
local hooh_brain = Class(Brain, function(self, inst)
    Brain._ctor(self, inst)
end)

--This function sets up our brain's 'behavior tree'.  A behavior tree is just a prioritized list of behaviors.  
--In this case, our creature's first priority is always to runaway and it's second priority is to stand around 
--looking pretty.  You can find more behaviours in the game's data/scripts/behaviours folder.
function hooh_brain:OnStart()

	--Some behavior trees have multiple priority nodes.  Ours has a single node with two behaviours.    
    local root = PriorityNode(
    {
    	--Here we tell our creature to 'RunAway' from anything in the game tagged as 'scarytoprey' and then we 
        --specify the distances we want to start and stop running at.
        ChaseAndAttack(self.inst, 20, 60, nil, nil, true),

        --Here we tell our creature that if it's not running away, it should simply stand still.
        StandStill(self.inst, function() return true end),

    --This tells the creature to check every 0.25 seconds if it should be changing which behaviour it's doing.
    }, .25)
    
    --Now we attach the behaviour tree to our brain.
    self.bt = BT(self.inst, root)
    
end

--Register our new brain so that it can later be attached to any creature we create.
return hooh_brain
