how to define a custom bomb?

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
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

how to define a custom bomb?

Post by bongobeat »

Hey all,
(continuing with the disintegrate things, humm...)
is their a way to define a custom bomb, which give physical damage, and after hit, it shows the disintegrate effect?

I did not find any particle system related to the disintegrate spell, where can it be find?

Actually I have done this with a new base_spell object: it works, but the particle effect is based on a blob particle and it don't give xp.
SpoilerShow

Code: Select all

defineObject{
	name = "star_bomb",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/shock_bomb.fbx",
		},
		{
			class = "Item",
			uiName = "Stars Bomb",
			gfxIndex = 90,
			gfxAtlas = "mod_assets/textures/oliveitem.tga",
			impactSound = "impact_blunt",
			stackable = true,
			projectileRotationSpeed = 10,
			projectileRotationZ = -30,
			weight = 0.8,
			traits = { "throwing_weapon" },
                        convertToItemOnImpact = "greater_blob_blast",
		},
		{
			class = "ThrowAttack",
			cooldown = 4,
		},
--		{
--			class = "BombItem",
--			bombType = "shock",
--			bombPower = 1000,
--		},
	},
	tags = { "weapon", "weapon_throwing" },
}

defineObject{
	name = "greater_blob_blast",
	baseObject = "base_spell",
	components = {
		{
			class = "Particle",
			particleSystem = "greater_blob_hit",
			destroyObject = true,
		},
		{
			class = "Light",
			color = vec(0.4, 0.5, 0.6),
			brightness = 60,
			range = 10,
			fadeOut = 0.5,
		},
		{
			class = "Sound",
			sound = "blob_hit",
		},
		{
			class = "TileDamager",
			name =  "damager1",
			attackPower = 1000,
			damageType = "physical",
			woundChance = 100,
		},
	},
}

defineParticleSystem{
	name = "greater_blob_hit",
	emitters = {
		-- sparks
		{
			spawnBurst = true,
			maxParticles = 80,
			boxMin = { 0.0, 0.5, 0.0},
			boxMax = { 0.0,  1.0, 0.0},
			sprayAngle = {0,360},
			velocity = {4,6},
			objectSpace = false,
			texture = "assets/textures/particles/teleporter.tga",
			lifetime = {0.2,0.6},
			color0 = {4.0,3.0,3.0},
			opacity = 1,
			fadeIn = 0.1,
			fadeOut = 0.3,
			size = {1.0, 4.0},
			gravity = {0,-6,0},
			airResistance = 1,
			rotationSpeed = 2,
			blendMode = "Additive",
		},

		-- fog
		{
			spawnBurst = true,
			maxParticles = 30,
			sprayAngle = {0,360},
			velocity = {0,3},
			objectSpace = true,
			texture = "assets/textures/particles/fog.tga",
			lifetime = {0.4,0.6},
			color0 = {0.4, 0.5, 0.6},
			opacity = 0.7,
			fadeIn = 0.1,
			fadeOut = 0.3,
			size = {2, 4},
			gravity = {0,0,0},
			airResistance = 0.5,
			rotationSpeed = 1,
			blendMode = "Additive",
		},

		-- glow
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 0,
			maxParticles = 1,
			boxMin = { 0.0, 0.5, 0.0},
			boxMax = { 0.0,  1.0, 0.0},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/glow.tga",
			lifetime = {0.5, 0.5},
			colorAnimation = false,
			color0 = {1, 1, 1},
			opacity = 1,
			fadeIn = 0.01,
			fadeOut = 0.5,
			size = {3, 6},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 2,
			blendMode = "Additive",
		}
	}
}
By the way, is there any other way to make a custom bomb which gives physical damage, without doing this?
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: how to define a custom bomb?

Post by Dr.Disaster »

This should be rather easy. "recipes.lua" in the scripts folder let's you add your own recipe for a custom bomb (within mortar limits) and "throwing_weapons.lua" in items subfolder let's you add your custom bomb definition which includes the damage type (bombType).
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: how to define a custom bomb?

Post by bongobeat »

do you realy need to make a new recipe for that?

I ve already try adding physical to the definition,
SpoilerShow

Code: Select all

		{
			class = "BombItem",
			damageType = "physical",
			bombPower = 1000,
		},
this don't work.
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
Dr.Disaster
Posts: 2876
Joined: Wed Aug 15, 2012 11:48 am

Re: how to define a custom bomb?

Post by Dr.Disaster »

bongobeat wrote:do you realy need to make a new recipe for that?
It's only needed if you want to give the player the ability to make (more of) them.
bongobeat wrote:I ve already try adding physical to the definition,
SpoilerShow

Code: Select all

		{
			class = "BombItem",
			damageType = "physical",
			bombPower = 1000,
		},
