From 6ad4a97df16eb47b30ed383677f3993ce935131b Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Sat, 12 Nov 2016 23:42:34 +0100
Subject: [PATCH] All artifacts now have a special doll image. Look unique!
 Look dashing!

---
 game/modules/tome/class/Object.lua            | 66 +++++++++++++++++++
 .../objects/boss-artifacts-far-east.lua       |  1 +
 .../objects/boss-artifacts-maj-eyal.lua       |  3 +
 .../data/general/objects/quest-artifacts.lua  |  2 +-
 .../objects/world-artifacts-maj-eyal.lua      |  1 +
 .../data/general/objects/world-artifacts.lua  |  8 ++-
 .../tome/data/zones/high-peak/objects.lua     |  1 +
 7 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua
index ea2a2f3390..3f25c9dd44 100644
--- a/game/modules/tome/class/Object.lua
+++ b/game/modules/tome/class/Object.lua
@@ -81,6 +81,17 @@ function _M:getRequirementDesc(who)
 	end
 end
 
+local auto_moddable_tile_slots = {
+	MAINHAND = true,
+	OFFHAND = true,
+	BODY = true,
+	CLOAK = true,
+	HEAD = true,
+	HANDS = true,
+	FEET = true,
+	QUIVER = true,
+}
+
 function _M:init(t, no_default)
 	t.encumber = t.encumber or 0
 
@@ -93,6 +104,61 @@ function _M:init(t, no_default)
 		self.auto_image = nil
 		self.image = "object/"..(self.unique and "artifact/" or "")..self.name:lower():gsub("[^a-z0-9]", "")..".png"
 	end
+	if not self.auto_moddable_tile_check and self.unique and self.slot and auto_moddable_tile_slots[self.slot] and (not self.moddable_tile or type(self.moddable_tile) == "table" or (type(self.moddable_tile) == "string" and not self.moddable_tile:find("^special/"))) then
+		self.auto_moddable_tile_check = true
+		local file, filecheck = nil, nil
+		if self.type == "weapon" or self.subtype == "shield" then
+			file = "special/%s_"..self.name:lower():gsub("[^a-z0-9]", "_")
+			filecheck = file:format("left")
+		elseif self.subtype == "cloak" then
+			file = "special/"..self.name:lower():gsub("[^a-z0-9]", "_").."_%s"
+			filecheck = file:format("behind")
+		else
+			file = "special/"..self.name:lower():gsub("[^a-z0-9]", "_")
+			filecheck = file
+		end
+		if file and fs.exists("/data/gfx/shockbolt/player/human_female/"..filecheck..".png") then
+			self.moddable_tile = file
+			-- print("[UNIQUE MODDABLE] auto moddable set for ", self.name, file)
+		else
+			-- Try using the artifact image name
+			if type(self.image) == "string" and self.image:find("^object/artifact/") then
+				local base = self.image:gsub("object/artifact/", ""):gsub("%.png$", "")
+				if self.type == "weapon" or self.subtype == "shield" then
+					file = "special/%s_"..base
+					filecheck = file:format("left")
+				elseif self.subtype == "cloak" then
+					file = "special/"..base.."_%s"
+					filecheck = file:format("behind")
+				else
+					file = "special/"..base
+					filecheck = file
+				end
+				if file and fs.exists("/data/gfx/shockbolt/player/human_female/"..filecheck..".png") then
+					self.moddable_tile = file
+					-- print("[UNIQUE MODDABLE] auto moddable set for ", self.name, file)
+				else
+					print("[UNIQUE MODDABLE] auto moddable failed for ", self.name)
+				end
+			end
+		end
+	end
+
+	-- if self.unique and self.slot and type(self.moddable_tile) == "string" then
+	-- 	local filecheck = nil, nil
+	-- 	if self.type == "weapon" or self.subtype == "shield" then
+	-- 		filecheck = self.moddable_tile:format("left")
+	-- 	elseif self.subtype == "cloak" then
+	-- 		filecheck = self.moddable_tile:format("behind")
+	-- 	else
+	-- 		filecheck = self.moddable_tile
+	-- 	end
+	-- 	if filecheck and fs.exists("/data/gfx/shockbolt/player/human_female/"..filecheck..".png") then
+	-- 		-- print("[UNIQUE MODDABLE] auto moddable set for ", self.name, file)
+	-- 	else
+	-- 		print("[UNIQUE MODDABLE] auto moddable failed for ", self.name, self.moddable_tile, filecheck)
+	-- 	end
+	-- end
 end
 
 function _M:altered(t)
