Page 1 of 2

Wish there was more info on the Brain component

Posted: Tue Nov 11, 2014 4:10 am
by MrChoke
My next challenge is to see if I can get some custom AI going. I know this is going be tough. For starters, there are a few BrainComponent functions that I wish I understood more.
Take these for example:

BrainComponent:goTo(string)
BrainComponent:here(string)

They want a string input. But what is the string? And what do they do? I am thinking goto means go to a square? But wouldn't it need at least two parameters?

BrainComponent:operate(string)
BrainComponent:seek(number)

Two more functions. No idea what the input is or what they do. I wish I did. I have so many ideas......

Re: Wish there was more info on the Brain component

Posted: Tue Nov 11, 2014 5:58 am
by minmay
I'm sure there will be more info when the scripting reference is finished.

Re: Wish there was more info on the Brain component

Posted: Tue Nov 11, 2014 9:22 am
by Prozail
goTo atleast takes an item-id as input... so you can do

function onThink()
if something:goTo("lever_1") then
print("I AM HERE!")
end
end

Re: Wish there was more info on the Brain component

Posted: Tue Nov 11, 2014 1:46 pm
by JKos
Other examples can be found here:
viewtopic.php?f=22&t=7918

Re: Wish there was more info on the Brain component

Posted: Tue Nov 11, 2014 2:47 pm
by MrChoke
I did figure out a few on my own too after the post.

BrainComponent:goTo(string)
Input is the id of an object to move to. It will only work if the monster is on the same level as object

BrainComponent:here(string)
Input is an object ID again and reports true if the monster is in the same square as the object

I cannot seem to get a few others to work:

BrainComponent:openLockWith(string, string)
I assume these are IDs again. Is it lock_Id then key_id? I have tried every combination I can think of.

BrainComponent:operate(string)
This is for levers and buttons? I cannot get him to operate a button. I didn't try a lever yet, I will do that


JKos, I read the post you gave. Perhaps I couldn't get it to work because of the monster I was using. I used a skeleton_trooper. I will see about using a Herder since that was in the post.

This next one I didn't try yet and I really don't know what the input should be:
BrainComponent:seek(number)

Seek what? With what number?

Re: Wish there was more info on the Brain component

Posted: Tue Nov 11, 2014 3:11 pm
by MrChoke
@JKos,
I looked at all the examples you gave in the other post. I have a question about this code:

Code: Select all

  onThink = function(self) 
         self:turnLeft()
      end,
      onThinkSpecial = function(self,arg1,arg2,arg3) 
         self:turnRight()
      end,     
I see onThinkSpecial() defined for a Trickster brain. Believe or not I didn't finish the game yet so I am not sure who this guy is!! So is onThinkSpeical() called each time onThink() is? Is there any difference?

Thanks

Re: Wish there was more info on the Brain component

Posted: Tue Nov 11, 2014 5:23 pm
by JKos
That example was before when the official scripting reference was released, I dug those hooks from .dat file and thought that they were both available for normal BrainComponent. I haven't played with trickster brain yet, so I don't know when onThinkSpecial is called. Maybe someone else does?

Re: Wish there was more info on the Brain component

Posted: Tue Nov 11, 2014 5:26 pm
by MrChoke
JKos wrote:That example was before when the official scripting reference was released, I dug those hooks from .dat file and thought that they were both available for normal BrainComponent. I haven't played with trickster brain yet, so I don't know when onThinkSpecial is called. Maybe someone else does?
Ok thanks. I will keep trying to figure it out.

Do you know anything about seek(), openWithLock() or operate()? I couldn't get operate() or openWithLock() to work but maybe I need to use another monster.

Re: Wish there was more info on the Brain component

Posted: Thu Nov 13, 2014 4:15 pm
by Aisuu
Sorry to jumping into your topic. But I have difficulty with brains too.
I need to script monster to patroll. For example going in circle, or from left to right guarding something. Then, as soon as monster see party, he go after them and forget patrolling :)
I also need to create neutral monster. Completely ignoring party, but become aggressive after party attack it.

Re: Wish there was more info on the Brain component

Posted: Thu Nov 13, 2014 7:59 pm
by MrChoke
Aisuu wrote:Sorry to jumping into your topic. But I have difficulty with brains too.
I need to script monster to patroll. For example going in circle, or from left to right guarding something. Then, as soon as monster see party, he go after them and forget patrolling :)
I also need to create neutral monster. Completely ignoring party, but become aggressive after party attack it.
Sounds like you want it to do some complicated stuff. All I can say is the way it works is you have to "override" a monster's default behavior in the onThink() hook and you need to keep having it override on every thought trigger. OnThink() is called multiple times before an action is made. It is called a ton. As soon as you stop telling the monster what to do in onThink() he will go back to his default behavior, whatever that may be (must depend on the specific BrainComponent)

I have found out the hard way that some Brain commands simply will not work for all but certain monsters. The trickster is by far the most advanced. But I believe all monsters will respond to turn commands, guard, move, flee, move toward party, etc... They also respond to seek() which tells him to go to a certain square or goTo() which tells him to go to an object as long as it is on the same level.