From 51b7934d84b56679e757e9aef92a7308d3b2a186 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sun, 5 Aug 2012 22:29:21 +0000
Subject: [PATCH] fixes

git-svn-id: http://svn.net-core.org/repos/t-engine4@5414 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/class/Actor.lua             |  2 +-
 game/modules/tome/data/damage_types.lua       |  2 +-
 .../modules/tome/data/general/npcs/horror.lua | 22 +++++++++----------
 .../data/talents/corruptions/shadowflame.lua  |  2 +-
 .../tome/data/talents/psionic/discharge.lua   |  2 +-
 .../tome/data/talents/psionic/distortion.lua  |  8 +++----
 .../tome/data/talents/psionic/dreaming.lua    |  6 ++---
 .../tome/data/talents/psionic/nightmare.lua   |  2 +-
 .../tome/data/talents/psionic/psionic.lua     |  3 ++-
 .../tome/data/talents/psionic/slumber.lua     |  4 ++--
 .../tome/data/talents/psionic/solipsism.lua   |  4 ++--
 .../data/talents/psionic/thought-forms.lua    |  2 +-
 .../tome/data/timed_effects/mental.lua        | 12 +++++-----
 .../modules/tome/data/timed_effects/other.lua | 10 ++++-----
 14 files changed, 40 insertions(+), 41 deletions(-)

diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua
index 48642f4d3e..fceb528f1e 100644
--- a/game/modules/tome/class/Actor.lua
+++ b/game/modules/tome/class/Actor.lua
@@ -3522,7 +3522,7 @@ function _M:postUseTalent(ab, ret)
 	if ab.id ~= self.T_GATHER_THE_THREADS and ab.id ~= self.T_SPACETIME_TUNING and ab.is_spell then self:breakChronoSpells() end
 	if ab.id ~= self.T_RELOAD then self:breakReloading() end
 	self:breakStepUp()
-	if not ab.no_break_channel then self:breakPsionicChannel(ab.id) end
+	if not (ab.no_energy or ab.no_break_channel) then self:breakPsionicChannel(ab.id) end
 
 	if ab.id ~= self.T_REDUX and self:hasEffect(self.EFF_REDUX) and ab.type[1]:find("^chronomancy/") and ab.mode == "activated" and self:getTalentLevel(self.T_REDUX) >= self:getTalentLevel(ab.id) then
 		self:removeEffect(self.EFF_REDUX)
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index 44d1e16f3e..855058ba67 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -484,7 +484,7 @@ newDamageType{
 	projector = function(src, x, y, type, dam)
 		local target = game.level.map(x, y, Map.ACTOR)
 		if target then
-			local mindpower, mentalresist, alwaysHit
+			local mindpower, mentalresist, alwaysHit, crossTierChance
 			if _G.type(dam) == "table" then dam, mindpower, mentalresist, alwaysHit, crossTierChance = dam.dam, dam.mindpower, dam.mentalresist, dam.alwaysHit, dam.crossTierChance end
 			local hit_power = mindpower or src:combatMindpower()
 			if alwaysHit or target:checkHit(hit_power, mentalresist or target:combatMentalResist(), 0, 95, 15) then
diff --git a/game/modules/tome/data/general/npcs/horror.lua b/game/modules/tome/data/general/npcs/horror.lua
index 761af21563..e6f920fe35 100644
--- a/game/modules/tome/data/general/npcs/horror.lua
+++ b/game/modules/tome/data/general/npcs/horror.lua
@@ -682,7 +682,7 @@ With each slow breath it takes reality distorts around it.  Blue twirls into red
 		[Talents.T_BACKLASH]={base=2, every=6, max=8},
 		
 		[Talents.T_MENTAL_SHIELDING]={base=2, every=6, max=8},
-	
+
 		[Talents.T_SOLIPSISM]=7, -- Seven gives some damage to health though it's very small
 		[Talents.T_BALANCE]={base=2, every=6, max=8},
 		[Talents.T_CLARITY]={base=2, every=6, max=8},
@@ -695,10 +695,10 @@ With each slow breath it takes reality distorts around it.  Blue twirls into red
 		[Talents.T_DREAMSCAPE]=10,
 	},
 
