Cannon that spawns after hit

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

Cannon that spawns after hit

Post by Emera Nova »

So I recently just finished working on a pistol that could give a monster a status effect after being hit with the special attack. Next I'd like to just for the shits and giggles to work out a cannon that would after it lands a hit on an enemy or object check for the position and then either spawn say fireballs on that position or around it.

I was thinking that maybe a way to get around having to position check and all that would to just make when the cannon fires it shoots out a magma golums fireball so that it hits with damage plus doing an effective area damage.

Any idea's on how to make the secondaryAttack that I'm looking for here work right?
Going to try to work on the Magma Golum idea and see if it works how I think it should.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Cannon that spawns after hit

Post by minmay »

FirearmAttackComponent is kind of like a melee attack, it doesn't make a projectile that you can attach an onProjectileHit hook to. But unlike MeleeAttackComponent it also doesn't have an onHitMonster hook. I'm curious what you did to give the monster a "status effect after being hit" - did you use the MonsterComponent.onDamage hook? That's gross but also the only way I can think of to do it...

edit: welp, apparently I was wrong. I could swear I checked for the existence of FirearmAttackComponent.onHitMonster in an earlier version of the game, at least...
Last edited by minmay on Fri Aug 14, 2015 8:11 pm, edited 1 time in total.
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.
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Re: Cannon that spawns after hit

Post by Emera Nova »

This is what I used to give the monster a status effect

Code: Select all

{
			class = "FirearmAttack",
			name = "mark",
			gameEffect = "Cause lingering damage over time",
			uiName = "Mark of the Devourer",
			cooldown = 8,
			energyCost = 25,
			ammo = "pellet",
			attackPower = 10,
			onHitMonster = function(self, monster)
				monster:setCondition("poisoned", 18)

				-- mark condition so that exp is awarded if monster is killed by the condition
				local poisonedCondition = monster.go.poisoned
				if poisonedCondition then
					poisonedCondition:setCausedByChampion(1)
				end
				end,
			requirements = { "firearms", 2, "critical", 1 }
		},
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Re: Cannon that spawns after hit

Post by Emera Nova »

And Ok so if I make it a CastSpell instead and shoot out say a fireball, how can I get it so afterwards on the hit it will check for hte position of where it blew up and then spawn wall_fire in the squares around it if open. It turns out that the magma golem doesn't use a spell on it so I can't just call on the magma_meteor.
Post Reply