From 223b3b31e349b6d05b2db889a661ec9b2c8c471a Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@net-core.org>
Date: Sat, 19 Oct 2013 02:04:20 +0200
Subject: [PATCH] Corpses (from the curse) coming out in the middle of an
 attack will not be destroyed by said attack

---
 .../tome/data/talents/cursed/cursed-aura.lua  |  4 +-
 .../tome/data/talents/cursed/punishments.lua  |  4 +-
 game/modules/tome/data/talents/spells/air.lua |  2 +-
 .../tome/data/timed_effects/mental.lua        | 12 +++---
 .../modules/tome/data/timed_effects/other.lua | 39 ++++++++++---------
 5 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/game/modules/tome/data/talents/cursed/cursed-aura.lua b/game/modules/tome/data/talents/cursed/cursed-aura.lua
index f24f4a5dd0..df43d26209 100644
--- a/game/modules/tome/data/talents/cursed/cursed-aura.lua
+++ b/game/modules/tome/data/talents/cursed/cursed-aura.lua
@@ -38,7 +38,7 @@ newTalent{
 		return { self.EFF_CURSE_OF_CORPSES, self.EFF_CURSE_OF_MADNESS, self.EFF_CURSE_OF_MISFORTUNE, self.EFF_CURSE_OF_NIGHTMARES, self.EFF_CURSE_OF_SHROUDS }
 	end,
 	cursePenalty = function(self, t)
-		return self:combatTalentLimit(math.max(1, self:getTalentLevel(t)-9), 0, 1, 0.50)
+		return self:combatTalentLimit(math.max(1, self:getTalentLevel(t)-4), 0, 1, 0.64)
 	end,
 	-- tests whether or not an item can be cursed (takes into account current talent level unless ignoreLevel = true)
 	canCurseItem = function(self, t, item, level)
@@ -263,7 +263,7 @@ newTalent{
 		Level 9  -- tools/totems/torques/wands
 		level 10 -- ammunition
 		At level 5, you can activate this talent to surround yourself with an aura that adds 2 levels to a curse of your choosing. (%s chosen)
-		Talent levels higher than 10 reduce the negative effects of your curses (currently %d%% reduction).]]):
+		Also, talent levels above 5 reduce the negative effects of your curses (currently %d%% reduction).]]):
 		format(t.getCursedAuraName(self, t), (1-t.cursePenalty(self, t))*100)
 	end,
 }
