Wish there was more info on the Brain component

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Wish there was more info on the Brain component

Post by Soaponarope »

Trying to figure out brain scripts and not getting it. I even just tried to make the trickster move by doing what AH did in the twigroot tunnels and it's still not working.

Floor trigger activates this;

function startTrickster()
if cell_trickster then
local brain = cell_trickster.brain
brain:enable()
cell_trickster.rangedAttack:disable()
end
end

So far so good, trickster is active and does not attack

Trickster brain script;

function think(self)
if self:here("floor_target") then
return self:performAction("escape")
else
return self:goTo("floor target")
end
end

Trickster won't go to the spot. Please help
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Wish there was more info on the Brain component

Post by msyblade »

add an underline to the 2nd "floor_trigger" line. Also, make sure your trickster is named cell_trickster.

Hope it works for you!
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: Wish there was more info on the Brain component

Post by MrChoke »

Soaponarope wrote:Trying to figure out brain scripts and not getting it. I even just tried to make the trickster move by doing what AH did in the twigroot tunnels and it's still not working.

Floor trigger activates this;

function startTrickster()
if cell_trickster then
local brain = cell_trickster.brain
brain:enable()
cell_trickster.rangedAttack:disable()
end
end

So far so good, trickster is active and does not attack

Trickster brain script;

function think(self)
if self:here("floor_target") then
return self:performAction("escape")
else
return self:goTo("floor target")
end
end

Trickster won't go to the spot. Please help
A few quick questions, though you probably are doing them right. You added the onThink() hook and the "think" function is being called correct?
Second question, "floor_target" is an object ID and the object is on the same floor as Trickster?

Oh wait! You missed the underscore for "floor_target" in the goTo() line:
return self:goTo("floor target")

No underscore means it is not a valid ID and he won't go there.

NOTE: I hope its a fairly easy path to get to "floor_target". One thing I have found with the pathfinding AI is if its a complicated path, he can get stuck and not move at all. :( I actually had to build my own pathfinding logic to make up for this. Anyway, hopefully the path is easy enough to get there.
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Wish there was more info on the Brain component

Post by Soaponarope »

You gotta be f#!king kidding me...

Thank you, it works. :lol:

Now to do what I actually want to have happen.

think was simply the name of the function, no onThink hook is needed when using think(self) on a monster brain

second question yes to both :)
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Wish there was more info on the Brain component

Post by Soaponarope »

Had this working, then not...

Why is this working,

function think(self)
if self:here("trickster_lock_1") then
if cell_door_2.door:isOpen()then return self:performAction("escape")
else
return self:operate("trickster_lock_1")
end
else
return self:goTo("trickster_lock_1")
end
end

but not this,

function think(self)
if self:here("trickster_lock_1") then
if cell_door_2.door:isOpen()then return self:goTo("cell_trickster_target_1")
else
return self:operate("trickster_lock_1")
end
else
return self:goTo("trickster_lock_1")
end
end

Can you only use one goTo command?
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: Wish there was more info on the Brain component

Post by MrChoke »

Both versions look ok. I don't know your map to know where this is going:

self:goTo("cell_trickster_target_1")

If that object is in a place he knows he cannot reach, he will ignore the command.
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Wish there was more info on the Brain component

Post by Soaponarope »

It is going to a place easy for him to get to. I even moved it 2 spaces away and it still wouldn't work. Positive there are no typos this time too.
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: Wish there was more info on the Brain component

Post by Prozail »

once makes one move towards "cell_trickster_target_1", he is no longer by the lock, and will start moving towards the lock instead.
MrChoke
Posts: 324
Joined: Sat Oct 25, 2014 7:20 pm

Re: Wish there was more info on the Brain component

Post by MrChoke »

Soaponarope wrote:It is going to a place easy for him to get to. I even moved it 2 spaces away and it still wouldn't work. Positive there are no typos this time too.
OK, I see it now. Didn't before because lack of indention in the code (suggest using tags next time.

So your code has the trickster moving toward the lock until he reaches it (here() returns true). However, it is in this condition that you then tell him to move toward target one. As soon as he steps off the square where the lock is, here() is false again and he turns around and moves right back to the lock.

You need to change the code to have him moving toward target without having to be at the lock first.
User avatar
Soaponarope
Posts: 180
Joined: Thu Oct 04, 2012 3:21 am

Re: Wish there was more info on the Brain component

Post by Soaponarope »

Hmm, thanks guys I see what you mean.

My idea involved going from one spot to another so he would have to be at a previous spot first. I may just keep this brain stuff simple since more complicated scripts are a pain for me without scripting experience.
Really like the editor though and learn something new each time.
Post Reply

Return to “Mod Creation”