Damage Type on Throwing Weapons

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
mythos
Posts: 14
Joined: Fri Oct 24, 2014 2:04 am

Damage Type on Throwing Weapons

Post by mythos »

I can't seem to find the correct definition to change the damage type for throwing weapons. For example I am trying to make a throwing knife that does fire damage. Is this possible? I have been able to create elemental based weapons for everything else without issue. Any help would be appreciated.
User avatar
Zo Kath Ra
Posts: 941
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Damage Type on Throwing Weapons

Post by Zo Kath Ra »

mythos wrote:I can't seem to find the correct definition to change the damage type for throwing weapons. For example I am trying to make a throwing knife that does fire damage. Is this possible? I have been able to create elemental based weapons for everything else without issue. Any help would be appreciated.
The only solution I can think of is to use
ItemComponent.onThrowAttackHitMonster(self, monster)
and then spawning a TileDamager on the monster's location.
mythos
Posts: 14
Joined: Fri Oct 24, 2014 2:04 am

Re: Damage Type on Throwing Weapons

Post by mythos »

That's a good suggestion. I found another workground by applying a bombItem class to the weapon. Only problem now is the item is consumed. Is there anyway to edit the bomb mechanics or create a new one that doesn't consume the item?

Thanks!
User avatar
Isaac
Posts: 3191
Joined: Fri Mar 02, 2012 10:02 pm

Re: Damage Type on Throwing Weapons

Post by Isaac »

Zo Kath Ra wrote:and then spawning a TileDamager on the monster's location.
But (as we know) tile damager would burn the whole troop, not just the target; in cases of grouped attackers.

*And for that we could as well make a knife shaped fire-bomb... but an over powered one, as it isn't destroyed upon use.

Here is one (if slightly overpowered) way to do a burning throwing knife:

https://www.dropbox.com/s/8n4oufxwktep4 ... e.avi?dl=0

Code: Select all

defineObject{
	name = "throwing_knife_fire_effect",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/knife.fbx",
		},
		{
			class = "Item",
			gameEffect = "50% chance of immolating the target.",
			UiName = "Immolating Throwing Knife",
			gfxAtlas = "assets/textures/gui/items_2.tga",
			gfxIndex = 28,
			impactSound = "impact_blade",
			stackable = false, --MUST BE FALSE
			sharpProjectile = true,
			weight = 0.5,
			projectileRotationSpeed = -20,
			projectileRotationX = 90,
			projectileRotationY = 90,
			traits = { "throwing_weapon" },
			onEquipItem = function(self, champion, slot) self.go.item:setGameEffect("50% chance of immolating the target.") end,
			onThrowAttackHitMonster = function(self, monster) 
							--optional random failure ~to offset the significant damage a successful immolation attack inflicts.
							if math.random() >.5 then 
								monster.go:createComponent("BurningMonster")
								local champ = tonumber(self.go.item:getGameEffect())
								if champ and type(champ) == "number" then
									monster.go.burningmonster:setCausedByChampion(champ)
								
								--optional
									local output = string.gsub(party.party:getChampionByOrdinal(champ):getName().."\'s "..self.go.item:getUiName().." set the "..monster.go.name.." ablaze.", "%d" , " ")
									hudPrint(string.gsub(output, "_", " "))
								end
							end
						end,
						
		},
		{
			class = "ThrowAttack",
			attackPower = 9,
			cooldown = 4,
			onPostAttack = function(self, champion, slot) 
					self.go.item:setGameEffect(champion:getOrdinal())
				end,
		},
	},
	tags = { "weapon", "weapon_throwing" },
}
Last edited by Isaac on Thu Nov 26, 2015 10:42 am, edited 2 times in total.
mythos
Posts: 14
Joined: Fri Oct 24, 2014 2:04 am

Re: Damage Type on Throwing Weapons

Post by mythos »

Isaac wrote:
Zo Kath Ra wrote:and then spawning a TileDamager on the monster's location.
But (as we know) tile damager would burn the whole troop, not just the target; in cases of grouped attackers.

*And for that we could as well make a knife shaped fire-bomb... but an over powered one, as it isn't destroyed upon use.

Here is one (if slightly overpowered) way to do a burning throwing knife:

https://www.dropbox.com/s/8n4oufxwktep4 ... e.avi?dl=0

Code: Select all

defineObject{
	name = "throwing_knife_fire_effect",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/knife.fbx",
		},
		{
			class = "Item",
			gameEffect = "50% chance of immolating the target.",
			UiName = "Immolating Throwing Knife",
			gfxAtlas = "assets/textures/gui/items_2.tga",
			gfxIndex = 28,
			impactSound = "impact_blade",
			stackable = false, --MUST BE FALSE
			sharpProjectile = true,
			weight = 0.5,
			projectileRotationSpeed = -20,
			projectileRotationX = 90,
			projectileRotationY = 90,
			traits = { "throwing_weapon" },
			onEquipItem = function(self, champion, slot) self.go.item:setGameEffect("50% chance of immolating the target.") end,
			onThrowAttackHitMonster = function(self, monster) 
							--optional random failure ~to offset the significant damage a successful immolation attack inflicts.
							if math.random() >.5 then 
								monster.go:createComponent("BurningMonster")
								monster.go.burningmonster:setCausedByChampion(tonumber(self.go.item:getGameEffect()))
								
								--optional
								local output = string.gsub(party.party:getChampionByOrdinal(monster.go.burningmonster:getCausedByChampion()):getName().."\'s "..self.go.item:getUiName().." set the "..monster.go.name.." ablaze.", "%d" , " ")
								hudPrint(string.gsub(output, "_", " "))
							
							end
						end,
						
		},
		{
			class = "ThrowAttack",
			attackPower = 9,
			cooldown = 4,
			onPostAttack = function(self, champion, slot) 
					self.go.item:setGameEffect(champion:getOrdinal())
				end,
		},
	},
	tags = { "weapon", "weapon_throwing" },
}
Perfect! You rock. I can always make it an end game item or something. I just wanted to do something unique with throwing weapons.
User avatar
Isaac
Posts: 3191
Joined: Fri Mar 02, 2012 10:02 pm

Re: Damage Type on Throwing Weapons

Post by Isaac »

Looking over it again, I spotted a bug [and fixed it]; use the updated definition.

*Before, it could crash if the player picked up the knife and threw it via the mouse.
Post Reply