this don't work.
I don't think "damageType" is a supported variable here. Looking at the modding section info it has to be "bombType".
User avatar
Frenchie
Posts: 219
Joined: Wed Oct 16, 2013 2:50 am

Re: how to define a custom bomb?

Post by Frenchie »

If it wasn't a spell, what exactly would this bomb be? A hand grenade that looks like any of elemental flasks or is a cannonball with a fuse? If the latter is true, then it's a new ammo for the hand cannon. The bomb could also be a small barrel with a long trail of gunpowder used to blow up caved in passages.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: how to define a custom bomb?

Post by minmay »

bongobeat wrote:I did not find any particle system related to the disintegrate spell, where can it be find?
It's in assets/scripts/monsters/wizard.lua.
bongobeat wrote:Actually I have done this with a new base_spell object: it works, but the particle effect is based on a blob particle and it don't give xp.
Here's one that has the disintegrate particle effect and sound and should give XP:

Code: Select all

defineObject{
	name = "greater_blob_blast",
	baseObject = "base_spell",
	components = {
		{
			class = "Particle",
			particleSystem = "wizard_explosion",
			offset = vec(0, 1.3, 0),
		},
		{
			class = "Light",
			color = vec(0.5, 0.75, 1.2),
			brightness = 10,
			range = 12,
			offset = vec(0, 1.3, 0),
			fadeOut = 1.5,
			destroyObject = true,
		},
		{
			class = "Sound",
			sound = "force_field_cast",
		},
		{
			class = "TileDamager",
			name =  "damager1",
			attackPower = 1000,
			damageType = "physical",
			woundChance = 100,
			onInit = function(self)
				-- Award experience.
				self:setDamageFlags(DamageFlags.Champion1)
			end
		},
	},
}
bongobeat wrote:By the way, is there any other way to make a custom bomb which gives physical damage, without doing this?
No, BombItemComponent is very limited.
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.
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: how to define a custom bomb?

Post by bongobeat »

Frenchie wrote:If it wasn't a spell, what exactly would this bomb be? A hand grenade that looks like any of elemental flasks or is a cannonball with a fuse? If the latter is true, then it's a new ammo for the hand cannon. The bomb could also be a small barrel with a long trail of gunpowder used to blow up caved in passages.
It's a bomb, just more powerful. But your new ammo is a good idea :)
it's same thing than the death bomb by Daveyx0, it just do only physical damage. It's an idea inspired by the disintegrate spell, but not as fatal as the spell.

seems that there is no other way to make custom bomb or spells
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: how to define a custom bomb?

Post by bongobeat »

minmay wrote:
bongobeat wrote:I did not find any particle system related to the disintegrate spell, where can it be find?
It's in assets/scripts/monsters/wizard.lua.
bongobeat wrote:Actually I have done this with a new base_spell object: it works, but the particle effect is based on a blob particle and it don't give xp.
Here's one that has the disintegrate particle effect and sound and should give XP:

Code: Select all

defineObject{
	name = "greater_blob_blast",
	baseObject = "base_spell",
	components = {
		{
			class = "Particle",
			particleSystem = "wizard_explosion",
			offset = vec(0, 1.3, 0),
		},
		{
			class = "Light",
			color = vec(0.5, 0.75, 1.2),
			brightness = 10,
			range = 12,
			offset = vec(0, 1.3, 0),
			fadeOut = 1.5,
			destroyObject = true,
		},
		{
			class = "Sound",
			sound = "force_field_cast",
		},
		{
			class = "TileDamager",
			name =  "damager1",
			attackPower = 1000,
			damageType = "physical",
			woundChance = 100,
			onInit = function(self)
				-- Award experience.
				self:setDamageFlags(DamageFlags.Champion1)
			end
		},
	},
}
bongobeat wrote:By the way, is there any other way to make a custom bomb which gives physical damage, without doing this?
No, BombItemComponent is very limited.
thanks a lot! :D
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: how to define a custom bomb?

Post by petri »

This will be possible with 2.2.3:

Code: Select all

defineObject{
	name = "bio_bomb",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/poison_bomb.fbx",
		},
		{
			class = "Item",
			uiName = "Bio Bomb",
			gfxIndex = 138,
			impactSound = "impact_blunt",
			stackable = true,
			projectileRotationSpeed = 10,
			projectileRotationZ = -30,
			weight = 0.8,
			traits = { "throwing_weapon" },
		},
		{
			class = "ThrowAttack",
			cooldown = 4,
		},
		{
			class = "BombItem",
			onExplode = function(self, level, x, y, facing, elevation)
				spawn("herder_small", level, x, y, facing, elevation)
				return false
			end,
		},
	},
	tags = { "weapon", "weapon_throwing" },
}
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

Re: how to define a custom bomb?

Post by bongobeat »

this looks cool! :lol:
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply