Page 1 of 1

Ogre Cast Spells

Posted: Thu Apr 28, 2016 8:00 am
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

Re: Ogre Cast Spells

Posted: Thu Apr 28, 2016 8:50 am
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".

Re: Ogre Cast Spells

Posted: Thu Apr 28, 2016 11:11 pm
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)

Re: Ogre Cast Spells

Posted: Thu Apr 28, 2016 11:36 pm
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).

Re: Ogre Cast Spells

Posted: Fri Apr 29, 2016 10:37 am
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.