diff --git a/game/modules/tome/data/general/objects/boss-artifacts-far-east.lua b/game/modules/tome/data/general/objects/boss-artifacts-far-east.lua
index c2e68f7429..5059856d99 100644
--- a/game/modules/tome/data/general/objects/boss-artifacts-far-east.lua
+++ b/game/modules/tome/data/general/objects/boss-artifacts-far-east.lua
@@ -194,6 +194,7 @@ newEntity{ base = "BASE_CLOTH_ARMOR",
 	define_as = "BLACK_ROBE",
 	name = "Black Robe", unique=true,
 	unided_name = "black robe", color=colors.DARK_GREY, image = "object/artifact/robe_black_robe.png",
+	moddable_tile = "special/robe_black_robe",
 	desc = [[A silk robe, darker than the darkest night sky, it radiates power.]],
 	level_range = {40, 50},
 	rarity = 280,
diff --git a/game/modules/tome/data/general/objects/boss-artifacts-maj-eyal.lua b/game/modules/tome/data/general/objects/boss-artifacts-maj-eyal.lua
index a3a60bbff4..d9dc19dddc 100644
--- a/game/modules/tome/data/general/objects/boss-artifacts-maj-eyal.lua
+++ b/game/modules/tome/data/general/objects/boss-artifacts-maj-eyal.lua
@@ -1310,6 +1310,7 @@ newEntity{ base = "BASE_MASSIVE_ARMOR",
 	desc = [[Inch-thick stralite plates lock together with voratun joints. The whole suit looks impenetrable, but has clearly been subjected to terrible treatment - great dents and misshaping warps, and caustic fissures bored across the surface.
 Though clearly a powerful piece, it must once have been much greater.]],
 	color = colors.WHITE, image = "object/artifact/armor_plate_borfasts_cage.png",
+	moddable_tile = "special/armor_plate_borfasts_cage",
 	level_range = {20, 28},
 	rarity = 200,
 	require = { stat = { str=35 }, },
@@ -1340,6 +1341,7 @@ newEntity{ base = "BASE_LEATHER_CAP", -- No armor training requirement
 	power_source = {psionic=true},
 	define_as = "ALETTA_DIADEM",
 	name = "Aletta's Diadem", unique=true, unided_name="jeweled diadem", image = "object/artifact/diadem_alettas_diadem.png",
+	moddable_tile = "special/diadem_alettas_diadem",
 	desc = [[A filigree of silver set with many small jewels, this diadem seems radiant - ethereal almost. But its touch seems to freeze your skin and brings wild thoughts to your mind. You want to drop it, throw it away, and yet you cannot resist thinking of what powers it might bring you.
 Is this temptation a weak will on your part, or some domination from the artifact itself...?]],
 	require = { stat = { wil=24 }, },
@@ -1363,6 +1365,7 @@ newEntity{ base = "BASE_SLING",
 	power_source = {nature=true},
 	define_as = "HARESKIN_SLING",
 	name = "Hare-Skin Sling", unique=true, unided_name = "hare-skin sling", image = "object/artifact/sling_hareskin_sling.png",
+	moddable_tile = "special/%s_hareskin_sling",
 	desc = [[This well-tended sling is made from the leather and sinews of a large hare. It feels smooth to the touch, yet very durable. Some say that the skin of a hare brings luck and fortune.
 Hard to tell if that really helped its former owner, but it's clear that the skin is at least also strong and reliable.]],
 	level_range = {20, 28},
diff --git a/game/modules/tome/data/general/objects/quest-artifacts.lua b/game/modules/tome/data/general/objects/quest-artifacts.lua
index e6f7ccd729..2a1bc407ee 100644
--- a/game/modules/tome/data/general/objects/quest-artifacts.lua
+++ b/game/modules/tome/data/general/objects/quest-artifacts.lua
@@ -31,9 +31,9 @@ newEntity{ define_as = "STAFF_ABSORPTION",
 	flavor_name = "magestaff",
 	level_range = {30, 30},
 	display = "\\", color=colors.VIOLET, image = "object/artifact/staff_absorption.png",
+	moddable_tile = "special/%s_staff_of_absorbtion",
 	encumber = 7,
 	auto_pickup = 1,
-	moddable_tile = resolvers.moddable_tile("staff"),
 	plot = true, quest = true,
 	desc = [[Carved with runes of power, this staff seems to have been made long ago, yet it bears no signs of tarnish.
 Light around it seems to dim and you can feel its tremendous power simply by touching it.]],
diff --git a/game/modules/tome/data/general/objects/world-artifacts-maj-eyal.lua b/game/modules/tome/data/general/objects/world-artifacts-maj-eyal.lua
index c5b229b404..8565d17123 100644
--- a/game/modules/tome/data/general/objects/world-artifacts-maj-eyal.lua
+++ b/game/modules/tome/data/general/objects/world-artifacts-maj-eyal.lua
@@ -375,6 +375,7 @@ newEntity{ base = "BASE_STAFF",
 	power_source = {arcane=true},
 	unique = true,
 	name = "Bolbum's Big Knocker", image = "object/artifact/staff_bolbums_big_knocker.png",
+	moddable_tile = "special/%s_staff_bolbums_big_knocker",
 	unided_name = "thick staff",
 	level_range = {20, 35},
 	color=colors.UMBER,
diff --git a/game/modules/tome/data/general/objects/world-artifacts.lua b/game/modules/tome/data/general/objects/world-artifacts.lua
index 0515ba46be..93f7fafe22 100644
--- a/game/modules/tome/data/general/objects/world-artifacts.lua
+++ b/game/modules/tome/data/general/objects/world-artifacts.lua
@@ -401,6 +401,7 @@ newEntity{ base = "BASE_LEATHER_BOOT",
 	power_source = {technique=true},
 	unique = true,
 	name = "Eden's Guile", image = "object/artifact/boots_edens_guile.png",
+	moddable_tile = "special/boots_edens_guile",
 	unided_name = "pair of yellow boots",
 	desc = [[The boots of a Rogue outcast, who knew that the best way to deal with a problem was to run from it.]],
 	on_id_lore = "eden-guile",
@@ -1369,7 +1370,7 @@ newEntity{ base = "BASE_BATTLEAXE",
 	unique = true,
 	unided_name = "crude iron battle axe",
 	name = "Crude Iron Battle Axe of Kroll", color = colors.GREY, image = "object/artifact/crude_iron_battleaxe_of_kroll.png",
-	moddable = "special/crude_iron_battleaxe_of_kroll",
+	moddable_tile = "special/crude_iron_battleaxe_of_kroll",
 	moddable_tile_big = true,
 	desc = [[Made in times before the Dwarves learned beautiful craftsmanship, the rough appearance of this axe belies its great power. Only Dwarves may harness its true strength, however.]],
 	require = { stat = { str=50 }, },
@@ -1485,6 +1486,7 @@ newEntity{ base = "BASE_LIGHT_ARMOR",
 	power_source = {technique=true},
 	unique = true,
 	name = "Behemoth Hide", image = "object/artifact/behemoth_skin.png",
+	moddable_tile = "special/behemoth_skin",
 	unided_name = "tough weathered hide",
 	desc = [[A rough hide made from a massive beast.  Seeing as it's so weathered but still usable, maybe it's a bit special...]],
 	color = colors.BROWN,
@@ -3967,6 +3969,7 @@ newEntity{ base = "BASE_LEATHER_BOOT", --Thanks Grayswandir!
 	power_source = {arcane=true},
 	unique = true,
 	name = "Aetherwalk", image = "object/artifact/aether_walk.png",
+	moddable_tile = "special/aether_walk",
 	unided_name = "ethereal boots",
 	desc = [[A wispy purple aura surrounds these translucent black boots.]],
 	color = colors.PURPLE,
@@ -6016,6 +6019,7 @@ newEntity{ base = "BASE_GREATSWORD",
 	power_source = {technique=true},
 	define_as = "DOUBLESWORD",
 	name = "Borosk's Hate", unique=true, image="object/artifact/borosks_hate.png",
+	moddable_tile = "special/%s_borosks_hate",
 	unided_name = "double-bladed sword", color=colors.GREY,
 	desc = [[This impressive looking sword features two massive blades aligned in parallel. They seem weighted remarkably well.]],
 	require = { stat = { str=35 }, },
@@ -6451,6 +6455,7 @@ newEntity{ base = "BASE_ARROW",
 	power_source = {technique=true},
 	unique = true,
 	name = "Arkul's Siege Arrows", image = "object/artifact/arkuls_seige_arrows.png",
+	moddable_tile = "special/arkuls_seige_arrows",
 	proj_image = "object/artifact/arrow_s_arkuls_seige_arrows.png",
 	unided_name = "gigantic spiral arrows",
 	desc = [[These titanic double-helical arrows seem to have been designed more for knocking down towers than for use in regular combat. They'll no doubt make short work of most foes.]],
@@ -7096,6 +7101,7 @@ newEntity{ base = "BASE_HELM",
 newEntity{ base = "BASE_GREATSWORD",
 	power_source = {technique=true, arcane=true},
 	name = "Champion's Will", unique=true, image = "object/artifact/champions_will.png",
+	moddable_tile = "special/%s_champions_will",
 	unided_name = "blindingly bright sword", color=colors.YELLOW,
 	desc = [[This impressive looking sword features a golden engraving of a sun in its hilt. Etched into its blade are a series of runes claiming that only one who has mastered both their body and mind may wield this sword effectively.]],
 	require = { stat = { str=35 }, },
diff --git a/game/modules/tome/data/zones/high-peak/objects.lua b/game/modules/tome/data/zones/high-peak/objects.lua
index 0360b3c58d..b6990d771e 100644
--- a/game/modules/tome/data/zones/high-peak/objects.lua
+++ b/game/modules/tome/data/zones/high-peak/objects.lua
@@ -33,6 +33,7 @@ newEntity{ define_as = "STAFF_ABSORPTION_AWAKENED", base="BASE_STAFF",
 	unided_name = "ominous, dark runed staff",
 	force_lore_artifact=true,
 	display = "\\", color=colors.VIOLET, image = "object/artifact/staff_absorption.png",
+	moddable_tile = "special/%s_awaken_staff_of_absorbtion",
 	encumber = 7,
 	plot=true,
 	desc = [[Carved with runes of power, this staff seems to have been made long ago, yet it bears no signs of tarnish.
-- 
GitLab