From 1ceec10a56ccb951eb35581113ad950e96a45844 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Fri, 13 Aug 2010 11:50:00 +0000
Subject: [PATCH] Added three new artifacts The Orbs of Command now grant a
 stat increase while carried

git-svn-id: http://svn.net-core.org/repos/t-engine4@1016 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engine/Actor.lua                         |  2 +
 game/engine/interface/ActorInventory.lua      | 12 ++-
 game/modules/tome/class/Actor.lua             | 13 +++
 game/modules/tome/class/Game.lua              |  2 +
 game/modules/tome/class/Object.lua            |  5 +
 game/modules/tome/data/damage_types.lua       |  4 +-
 .../data/general/objects/quest-artifacts.lua  | 16 +++
 .../data/general/objects/world-artifacts.lua  | 98 ++++++++++++++++++-
 .../data/talents/gifts/summon-utility.lua     |  2 +-
 game/modules/tome/data/talents/misc/npcs.lua  |  2 +-
 .../tome/data/talents/techniques/archery.lua  |  2 +-
 11 files changed, 147 insertions(+), 11 deletions(-)

diff --git a/game/engine/Actor.lua b/game/engine/Actor.lua
index ae58809e84..d7297b10d2 100644
--- a/game/engine/Actor.lua
+++ b/game/engine/Actor.lua
@@ -27,6 +27,8 @@ module(..., package.seeall, class.inherit(Entity))
 _M.display_on_seen = true
 _M.display_on_remember = false
 _M.display_on_unknown = false
+-- Allow actors to act as object carriers, if the interface is loaded
+_M.__allow_carrier = true
 
 function _M:init(t, no_default)
 	t = t or {}
diff --git a/game/engine/interface/ActorInventory.lua b/game/engine/interface/ActorInventory.lua
index e960d57752..476beb68c9 100644
--- a/game/engine/interface/ActorInventory.lua
+++ b/game/engine/interface/ActorInventory.lua
@@ -174,11 +174,13 @@ end
 
 --- Called upon adding an object
 function _M:onAddObject(o)
-	-- Apply carrier properties
-	if o.carrier then
+	if self.__allow_carrier then
+		-- Apply carrier properties
 		o.carried = {}
-		for k, e in pairs(o.carrier) do
-			o.carried[k] = self:addTemporaryValue(k, e)
+		if o.carrier then
+			for k, e in pairs(o.carrier) do
+				o.carried[k] = self:addTemporaryValue(k, e)
+			end
 		end
 	end
 end
@@ -346,8 +348,8 @@ end
 --- Call when an object is worn
 function _M:onWear(o)
 	-- Apply wielder properties
+	o.wielded = {}
 	if o.wielder then
-		o.wielded = {}
 		for k, e in pairs(o.wielder) do
 			o.wielded[k] = self:addTemporaryValue(k, e)
 		end
diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 31d31ef511..e32c566c21 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -292,6 +292,18 @@ function _M:probabilityTravel(x, y, dist)
 	return true
 end
 
+--- Teleports randomly to a passable grid
+-- This simply calls the default actor teleportRandom but first checks for space-time stability
+-- @param x the coord of the teleporatation
+-- @param y the coord of the teleporatation
+-- @param dist the radius of the random effect, if set to 0 it is a precise teleport
+-- @param min_dist the minimun radius of of the effect, will never teleport closer. Defaults to 0 if not set
+-- @return true if the teleport worked
+function _M:teleportRandom(x, y, dist, min_dist)
+
+	return engine.Actor.teleportRandom(x, y, dist, min_dist)
+end
+
 --- Quake a zone
 -- Moves randomly each grid to an other grid
 function _M:doQuake(tg, x, y)
@@ -1185,6 +1197,7 @@ function _M:canBe(what)
 	if what == "blind" and rng.percent(100 * (self:attr("blind_immune") or 0)) then return false end
 	if what == "silence" and rng.percent(100 * (self:attr("silence_immune") or 0)) then return false end
 	if what == "disarm" and rng.percent(100 * (self:attr("disarm_immune") or 0)) then return false end
+	if what == "pin" and rng.percent(100 * (self:attr("pin_immune") or 0)) then return false end
 	if what == "stun" and rng.percent(100 * (self:attr("stun_immune") or 0)) then return false end
 	if what == "fear" and rng.percent(100 * (self:attr("fear_immune") or 0)) then return false end
 	if what == "knockback" and rng.percent(100 * (self:attr("knockback_immune") or 0)) then return false end
diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 64d9da091f..9f8d4a6272 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -485,6 +485,8 @@ function _M:setupCommands()
 		end,
 		[{"_f","ctrl"}] = function()
 			if config.settings.tome.cheat then
+				self.player:incStat("str", 100) self.player:incStat("dex", 100) self.player:incStat("mag", 100) self.player:incStat("wil", 100) self.player:incStat("cun", 100) self.player:incStat("con", 100)
+				self.player:learnTalent(self.player.T_HEAVY_ARMOUR_TRAINING, true) self.player:learnTalent(self.player.T_MASSIVE_ARMOUR_TRAINING, true)
 				for i, e in ipairs(self.zone.object_list) do
 					if e.unique and e.rarity then
 						local a = self.zone:finishEntity(self.level, "object", e)
diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua
index d50b9a2426..989d786b24 100644
--- a/game/modules/tome/class/Object.lua
+++ b/game/modules/tome/class/Object.lua
@@ -68,6 +68,10 @@ function _M:use(who, typ)
 		game.logPlayer(who, "You are silenced!")
 		return
 	end
+	if self:wornInven() and not self.wielded and not self.use_no_wear then
+		game.logPlayer(who, "You must wear this object to use it!")
+		return
+	end
 
 	local types = {}
 	if self:canUseObject() then types[#types+1] = "use" end
@@ -286,6 +290,7 @@ function _M:getTextualDesc()
 	if w.silence_immune then desc[#desc+1] = ("Increases silence immunity: %d%%."):format(w.silence_immune * 100) end
 	if w.disarm_immune then desc[#desc+1] = ("Increases disarm immunity: %d%%."):format(w.disarm_immune * 100) end
 	if w.confusion_immune then desc[#desc+1] = ("Increases confusion immunity: %d%%."):format(w.confusion_immune * 100) end
+	if w.pin_immune then desc[#desc+1] = ("Increases pinning immunity: %d%%."):format(w.pin_immune * 100) end
 	if w.stun_immune then desc[#desc+1] = ("Increases stun immunity: %d%%."):format(w.stun_immune * 100) end
 	if w.fear_immune then desc[#desc+1] = ("Increases fear immunity: %d%%."):format(w.fear_immune * 100) end
 	if w.knockback_immune then desc[#desc+1] = ("Increases knockback immunity: %d%%."):format(w.knockback_immune * 100) end
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index 3c2b3e1ef9..c957051c50 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -328,7 +328,7 @@ newDamageType{
 		DamageType:get(DamageType.COLD).projector(src, x, y, DamageType.COLD, dam.dam)
 		local target = game.level.map(x, y, Map.ACTOR)
 		if target then
-			if target:checkHit(src:combatSpellpower(), target:combatSpellResist(), 0, 95, 15) and target:canBe("stun") and not target:attr("fly") and not target:attr("levitation") then
+			if target:checkHit(src:combatSpellpower(), target:combatSpellResist(), 0, 95, 15) and target:canBe("pin") and target:canBe("stun") and not target:attr("fly") and not target:attr("levitation") then
 				target:setEffect(target.EFF_FROZEN_FEET, dam.dur, {})
 			end
 		end
@@ -584,7 +584,7 @@ newDamageType{
 		DamageType:get(DamageType.PHYSICAL).projector(src, x, y, DamageType.PHYSICAL, dam.dam)
 		local target = game.level.map(x, y, Map.ACTOR)
 		if target then
-			if target:checkHit(src:combatAttackStr(), target:combatPhysicalResist(), 0, 95, 15) then
+			if target:checkHit(src:combatAttackStr(), target:combatPhysicalResist(), 0, 95, 15) and target:canBe("pin") then
 				target:setEffect(target.EFF_PINNED, dam.dur, {})
 			else
 				game.logSeen(target, "%s resists!", target.name:capitalize())
diff --git a/game/modules/tome/data/general/objects/quest-artifacts.lua b/game/modules/tome/data/general/objects/quest-artifacts.lua
index 98e382b19a..595300a639 100644
--- a/game/modules/tome/data/general/objects/quest-artifacts.lua
+++ b/game/modules/tome/data/general/objects/quest-artifacts.lua
@@ -114,6 +114,10 @@ newEntity{ define_as = "ORB_UNDEATH",
 			return true
 		end
 	end,
+
+	carrier = {
+		inc_stats = { [Stats.STAT_DEX] = 6, },
+	},
 }
 
 -- Gorbat Pride
@@ -133,6 +137,10 @@ newEntity{ define_as = "ORB_DRAGON",
 			return true
 		end
 	end,
+
+	carrier = {
+		inc_stats = { [Stats.STAT_CUN] = 6, },
+	},
 }
 
 -- Vor Pride
@@ -152,6 +160,10 @@ newEntity{ define_as = "ORB_ELEMENTS",
 			return true
 		end
 	end,
+
+	carrier = {
+		inc_stats = { [Stats.STAT_MAG] = 6, },
+	},
 }
 
 -- Grushnak Pride
@@ -171,4 +183,8 @@ newEntity{ define_as = "ORB_DESTRUCTION",
 			return true
 		end
 	end,
+
+	carrier = {
+		inc_stats = { [Stats.STAT_STR] = 6, },
+	},
 }
diff --git a/game/modules/tome/data/general/objects/world-artifacts.lua b/game/modules/tome/data/general/objects/world-artifacts.lua
index 1aea25624c..9b8d1f88d9 100644
--- a/game/modules/tome/data/general/objects/world-artifacts.lua
+++ b/game/modules/tome/data/general/objects/world-artifacts.lua
@@ -96,7 +96,7 @@ newEntity{ base = "BASE_RING",
 	unided_name = "multi-hued ring",
 	desc = [[This ring shines with many colors.]],
 	level_range = {15, 30},
-	rarity = 150,
+	rarity = 200,
 	cost = 500,
 	material_level = 3,
 
@@ -416,3 +416,99 @@ newEntity{
 		end
 	end },
 }
+
+newEntity{ base = "BASE_HELM",
+	unique = true,
+	name = "Star of Earendil",
+	unided_name = "shining helm",
+	desc = [[A headband with a glowing gem set in it, made in likeness of the silmaril that Earendil wore, and imbued with some of its light.]],
+	level_range = {20, 28},
+	rarity = 240,
+	cost = 700,
+	material_level = 4,
+	wielder = {
+		lite = 1,
+		combat_armor = 6,
+		fatigue = 4,
+		blind_immune = 0.3,
+		inc_stats = { [Stats.STAT_WIL] = 3, [Stats.STAT_MAG] = 4, },
+	},
+	max_power = 30, power_regen = 1,
+	use_talent = { id = Talents.T_SUN_FLARE, level = 3, power = 30 },
+}
+
+newEntity{ base = "BASE_KNIFE",
+	unique = true,
+	name = "Sting, Bilbo's Small Sword",
+	unided_name = "shining dagger",
+	desc = [["I will give you a name, and I shall call you Sting."
+The perfect size for Bilbo, and stamped forever by the courage he found in Mirkwood, this sturdy little blade grants the wearer combat prowess and survivalabilities they did not know they had.]],
+	level_range = {40, 50},
+	rarity = 300,
+	require = { stat = { dex=44 }, },
+	cost = 550,
+	material_level = 5,
+	combat = {
+		dam = 45,
+		apr = 11,
+		physcrit = 18,
+		dammod = {dex=0.55,str=0.35},
+	},
+	wielder = {
+		lite = 1,
+		inc_damage={
+			[DamageType.PHYSICAL] = 10,
+			[DamageType.LIGHT] = 8,
+		},
+		pin_immune = 0.5,
+		inc_stats = { [Stats.STAT_DEX] = 5, [Stats.STAT_CUN] = 4, },
+		esp = {["humanoid/orc"]=1},
+	},
+}
+
+newEntity{ base = "BASE_RING",
+	unique = true,
+	name = "Ring of the War Master", color = colors.DARK_GREY,
+	unided_name = "blade-edged ring",
+	desc = [[Elrond was told of the way to fashion a fourth ring by Celebrimbor, one he did not make out of fear it would also fall under the influence of the Ruling Ring.
+After Frodo destroyed it, Elrond passed the knowledge to Aragorn the King of Men to use against any remaining forces which once followed Sauron.]],
+	level_range = {15, 30},
+	rarity = 200,
+	cost = 500,
+	material_level = 5,
+
+	wielder = {
+		inc_stats = { [Stats.STAT_STR] = 3, [Stats.STAT_DEX] = 3, [Stats.STAT_CON] = 3, },
+		talents_types_mastery = {
+			["technique/2hweapon-cripple"] = 0.1,
+			["technique/2hweapon-offense"] = 0.1,
+			["technique/archery-bow"] = 0.1,
+			["technique/archery-sling"] = 0.1,
+			["technique/archery-training"] = 0.1,
+			["technique/archery-utility"] = 0.1,
+			["technique/combat-techniques-active"] = 0.1,
+			["technique/combat-techniques-passive"] = 0.1,
+			["technique/combat-training"] = 0.1,
+			["technique/dualweapon-attack"] = 0.1,
+			["technique/dualweapon-training"] = 0.1,
+			["technique/shield-defense"] = 0.1,
+			["technique/shield-offense"] = 0.1,
+		},
+	},
+}
+
+newEntity{
+	unique = true,
+	type = "jewelry", subtype="anhk",
+	unided_name = "glowing anhk",
+	name = "Anchoring Anhk",
+	desc = [[As you lift the anhk you feel stable. The world around you feels stable.]],
+	level_range = {15, 50},
+	rarity = 400,
+	display = "*", color=colors.YELLOW, image = "object/fireopal.png",
+	encumber = 2,
+
+	carrier = {
+
+	},
+}
diff --git a/game/modules/tome/data/talents/gifts/summon-utility.lua b/game/modules/tome/data/talents/gifts/summon-utility.lua
index 07694634ad..877f68f5a4 100644
--- a/game/modules/tome/data/talents/gifts/summon-utility.lua
+++ b/game/modules/tome/data/talents/gifts/summon-utility.lua
@@ -80,7 +80,7 @@ newTalent{ short_name="SPIDER_WEB",
 		if not x or not y then return nil end
 		self:project(tg, x, y, function(tx, ty)
 			local target = game.level.map(tx, ty, Map.ACTOR)
-			if target and target:checkHit(self:combatAttackStr(), target:combatPhysicalResist(), 0, 95, 7) then
+			if target and target:checkHit(self:combatAttackStr(), target:combatPhysicalResist(), 0, 95, 7) and target:canBe("pin") then
 				target:setEffect(target.EFF_PINNED, 3 + self:getTalentLevel(t), {})
 			end
 		end)
diff --git a/game/modules/tome/data/talents/misc/npcs.lua b/game/modules/tome/data/talents/misc/npcs.lua
index ab8c4fe7d0..1d48da8789 100644
--- a/game/modules/tome/data/talents/misc/npcs.lua
+++ b/game/modules/tome/data/talents/misc/npcs.lua
@@ -611,7 +611,7 @@ newTalent{
 				return mod.class.Trap.canTrigger(self, x, y, who)
 			end,
 			triggered = function(self, x, y, who)
-				if who:checkHit(self.disarm_power + 5, who:combatPhysicalResist(), 0, 95, 15) and who:canBe("stun") then
+				if who:checkHit(self.disarm_power + 5, who:combatPhysicalResist(), 0, 95, 15) and who:canBe("stun") and who:canBe("pin") then
 					who:setEffect(who.EFF_PINNED, dur, {})
 				else
 					game.logSeen(who, "%s resists!", who.name:capitalize())
diff --git a/game/modules/tome/data/talents/techniques/archery.lua b/game/modules/tome/data/talents/techniques/archery.lua
index 4d5abbe819..0e70367b6c 100644
--- a/game/modules/tome/data/talents/techniques/archery.lua
+++ b/game/modules/tome/data/talents/techniques/archery.lua
@@ -234,7 +234,7 @@ newTalent{
 	require = techs_dex_req3,
 	range = 20,
 	archery_onhit = function(self, t, target, x, y)
-		if target:checkHit(self:combatAttackDex(), target:combatPhysicalResist(), 0, 95, 10) then
+		if target:checkHit(self:combatAttackDex(), target:combatPhysicalResist(), 0, 95, 10) and target:canBe("pin") then
 			target:setEffect(target.EFF_PINNED, 2 + self:getTalentLevelRaw(t), {})
 		else
 			game.logSeen(target, "%s resists!", target.name:capitalize())
-- 
GitLab