From c9c6c046f09611d72a791aca7560828da96c9cc5 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 31 Oct 2010 03:02:04 +0000
Subject: [PATCH] Most bosses taht drop an artifact now have only a chance of
 dropping theirs, if they do not they will drop a random one and theirs will
 be added to the random pool

git-svn-id: http://svn.net-core.org/repos/t-engine4@1724 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/Entity.lua         |  6 ++++++
 game/modules/tome/class/Actor.lua              | 17 +++++++++++++++++
 game/modules/tome/class/Game.lua               |  2 +-
 game/modules/tome/class/GameState.lua          | 18 ++++++++++++++++++
 .../data/general/objects/world-artifacts.lua   |  6 ++++++
 .../data/zones/ancient-elven-ruins/npcs.lua    |  2 +-
 .../tome/data/zones/blighted-ruins/npcs.lua    |  2 +-
 .../tome/data/zones/charred-scar/npcs.lua      |  2 +-
 game/modules/tome/data/zones/daikara/npcs.lua  |  4 ++--
 .../tome/data/zones/flooded-cave/npcs.lua      |  2 +-
 .../tome/data/zones/gorbat-pride/npcs.lua      |  2 +-
 .../tome/data/zones/grushnak-pride/npcs.lua    |  2 +-
 game/modules/tome/data/zones/maze/npcs.lua     |  4 ++--
 .../tome/data/zones/old-forest/npcs.lua        |  2 +-
 .../tome/data/zones/rak-shor-pride/npcs.lua    |  2 +-
 game/modules/tome/data/zones/reknor/npcs.lua   |  2 +-
 .../tome/data/zones/ruins-kor-pul/npcs.lua     |  4 ++--
 game/modules/tome/data/zones/telmur/npcs.lua   |  2 +-
 .../modules/tome/data/zones/tol-falas/npcs.lua |  4 ++--
 .../tome/data/zones/trollshaws/npcs.lua        |  6 +++---
 .../tome/data/zones/valley-moon/npcs.lua       |  2 +-
 .../tome/data/zones/vor-armoury/npcs.lua       |  2 +-
 .../modules/tome/data/zones/vor-pride/npcs.lua |  2 +-
 game/modules/tome/resolvers.lua                |  8 ++++++++
 24 files changed, 80 insertions(+), 25 deletions(-)

diff --git a/game/engines/default/engine/Entity.lua b/game/engines/default/engine/Entity.lua
index ddae7677c0..a9c9bf9f5c 100644
--- a/game/engines/default/engine/Entity.lua
+++ b/game/engines/default/engine/Entity.lua
@@ -423,6 +423,12 @@ function _M:loadList(file, no_default, res, mod, loaded)
 			res[#res+1] = e
 			if t.define_as then res[t.define_as] = e end
 		end,
+		importEntity = function(t)
+			local e = t:cloneFull()
+			if mod then mod(e) end
+			res[#res+1] = e
+			if t.define_as then res[t.define_as] = e end
+		end,
 		load = function(f, new_mod)
 			self:loadList(f, no_default, res, new_mod or mod, loaded)
 		end,
diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index e6acfa6be2..87464626a1 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -747,9 +747,26 @@ function _M:die(src)
 		if not self.no_drops then
 			for inven_id, inven in pairs(self.inven) do
 				for i, o in ipairs(inven) do
+					-- Handle boss wielding artifacts
+					if o.__special_boss_drop and rng.percent(o.__special_boss_drop.chance) then
+						print("Refusing to drop "..self.name.." artifact "..o.name)
+
+						-- Do not drop
+						o.no_drop = true
+
+						-- Drop a random artifact instead
+						local ro = game.zone:makeEntity(game.level, "object", {unique=true}, nil, true)
+						if ro then game.zone:addEntity(game.level, ro, "object", self.x, self.y) end
+
+						-- Add to the pool
+						game.state:addWorldArtifact(o.define_as, o.__special_boss_drop)
+					end
+
 					if not o.no_drop then
 						o.droppedBy = self.name
 						game.level.map:addObject(self.x, self.y, o)
+					else
+						o:removed()
 					end
 				end
 			end
diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 7eeacb8b6d..d31f07c3e7 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -678,7 +678,7 @@ function _M:setupCommands()
 				a.faction = "enemies"
 				self.zone:addEntity(self.level, a, "actor", self.player.x+1, self.player.y)
 --]]
