Ogre Cast Spells

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
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Ogre Cast Spells

Post by Mysterious »

I would like to know if the Forest Ogre can be changed to a Spell casting Ogre rather than a meele attacking one. I do not have a clue on how to do this or if it would work. Has anyone got one or know how to do the code for one?

I looked at some of the spell casters in LOG 2 files but I really cannot figure it out, how to stop the meele attack and just make him cast some spells at the party.

Any help please on how to do this. Thank you
User avatar
THOM
Posts: 1281
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Ogre Cast Spells

Post by THOM »

If you mean, istead of smashing the party the ogre should cast a spell, for example a poison-cloud, you just need to change the entries at the attack component.
Mind that he will still use the animation for hitting.

If you mean he should use a ranged spell (poison bolt) you must
- give him a brain that uses ranged attacks
- change his attack-component to a ranged-attack component (or add this)

Still he will use the hit-animation.

To make it perfect you should also create a new animation where the ogre makes a "casting-gesture".
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: Ogre Cast Spells

Post by bongobeat »

you have to check other monster definition to make you an idea:

e.g: the ice guardian has some spell definition in his basic attack.

here is my ogre mage version for basic and turn attack:
SpoilerShow

Code: Select all

		{
			class = "MonsterAttack",
			name = "basicAttack",
			attackPower = 90,
			woundChance = 50,
			accuracy = 60,
			cooldown = 4,
			sound = "ogre_attack",
			impactSound = "ogre_impact",
			cameraShake = true,
			screenEffect = "damage_screen",
			onBeginAction = function(self)
				-- randomize animation
				if math.random() < 0.5 then
					self:setAnimation("attack")
				else
					self:setAnimation("attack2")
				end
			end,
			onAttack = function(self)
				local dx,dy = getForward(self.go.facing)
				local x = self.go.x + dx
				local y = self.go.y + dy
				local spell = spawn("wall_fire", self.go.level, x, y, self.go.facing, self.go.elevation)
				spell.tiledamager:setAttackPower(100)
			end,
		},
		{
			class = "MonsterAttack",
			name = "turnAttack",
			attackPower = 130,
			woundChance = 50,
			accuracy = 60,
			cooldown = 4,
			sound = "ogre_attack",
			impactSound = "ogre_impact",
			turnToAttackDirection = true,
			cameraShake = true,
			screenEffect = "damage_screen",
			onAttack = function(self)
				local dx,dy = getForward(self.go.facing)
				local x = self.go.x + dx
				local y = self.go.y + dy
				local spell = spawn("ice_shards", self.go.level, x, y, self.go.facing, self.go.elevation)
				spell.tiledamager:setAttackPower(100)
			end,
		},
when the ogres turns to attack you it use melee damage and cast an ice shards,
same thing for the front attack, melee + a wall of fire.

(note that in these spell the attackpower is 100, which is very high for a basic monster)
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Ogre Cast Spells

Post by minmay »

Also note that bongobeat's approach will still leave the monster with its regular melee attack; the "spells" are just tacked onto it. If you don't want a melee attack, either set the MonsterAttackComponent's shootProjectile field (if you just want to shoot a projectile) or use a plain MonsterActionComponent (if you want to do something else).
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.
User avatar
Mysterious
Posts: 226
Joined: Wed Nov 06, 2013 8:31 am

Re: Ogre Cast Spells

Post by Mysterious »

minmay wrote:Also note that bongobeat's approach will still leave the monster with its regular melee attack; the "spells" are just tacked onto it. If you don't want a melee attack, either set the MonsterAttackComponent's shootProjectile field (if you just want to shoot a projectile) or use a plain MonsterActionComponent (if you want to do something else).
Hi Minmay. I am sorry but I really don't know what you mean. Thxs Bongo for the code. Once again I am finding it hard to comprehend. I am not the best at coding even though I am trying to understand how it all works. I think I have bitten of more than I can chew. Thank you for the help guys.
Post Reply