From 7cdf22d873e5b086bc1fdcd2685a0a09cb1aeec4 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Fri, 17 Feb 2012 01:04:04 +0000
Subject: [PATCH] Boots of Spellbinding and Staff of Channeling reworked Corona
 no longer deactivates when there's no energy to fire Added Spell Cooldown,
 Mind Crit, and Crit Reduction to the character sheet Darkest Light can no
 longer give back negative energy (for real this time)

git-svn-id: http://svn.net-core.org/repos/t-engine4@4885 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Object.lua            |  1 +
 game/modules/tome/class/interface/Combat.lua  | 27 ++++++++++---------
 .../tome/class/interface/TooltipsData.lua     | 14 +++++++++-
 .../data/general/objects/boss-artifacts.lua   |  2 +-
 .../tome/data/general/objects/egos/boots.lua  | 11 ++++----
 .../tome/data/general/objects/egos/staves.lua | 23 +++++++++++++---
 .../tome/data/talents/celestial/eclipse.lua   |  9 ++++---
 .../tome/data/talents/spells/earth.lua        |  2 +-
 .../tome/data/timed_effects/physical.lua      |  2 ++
 game/modules/tome/dialogs/CharacterSheet.lua  | 11 ++++++--
 10 files changed, 72 insertions(+), 30 deletions(-)

diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua
index f6b4586571..7c51857cc7 100644
--- a/game/modules/tome/class/Object.lua
+++ b/game/modules/tome/class/Object.lua
@@ -760,6 +760,7 @@ function _M:getTextualDesc(compare_with)
 
 		compare_fields(w, compare_with, field, "combat_spellpower", "%+d", "Spellpower: ")
 		compare_fields(w, compare_with, field, "combat_spellcrit", "%+d%%", "Spell crit. chance: ")
+		compare_fields(w, compare_with, field, "spell_cooldown_reduction", "%d%%", "Lowers spell cool-downs by: ", 100)
 
 		compare_fields(w, compare_with, field, "combat_mindpower", "%+d", "Mindpower: ")
 		compare_fields(w, compare_with, field, "combat_mindcrit", "%+d%%", "Mental crit. chance: ")
diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua
index 2e9a9ead6e..5a801bec4f 100644
--- a/game/modules/tome/class/interface/Combat.lua
+++ b/game/modules/tome/class/interface/Combat.lua
@@ -1042,6 +1042,18 @@ function _M:combatSummonSpeed()
 	return math.max(1 - ((self:attr("fast_summons") or 0) / 100), 0.1)
 end
 
+--- Computes physical crit chance reduction
+function _M:combatCritReduction()
+	local crit_reduction = 0
+	if self:hasHeavyArmor() and self:knowTalent(self.T_ARMOUR_TRAINING) then
+		crit_reduction = crit_reduction + self:getTalentLevel(self.T_ARMOUR_TRAINING) * 1.9
+	end
+	if self:attr("combat_crit_reduction") then
+		crit_reduction = crit_reduction + self:attr("combat_crit_reduction")
+	end
+	return crit_reduction
+end
+
 --- Computes physical crit for a damage
 function _M:physicalCrit(dam, weapon, target, atk, def)
 	local tier_diff = self:getTierDiff(atk, def)
@@ -1054,8 +1066,8 @@ function _M:physicalCrit(dam, weapon, target, atk, def)
 	local crit = false
 	if self:knowTalent(self.T_BACKSTAB) and target:attr("stunned") then chance = chance + self:getTalentLevel(self.T_BACKSTAB) * 10 end
 
-	if target:attr("combat_critical") then
-		chance = chance + target:attr("combat_critical")
+	if target:attr("combat_crit_vulnerable") then
+		chance = chance + target:attr("combat_crit_vulnerable")
 	end
 	if target:hasEffect(target.EFF_SET_UP) then
 		local p = target:hasEffect(target.EFF_SET_UP)
@@ -1063,17 +1075,8 @@ function _M:physicalCrit(dam, weapon, target, atk, def)
 			chance = chance + p.power
 		end
 	end
