From 806cd9fbd9f2801dd595c6070825b1329d51969f Mon Sep 17 00:00:00 2001
From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54>
Date: Sat, 28 Nov 2009 02:11:22 +0000
Subject: [PATCH] fixes, fireflash

git-svn-id: http://svn.net-core.org/repos/t-engine4@56 51575b47-30f0-44d4-a5cc-537603b46e54
---
 game/engine/Map.lua                           | 15 ++++++
 game/modules/tome/class/Game.lua              |  2 +-
 game/modules/tome/class/interface/Combat.lua  | 24 +++++----
 game/modules/tome/data/abilities.lua          | 54 +++++++++++++++++--
 .../tome/data/zones/ancient_ruins/zone.lua    |  2 +-
 5 files changed, 81 insertions(+), 16 deletions(-)

diff --git a/game/engine/Map.lua b/game/engine/Map.lua
index 49ede6760c..384691b3cb 100644
--- a/game/engine/Map.lua
+++ b/game/engine/Map.lua
@@ -267,6 +267,21 @@ function _M:checkAllEntities(x, y, what, ...)
 	end
 end
 
+--- Check specified entity position of the grid for a property
+-- @param x position
+-- @param y position
+-- @param pos entity position in the grid
+-- @param what property to check
+function _M:checkEntity(x, y, pos, what, ...)
+	if x < 0 or x >= self.w or y < 0 or y >= self.h then return end
+	if self.map[x + y * self.w] then
+		if self.map[x + y * self.w][pos] then
+			local p = self.map[x + y * self.w][pos]:check(what, x, y, ...)
+			if p then return p end
+		end
+	end
+end
+
 --- Lite all grids
 function _M:liteAll(x, y, w, h)
 	for i = x, x + w - 1 do for j = y, y + h - 1 do
diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua
index 28f9763439..a5b3bf7053 100644
--- a/game/modules/tome/class/Game.lua
+++ b/game/modules/tome/class/Game.lua
@@ -232,7 +232,7 @@ function _M:setupCommands()
 	{
 		-- ability test
 		_a = function()
-			self.player:useAbility(ActorAbilities.AB_MANATHRUST)
+			self.player:useAbility(ActorAbilities.AB_FIREFLASH)
 		end,
 
 		_LEFT  = function() self.player:move(self.player.x - 1, self.player.y    ) end,
diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua
index d111d1f47f..eea172f12d 100644
--- a/game/modules/tome/class/interface/Combat.lua
+++ b/game/modules/tome/class/interface/Combat.lua
@@ -63,26 +63,28 @@ function _M:project(t, x, y, damtype, dam)
 	if dam < 0 then return end
 	local typ = Target:getType(t)
 
+	-- Stop at range or on block
 	local lx, ly = x, y
-	if typ.stop_block then
-		local l = line.new(self.x, self.y, x, y)
-		lx, ly = l()
-		while lx and ly do
-			if typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then break end
-			if typ.range and math.sqrt((self.source_actor.x-lx)^2 + (self.source_actor.y-ly)^2) > typ.range then break end
+	local l = line.new(self.x, self.y, x, y)
+	lx, ly = l()
+	while lx and ly do
+		if typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then break
+		elseif game.level.map:checkEntity(lx, ly, Map.TERRAIN, "block_move") then break end
+		if typ.range and math.sqrt((self.x-lx)^2 + (self.y-ly)^2) > typ.range then break end
 
-			-- Deam damage: beam
-			if typ.line then DamageType:get(damtype).projector(self, lx, ly, damtype, dam) end
+		-- Deam damage: beam
+		if typ.line then DamageType:get(damtype).projector(self, lx, ly, damtype, dam) end
 
-			lx, ly = l()
-		end
+		lx, ly = l()
 	end
+	-- Ok if we are at the end reset lx and ly for the next code
+	if not lx and not ly then lx, ly = x, y end
 
 	if typ.ball then
+	print(lx, ly, typ.ball)
 		core.fov.calc_circle(lx, ly, typ.ball, function(self, px, py)
 			-- Deam damage: ball
 			DamageType:get(damtype).projector(self, px, py, damtype, dam)
---			self.sg:toScreen(self.display_x + (lx - game.level.map.mx) * self.tile_w, self.display_y + (ly - game.level.map.my) * self.tile_h)
 		end, function()end, self)
 		DamageType:get(damtype).projector(self, lx, ly, damtype, dam)
 	elseif typ.cone then
diff --git a/game/modules/tome/data/abilities.lua b/game/modules/tome/data/abilities.lua
index 4b75d296b4..f2030c0aa4 100644
--- a/game/modules/tome/data/abilities.lua
+++ b/game/modules/tome/data/abilities.lua
@@ -1,15 +1,20 @@
 -- Mana spells
 newAbilityType{ type="spell/arcane", name = "arcane" }
+newAbilityType{ type="spell/fire", name = "fire" }
+newAbilityType{ type="spell/earth", name = "earth" }
+newAbilityType{ type="spell/cold", name = "cold" }
+newAbilityType{ type="spell/lightning", name = "lightning" }
+newAbilityType{ type="spell/conveyance", name = "conveyance" }
 
 newAbility{
 	name = "Manathrust",
 	type = "spell/arcane",
-	mana = 15,
+	mana = 10,
 	tactical = {
 		ATTACK = 10,
 	},
 	action = function(self)
-		local t = {type="ball", range=20, radius=4}
+		local t = {type="bolt", range=20}
 		local x, y = self:getTarget(t)
 		if not x or not y then return nil end
 		self:project(t, x, y, DamageType.ARCANE, 10 + self:getMag())
@@ -19,5 +24,48 @@ newAbility{
 	info = function(self)
 		return ([[Conjures up mana into a powerful bolt doing %0.2f arcane damage",
 		The damage will increase with the Magic stat]]):format(10 + self:getMag())
-	end
+	end,
+}
+
+newAbility{
+	name = "Fireflash",
+	type = "spell/fire",
+	mana = 45,
+	tactical = {
+		ATTACKAREA = 10,
+	},
+	action = function(self)
+		local t = {type="ball", range=15, radius=math.min(6, 2 + self:getMag(6))}
+		local x, y = self:getTarget(t)
+		if not x or not y then return nil end
+		self:project(t, x, y, DamageType.FIRE, 8 + self:getMag(70))
+		return true
+	end,
+	require = { stat = { mag=16 }, },
+	info = function(self)
+		return ([[Conjures up a flash of fire doing %0.2f fire damage in a radius of %d",
+		The damage will increase with the Magic stat]]):format(8 + self:getMag(70), math.min(6, 2 + self:getMag(6)))
+	end,
+}
+
+newAbility{
+	name = "Phase Door",
+	type = "spell/conveyance",
+	message = "@Source@ blinks.",
+	mana = 15,
+	tactical = {
+		ESCAPE = 4,
+	},
+	action = function(self)
+		local t = {type="ball", range=15, radius=math.min(6, 2 + self:getMag(6))}
+		local x, y = self:getTarget(t)
+		if not x or not y then return nil end
+		self:project(t, x, y, DamageType.FIRE, 8 + self:getMag(70))
+		return true
+	end,
+	require = { stat = { mag=16 }, },
+	info = function(self)
+		return ([[Teleports you randomly on a small scale range",
+		The damage will increase with the Magic stat]]):format(8 + self:getMag(70), math.min(6, 2 + self:getMag(6)))
+	end,
 }
diff --git a/game/modules/tome/data/zones/ancient_ruins/zone.lua b/game/modules/tome/data/zones/ancient_ruins/zone.lua
index 9eafda75a4..617575782f 100644
--- a/game/modules/tome/data/zones/ancient_ruins/zone.lua
+++ b/game/modules/tome/data/zones/ancient_ruins/zone.lua
@@ -7,7 +7,7 @@ return {
 	persistant = true,
 	generator =  {
 		map = {
-			class= "engine.generator.map.Empty",
+			class= "engine.generator.map.Rooms",
 			floor = "FLOOR",
 			wall = "WALL",
 			up = "UP",
-- 
GitLab