Brains

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!
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Brains

Post by JKos »

I just leave this here ;)

Code: Select all

defineObject{
   name = "herder_ai_test",
   baseObject = "herder",
   components = {
	{
		class = 'Brain',
		onThink = function(self) 
			self:turnLeft()
		end,
		onThinkSpecial = function(self,arg1,arg2,arg3) 
			self:turnRight()
		end,		
	}
}
}
Let the brain surgery begin. :ugeek:
- 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
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: Brains

Post by Prozail »

I've been playing around with that thing lots yesterday.. still havn't gotten very far.
I tried to get a herder to go pull a lever when they spot the party, but it seems it's more complicated than i first thought.

Some of the basic herder stuff (like chasing after the party) i couldn't get rid of, so it kindof conflicted with moving toward a lever.... then i went on trying the tricksterbrain instead and that got REALLY messy.
User avatar
Isaac
Posts: 3179
Joined: Fri Mar 02, 2012 10:02 pm

Re: Brains

Post by Isaac »

Hopefully we will get a plain text version of the Trickster brain in the asset pack, or perhaps Petri will post snippets of it in this thread. 8-)
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Brains

Post by JKos »

This script makes the herder_test move to the lever_1 after it has seen the party.

Code: Select all

defineObject{
   name = "herder_test",
   baseObject = "herder",
   components = {
	{
		class = 'Brain',
		onThink = function(self) 
			if self.partyLastSeen ~= 0 then
				self:goTo("lever_1")
			end		
		end
	}
}
}

Harder can't operate devices, it doesn't have the animation for it.
- 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
User avatar
Isaac
Posts: 3179
Joined: Fri Mar 02, 2012 10:02 pm

Re: Brains

Post by Isaac »

JKos wrote:Harder can't operate devices, it doesn't have the animation for it.
That can change... but we might not want that with herders; other monsters though. :)
User avatar
Prozail
Posts: 158
Joined: Mon Oct 27, 2014 3:36 pm

Re: Brains

Post by Prozail »

ooo. nice one!
I'll have to try that tomorrow. I totally missed the "goTo" function.

i was playing around with giving it the MonsterOperateDeviceComponent, and pointed the animation to the attack anim.... and got it to actually play that once i managed to lure it over to a lever..

so.. lets see tomorrow :)
User avatar
sps999
Posts: 44
Joined: Sun Oct 26, 2014 11:16 pm

Re: Brains

Post by sps999 »

Code: Select all

      onThink = function(self) 
         self:flee()
      end,

Code: Select all

function speedUp()
	herderTest.move:setCooldown(0)
	herderTest.move:setAnimationSpeed(5)
	herderTest.turn:setCooldown(0)
	herderTest.turn:setAnimationSpeed(5)
end
speedUp()
Runaway herder coming through.

Would be cool to hook this up to occur when the herder is on fire, seeing as there is a "BurningMonsterComponent". No idea how to handle that one though.
User avatar
Eleven Warrior
Posts: 736
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Brains

Post by Eleven Warrior »

If you placed a floor trigger in front of the lever_2 which activates a Script, which the floor trigger is activated by Monster only, the door could open I think? I don't know the Script for this.
User avatar
JKos
Posts: 464
Joined: Wed Sep 12, 2012 10:03 pm
Location: Finland
Contact:

Re: Brains

Post by JKos »

Well you can do it by scripting for example like this:


herder_ai_test script entity

Code: Select all

state = "begin"

function onThink(self)
	if state == "begin" and self.partyLastSeen ~= 0 then
		if self:goTo("lever_1") then
			state = "operate"
		end
	end
	if state == "operate" then
		lever_1.lever:toggle()
		state = "end"
	end
end
just call herder_ai_test.script.onThink(self) from the onThink hook. But floor trigger works too of course.
- 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
User avatar
Doridion
Posts: 256
Joined: Tue Jun 10, 2014 9:23 pm

Re: Brains

Post by Doridion »

JKos wrote:Harder can't operate devices, it doesn't have the animation for it.
Haven't got the animation, but seems got the .Operate("") function ( Thanks for all componements JKos ;) ).

Is something like :

Code: Select all

defineObject{
   name = "herder_test",
   baseObject = "herder",
   components = {
   {
      class = 'Brain',
      onThink = function(self)
         if self.partyLastSeen ~= 0 then
            while lever_1.getPosition ~= self.getPosition do
               self:goTo("lever_1")
            else
               self:Operate("lever_1")
            end
         end      
      end
   }
}
could be better ?
Post Reply