From 497207b2171116263a3525bba865d7f761b78fdc Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Thu, 24 Feb 2011 23:37:28 +0000
Subject: [PATCH] fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@2831 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Actor.lua             | 20 +++++++++----------
 game/modules/tome/data/damage_types.lua       |  6 ++++--
 game/modules/tome/data/general/npcs/all.lua   |  1 +
 .../data/general/objects/boss-artifacts.lua   |  2 +-
 .../data/talents/chronomancy/anomalies.lua    |  2 +-
 .../tome/data/talents/chronomancy/gravity.lua |  2 +-
 .../talents/chronomancy/spacetime-weaving.lua |  5 +++--
 .../talents/chronomancy/speed-control.lua     |  2 +-
 game/modules/tome/data/talents/misc/misc.lua  |  1 +
 .../tome/data/talents/techniques/archery.lua  |  1 +
 game/modules/tome/data/timed_effects.lua      |  9 +++++++++
 11 files changed, 33 insertions(+), 18 deletions(-)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index cc868dc422..7e91d6d372 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -1564,7 +1564,7 @@ function _M:equilibriumChance(eq)
 end
 
 --- Paradox check
-function _M:paradoxChance(pa)
+function _M:paradoxFailChance(pa)
 	--check for Paradox Mastery
 	if self:knowTalent(self.T_PARADOX_MASTERY) and self:isTalentActive(self.T_PARADOX_MASTERY) then
 		modifier = self:getWil() * (1 + (self:getTalentLevel(self.T_PARADOX_MASTERY)/10) or 0 )
@@ -1574,7 +1574,7 @@ function _M:paradoxChance(pa)
 	--print("[Paradox] Will modifier: ", modifier, "::", self:getParadox())
 	local chance = math.pow (((self:getParadox() - modifier)/200), 2)*((100 + self:combatFatigue()) / 100)
 	--print("[Paradox] Fail chance: ", chance, "::", self:getParadox())
-	return rng.percent(100 - chance * 100), 100 - chance * 100
+	return rng.percent(chance)
 end
 
 --- Called before a talent is used
@@ -1672,8 +1672,14 @@ function _M:preUseTalent(ab, silent, fake)
 
 	-- Paradox is special, it has no max, but the higher it is the higher the chance of something bad happening
 	if (ab.paradox or ab.sustain_paradox) and not fake then
-		-- Check anomalies first
-		if not game.zone.no_anomalies and not self:attr("no_paradox_fail") and rng.percent(math.pow((self:getParadox()/400), 4)) then
+		-- Check failure first
+		if not self:attr("no_paradox_fail") and self:paradoxFailChance(ab.paradox or ab.sustain_paradox) then
+			if not silent then game.logPlayer(self, "You fail to use %s due to your paradox!", ab.name) end
+			self:incParadox(ab.paradox or ab.paradox_sustain / 10)
+			self:useEnergy()
+			return false
+		-- Now Check Anomalies
+		elseif not game.zone.no_anomalies and not self:attr("no_paradox_fail") and rng.percent(math.pow((self:getParadox()/400), 4)) then
 			-- Random anomaly
 			self:incParadox(ab.paradox or ab.paradox_sustain / 2)
 			local ts = {}
@@ -1684,12 +1690,6 @@ function _M:preUseTalent(ab, silent, fake)
 			self:forceUseTalent(rng.table(ts), {ignore_energy=true})
 			self:useEnergy()
 			return false
