From f97d7f5b831f82fdb46fe9e54bcce3df230127de Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sat, 12 Jun 2010 11:22:42 +0000
Subject: [PATCH] knockback breaths/balls will not do multiple knockbacks

git-svn-id: http://svn.net-core.org/repos/t-engine4@782 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engine/interface/ActorProject.lua  |  5 +++--
 game/modules/tome/data/damage_types.lua | 14 ++++++++------
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/game/engine/interface/ActorProject.lua b/game/engine/interface/ActorProject.lua
index b4f237636c..e927f057c9 100644
--- a/game/engine/interface/ActorProject.lua
+++ b/game/engine/interface/ActorProject.lua
@@ -94,6 +94,7 @@ function _M:project(t, x, y, damtype, dam, particles)
 	end
 
 	-- Now project on each grid, one type
+	local tmp = {}
 	if type(damtype) == "function" then
 		local stop = false
 		for px, ys in pairs(grids) do
@@ -113,13 +114,13 @@ function _M:project(t, x, y, damtype, dam, particles)
 					-- Friendly fire ?
 					if px == self.x and py == self.y then
 						if t.friendlyfire then
-							DamageType:get(damtype).projector(self, px, py, damtype, dam)
+							DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp)
 							if particles then
 								game.level.map:particleEmitter(px, py, 1, particles.type)
 							end
 						end
 					else
-						DamageType:get(damtype).projector(self, px, py, damtype, dam)
+						DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp)
 						if particles then
 							game.level.map:particleEmitter(px, py, 1, particles.type)
 						end
diff --git a/game/modules/tome/data/damage_types.lua b/game/modules/tome/data/damage_types.lua
index 38d6a493dd..2e616733cd 100644
--- a/game/modules/tome/data/damage_types.lua
+++ b/game/modules/tome/data/damage_types.lua
@@ -303,10 +303,11 @@ newDamageType{
 -- Physical damage + repulsion; checks for spell power against physical resistance
 newDamageType{
 	name = "spellknockback", type = "SPELLKNOCKBACK",
-	projector = function(src, x, y, type, dam)
-		DamageType:get(DamageType.PHYSICAL).projector(src, x, y, DamageType.PHYSICAL, dam)
+	projector = function(src, x, y, type, dam, tmp)
 		local target = game.level.map(x, y, Map.ACTOR)
-		if target then
+		if target and not tmp[target] then
+			tmp[target] = true
+			DamageType:get(DamageType.PHYSICAL).projector(src, x, y, DamageType.PHYSICAL, dam)
 			if target:checkHit(src:combatSpellpower(), target:combatPhysicalResist(), 0, 95, 15) and target:canBe("knockback") then
 				target:knockback(src.x, src.y, 3)
 				game.logSeen(target, "%s is knocked back!", target.name:capitalize())
@@ -320,10 +321,11 @@ newDamageType{
 -- Physical damage + repulsion; checks for spell power against physical resistance
 newDamageType{
 	name = "physknockback", type = "PHYSKNOCKBACK",
-	projector = function(src, x, y, type, dam)
-		DamageType:get(DamageType.PHYSICAL).projector(src, x, y, DamageType.PHYSICAL, dam.dam)
+	projector = function(src, x, y, type, dam, tmp)
 		local target = game.level.map(x, y, Map.ACTOR)
-		if target then
+		if target and not tmp[target] then
+			tmp[target] = true
+			DamageType:get(DamageType.PHYSICAL).projector(src, x, y, DamageType.PHYSICAL, dam.dam)
 			if target:checkHit(src:combatAttackStr(), target:combatPhysicalResist(), 0, 95, 15) and target:canBe("knockback") then
 				target:knockback(src.x, src.y, dam.dist)
 				game.logSeen(target, "%s is knocked back!", target.name:capitalize())
-- 
GitLab