Fire the CANNONS!

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

Fire the CANNONS!

Post by Emera Nova »

So I'm working on something at the moment and I'd like to make it so after some text pops up (AKA Fire the cannons) a few spawners will be triggered to fire a cannonball at the party much like if you had the ratling boss firing his cannon. How do I set it up so that I have a projectile that is a cannonball that I can have shot out of a spawner.

Code: Select all

defineObject{
	name = "test_cannonball",
	baseObject = "cannon_ball",
	components = {
		{
			class = "Model",
			model = "assets/models/items/cannon_ball.fbx",
		},
		{
			class = "Projectile",
			impactSound = "gun_shot_cannon",
			spawnOffsetY = 1.35,
			velocity = 10,
			projectileRotationSpeed = 10,
			projectileRotationZ = -30,
			radius = 0.1,
		},
	},
}
xD this works as far as shooting a ball at the party but it doesn't deal damage, it also throws up an error after hitting the party.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Fire the CANNONS!

Post by minmay »

1. cannon shots aren't projectiles, firearm attacks don't work like projectiles at all. They are arguably more similar to melee attacks. Look at the definitions for ratlings to see how to make a firearm attack without using an item with a FirearmAttackComponent.

2. you are getting an error because you are trying to make a thrown item by adding a ProjectileComponent yourself. You should NEVER manually add a ProjectileComponent to an object with an ItemComponent. You HAVE to use ItemComponent:throwItem().
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: Fire the CANNONS!

Post by Emera Nova »

Thanks minmay, I'll take a look at that, for now I've put in the ratling boss without the ability to move and his model turned off so he can fire off the attack.
Post Reply