-	if target:hasEffect(target.EFF_OFFGUARD) then
-		chance = chance + 10
-	end
-
-	if target:hasHeavyArmor() and target:knowTalent(target.T_ARMOUR_TRAINING) then
-		chance = chance - target:getTalentLevel(target.T_ARMOUR_TRAINING) * 1.9
-	end
 
-	if target:attr("combat_critreduction") then
-		chance = chance - target:attr("combat_critreduction")
-	end
+	chance = chance - target:combatCritReduction()
 
 	if target:hasEffect(target.EFF_DISMAYED) then
 		chance = 100
diff --git a/game/modules/tome/class/interface/TooltipsData.lua b/game/modules/tome/class/interface/TooltipsData.lua
index c09c5fbdee..df863ff21b 100644
--- a/game/modules/tome/class/interface/TooltipsData.lua
+++ b/game/modules/tome/class/interface/TooltipsData.lua
@@ -239,6 +239,9 @@ TOOLTIP_ARMOR_HARDINESS = [[#GOLD#Armour Hardiness#LAST#
 Armour hardiness value represents how much of every incoming blows the armour will affect.
 Absorbs (hardiness)% of incoming physical damage, up to a maximum of (armour) damage absorbed.
 ]]
+TOOLTIP_CRIT_REDUCTION = [[#GOLD#Crit Reduction#LAST#
+Crit reduction reduces the chance an opponent has of landing a critical strike with a melee or ranged attack.
+]]
 TOOLTIP_DEFENSE = [[#GOLD#Defense#LAST#
 Defense represents your chance to avoid physical melee attacks and reduces the chance you'll be knocked off-balance by an enemies attack. It is measured against the attacker's Accuracy.
 ]]
@@ -263,7 +266,7 @@ Your spellpower value represents how powerful your spells are.
 In addition, when your spells inflict temporary detrimental effects, every point your opponent's relevant saving throw exceeds your spellpower will reduce the duration of the effect by 5%.
 ]]
 TOOLTIP_SPELL_CRIT = [[#GOLD#Spell critical chance#LAST#
-Each time you deal damage with a spell you have a chance to make a critical hit that deals 150% of the normal damage.
+Each time you deal damage with a spell you may have a chance to make a critical hit that deals 150% of the normal damage.
 Some talents allow you to increase this percentage.
 It is improved by Cunning.
 ]]
@@ -271,10 +274,19 @@ TOOLTIP_SPELL_SPEED = [[#GOLD#Spellcasting speed#LAST#
 Spellcasting speed represents how fast your spellcasting is compared to a normal turn.
 The lower it is the faster it is.
 ]]
+TOOLTIP_SPELL_COOLDOWN = [[#GOLD#Spellcooldown#LAST#
+Spell cooldown represents how fast your spells will come off of cooldown.
+The lower it is the more often you'll be able to use your spell talents and runes.
+]]
 TOOLTIP_MINDPOWER = [[#GOLD#Mindpower#LAST#
 Your mindpower value represents how powerful your mental abilities are.
 In addition, when your mental abilities inflict temporary detrimental effects, every point your opponent's relevant saving throw exceeds your  mindpower will reduce the duration of the effect by 5%.
 ]]
+TOOLTIP_MIND_CRIT = [[#GOLD#Mental critical chance#LAST#
+Each time you deal damage with a mental attack you may have a chance to make a critical hit that deals 150% of the normal damage.
+Some talents allow you to increase this percentage.
+It is improved by Cunning.
+]]
 
 -------------------------------------------------------------
 -- Damage and resists
diff --git a/game/modules/tome/data/general/objects/boss-artifacts.lua b/game/modules/tome/data/general/objects/boss-artifacts.lua
index 489843de2e..9be1819d7d 100644
--- a/game/modules/tome/data/general/objects/boss-artifacts.lua
+++ b/game/modules/tome/data/general/objects/boss-artifacts.lua
@@ -1145,7 +1145,7 @@ Though clearly a powerful piece, it must once have been much greater.]],
 		knockback_immune = 0.3,
 
 		combat_physresist = 15,