diff --git a/game/modules/tome/data/talents/cursed/punishments.lua b/game/modules/tome/data/talents/cursed/punishments.lua
index dc3bd2b6b9..cad4474b0c 100644
--- a/game/modules/tome/data/talents/cursed/punishments.lua
+++ b/game/modules/tome/data/talents/cursed/punishments.lua
@@ -117,7 +117,7 @@ newTalent{
 		local jumpDuration = t.getJumpDuration(self, t)
 		local hateGain = t.getHateGain(self, t)
 		target:setEffect(target.EFF_HATEFUL_WHISPER, duration, {
-			source = self,
+			src = self,
 			damage = damage,
 			duration = duration,
 			mindpower = mindpower,
@@ -288,7 +288,7 @@ newTalent{
 		local mindpower = self:combatMindpower()
 		local duration = t.getDuration(self, t)
 		target:setEffect(target.EFF_AGONY, duration, {
-			source = self,
+			src = self,
 			mindpower = mindpower,
 			damage = damage,
 			duration = duration,
diff --git a/game/modules/tome/data/talents/spells/air.lua b/game/modules/tome/data/talents/spells/air.lua
index 08182eb019..378890a1e8 100644
--- a/game/modules/tome/data/talents/spells/air.lua
+++ b/game/modules/tome/data/talents/spells/air.lua
@@ -70,7 +70,7 @@ newTalent{
 	reflectable = true,
 	requires_target = true,
 	getDamage = function(self, t) return self:combatTalentSpellDamage(t, 10, 250) end,
-	getTargetCount = function(self, t) return 3 + self:getTalentLevelRaw(t) end,
+	getTargetCount = function(self, t) return math.floor(self:combatTalentScale(t, 4, 8, "log")) end,
 	action = function(self, t)
 		local tg = {type="bolt", range=self:getTalentRange(t), talent=t}
 		local fx, fy = self:getTarget(tg)
diff --git a/game/modules/tome/data/timed_effects/mental.lua b/game/modules/tome/data/timed_effects/mental.lua
index 09481017be..4c01227952 100644
--- a/game/modules/tome/data/timed_effects/mental.lua
+++ b/game/modules/tome/data/timed_effects/mental.lua
@@ -777,7 +777,7 @@ newEffect{
 
 		local damage = math.floor(eff.damage * (eff.turn / eff.duration))
 		if damage > 0 then
-			DamageType:get(DamageType.MIND).projector(eff.source, self.x, self.y, DamageType.MIND, { dam=damage, crossTierChance=25 })
+			DamageType:get(DamageType.MIND).projector(eff.src, self.x, self.y, DamageType.MIND, { dam=damage, crossTierChance=25 })
 			game:playSoundNear(self, "talents/fire")
 		end
 
@@ -803,10 +803,10 @@ newEffect{
 	on_gain = function(self, err) return "#Target# has heard the hateful whisper!", "+Hateful Whisper" end,
 	on_lose = function(self, err) return "#Target# no longer hears the hateful whisper.", "-Hateful Whisper" end,
 	activate = function(self, eff)
-		if not eff.source.dead and eff.source:knowTalent(eff.source.T_HATE_POOL) then
-			eff.source:incHate(eff.hateGain)
+		if not eff.src.dead and eff.src:knowTalent(eff.src.T_HATE_POOL) then
+			eff.src:incHate(eff.hateGain)
 		end
-		DamageType:get(DamageType.MIND).projector(eff.source, self.x, self.y, DamageType.MIND, { dam=eff.damage, crossTierChance=25 })
+		DamageType:get(DamageType.MIND).projector(eff.src, self.x, self.y, DamageType.MIND, { dam=eff.damage, crossTierChance=25 })
 
 		if self.dead then
 			-- only spread on activate if the target is dead
@@ -851,7 +851,7 @@ newEffect{
 		for x, yy in pairs(grids) do
 			for y, _ in pairs(grids[x]) do
 				local a = game.level.map(x, y, game.level.map.ACTOR)
-				if a and eff.source:reactionToward(a) < 0 and self:hasLOS(a.x, a.y) then
+				if a and eff.src:reactionToward(a) < 0 and self:hasLOS(a.x, a.y) then
 					if not a:hasEffect(a.EFF_HATEFUL_WHISPER) then
 						targets[#targets+1] = a
 					end
@@ -862,7 +862,7 @@ newEffect{
 		if #targets > 0 then
 			local target = rng.table(targets)
 			target:setEffect(target.EFF_HATEFUL_WHISPER, eff.duration, {
-				source = eff.source,
+				src = eff.src,
 				duration = eff.duration,
 				damage = eff.damage,
 				mindpower = eff.mindpower,
diff --git a/game/modules/tome/data/timed_effects/other.lua b/game/modules/tome/data/timed_effects/other.lua
index 080d75d971..3541bde74a 100644
--- a/game/modules/tome/data/timed_effects/other.lua
+++ b/game/modules/tome/data/timed_effects/other.lua
@@ -753,27 +753,28 @@ newEffect{
 		if math.min(eff.unlockLevel, eff.level) >= 4 and target.type == "humanoid" and rng.percent(def.getReprieveChance(eff.level)) then
 			if not self:canBe("summon") then return end
 
-			local x, y = target.x, target.y
-			local m = require("mod.class.NPC").new(def.npcWalkingCorpse)
-			m.faction = self.faction
-			m.summoner = self
-			m.summoner_gain_exp = true
-			m.summon_time = 6
-			m:resolve() m:resolve(nil, true)
-			m:forceLevelup(math.max(1, self.level - 2))
-			game.zone:addEntity(game.level, m, "actor", x, y)
-
-			-- Add to the party
-			if self.player then
-				m.remove_from_party_on_death = true
-				game.party:addMember(m, {control="no", type="summon", title="Summon"})
-			end
-
-			game.level.map:particleEmitter(x, y, 1, "slime")
+			game:onTickEnd(function()
+				local x, y = util.findFreeGrid(target.x, target.y,1)
+				if not x then return end
+				local m = require("mod.class.NPC").new(def.npcWalkingCorpse)
+				m.faction = self.faction
+				m.summoner = self
+				m.summoner_gain_exp = true
+				m.summon_time = 6
+				m:resolve() m:resolve(nil, true)
+				m:forceLevelup(math.max(1, self.level - 2))
+				game.zone:addEntity(game.level, m, "actor", x, y)
+				-- Add to the party
+				if self.player then
+					m.remove_from_party_on_death = true
+					game.party:addMember(m, {control="no", type="summon", title="Summon"})
+				end
 
-			game.logSeen(target, "#F53CBE#The corpse of the %s pulls itself up to fight for you.", target.name)
-			game:playSoundNear(who, "talents/slime")
+				game.level.map:particleEmitter(x, y, 1, "slime")
 
+				game.logSeen(m, "#F53CBE#The corpse of the %s pulls itself up to fight for you.", target.name)
+				game:playSoundNear(who, "talents/slime")
+			end)
 			return true
 		else
 			return false
-- 
GitLab