Giving monsters new abilities

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
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Giving monsters new abilities

Post 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.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Giving monsters new abilities

Post 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.
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Re: Giving monsters new abilities

Post 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.
User avatar
Isaac
Posts: 3192
Joined: Fri Mar 02, 2012 10:02 pm

Re: Giving monsters new abilities

Post 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.
Eburt
Posts: 69
Joined: Thu Feb 05, 2015 5:44 am

Re: Giving monsters new abilities

Post 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.
Post Reply