-	resolvers.inscriptions(1, {"regeneration infusion"}),
-	
+	resolvers.inscriptions(2, {"regeneration infusion", "phase door rune"}, nil, true),  -- Really has a phase door rune :P
+
 	resolvers.sustains_at_birth(),
-	
+
 	-- Used to track if he's awake or spawning projections
 	dreamer_sleep_state = 1,
 	-- And some particles to show that we're asleep
@@ -709,7 +709,7 @@ With each slow breath it takes reality distorts around it.  Blue twirls into red
 			e.sleep_particle = e:addParticles(engine.Particles.new("ultrashield", 1, {rm=0, rM=0, gm=180, gM=255, bm=180, bM=255, am=70, aM=180, radius=0.4, density=60, life=14, instop=1, static=100}))
 		end
 	end),
-	
+
 	-- Spawn Dream Seeds
 	on_act = function(self)
 		if self.dreamer_sleep_state and self.ai_target.actor then 
@@ -738,7 +738,7 @@ With each slow breath it takes reality distorts around it.  Blue twirls into red
 				game.logSeen(self, "%s spawns a dream seed!", self.name:capitalize())
 			end
 		-- Script the AI to encourage opening with dream scape
-		elseif self.ai_target.actor and not game.zone.is_dream_scape then
+		elseif self.ai_target.actor and self.ai_target.actor.game_ender and not game.zone.is_dream_scape then
 			if not self:isTalentCoolingDown(self.T_SLUMBER) then
 				self:forceUseTalent(self.T_SLUMBER, {})
 			elseif not self:isTalentCoolingDown(self.T_DREAMSCAPE) and self.ai_target.actor:attr("sleep") then
