sorcery  Artifact [b98b74d4f6]

Artifact b98b74d4f695efd9c4ea43c4d9498973d342d238f514c1c9ad71d46d2d62f09a:

  • File tools.lua — part of check-in [ea6e475e44] at 2020-10-19 09:52:11 on branch trunk — continue dev on celestial mechanics, add melding+division spells (resonance), refine itemclasses, add keypunch and punchcards, add paper pulp, add a shitload of visuals, add convenience scripts for working with the wiki, make the flamebolt spell actually useful instead of just a pretty lightshow, add essences, inferno crystal, and other goodies; iterate on wands, lots of shit i can't remember, various bugfixes (user: lexi, size: 2259) [annotate] [blame] [check-ins using]

local dagger_uses = 16

minetest.register_tool("sorcery:dagger", {
	description = "Sacrificial Dagger",
	inventory_image = "sorcery_dagger.png",
	tool_capabilities = {
		full_punch_interval = 1.6,
		max_drop_level = 1,
		damage_groups = { fleshy = 2 },
	},
	sound = { breaks = "default_tool_breaks" },
	groups = { sorcery_sanctify = 1, sword = 1 },
	punch_attack_uses = 16
})

local dagger_usefn = function(selfharm)
	return function(stack,user,pointat)
		if (not minetest.is_player(pointat)) and
				selfharm == false then
			return nil
		end

		local inv = user:get_inventory()
		local btl = ItemStack('vessels:glass_bottle')
		if not inv:contains_item('main', btl) then
			return nil
		end

		local blood
		local target
		local caps
		if selfharm then
			blood = ItemStack('sorcery:blood 1')
			target = user
			caps = {
				full_punch_interval = 1.0,
				damage_groups = { fleshy = 3 },
			} 
		else
			if not minetest.is_player(pointat) then
				return nil
			end
			target = pointat
			caps = stack:get_tool_capabilities()
			blood = ItemStack {
				name = 'sorcery:blood';
				count = math.floor(caps.damage_groups.fleshy * 1.5);
			}
		end
		local pos = target:get_pos()
		pos.y = pos.y + 1.5

		local wear = 65535 / dagger_uses
		stack:add_wear(wear)

		inv:remove_item('main',btl)
		inv:add_item('main',blood)

		target:punch(user, 1.0, caps, nil)
		sorcery.vfx.bloodburst(pos)

		if math.random(3 + sorcery.enchant.strength(stack,'sanctify') * 6) == 1 then
			-- we've used up the consecration
			local unholy = ItemStack("sorcery:dagger")
			unholy:set_wear(stack:get_wear())
			local ench = sorcery.enchant.get(stack)
			if #ench.spells > 0 then
				sorcery.enchant.set(unholy,ench)
			end
			return unholy
		else
			-- consecration is holding, return dagger as-is
			return stack
		end
	end
end


minetest.register_tool("sorcery:dagger_consecrated", {
	description = "Consecrated Dagger",
	inventory_image = "sorcery_dagger_consecrated.png",
	tool_capabilities = {
		full_punch_interval = 1.6,
		max_drop_level = 1,
		damage_groups = { fleshy = 6 },
	},
	sound = { breaks = "default_tool_breaks" },
	groups = { sorcery_sanctify = 2, sword = 1 },
	punch_attack_uses = 16,
	on_use = dagger_usefn(false),
	on_secondary_use = dagger_usefn(true),
})