Page 1 of 1

Giving monsters new abilities

Posted: Thu Apr 02, 2015 3:01 pm
by Emera Nova
So I want to try to give the uggaurdian the ability to summon in fire elementals like the skeleton commander, for the time being I don't have anything for a new animation so it would just appear after the command is given.

What I want to know is it possible to give it that ability with this

Code: Select all

{
			class = "MonsterAttack",
			name = "summonUndead",
			cooldown = 10,
			repeatChance = 0,
			animation = "summonUndead",
			sound = "skeleton_commander_summon_spell",
			onAttack = function(self)
				for tries=1,20 do
					-- choose summon location
					local dx,dy = getForward(self.go.facing)
					local x = self.go.x + math.random(-1,1)
					local y = self.go.y + math.random(-1,1)
					
					-- is valid spawn point?
					local map = self.go.map
					local elevation = map:getElevation(x, y)
					if not map:isBlocked(x, y, elevation) then
						spawn("hell_fire_elemental", self.go.level, x, y, self.go.facing, elevation)
						return
					end
				end
			end,
		},
I put that in the .lua file and it showed up in game as an option to click on but when it came down to fighting the monster it didn't summon anything.

Re: Giving monsters new abilities

Posted: Thu Apr 02, 2015 3:13 pm
by Isaac
I haven't really experimented with custom actions yet, but I think your answer lays here: http://www.grimrock.net/modding/scripti ... nComponent

*Though I have not checked, it may be as simple as using the skeleton commander's brain. Or roll your own onThink hook to decide when to do the summons.

Re: Giving monsters new abilities

Posted: Thu Apr 02, 2015 3:22 pm
by Emera Nova
Is there a way to look at what is inside the Brain script? I'm looking thru the asset pack and nothing jumps out with a clear direction on where to go. On the monsters .lua file it just shows that the brain is set for itself but doesn't seem to be an editable object.

Re: Giving monsters new abilities

Posted: Thu Apr 02, 2015 4:26 pm
by Isaac
I had originally hoped to see the Trickster's brain in the asset pack, but it would seem that the built in brains are really ~built in.

Re: Giving monsters new abilities

Posted: Fri Apr 03, 2015 1:13 am
by Eburt
Shameless plug for a thread that explains how to do this.

It's not really hard - you can use the uggardian brain and just give it an onThink component with some condition to cast and it will override whatever it would do instead... also, just an aside, but I would consider increasing the cooldown on that ability as it could be pretty brutal. Oh, and the game may crash with that animation, because it isn't defined for an uggardian... but it may just throw an error.