Weapon that heals.

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

Weapon that heals.

Post by Emera Nova »

I'd like to make a weapon that either gives a % of your hit back as health for the user of the weapon or make it so it has (x) amount of charges to heal either (x) amount of heal or heal a % of its next hit.

Ideas?
User avatar
Zo Kath Ra
Posts: 944
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Weapon that heals.

Post by Zo Kath Ra »

Emera Nova wrote:I'd like to make a weapon that either gives a % of your hit back as health for the user of the weapon or make it so it has (x) amount of charges to heal either (x) amount of heal or heal a % of its next hit.

Ideas?
Search the asset pack for files that contain the word "boneblade"
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Weapon that heals.

Post by minmay »

Code: Select all

defineObject{
	name = "backbiter",
	baseObject = "base_item",
	components = {
		{
			class = "Model",
			model = "assets/models/items/backbiter.fbx",
		},
		{
			class = "Item",
			uiName = "Backbiter",
			description = "A vicious little blade tainted by unholy rites.",
			gfxIndex = 228,
			gfxIndexPowerAttack = 202,
			impactSound = "impact_blade",
			weight = 2.4,
			secondaryAction = "leech",
			traits = { "light_weapon", "dagger" },
		},
		{
			class = "MeleeAttack",
			attackPower = 10,
			accuracy = 5,
			cooldown = 3,
			swipe = "vertical",
			attackSound = "swipe_light",
		},
		{
			class = "MeleeAttack",
			name = "leech",
			uiName = "Leech",
			attackPower = 20,
			accuracy = 20,
			cooldown = 4.5,
			energyCost = 25,
			swipe = "vertical",
			attackSound = "swipe_light",
			requirements = { "light_weapons", 3 },
			onHitMonster = function(self, monster, side, dmg, champion)
				if monster:hasTrait("undead") then
					-- draining undeads is not wise
					monster:showDamageText("Backlash", "FF0000")
					champion:damage(dmg*0.7, "physical")
					return false
				elseif monster:hasTrait("elemental") or monster:hasTrait("construct") then
					-- elementals are constructs are immune to leech
					monster:showDamageText("Immune")
					return false
				else
					champion:regainHealth(dmg*0.7)
				end
			end,
			gameEffect = "Successful hit drains life from target and heals you.",
		},
	},
	tags = { "weapon" },
}
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.
User avatar
Eleven Warrior
Posts: 752
Joined: Thu Apr 18, 2013 2:32 pm
Location: Australia

Re: Weapon that heals.

Post by Eleven Warrior »

Hi Minmay just a question what does the (monster:showDamageText("Backlash", "FF0000") FF0000 mean?
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Weapon that heals.

Post by minmay »

It's the colour of the text in hex R8G8B8 format.
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.
Post Reply