Wish there was more info on the Brain component
Wish there was more info on the Brain component
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......
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
I'm sure there will be more info when the scripting reference is finished.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Wish there was more info on the Brain component
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
function onThink()
if something:goTo("lever_1") then
print("I AM HERE!")
end
end
Links to my YouTube playlist of "tutorials" and to my forum thread.
Re: Wish there was more info on the Brain component
Other examples can be found here:
viewtopic.php?f=22&t=7918
viewtopic.php?f=22&t=7918
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
Re: Wish there was more info on the Brain component
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?
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
@JKos,
I looked at all the examples you gave in the other post. I have a question about this code:
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
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,
Thanks
Re: Wish there was more info on the Brain component
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?
- LoG Framework 2http://sites.google.com/site/jkoslog2 Define hooks in runtime by entity.name or entity.id + multiple hooks support.
- cloneObject viewtopic.php?f=22&t=8450
- cloneObject viewtopic.php?f=22&t=8450
Re: Wish there was more info on the Brain component
Ok thanks. I will keep trying to figure it out.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?
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
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.
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
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)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.
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.