-				self:changeLevel(2, "tempest-peak")
+				self:changeLevel(5)
 			end
 		end,
 	}
diff --git a/game/modules/tome/class/GameState.lua b/game/modules/tome/class/GameState.lua
index 7bc34a71b5..2f965222fd 100644
--- a/game/modules/tome/class/GameState.lua
+++ b/game/modules/tome/class/GameState.lua
@@ -26,12 +26,15 @@ function _M:init(t, no_default)
 	engine.Entity.init(self, t, no_default)
 
 	self.allow_backup_guardians = {}
+	self.world_artifacts_pool = {}
 end
 
+--- Discovered the far east
 function _M:goneEast()
 	self.gone_east = true
 end
 
+--- Setup a backup guardian for the given zone
 function _M:activateBackupGuardian(guardian, on_level, zonelevel, rumor, action)
 	if self.gone_east then return end
 	print("Zone guardian dead, setting up backup guardian", guardian, zonelevel)
@@ -46,6 +49,7 @@ function _M:activateBackupGuardian(guardian, on_level, zonelevel, rumor, action)
 	}
 end
 
+--- Activate a backup guardian & settings, if available
 function _M:zoneCheckBackupGuardian()
 	if not self.gone_east then print("Not gone east, no backup guardian") return end
 
@@ -82,6 +86,20 @@ function _M:zoneCheckBackupGuardian()
 	end
 end
 
+--- A boss refused to drop his artifact! Bastard! Add it to the world pool
+function _M:addWorldArtifact(define, config)
+	local o = game.zone.object_list[define]
+	o.level_range = config.level_range
+	o.rarity = config.rarity
+	self.world_artifacts_pool[define] = o
+end
+
+--- Load all refused boss artifacts
+-- This is caleld from the world-artifacts.lua file
+function _M:getWorldArtifacts()
+	return self.world_artifacts_pool
+end
+
 local wda_cache = {}
 
 --- Runs the worldmap directory AI
diff --git a/game/modules/tome/data/general/objects/world-artifacts.lua b/game/modules/tome/data/general/objects/world-artifacts.lua
index 81a164b279..560e6c8725 100644
--- a/game/modules/tome/data/general/objects/world-artifacts.lua
+++ b/game/modules/tome/data/general/objects/world-artifacts.lua
@@ -20,6 +20,12 @@
 local Stats = require "engine.interface.ActorStats"
 local Talents = require "engine.interface.ActorTalents"
 