-		combat_critreduction = 20,
+		combat_crit_reduction = 20,
 	},
 }
 
diff --git a/game/modules/tome/data/general/objects/egos/boots.lua b/game/modules/tome/data/general/objects/egos/boots.lua
index 0895bbaeb9..d81e759ba1 100644
--- a/game/modules/tome/data/general/objects/egos/boots.lua
+++ b/game/modules/tome/data/general/objects/egos/boots.lua
@@ -172,6 +172,7 @@ newEntity{
 newEntity{
 	power_source = {technique=true},
 	name = "stalker's ", prefix=true, instant_resolve=true,
+	keywords = {stalker=true},
 	level_range = {1, 50},
 	rarity = 5,
 	cost = 6,
@@ -357,21 +358,21 @@ newEntity{
 		},
 	},
 }
--- TODO: Make into an artifact effect and remove
+
 newEntity{
 	power_source = {arcane=true},
 	name = " of spellbinding", suffix=true, instant_resolve=true,
 	keywords = {spellbinding=true},
-	level_range = {10, 50},
+	level_range = {30, 50},
 	greater_ego = 1,
-	rarity = 35,
+	rarity = 30,
 	cost = 30,
-	max_power = 80, power_regen = 1,
-	use_talent = { id = Talents.T_METAFLOW, level = 2, power = 80 },
 	wielder = {
 		inc_stats = {
 			[Stats.STAT_MAG] = resolvers.mbonus_material(5, 1),
 		},
+		combat_spellresist = resolvers.mbonus_material(7, 1),
+		spell_cooldown_reduction = 0.1,
 	},
 }
 
diff --git a/game/modules/tome/data/general/objects/egos/staves.lua b/game/modules/tome/data/general/objects/egos/staves.lua
index 0f6b6ed8cf..e208ba884d 100644
--- a/game/modules/tome/data/general/objects/egos/staves.lua
+++ b/game/modules/tome/data/general/objects/egos/staves.lua
@@ -275,21 +275,36 @@ newEntity{
 	use_talent = { id = Talents.T_DISPLACEMENT_SHIELD, level = 4, power = 80 },
 }
 
--- TODO: Make into an artifact effect and remove
 newEntity{
 	power_source = {arcane=true},
 	name = " of channeling", suffix=true, instant_resolve=true,
 	keywords = {channeling=true},
 	level_range = {30, 50},
 	greater_ego = 1,
-	rarity = 38,
+	rarity = 20,
 	cost = 45,
 	wielder = {
 		combat_spellpower = resolvers.mbonus_material(12, 3),
 		mana_regen = resolvers.mbonus_material(30, 10, function(e, v) v=v/100 return 0, v end),
 	},
-	max_power = 80, power_regen = 1,
-	use_talent = { id = Talents.T_METAFLOW, level = 3, power = 80 },
+	max_power = 30, power_regen = 1,
+	use_power = { name = "channel mana (increasing mana regen by 500% for ten turns)", power = 30,
+		use = function(self, who)
+			if who.mana_regen > 0 and not who:hasEffect(who.EFF_MANASURGE) then
+				who:setEffect(who.EFF_MANASURGE, 10, {power=who.mana_regen * 5})
+			else
+				if who.mana_regen < 0 then
+					game.logPlayer(who, "Your negative mana regeneration rate is unaffected by the staff.")
+				elseif who:hasEffect(who.EFF_MANASURGE) then
+					game.logPlayer(who, "Another mana surge is currently active.")
+				else
+					game.logPlayer(who, "Your nonexistant mana regeneration rate is unaffected by the staff.")
+				end
+			end
+			game.logSeen(who, "%s is channeling mana!", who.name:capitalize())
+			return {id=true, used=true}
+		end
+	},
 }
 
 newEntity{
diff --git a/game/modules/tome/data/talents/celestial/eclipse.lua b/game/modules/tome/data/talents/celestial/eclipse.lua
index 1c0e47a43c..a0b06d9767 100644
--- a/game/modules/tome/data/talents/celestial/eclipse.lua
+++ b/game/modules/tome/data/talents/celestial/eclipse.lua
@@ -84,8 +84,8 @@ newTalent{
 	getDarknessDamage = function(self, t) return self:combatTalentSpellDamage(t, 15, 70) end,
 	on_crit = function(self, t)
 		if self:getPositive() < 2 or self:getNegative() < 2 then
-			self:forceUseTalent(t.id, {ignore_energy=true})
-			return
+		--	self:forceUseTalent(t.id, {ignore_energy=true})
+			return nil
 		end
 		local tgts = {}
 		local grids = core.fov.circle_grids(self.x, self.y, 10, true)
@@ -127,7 +127,8 @@ newTalent{
 		local lightdamage = t.getLightDamage(self, t)
 		local darknessdamage = t.getDarknessDamage(self, t)
 		return ([[Each time one of your spells is a critical you project a bolt of light or shadow at %d targets in a radius of 10, doing %0.2f light damage or %0.2f darkness damage.
-		The damage scales with the Magic stat and each bolt fired will cost 2 positive or negative energy respectively.]]):
+		This effect costs 2 positive or 2 negative energy each time it's triggered and will not trigger if either your positive or negative energy is below 2.
+		The damage scales with the Magic stat.]]):
 		format(targetcount, damDesc(self, DamageType.LIGHT, lightdamage), damDesc(self, DamageType.DARKNESS, darknessdamage))
 	end,
 }