@@ -769,20 +769,20 @@ newEntity{ base = "BASE_NPC_HORROR", define_as = "DREAM_SEED",
 	rank = 2,
 	max_life = 1, life_rating = 4,  -- Solipsism will take care of hit points
 	autolevel = "wildcaster",
-	
+
 	ai = "tactical",
 	ai_state = { ai_target="target_player_radius", sense_radius=20, talent_in=3, },
 	dont_pass_target = true,
 	can_pass = {pass_wall=20},
 	levitation = 1,
-	
+
 	combat_armor = 1, combat_def = 5,
 	combat = { dam=resolvers.levelup(20, 1, 1.1), atk=10, apr=10, dammod={wil=1}, damtype=engine.DamageType.MIND},
-	
+
 	resolvers.talents{
 		[Talents.T_BACKLASH]={base=2, every=6, max=8},
 		[Talents.T_DISTORTION_BOLT]={base=2, every=6, max=8},
-	
+
 		[Talents.T_SOLIPSISM]=8,
 
 		[Talents.T_SLEEP]={base=2, every=6, max=8},
@@ -791,7 +791,7 @@ newEntity{ base = "BASE_NPC_HORROR", define_as = "DREAM_SEED",
 	},
 
 	resolvers.sustains_at_birth(),
-	
+
 	-- Remove ourselves from the dream seed limit
 	on_die = function(self)
 		if self.summoner and self.summoner.dreamer_sleep_state then
diff --git a/game/modules/tome/data/talents/corruptions/shadowflame.lua b/game/modules/tome/data/talents/corruptions/shadowflame.lua
index e81b70c4c7..2a692d23bf 100644
--- a/game/modules/tome/data/talents/corruptions/shadowflame.lua
+++ b/game/modules/tome/data/talents/corruptions/shadowflame.lua
@@ -129,7 +129,7 @@ newTalent{
 	cooldown = 60,
 	no_sustain_autoreset = true,
 	random_boss_rarity = 10,
-	tactical = { DISABLE = 3 },
+	tactical = { DISABLE = function(self, t, target) if target.game_ender then return 3 else return 0 end end},
 	range = 5,
 	on_pre_use = function(self, t) return self:canBe("planechange") end,
 	activate = function(self, t)
diff --git a/game/modules/tome/data/talents/psionic/discharge.lua b/game/modules/tome/data/talents/psionic/discharge.lua
index fa792b8a1a..3228148f03 100644
--- a/game/modules/tome/data/talents/psionic/discharge.lua
+++ b/game/modules/tome/data/talents/psionic/discharge.lua
@@ -102,7 +102,7 @@ newTalent{
 		local charge_ratio = t.getOverchargeRatio(self, t)
 		return ([[Unleash your subconscious on the world around you.  While active the range of all Discharge talents will be increased by %d and you'll fire up to %d bolts each turn (one per hostile target) that deal %0.2f mind damage.  Each bolt consumes 1 Feedback.
 		Feedback gains beyond your maximum allowed amount may generate extra bolts (one bolt per %d excess Feedback), but no more then %d extra bolts per turn.
-		This effect is a psionic channel and will break if you move, use a talent, or activate an item.
+		This effect is a psionic channel and will break if you move, use a talent that consumes a turn, or activate an item.
 		The damage will scale with your mindpower.]]):format(range_increase, targets, damDesc(self, DamageType.MIND, damage), charge_ratio, targets)
 	end,
 }
diff --git a/game/modules/tome/data/talents/psionic/distortion.lua b/game/modules/tome/data/talents/psionic/distortion.lua
index 2483c75c7a..e11c835d71 100644
--- a/game/modules/tome/data/talents/psionic/distortion.lua
+++ b/game/modules/tome/data/talents/psionic/distortion.lua
@@ -60,8 +60,8 @@ newTalent{
 	require = psi_wil_req2,
 	cooldown = 6,
 	psi = 10,
-	tactical = { ATTACK = { PHYSICAL = 2},
-		DISABLE = function(self, t, target) if target:hasEffect(target.EFF_DISTORION) then return 4 else return 2 end end,
+	tactical = { ATTACKAREA = { PHYSICAL = 2}, ESCAPE = 2,
+		DISABLE = function(self, t, target) if target:hasEffect(target.EFF_DISTORTION) then return 2 else return 0 end end,
 	},
 	range = 0,
 	radius = function(self, t) return 3 + math.ceil(self:getTalentLevel(t)/2) end,
@@ -100,7 +100,7 @@ newTalent{
 	cooldown = 12,
 	psi = 20,
 	tactical = { ATTACK = { PHYSICAL = 2},
-		DISABLE = function(self, t, target) if target:hasEffect(target.EFF_DISTORION) then return 4 else return 0 end end,
+		DISABLE = function(self, t, target) if target:hasEffect(target.EFF_DISTORTION) then return 4 else return 0 end end,
 	},
 	range = 10,
 	requires_target = true,
@@ -143,7 +143,7 @@ newTalent{
 	require = psi_wil_req4,
 	cooldown = 24,
 	psi = 30,
-	tactical = { ATTACK = { PHYSICAL = 2}, DISABLE = 2},
+	tactical = { ATTACK = { PHYSICAL = 2}, DISABLE = 2, ESCAPE=2 },
 	range = 10,
 	radius = function(self, t) return math.min(4, 1 + math.ceil(self:getTalentLevel(t)/3)) end,
 	requires_target = true,
diff --git a/game/modules/tome/data/talents/psionic/dreaming.lua b/game/modules/tome/data/talents/psionic/dreaming.lua
index 31e72dfca9..29513bb835 100644
--- a/game/modules/tome/data/talents/psionic/dreaming.lua
+++ b/game/modules/tome/data/talents/psionic/dreaming.lua
@@ -91,7 +91,7 @@ newTalent{
 		local power = t.getSleepPower(self, t)
 		local insomnia = t.getInsomniaPower(self, t)
 		return([[Puts targets in a radius of %d to sleep for %d turns, rendering them unable to act.  Every %d points of damage the target suffers will reduce the effect duration by one turn.
-		When Sleep ends the target will suffer from Insomnia for a number of turns equal to the amount of time it was asleep, granting it %d%% sleep immunity for each turn of the Insomnia effect.
+		When Sleep ends the target will suffer from Insomnia for a number of turns equal to the amount of time it was asleep (up to five turns max), granting it %d%% sleep immunity for each turn of the Insomnia effect.
 		At talent level 5 Sleep will become contagious and has a 25%% chance to spread to nearby targets each turn.
 		The damage threshold will scale with your mindpower.]]):format(radius, duration, power, insomnia)
 	end,
@@ -198,7 +198,7 @@ newTalent{
 	require = psi_wil_req4,
 	mode = "sustained",
 	sustain_psi = 40,
-	cooldown = 50,
+	cooldown = function(self, t) return 50 - self:getTalentLevelRaw(t) * 5 end,
 	tactical = { DISABLE = function(self, t, target) if target:attr("sleep") then return 4 else return 0 end end},
 	range = function(self, t) return 5 + math.min(5, self:getTalentLevelRaw(t)) end,
 	requires_target = true,
@@ -222,7 +222,7 @@ newTalent{
 	info = function(self, t)
 		local drain = t.getDrain(self, t)
 		return ([[Imprisons all sleeping targets within range in their dream state, effectively extending sleeping effects for as long as Dream Prison is maintainted.
-		This powerful effect constantly drains %d Psi per turn and is considered a psionic channel as such it will break if you move, use a talent, or activate an item.
+		This powerful effect constantly drains %d Psi per turn and is considered a psionic channel as such it will break if you move, use a talent that consumes a turn, or activate an item.
 		(Note that sleeping effects that happen each turn, such as Nightmare's damage and Sleep's contagion, will cease to function for the duration of the effect.)]]):format(drain)
 	end,
 }
\ No newline at end of file
diff --git a/game/modules/tome/data/talents/psionic/nightmare.lua b/game/modules/tome/data/talents/psionic/nightmare.lua
index b1ef267bed..7f62378656 100644
--- a/game/modules/tome/data/talents/psionic/nightmare.lua
+++ b/game/modules/tome/data/talents/psionic/nightmare.lua
@@ -80,7 +80,7 @@ newTalent{
 		local insomnia = t.getInsomniaPower(self, t)
 		return([[Puts targets in a radius %d cone into a nightmarish sleep for %d turns, rendering them unable to act.  Every %d points of damage the target suffers will reduce the effect duration by one turn.
 		Each turn they'll suffer %0.2f darkness damage.  This damage will not reduce the duration of the effect.
-		When Nightmare ends the target will suffer from Insomnia for a number of turns equal to the amount of time it was asleep, granting it %d%% sleep immunity for each turn of the Insomnia effect.
+		When Nightmare ends the target will suffer from Insomnia for a number of turns equal to the amount of time it was asleep (up to five turns max), granting it %d%% sleep immunity for each turn of the Insomnia effect.
 		The damage threshold and mind damage will scale with your mindpower.]]):format(radius, duration, power, damDesc(self, DamageType.DARKNESS, (damage)), insomnia)
 	end,
 }
diff --git a/game/modules/tome/data/talents/psionic/psionic.lua b/game/modules/tome/data/talents/psionic/psionic.lua
index 09cbcd36e5..2dc38987f8 100644
--- a/game/modules/tome/data/talents/psionic/psionic.lua
+++ b/game/modules/tome/data/talents/psionic/psionic.lua
@@ -186,12 +186,13 @@ function setupThoughtForm(self, m, x, y)
 	m.subtype = "thought-form"
 	m.summoner_gain_exp=true
 	m.faction = self.faction
-	m.no_inventory_access = true -- Uncomment later; just for testing
+	m.no_inventory_access = true
 	m.rank = 2
 	m.size_category = 3
 	m.infravision = 10
 	m.lite = 1
 	m.no_breath = 1
+	m.move_others = true
 	
 	-- Less tedium
 	m.life_regen = 1
diff --git a/game/modules/tome/data/talents/psionic/slumber.lua b/game/modules/tome/data/talents/psionic/slumber.lua
index 8996af1420..7723281827 100644
--- a/game/modules/tome/data/talents/psionic/slumber.lua
+++ b/game/modules/tome/data/talents/psionic/slumber.lua
@@ -73,7 +73,7 @@ newTalent{
 		local power = t.getSleepPower(self, t)
 		local insomnia = t.getInsomniaPower(self, t)
 		return([[Puts the target into a deep sleep for %d turns, rendering it unable to act.  Every %d points of damage the target suffers will reduce the effect duration by one turn.
-		When Slumber ends the target will suffer from Insomnia for a number of turns equal to the amount of time it was asleep, granting it %d%% sleep immunity for each turn of the Insomnia effect.
+		When Slumber ends the target will suffer from Insomnia for a number of turns equal to the amount of time it was asleep (up to five turns max), granting it %d%% sleep immunity for each turn of the Insomnia effect.
 		The damage threshold will scale with your mindpower.]]):format(duration, power, insomnia)
 	end,
 }
@@ -117,7 +117,7 @@ newTalent{
 	cooldown = 24,
 	psi = 40,
 	random_boss_rarity = 10,
-	tactical = { DISABLE = function(self, t, target) if target:attr("sleep") then return 4 else return 0 end end},
+	tactical = { DISABLE = function(self, t, target) if target.game_ender and target:attr("sleep") then return 4 else return 0 end end},
 	direct_hit = true,
 	requires_target = true,
 	range = function(self, t) return 5 + math.min(5, self:getTalentLevelRaw(t)) end,
diff --git a/game/modules/tome/data/talents/psionic/solipsism.lua b/game/modules/tome/data/talents/psionic/solipsism.lua
index 3965eceff2..19faccb98b 100644
--- a/game/modules/tome/data/talents/psionic/solipsism.lua
+++ b/game/modules/tome/data/talents/psionic/solipsism.lua
@@ -146,7 +146,7 @@ newTalent{
 	points = 5, 
 	require = psi_wil_req4,
 	mode = "passive",
-	getSavePercentage = function(self, t) return math.min(0.4 + self:getTalentLevel(t) * 0.16, 1.5) end,
+	getSavePercentage = function(self, t) return math.min(0.25 + self:getTalentLevel(t) * 0.1, 1) end,
 	on_learn = function(self, t)
 		if self:getTalentLevelRaw(t) == 1 then
 			self.inc_resource_multi.psi = (self.inc_resource_multi.psi or 0) + 1
@@ -171,7 +171,7 @@ newTalent{
 		end
 	end,
 	doDismissalOnHit = function(self, value, src, t)
-		local saving_throw = self:mindCrit(self:combatMentalResist(), t.getSavePercentage(self, t))
+		local saving_throw = self:mindCrit(self:combatMentalResist()) * t.getSavePercentage(self, t)
 		print("[Dismissal] ", self.name:capitalize(), " attempting to ignore ", value, "damage from ", src.name:capitalize(), "using", saving_throw,  "mental save.")
 		if self:checkHit(saving_throw, value) then
 			game.logSeen(self, "%s dismisses %s's damage!", self.name:capitalize(), src.name:capitalize())
diff --git a/game/modules/tome/data/talents/psionic/thought-forms.lua b/game/modules/tome/data/talents/psionic/thought-forms.lua
index 28cd2e8544..24d8fdc0ea 100644
--- a/game/modules/tome/data/talents/psionic/thought-forms.lua
+++ b/game/modules/tome/data/talents/psionic/thought-forms.lua
@@ -528,7 +528,7 @@ newTalent{
 			game.party:hasMember(target).on_control = function(self)
 				self.summoner.over_mind_ai = self.summoner.ai
 				self.summoner.ai = "none"
-				target:hotkeyAutoTalents()
+				self:hotkeyAutoTalents()
 			end
 			game.party:hasMember(target).on_uncontrol = function(self)
 				self.summoner.ai = self.summoner.over_mind_ai
diff --git a/game/modules/tome/data/timed_effects/mental.lua b/game/modules/tome/data/timed_effects/mental.lua
index 1f5f7d9c15..bceca9ef3b 100644
--- a/game/modules/tome/data/timed_effects/mental.lua
+++ b/game/modules/tome/data/timed_effects/mental.lua
@@ -1472,7 +1472,7 @@ newEffect{
 
 newEffect{
 	name = "WAKING_NIGHTMARE", image = "talents/waking_nightmare.png",
-	desc = "Waking NIGHTMARE",
+	desc = "Waking Nightmare",
 	long_desc = function(self, eff) return ("The target is lost in a nightmare that deals %0.2f mind damage each turn and has a %d%% chance to cause a random detrimental effect."):format(eff.dam, eff.chance) end,
 	type = "mental",
 	subtype = { nightmare=true, darkness=true },
@@ -2459,7 +2459,7 @@ newEffect{
 			self:removeParticles(eff.particle)
 		end
 		-- Incriment Insomnia Duration
-		eff.insomnia_duration = math.min(eff.insomnia_duration + 1, 10)
+		eff.insomnia_duration = math.min(eff.insomnia_duration + 1, 5)
 	end,
 	activate = function(self, eff)
 		eff.insomnia_duration = 0
@@ -2511,7 +2511,7 @@ newEffect{
 			self:removeParticles(eff.particle)
 		end
 		-- Incriment Insomnia Duration
-		eff.insomnia_duration = math.min(eff.insomnia_duration + 1, 10)
+		eff.insomnia_duration = math.min(eff.insomnia_duration + 1, 5)
 	end,
 	activate = function(self, eff)
 		eff.insomnia_duration = 0
@@ -2572,7 +2572,7 @@ newEffect{
 			self:removeParticles(eff.particle)
 		end
 		-- Incriment Insomnia Duration
-		eff.insomnia_duration = math.min(eff.insomnia_duration + 1, 10)
+		eff.insomnia_duration = math.min(eff.insomnia_duration + 1, 5)
 	end,
 	activate = function(self, eff)
 		eff.insomnia_duration = 0
@@ -2604,8 +2604,8 @@ newEffect{
 	on_gain = function(self, err) return "#Target# is suffering from insomnia.", "+Insomnia" end,
 	on_lose = function(self, err) return "#Target# is no longer suffering from insomnia.", "-Insomnia" end,
 	on_merge = function(self, old_eff, new_eff)
-		-- Merge the effect
-		local dur = math.min(10, math.ceil(old_eff.dur + new_eff.dur))
+		-- Take the longest of the two durations on merge
+		local dur = math.max(old_eff.dur, new_eff.dur)
 		old_eff.dur = dur
 		old_eff.cur_power = old_eff.power * old_eff.dur
 		-- Need to remove and re-add the effect
diff --git a/game/modules/tome/data/timed_effects/other.lua b/game/modules/tome/data/timed_effects/other.lua
index 8364315403..5c01d16434 100644
--- a/game/modules/tome/data/timed_effects/other.lua
+++ b/game/modules/tome/data/timed_effects/other.lua
@@ -1660,12 +1660,10 @@ newEffect{
 
 			-- track number killed
 			m.on_die = function(self, who)
-				if who then
-					local p = who:hasEffect(who.EFF_DREAMSCAPE)
-					if p then -- For the rare instance we die after the effect ends but before the dreamscape instance closes
-						p.projections_killed = p.projections_killed + 1
-						game.logSeen(p.target, "#LIGHT_RED#%s writhes in agony as a fragment of it's mind is destroyed!", p.target.name:capitalize())
-					end
+				local p = (who and who:hasEffect(who.EFF_DREAMSCAPE)) or (who.summoner and who.summoner:hasEffect(who.summoner.EFF_DREAMSCAPE))
+				if p then -- For the rare instance we die after the effect ends but before the dreamscape instance closes
+					p.projections_killed = p.projections_killed + 1
+					game.logSeen(p.target, "#LIGHT_RED#%s writhes in agony as a fragment of it's mind is destroyed!", p.target.name:capitalize())
 				end
 			end
 
-- 
GitLab