+--- Load boss artifacts that failed to be dropped
+for def, e in pairs(game.state:getWorldArtifacts()) do
+	importEntity(e)
+	print("Importing failed boss drop "..e.name.." into world artifacts")
+end
+
 -- This file describes artifacts not bound to a special location, they can be found anywhere
 newEntity{ base = "BASE_STAFF",
 	unique = true,
diff --git a/game/modules/tome/data/zones/ancient-elven-ruins/npcs.lua b/game/modules/tome/data/zones/ancient-elven-ruins/npcs.lua
index e03228058d..6174ba57c7 100644
--- a/game/modules/tome/data/zones/ancient-elven-ruins/npcs.lua
+++ b/game/modules/tome/data/zones/ancient-elven-ruins/npcs.lua
@@ -46,7 +46,7 @@ newEntity{ define_as = "GREATER_MUMMY_LORD",
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, HEAD=1, },
 	equipment = resolvers.equip{
-		{type="weapon", subtype="longsword", defined="LONGSWORD_RINGIL", autoreq=true},
+		{type="weapon", subtype="longsword", defined="LONGSWORD_RINGIL", random_art_replace={chance=75, rarity=280, level_range={35, 45}}, autoreq=true},
 		{type="armor", subtype="shield", ego_chance=100, autoreq=true},
 		{type="armor", subtype="mummy", ego_chance=100, autoreq=true},
 	},
diff --git a/game/modules/tome/data/zones/blighted-ruins/npcs.lua b/game/modules/tome/data/zones/blighted-ruins/npcs.lua
index 01039bf680..74e41a1aa2 100644
--- a/game/modules/tome/data/zones/blighted-ruins/npcs.lua
+++ b/game/modules/tome/data/zones/blighted-ruins/npcs.lua
@@ -83,7 +83,7 @@ This specimen look like it was hastily assembled and is not really complete yet.
 	resolvers.sustains_at_birth(),
 
 	resolvers.drops{chance=100, nb=3, {ego_chance=100} },
-	resolvers.drops{chance=100, nb=1, {defined="UNDEATH_PHIAL"} },
+	resolvers.drops{chance=100, nb=1, {defined="UNDEATH_PHIAL", random_art_replace={chance=75, rarity=150, level_range={1, 10}}} },
 
 	ai = "dumb_talented_simple", ai_state = { talent_in=4, ai_move="move_astar", },
 
diff --git a/game/modules/tome/data/zones/charred-scar/npcs.lua b/game/modules/tome/data/zones/charred-scar/npcs.lua
index 7a535ea8b5..15fbfd04a3 100644
--- a/game/modules/tome/data/zones/charred-scar/npcs.lua
+++ b/game/modules/tome/data/zones/charred-scar/npcs.lua
@@ -276,7 +276,7 @@ This one looks even nastier and looks toward you with what seems to be disdain.
 	ai = "dumb_talented_simple", ai_state = { talent_in=1, ai_move="move_astar" },
 
 	resolvers.equip{
-		{type="jewelry", subtype="amulet", defined="FIERY_CHOKER"},
+		{type="jewelry", subtype="amulet", defined="FIERY_CHOKER", random_art_replace={chance=75, rarity=200, level_range={35, 45}}},
 	},
 	resolvers.drops{chance=20, nb=1, {defined="JEWELER_TOME"} },
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
diff --git a/game/modules/tome/data/zones/daikara/npcs.lua b/game/modules/tome/data/zones/daikara/npcs.lua
index 2e92fbe5b0..2e5c5f8842 100644
--- a/game/modules/tome/data/zones/daikara/npcs.lua
+++ b/game/modules/tome/data/zones/daikara/npcs.lua
@@ -47,7 +47,7 @@ newEntity{ define_as = "RANTHA_THE_WORM",
 	resists = { [DamageType.FIRE] = -20, [DamageType.COLD] = 100 },
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
-	resolvers.drops{chance=100, nb=1, {defined="FROST_TREADS"}, },
+	resolvers.drops{chance=100, nb=1, {defined="FROST_TREADS", random_art_replace={chance=75, rarity=150, level_range={12, 22}}}, },
 	resolvers.drops{chance=100, nb=3, {ego_chance=100} },
 	resolvers.drops{chance=100, nb=10, {type="money"} },
 
@@ -101,7 +101,7 @@ newEntity{ base="BASE_NPC_ORC_GRUSHNAK", define_as = "MASSOK",
 	resolvers.equip{
 		{type="weapon", subtype="battleaxe", ego_change=100, autoreq=true},
 		{type="armor", subtype="massive", ego_chance=100, autoreq=true},
-		{type="armor", subtype="head", defined="RUNED_SKULL", autoreq=true},
+		{type="armor", subtype="head", defined="RUNED_SKULL", random_art_replace={chance=75, rarity=250, level_range={45, 50}}, autoreq=true},
 		{type="armor", subtype="feet", ego_chance=100, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
diff --git a/game/modules/tome/data/zones/flooded-cave/npcs.lua b/game/modules/tome/data/zones/flooded-cave/npcs.lua
index 3ab686b410..3d6538f4ff 100644
--- a/game/modules/tome/data/zones/flooded-cave/npcs.lua
+++ b/game/modules/tome/data/zones/flooded-cave/npcs.lua
@@ -50,7 +50,7 @@ newEntity{ define_as = "UKLLMSWWIK",
 	resists = { [DamageType.COLD] = 60, [DamageType.LIGHTNING] = 20, },
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
-	resolvers.drops{chance=100, nb=1, {defined="TRIDENT_TIDES", autoreq=true} },
+	resolvers.drops{chance=100, nb=1, {defined="TRIDENT_TIDES", random_art_replace={chance=50, rarity=250, level_range={30, 40}}, autoreq=true} },
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
 	resolvers.drops{chance=100, nb=10, {type="money"} },
 
diff --git a/game/modules/tome/data/zones/gorbat-pride/npcs.lua b/game/modules/tome/data/zones/gorbat-pride/npcs.lua
index 6e1e200d90..fcfb5484c8 100644
--- a/game/modules/tome/data/zones/gorbat-pride/npcs.lua
+++ b/game/modules/tome/data/zones/gorbat-pride/npcs.lua
@@ -49,7 +49,7 @@ newEntity{ base="BASE_NPC_ORC_GORBAT", define_as = "GORBAT",
 
 	resolvers.equip{
 		{type="weapon", subtype="greatmaul", ego_change=100, autoreq=true},
-		{type="armor", subtype="light", defined="CHROMATIC_HARNESS", autoreq=true},
+		{type="armor", subtype="light", defined="CHROMATIC_HARNESS", random_art_replace={chance=75, rarity=250, level_range={40, 50}}, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=1, {defined="ORB_DRAGON"} },
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
diff --git a/game/modules/tome/data/zones/grushnak-pride/npcs.lua b/game/modules/tome/data/zones/grushnak-pride/npcs.lua
index ac2a439aca..5fa18ef828 100644
--- a/game/modules/tome/data/zones/grushnak-pride/npcs.lua
+++ b/game/modules/tome/data/zones/grushnak-pride/npcs.lua
@@ -55,7 +55,7 @@ newEntity{ base="BASE_NPC_ORC_GRUSHNAK", define_as = "GRUSHNAK",
 --		Commented because this can generate rings of invis or amulets of telepathy and drain the life of the boss
 --		{type="jewelry", subtype="amulet", ego_chance=100, autoreq=true},
 --		{type="jewelry", subtype="ring", ego_chance=100, autoreq=true},
-		{type="jewelry", subtype="ring", defined="PRIDE_GLORY", autoreq=true},
+		{type="jewelry", subtype="ring", defined="PRIDE_GLORY", random_art_replace={chance=75, rarity=250, level_range={40, 50}}, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=1, {defined="ORB_DESTRUCTION"} },
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
diff --git a/game/modules/tome/data/zones/maze/npcs.lua b/game/modules/tome/data/zones/maze/npcs.lua
index 9f8f7d1111..e69167929f 100644
--- a/game/modules/tome/data/zones/maze/npcs.lua
+++ b/game/modules/tome/data/zones/maze/npcs.lua
@@ -50,7 +50,7 @@ newEntity{ define_as = "MINOTAUR_MAZE",
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, HEAD=1, },
 	resolvers.equip{
 		{type="weapon", subtype="battleaxe", autoreq=true},
-		{type="armor", subtype="head", defined="HELM_OF_HAMMERHAND", autoreq=true},
+		{type="armor", subtype="head", defined="HELM_OF_HAMMERHAND", random_art_replace={chance=75, rarity=200, level_range={12, 22}}, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
 
@@ -87,7 +87,7 @@ newEntity{ base = "BASE_NPC_SPIDER", define_as = "NIMISIL",
 	instakill_immune = 1,
 
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
-	resolvers.drops{chance=100, nb=1, {defined="LUNAR_SHIELD"} },
+	resolvers.drops{chance=100, nb=1, {defined="LUNAR_SHIELD", random_art_replace={chance=75, rarity=220, level_range={40, 50}}} },
 
 	combat_armor = 25, combat_def = 33,
 
diff --git a/game/modules/tome/data/zones/old-forest/npcs.lua b/game/modules/tome/data/zones/old-forest/npcs.lua
index e7ee460372..6f28db77d8 100644
--- a/game/modules/tome/data/zones/old-forest/npcs.lua
+++ b/game/modules/tome/data/zones/old-forest/npcs.lua
@@ -55,7 +55,7 @@ newEntity{ define_as = "OLD_MAN_WILLOW",
 	resists = { [DamageType.FIRE] = -50 },
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
-	equipment = resolvers.equip{ {type="armor", subtype="shield", defined="OLD_MAN_WILLOW_SHIELD", autoreq=true}, },
+	equipment = resolvers.equip{ {type="armor", subtype="shield", defined="OLD_MAN_WILLOW_SHIELD", random_art_replace={chance=75, rarity=200, level_range={10, 20}}, autoreq=true}, },
 	drops = resolvers.drops{chance=100, nb=5, {ego_chance=100} },
 
 	resolvers.talents{
diff --git a/game/modules/tome/data/zones/rak-shor-pride/npcs.lua b/game/modules/tome/data/zones/rak-shor-pride/npcs.lua
index 3a51bfb656..c164698cf6 100644
--- a/game/modules/tome/data/zones/rak-shor-pride/npcs.lua
+++ b/game/modules/tome/data/zones/rak-shor-pride/npcs.lua
@@ -52,7 +52,7 @@ newEntity{ base="BASE_NPC_ORC_RAK_SHOR", define_as = "RAK_SHOR",
 
 	resolvers.equip{
 		{type="weapon", subtype="staff", ego_change=100, autoreq=true},
-		{type="armor", subtype="cloth", defined="BLACK_ROBE", autoreq=true},
+		{type="armor", subtype="cloth", defined="BLACK_ROBE", random_art_replace={chance=75, rarity=250, level_range={40, 50}}, autoreq=true},
 	},
 	resolvers.drops{chance=20, nb=1, {defined="JEWELER_TOME"} },
 	resolvers.drops{chance=100, nb=1, {defined="ORB_UNDEATH"} },
diff --git a/game/modules/tome/data/zones/reknor/npcs.lua b/game/modules/tome/data/zones/reknor/npcs.lua
index 26fd58c3b8..cdcab34dd6 100644
--- a/game/modules/tome/data/zones/reknor/npcs.lua
+++ b/game/modules/tome/data/zones/reknor/npcs.lua
@@ -167,7 +167,7 @@ newEntity{ define_as = "LITHFENGEL", -- Lord of Ash; backup guardian
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
 	resolvers.equip{
-		{type="weapon", subtype="waraxe", defined="MALEDICTION", autoreq=true},
+		{type="weapon", subtype="waraxe", defined="MALEDICTION", random_art_replace={chance=75, rarity=200, level_range={35, 45}}, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=4, {ego_chance=100} },
 	resolvers.drops{chance=100, nb=1, {defined="ATHAME_WEST"} },
diff --git a/game/modules/tome/data/zones/ruins-kor-pul/npcs.lua b/game/modules/tome/data/zones/ruins-kor-pul/npcs.lua
index 650646f8f6..6b7a905760 100644
--- a/game/modules/tome/data/zones/ruins-kor-pul/npcs.lua
+++ b/game/modules/tome/data/zones/ruins-kor-pul/npcs.lua
@@ -48,7 +48,7 @@ newEntity{ define_as = "SHADE",
 	move_others=true,
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
-	equipment = resolvers.equip{ {type="weapon", subtype="staff", defined="STAFF_KOR", autoreq=true}, {type="armor", subtype="light", autoreq=true}, },
+	equipment = resolvers.equip{ {type="weapon", subtype="staff", defined="STAFF_KOR", random_art_replace={chance=75, rarity=150, level_range={1, 10}}, autoreq=true}, {type="armor", subtype="light", autoreq=true}, },
 	drops = resolvers.drops{chance=100, nb=3, {ego_chance=100} },
 
 	resolvers.talents{
@@ -98,7 +98,7 @@ newEntity{ define_as = "KOR_FURY",
 	resolvers.equip{
 		{type="weapon", subtype="staff", ego_chance=100, autoreq=true},
 		{type="armor", subtype="light", autoreq=true},
-		{type="jewelry", subtype="amulet", defined="VOX", autoreq=true},
+		{type="jewelry", subtype="amulet", defined="VOX", random_art_replace={chance=75, rarity=220, level_range={40, 50}}, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=3, {ego_chance=100} },
 
diff --git a/game/modules/tome/data/zones/telmur/npcs.lua b/game/modules/tome/data/zones/telmur/npcs.lua
index 23a21d4b52..24a2bff5e5 100644
--- a/game/modules/tome/data/zones/telmur/npcs.lua
+++ b/game/modules/tome/data/zones/telmur/npcs.lua
@@ -58,7 +58,7 @@ newEntity{ define_as = "SHADE_OF_TELOS",
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, },
 	resolvers.equip{
-		{type="weapon", subtype="staff", defined="TELOS_TOP_HALF", autoreq=true},
+		{type="weapon", subtype="staff", defined="TELOS_TOP_HALF", random_art_replace={chance=75, rarity=190, level_range={40, 50}}, autoreq=true},
 		{type="weapon", subtype="staff", defined="TELOS_BOTTOM_HALF", autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=2, {type="wand"} },
diff --git a/game/modules/tome/data/zones/tol-falas/npcs.lua b/game/modules/tome/data/zones/tol-falas/npcs.lua
index 398550c583..52d8cd8e5a 100644
--- a/game/modules/tome/data/zones/tol-falas/npcs.lua
+++ b/game/modules/tome/data/zones/tol-falas/npcs.lua
@@ -51,7 +51,7 @@ newEntity{ define_as = "THE_MASTER",
 	equipment = resolvers.equip{
 		{type="weapon", subtype="greatsword", ego_chance=100, autoreq=true},
 		{type="armor", subtype="heavy", ego_chance=50, autoreq=true},
-		{type="jewelry", subtype="amulet", defined="AMULET_DREAD", autoreq=true},
+		{type="jewelry", subtype="amulet", defined="AMULET_DREAD", random_art_replace={chance=75, rarity=210, level_range={25, 35}}, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
 	resolvers.drops{chance=100, nb=1, {type="weapon", subtype="staff", defined="STAFF_ABSORPTION"} },
@@ -127,7 +127,7 @@ newEntity{ define_as = "PALE_DRAKE",
 		{type="armor", subtype="cloth", ego_chance=50, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
-	resolvers.drops{chance=100, nb=1, {defined="RUNED_SKULL"} },
+	resolvers.drops{chance=100, nb=1, {defined="RUNED_SKULL", random_art_replace={chance=75, rarity=250, level_range={40, 50}}} },
 
 	summon = {
 		{type="undead", subtype="bone giant", special_rarity="bonegiant_rarity", number=2, hasxp=true},
diff --git a/game/modules/tome/data/zones/trollshaws/npcs.lua b/game/modules/tome/data/zones/trollshaws/npcs.lua
index 31b6b46c21..4bcb402075 100644
--- a/game/modules/tome/data/zones/trollshaws/npcs.lua
+++ b/game/modules/tome/data/zones/trollshaws/npcs.lua
@@ -49,8 +49,8 @@ newEntity{ define_as = "TROLL_BILL",
 	move_others=true,
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
-	equipment = resolvers.equip{ {type="weapon", subtype="greatmaul", defined="GREATMAUL_BILL_TRUNK", autoreq=true}, },
-	drops = resolvers.drops{chance=100, nb=3, {ego_chance=100} },
+	resolvers.equip{ {type="weapon", subtype="greatmaul", defined="GREATMAUL_BILL_TRUNK", random_art_replace={chance=75, rarity=150, level_range={1, 10}}, autoreq=true}, },
+	resolvers.drops{chance=100, nb=3, {ego_chance=100} },
 
 	resolvers.talents{
 		[Talents.T_STUN]=2,
@@ -87,7 +87,7 @@ newEntity{ define_as = "ALUIN",
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
 	resolvers.equip{
 		{type="weapon", subtype="waraxe", ego_chance=100, autoreq=true},
-		{type="armor", subtype="shield", defined="SANGUINE_SHIELD", autoreq=true},
+		{type="armor", subtype="shield", defined="SANGUINE_SHIELD", random_art_replace={chance=65, rarity=220, level_range={35, 45}}, autoreq=true},
 		{type="armor", subtype="massive", ego_chance=100, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=3, {ego_chance=100} },
diff --git a/game/modules/tome/data/zones/valley-moon/npcs.lua b/game/modules/tome/data/zones/valley-moon/npcs.lua
index 7ededba649..853c5b4ef7 100644
--- a/game/modules/tome/data/zones/valley-moon/npcs.lua
+++ b/game/modules/tome/data/zones/valley-moon/npcs.lua
@@ -45,7 +45,7 @@ newEntity{ define_as = "CORRUPTED_BALROG",
 
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1 },
 	resolvers.equip{
-		{type="weapon", subtype="whip", defined="WHIP_GOTHMOG", autoreq=true},
+		{type="weapon", subtype="whip", defined="WHIP_GOTHMOG", random_art_replace={chance=75, rarity=290, level_range={40, 50}}, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=3, {ego_chance=100} },
 
diff --git a/game/modules/tome/data/zones/vor-armoury/npcs.lua b/game/modules/tome/data/zones/vor-armoury/npcs.lua
index 8e8a2c4b1a..808e49afc8 100644
--- a/game/modules/tome/data/zones/vor-armoury/npcs.lua
+++ b/game/modules/tome/data/zones/vor-armoury/npcs.lua
@@ -52,7 +52,7 @@ newEntity{ base="BASE_NPC_ORC_GRUSHNAK", define_as = "GNARG",
 	body = { INVEN = 10, MAINHAND=1, OFFHAND=1, BODY=1, HEAD=1 },
 
 	resolvers.equip{
-		{type="weapon", subtype="greatsword", defined="MURDERBLADE", autoreq=true},
+		{type="weapon", subtype="greatsword", defined="MURDERBLADE", random_art_replace={chance=75, rarity=250, level_range={35, 45}}, autoreq=true},
 		{type="armor", subtype="massive", ego_change=100, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=5, {ego_chance=100} },
diff --git a/game/modules/tome/data/zones/vor-pride/npcs.lua b/game/modules/tome/data/zones/vor-pride/npcs.lua
index 17808f7212..b888b232ef 100644
--- a/game/modules/tome/data/zones/vor-pride/npcs.lua
+++ b/game/modules/tome/data/zones/vor-pride/npcs.lua
@@ -47,7 +47,7 @@ newEntity{ base="BASE_NPC_ORC_VOR", define_as = "VOR",
 	resolvers.equip{
 		{type="weapon", subtype="staff", ego_change=100, autoreq=true},
 		{type="armor", subtype="cloth", ego_change=100, autoreq=true},
-		{type="armor", subtype="head", defined="CROWN_ELEMENTS", autoreq=true},
+		{type="armor", subtype="head", defined="CROWN_ELEMENTS", random_art_replace={chance=75, rarity=250, level_range={40, 50}}, autoreq=true},
 	},
 	resolvers.drops{chance=100, nb=1, {defined="ORB_ELEMENTS"} },
 	resolvers.drops{chance=20, nb=1, {defined="JEWELER_TOME"} },
diff --git a/game/modules/tome/resolvers.lua b/game/modules/tome/resolvers.lua
index 00f3c6eb95..9e81fe55df 100644
--- a/game/modules/tome/resolvers.lua
+++ b/game/modules/tome/resolvers.lua
@@ -56,6 +56,10 @@ function resolvers.calc.equip(t, e)
 			game.zone:addEntity(game.level, o, "object")
 
 			if t[1].id then o:identify(t[1].id) end
+
+			if filter.random_art_replace then
+				o.__special_boss_drop = filter.random_art_replace
+			end
 		end
 	end
 	-- Delete the origin field
@@ -115,6 +119,10 @@ function resolvers.calc.drops(t, e)
 			game.zone:addEntity(game.level, o, "object")
 
 			if t.id then o:identify(t.id) end
+
+			if filter.random_art_replace then
+				o.__special_boss_drop = filter.random_art_replace
+			end
 		end
 	end
 	-- Delete the origin field
-- 
GitLab