@@ -142,7 +143,7 @@ newTalent{
 	sustain_negative = 10,
 	tactical = { DEFEND = 2, ESCAPE = 2 },
 	getInvisibilityPower = function(self, t) return 5 + (self:getCun() / 15) * self:getTalentLevel(t) end,
-	getEnergyConvert = function(self, t) return 6 - math.max(0, self:getTalentLevelRaw(t)) end,
+	getEnergyConvert = function(self, t) return math.max(0, 6 - self:getTalentLevelRaw(t)) end,
 	getDamage = function(self, t) return self:combatTalentSpellDamage(t, 10, 100) end,
 	getRadius = function(self, t) return 2 + self:getTalentLevel(t) / 2 end,
 	activate = function(self, t)
diff --git a/game/modules/tome/data/talents/spells/earth.lua b/game/modules/tome/data/talents/spells/earth.lua
index 4766b8a21f..4c00ffc079 100644
--- a/game/modules/tome/data/talents/spells/earth.lua
+++ b/game/modules/tome/data/talents/spells/earth.lua
@@ -131,7 +131,7 @@ newTalent{
 			if not x or not y then return nil end
 		end
 
-		for _, coord in pairs(util.adjacentCoords(self.x, self.y)) do if game.level.map:isBound(coord[1], coord[2]) then
+		for _, coord in pairs(util.adjacentCoords(x, y)) do if game.level.map:isBound(coord[1], coord[2]) then
 			if not game.level.map:checkAllEntities(coord[1], coord[2], "block_move") then
 				-- Ok some explanation, we make a new *OBJECT* because objects can have energy and act
 				-- it stores the current terrain in "old_feat" and restores it when it expires
diff --git a/game/modules/tome/data/timed_effects/physical.lua b/game/modules/tome/data/timed_effects/physical.lua
index d46bbc3b10..932992d6e4 100644
--- a/game/modules/tome/data/timed_effects/physical.lua
+++ b/game/modules/tome/data/timed_effects/physical.lua
@@ -1456,8 +1456,10 @@ newEffect{
 	on_gain = function(self, err) return nil, "+Off-guard" end,
 	on_lose = function(self, err) return nil, "-Off-guard" end,
 	activate = function(self, eff)
+		eff.crit_vuln = self:addTemporaryValue("combat_crit_vulnerable", 10) -- increases chance to be crit
 	end,
 	deactivate = function(self, eff)
+		self:removeTemporaryValue("combat_crit_vulnerable", eff.crit_vuln)
 	end,
 }
 
diff --git a/game/modules/tome/dialogs/CharacterSheet.lua b/game/modules/tome/dialogs/CharacterSheet.lua
index 7178673764..df3add3c2d 100644
--- a/game/modules/tome/dialogs/CharacterSheet.lua
+++ b/game/modules/tome/dialogs/CharacterSheet.lua
@@ -639,11 +639,16 @@ function _M:drawDialog(kind, actor_to_compare)
 		self:mouseTooltip(self.TOOLTIP_SPELL_CRIT, s:drawColorStringBlended(self.font,  ("Crit. chance: #00ff00#%s"):format(text), w, h, 255, 255, 255, true)) h = h + self.font_h
 		text = compare_fields(player, actor_to_compare, function(actor, ...) return actor:combatSpellSpeed() end, "%.2f%%", "%+.2f%%", 100)
 		self:mouseTooltip(self.TOOLTIP_SPELL_SPEED, s:drawColorStringBlended(self.font, ("Spell speed : #00ff00#%s"):format(text), w, h, 255, 255, 255, true)) h = h + self.font_h
+		text = compare_fields(player, actor_to_compare, function(actor, ...) return (1 - (actor.spell_cooldown_reduction or 0)) * 100 end, "%3d%%", "%+.0f%%")
+		self:mouseTooltip(self.TOOLTIP_SPELL_COOLDOWN  , s:drawColorStringBlended(self.font,   ("Spell cooldown: #00ff00#%s"):format(text), w, h, 255, 255, 255, true)) h = h + self.font_h
 		h = h + self.font_h
+		s:drawColorStringBlended(self.font, "#LIGHT_BLUE#Mental:", w, h, 255, 255, 255, true) h = h + self.font_h
 		text = compare_fields(player, actor_to_compare, function(actor, ...) return actor:combatMindpower() end, "%3d", "%+.0f")
 		dur_text = ("%d"):format(math.floor(player:combatMindpower()/5))
 		self:mouseTooltip(self.TOOLTIP_MINDPOWER, s:drawColorStringBlended(self.font, ("Mindpower: #00ff00#%s"):format(text, dur_text), w, h, 255, 255, 255, true)) h = h + self.font_h
-
+		text = compare_fields(player, actor_to_compare, function(actor, ...) return actor:combatMindCrit() end, "%d%%", "%+.0f%%")
+		self:mouseTooltip(self.TOOLTIP_MIND_CRIT, s:drawColorStringBlended(self.font,  ("Crit. chance: #00ff00#%s"):format(text), w, h, 255, 255, 255, true)) h = h + self.font_h
+		
 		h = 0
 		w = self.w * 0.5
 
@@ -775,7 +780,9 @@ function _M:drawDialog(kind, actor_to_compare)
 		self:mouseTooltip(self.TOOLTIP_DEFENSE, s:drawColorStringBlended(self.font,           ("Defense         : #00ff00#%s"):format(text), w, h, 255, 255, 255, true)) h = h + self.font_h
 		text = compare_fields(player, actor_to_compare, function(actor, ...) return actor:combatDefenseRanged(true) end, "%3d", "%+.0f")
 		self:mouseTooltip(self.TOOLTIP_RDEFENSE,s:drawColorStringBlended(self.font,           ("Ranged Defense  : #00ff00#%s"):format(text), w, h, 255, 255, 255, true)) h = h + self.font_h
-
+		text = compare_fields(player, actor_to_compare, function(actor, ...) return actor:combatCritReduction()  end, "%d%%", "%+.0f%%")
+		self:mouseTooltip(self.TOOLTIP_CRIT_REDUCTION,s:drawColorStringBlended(self.font,           ("Crit. Reduction  : #00ff00#%s"):format(text), w, h, 255, 255, 255, true)) h = h + self.font_h
+		
 		h = h + self.font_h
 		s:drawColorStringBlended(self.font, "#LIGHT_BLUE#Saves:", w, h, 255, 255, 255, true) h = h + self.font_h
 		text = compare_fields(player, actor_to_compare, function(actor, ...) return math.floor(actor:combatPhysicalResist(true)) end, "%3d", "%+.0f")
-- 
GitLab