From da84c1880ac1e9b29207801bec750e95f44cfeb3 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Mon, 26 Sep 2011 10:11:24 +0000
Subject: [PATCH] Fixed golem eye beam and arcane combat causing a game freeze
 when actor is frozen Fixed a few rush-like talents when activated adjacent to
 the target

git-svn-id: http://svn.net-core.org/repos/t-engine4@4452 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/modules/tome/data/talents/misc/npcs.lua                  | 2 +-
 game/modules/tome/data/talents/psionic/augmented-mobility.lua | 2 +-
 game/modules/tome/data/talents/spells/golem.lua               | 1 +
 game/modules/tome/data/talents/techniques/grappling.lua       | 2 +-
 game/modules/tome/data/talents/techniques/magical-combat.lua  | 2 ++
 game/modules/tome/data/talents/techniques/pugilism.lua        | 2 +-
 src/fov.c                                                     | 2 +-
 7 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/game/modules/tome/data/talents/misc/npcs.lua b/game/modules/tome/data/talents/misc/npcs.lua
index 944cf7fafb..aa42afdd97 100644
--- a/game/modules/tome/data/talents/misc/npcs.lua
+++ b/game/modules/tome/data/talents/misc/npcs.lua
@@ -778,7 +778,7 @@ newTalent{
 		local block_actor = function(_, bx, by) return game.level.map:checkEntity(bx, by, Map.TERRAIN, "block_move", self) end
 		local l = self:lineFOV(x, y, block_actor)
 		local lx, ly, is_corner_blocked = l:step(block_actor)
-		local tx, ty = lx, ly
+		local tx, ty = self.x, self.y
 		while lx and ly do
 			if is_corner_blocked or game.level.map:checkAllEntities(lx, ly, "block_move", self) then break end
 			tx, ty = lx, ly
diff --git a/game/modules/tome/data/talents/psionic/augmented-mobility.lua b/game/modules/tome/data/talents/psionic/augmented-mobility.lua
index 053e01d0c6..2f3f5cf758 100644
--- a/game/modules/tome/data/talents/psionic/augmented-mobility.lua
+++ b/game/modules/tome/data/talents/psionic/augmented-mobility.lua
@@ -193,7 +193,7 @@ newTalent{
 			local block_actor = function(_, bx, by) return game.level.map:checkEntity(bx, by, engine.Map.TERRAIN, "block_move", self) end
 			local l = self:lineFOV(x, y, block_actor)
 			local lx, ly, is_corner_blocked = l:step(block_actor)
-			local tx, ty, _ = lx, ly
+			local tx, ty = self.x, self.y
 			while lx and ly do
 				if is_corner_blocked or block_actor(_, lx, ly) then break end
 				tx, ty = lx, ly
diff --git a/game/modules/tome/data/talents/spells/golem.lua b/game/modules/tome/data/talents/spells/golem.lua
index c367625eda..06b8ebe713 100644
--- a/game/modules/tome/data/talents/spells/golem.lua
+++ b/game/modules/tome/data/talents/spells/golem.lua
@@ -298,6 +298,7 @@ newTalent{
 		local tg = self:getTalentTarget(t)
 		local x, y = self:getTarget(tg)
 		if not x or not y then return nil end
+		if self.x == x and self.y == y then return nil end
 
 		-- We will always project the beam as far as possible
 		local l = self:lineFOV(x, y)
diff --git a/game/modules/tome/data/talents/techniques/grappling.lua b/game/modules/tome/data/talents/techniques/grappling.lua
index c5a0ec12ab..0856798eb1 100644
--- a/game/modules/tome/data/talents/techniques/grappling.lua
+++ b/game/modules/tome/data/talents/techniques/grappling.lua
@@ -232,7 +232,7 @@ newTalent{
 		local block_actor = function(_, bx, by) return game.level.map:checkEntity(bx, by, Map.TERRAIN, "block_move", self) end
 		local l = self:lineFOV(x, y, block_actor)
 		local lx, ly, is_corner_blocked = l:step(block_actor)
-		local tx, ty = lx, ly
+		local tx, ty = self.x, self.y
 		while lx and ly do
 			if is_corner_blocked or game.level.map:checkAllEntities(lx, ly, "block_move", self) then break end
 			tx, ty = lx, ly
diff --git a/game/modules/tome/data/talents/techniques/magical-combat.lua b/game/modules/tome/data/talents/techniques/magical-combat.lua
index 2d7ae9aac1..168ce622cd 100644
--- a/game/modules/tome/data/talents/techniques/magical-combat.lua
+++ b/game/modules/tome/data/talents/techniques/magical-combat.lua
@@ -28,6 +28,8 @@ newTalent{
 	cooldown = 5,
 	tactical = { BUFF = 2 },
 	do_trigger = function(self, t, target)
+		if self.x == target.x and self.y == target.y then return nil end
+
 		if rng.percent(20 + self:getTalentLevel(t) * (1 + self:getDex(9, true))) then
 			local spells = {}
 			local fatigue = (100 + 2 * self:combatFatigue()) / 100
diff --git a/game/modules/tome/data/talents/techniques/pugilism.lua b/game/modules/tome/data/talents/techniques/pugilism.lua
index 72c4a59c34..1b2c200c8c 100644
--- a/game/modules/tome/data/talents/techniques/pugilism.lua
+++ b/game/modules/tome/data/talents/techniques/pugilism.lua
@@ -180,7 +180,7 @@ newTalent{
 		local block_actor = function(_, bx, by) return game.level.map:checkEntity(bx, by, Map.TERRAIN, "block_move", self) end
 		local l = self:lineFOV(x, y, block_actor)
 		local lx, ly, is_corner_blocked = l:step(block_actor)
-		local tx, ty = lx, ly
+		local tx, ty = self.x, self.y
 		while lx and ly do
 			if is_corner_blocked or game.level.map:checkAllEntities(lx, ly, "block_move", self) then break end
 			tx, ty = lx, ly
diff --git a/src/fov.c b/src/fov.c
index ecf041bce3..3a3ab703c0 100644
--- a/src/fov.c
+++ b/src/fov.c
@@ -631,7 +631,7 @@ static int lua_fov_line_step(lua_State *L)
 {
 	fov_line_data *line = (fov_line_data*)auxiliar_checkclass(L, "core{fovline}", 1);
 	bool dont_stop_at_end = lua_toboolean(L, 2);
-	if (!dont_stop_at_end && line->dest_t == line->t) return 0;
+	if (!dont_stop_at_end && line->dest_t == line->t || line->dest_t == 0) return 0;
 
 	// If there is a tie, then choose the tile closer to a cardinal direction.
 	// If we weren't careful, this would be the most likely place to have floating precision
-- 
GitLab