From ffbd53f206016188d6ca796bb915d1c9193d40d5 Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Thu, 19 May 2011 22:04:25 +0000
Subject: [PATCH] Flameshock when using Burning Wake will leave a trail of fire
 of the correct shape

git-svn-id: http://svn.net-core.org/repos/t-engine4@3414 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engines/default/engine/Map.lua           |  8 ++++++--
 game/engines/default/engine/utils.lua         | 19 +++++++++++++++++++
 .../modules/tome/data/talents/spells/fire.lua |  2 +-
 .../tome/data/talents/spells/water.lua        |  5 ++---
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/game/engines/default/engine/Map.lua b/game/engines/default/engine/Map.lua
index f874d7dac1..f4f4663e8b 100644
--- a/game/engines/default/engine/Map.lua
+++ b/game/engines/default/engine/Map.lua
@@ -783,8 +783,11 @@ function _M:addEffect(src, x, y, duration, damtype, dam, radius, dir, angle, ove
 
 	local grids
 
+	-- Handle any angle
+	if type(dir) == "table" then
+		grids = core.fov.beam_any_angle_grids(x, y, radius, dir.angle, angle, true)
 	-- Handle balls
-	if dir == 5 then
+	elseif dir == 5 then
 		grids = core.fov.circle_grids(x, y, radius, true)
 	-- Handle beams
 	else
@@ -859,7 +862,8 @@ function _M:processEffects()
 			table.insert(todel, i)
 		elseif e.update_fct then
 			if e:update_fct() then
-				if e.dir == 5 then e.grids = core.fov.circle_grids(e.x, e.y, e.radius, true)
+				if type(dir) == "table" then e.grids = core.fov.beam_any_angle_gridse(e.x, e.y, e.radius, e.dir.angle, e.angle, true)
+				elseif e.dir == 5 then e.grids = core.fov.circle_grids(e.x, e.y, e.radius, true)
 				else e.grids = core.fov.beam_grids(e.x, e.y, e.radius, e.dir, e.angle, true) end
 				if e.particles then
 					if e.particles_only_one then
diff --git a/game/engines/default/engine/utils.lua b/game/engines/default/engine/utils.lua
index f2b3746bb4..1cefad5d6a 100644
--- a/game/engines/default/engine/utils.lua
+++ b/game/engines/default/engine/utils.lua
@@ -906,6 +906,25 @@ function core.fov.beam_grids(x, y, radius, dir, angle, block)
 	return grids
 end
 
+function core.fov.beam_any_angle_grids(x, y, radius, dir_angle, angle, block)
+	if not x or not y then return {} end
+	if radius == 0 then return {[x]={[y]=true}} end
+	local grids = {}
+	core.fov.calc_beam_any_angle(x, y, game.level.map.w, game.level.map.h, radius, dir_angle, angle, function(_, lx, ly)
+		if block and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then return true end
+	end,
+	function(_, lx, ly)
+		if not grids[lx] then grids[lx] = {} end
+		grids[lx][ly] = true
+	end, nil)
+
+	-- point of origin
+	if not grids[x] then grids[x] = {} end
+	grids[x][y] = true
+
+	return grids
+end
+
 --- Finds free grids around coords in a radius.
 -- This will return a random grid, the closest possible to the epicenter
 -- @param sx the epicenter coordinates
diff --git a/game/modules/tome/data/talents/spells/fire.lua b/game/modules/tome/data/talents/spells/fire.lua
index de298686e1..abda93b767 100644
--- a/game/modules/tome/data/talents/spells/fire.lua
+++ b/game/modules/tome/data/talents/spells/fire.lua
@@ -108,7 +108,7 @@ newTalent{
 				self.x, self.y, 4,
 				DamageType.INFERNO, self:attr("burning_wake"),
 				tg.radius,
-				dir, 55,
+				{angle=math.deg(math.atan2(y - self.y, x - self.x))}, 55,
 				{type="inferno"},
 				nil, self:spellFriendlyFire()
 			)
diff --git a/game/modules/tome/data/talents/spells/water.lua b/game/modules/tome/data/talents/spells/water.lua
index 7a213984c8..78f76a10ff 100644
--- a/game/modules/tome/data/talents/spells/water.lua
+++ b/game/modules/tome/data/talents/spells/water.lua
@@ -132,8 +132,8 @@ newTalent{
 		local damage = t.getDamage(self, t)
 		local duration = t.getDuration(self, t)
 		return ([[A wall of water rushes out from the caster doing %0.2f cold damage and %0.2f physical damage as well as knocking back targets each turn for %d turns.
-	        The damage and duration will increase with the Magic stat]]):
-			format(damDesc(self, DamageType.COLD, damage/2), damDesc(self, DamageType.PHYSICAL, damage/2), duration)
+		The damage and duration will increase with the Magic stat]]):
+		format(damDesc(self, DamageType.COLD, damage/2), damDesc(self, DamageType.PHYSICAL, damage/2), duration)
 	end,
 }
 
@@ -161,7 +161,6 @@ newTalent{
 			3,
 			5, nil,
 			{type="icestorm", only_one=true},
---			engine.Entity.new{alpha=100, display='', color_br=30, color_bg=60, color_bb=200},
 			function(e)
 				e.x = e.src.x
 				e.y = e.src.y
-- 
GitLab