-		-- Now check failure
-		elseif not self:attr("no_paradox_fail") and self:paradoxChance(ab.paradox or ab.sustain_paradox) then
-			if not silent then game.logPlayer(self, "You fail to use %s due to your paradox!", ab.name) end
-			self:incParadox(ab.paradox or ab.paradox_sustain / 10)
-			self:useEnergy()
-			return false
 		end
 	end
 
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index 4caf86150e..a6367ab977 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -642,9 +642,11 @@ newDamageType{
 -- Generic spell knockback vs. physresist.  Uses a more generic resist message
 newDamageType{
 	name = "repulsion", type = "REPULSION",
-	projector = function(src, x, y, type, dam)
+	projector = function(src, x, y, type, dam, tmp)
 		local target = game.level.map(x, y, Map.ACTOR)
-		if target and not target:attr("never_move") then
+		tmp = tmp or {}
+		if target and not target:attr("never_move") and not tmp[target] then
+			tmp[target] = true
 			if target:checkHit(src:combatSpellpower(), target:combatPhysicalResist(), 0, 95, 15) and target:canBe("knockback") then
 				target:knockback(src.x, src.y, 2)
 				game.logSeen(target, "%s is knocked back!", target.name:capitalize())
diff --git a/game/modules/tome/data/general/npcs/all.lua b/game/modules/tome/data/general/npcs/all.lua
index f4ddb03631..809312c7a6 100644
--- a/game/modules/tome/data/general/npcs/all.lua
+++ b/game/modules/tome/data/general/npcs/all.lua
@@ -37,6 +37,7 @@ loadIfNot("/data/general/npcs/ghost.lua")
 loadIfNot("/data/general/npcs/ghoul.lua")
 --loadIfNot("/data/general/npcs/gwelgoroth.lua")
 loadIfNot("/data/general/npcs/horror.lua")
+--loadIfNot("/data/general/npcs/horror-corrupted.lua")
 loadIfNot("/data/general/npcs/jelly.lua")
 loadIfNot("/data/general/npcs/minor-demon.lua")
 loadIfNot("/data/general/npcs/major-demon.lua")
diff --git a/game/modules/tome/data/general/objects/boss-artifacts.lua b/game/modules/tome/data/general/objects/boss-artifacts.lua
index 4e3b7666c2..07b7552ad6 100644
--- a/game/modules/tome/data/general/objects/boss-artifacts.lua
+++ b/game/modules/tome/data/general/objects/boss-artifacts.lua
@@ -829,7 +829,7 @@ newEntity{ base = "BASE_WAND", define_as = "ROD_OF_ANNULMENT",
 				local tids = {}
 				for tid, lev in pairs(target.talents) do
 					local t = target:getTalentFromId(tid)
-					if not target.talents_cd[tid] and t.mode == "activated" then tids[#tids+1] = t end
+					if not target.talents_cd[tid] and t.mode == "activated" and not t.innate then tids[#tids+1] = t end
 				end
 				for i = 1, 3 do
 					local t = rng.tableRemove(tids)
diff --git a/game/modules/tome/data/talents/chronomancy/anomalies.lua b/game/modules/tome/data/talents/chronomancy/anomalies.lua
index e0646d4b58..e37b73def5 100644
--- a/game/modules/tome/data/talents/chronomancy/anomalies.lua
+++ b/game/modules/tome/data/talents/chronomancy/anomalies.lua
@@ -550,7 +550,7 @@ newTalent{
 				local tids = {}
 				for tid, lev in pairs(target.talents) do
 					local t = target:getTalentFromId(tid)
-					if not target.talents_cd[tid] and t.mode == "activated" then tids[#tids+1] = t end
+					if not target.talents_cd[tid] and t.mode == "activated" and not t.innate then tids[#tids+1] = t end
 				end
 				for i = 1, t.getTalentCount(self, t) do
 					local power = t.getPower(self, t)
diff --git a/game/modules/tome/data/talents/chronomancy/gravity.lua b/game/modules/tome/data/talents/chronomancy/gravity.lua
index 8183526690..e2975f7797 100644
--- a/game/modules/tome/data/talents/chronomancy/gravity.lua
+++ b/game/modules/tome/data/talents/chronomancy/gravity.lua
@@ -62,6 +62,7 @@ newTalent{
 		local tg = self:getTalentTarget(t)
 		local x, y = self:getTarget(tg)
 		if not x or not y then return nil end
+		local _ _, x, y = self:canProject(tg, x, y)
 		x, y = checkBackfire(self, x, y)
 		local grids = self:project(tg, x, y, function(px, py)
 			local target = game.level.map(px, py, Map.ACTOR)
@@ -74,7 +75,6 @@ newTalent{
 		end)
 		self:project (tg, x, y, DamageType.PHYSICAL, self:spellCrit(t.getDamage(self, t)))
 		
-		local _ _, x, y = self:canProject(tg, x, y)
 		game.level.map:particleEmitter(x, y, tg.radius, "gravity_spike", {radius=tg.radius, grids=grids, tx=x, ty=y})
 		game:playSoundNear(self, "talents/earth")
 		return true
diff --git a/game/modules/tome/data/talents/chronomancy/spacetime-weaving.lua b/game/modules/tome/data/talents/chronomancy/spacetime-weaving.lua
index 0168862547..6670a51570 100644
--- a/game/modules/tome/data/talents/chronomancy/spacetime-weaving.lua
+++ b/game/modules/tome/data/talents/chronomancy/spacetime-weaving.lua
@@ -30,7 +30,8 @@ newTalent{
 	getAnomaly = function(self, t) return 6 - (self:getTalentLevelRaw(self.T_STATIC_HISTORY) or 0) end,
 	action = function(self, t)
 		-- open dialog to get desired paradox
-		local q = engine.dialogs.GetQuantity.new("Retuning the fabric of spacetime...", "What's your desired paradox level?", math.floor(self.paradox), nil, function(qty)
+		local q = engine.dialogs.GetQuantity.new("Retuning the fabric of spacetime...", 
+		"What's your desired paradox level?", math.floor(self.paradox), nil, function(qty)
 			
 			-- get reduction amount and find duration
 			amount = qty - self.paradox
@@ -49,7 +50,7 @@ newTalent{
 	end,
 	info = function(self, t)
 		local chance = t.getAnomaly(self, t)
-		return ([[Retunes your Paradox towards the desired level.  You will be dazed while tuning and each turn your Paradox will increase or decrease by an amount equal to your Willpower stat.
+		return ([[Retunes your Paradox towards the desired level and informs you of failure, anomaly, and backfire chances when you finish tuning.  You will be dazed while tuning and each turn your Paradox will increase or decrease by an amount equal to your Willpower stat.
 		Each turn you have a %d%% chance of triggering a temporal anomaly which will end the tuning process.]]):
 		format(chance)
 	end,
diff --git a/game/modules/tome/data/talents/chronomancy/speed-control.lua b/game/modules/tome/data/talents/chronomancy/speed-control.lua
index 2a455741d4..29dcace6be 100644
--- a/game/modules/tome/data/talents/chronomancy/speed-control.lua
+++ b/game/modules/tome/data/talents/chronomancy/speed-control.lua
@@ -68,10 +68,10 @@ newTalent{
 		local tg = self:getTalentTarget(t)
 		local x, y = self:getTarget(tg)
 		if not x or not y then return nil end
+		local _ _, x, y = self:canProject(tg, x, y)
 		x, y = checkBackfire(self, x, y)
 		local grids = self:project(tg, x, y, DamageType.STOP, t.getDuration(self, t))
 		
-		local _ _, x, y = self:canProject(tg, x, y)
 		game.level.map:particleEmitter(x, y, tg.radius, "temporal_flash", {radius=tg.radius, tx=x, ty=y})
 		game:playSoundNear(self, "talents/tidalwave")
 		return true
diff --git a/game/modules/tome/data/talents/misc/misc.lua b/game/modules/tome/data/talents/misc/misc.lua
index 385307dff6..0214f31057 100644
--- a/game/modules/tome/data/talents/misc/misc.lua
+++ b/game/modules/tome/data/talents/misc/misc.lua
@@ -34,6 +34,7 @@ newTalent{
 	type = {"base/class", 1},
 	no_energy = "fake",
 	hide = true,
+	innate = true,
 	points = 1,
 	range = 1,
 	message = false,
diff --git a/game/modules/tome/data/talents/techniques/archery.lua b/game/modules/tome/data/talents/techniques/archery.lua
index 615222fffc..a0a7db4b72 100644
--- a/game/modules/tome/data/talents/techniques/archery.lua
+++ b/game/modules/tome/data/talents/techniques/archery.lua
@@ -23,6 +23,7 @@ newTalent{
 	type = {"technique/archery-base", 1},
 	no_energy = "fake",
 	hide = true,
+	innate = true,
 	points = 1,
 	range = archery_range,
 	message = "@Source@ shoots!",
diff --git a/game/modules/tome/data/timed_effects.lua b/game/modules/tome/data/timed_effects.lua
index 8272dee3e1..89aa90aaa4 100644
--- a/game/modules/tome/data/timed_effects.lua
+++ b/game/modules/tome/data/timed_effects.lua
@@ -3407,7 +3407,16 @@ newEffect{
 		eff.tmpid = self:addTemporaryValue("dazed", 1)
 	end,
 	deactivate = function(self, eff)
+		if self:knowTalent(self.T_PARADOX_MASTERY) and self:isTalentActive(self.T_PARADOX_MASTERY) then
+			modifier = self:getWil() * (1 + (self:getTalentLevel(self.T_PARADOX_MASTERY)/10) or 0 )
+		else
+			modifier = self:getWil()
+		end
+		local failure = math.pow(((self:getParadox() - modifier)/200), 2)*((100 + self:combatFatigue()) / 100)
+		local anomaly = math.pow((self:getParadox()/400), 4)
+		local backfire = math.pow (((self:getParadox() - modifier)/300), 3)*((100 + self:combatFatigue()) / 100)
 		self:removeTemporaryValue("dazed", eff.tmpid)
+		game.logPlayer(self, "Your current failure chance is %d%%, your current anomoly chance is %d%%, and your current backfire chance is %d%%.", failure, anomaly, backfire)
 	end,
 }
 
-- 
GitLab