Skip to content
Snippets Groups Projects
Commit 806cd9fb authored by dg's avatar dg
Browse files

fixes, fireflash

git-svn-id: http://svn.net-core.org/repos/t-engine4@56 51575b47-30f0-44d4-a5cc-537603b46e54
parent ddaf6b90
No related branches found
No related tags found
No related merge requests found
...@@ -267,6 +267,21 @@ function _M:checkAllEntities(x, y, what, ...) ...@@ -267,6 +267,21 @@ function _M:checkAllEntities(x, y, what, ...)
end end
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 --- Lite all grids
function _M:liteAll(x, y, w, h) function _M:liteAll(x, y, w, h)
for i = x, x + w - 1 do for j = y, y + h - 1 do for i = x, x + w - 1 do for j = y, y + h - 1 do
......
...@@ -232,7 +232,7 @@ function _M:setupCommands() ...@@ -232,7 +232,7 @@ function _M:setupCommands()
{ {
-- ability test -- ability test
_a = function() _a = function()
self.player:useAbility(ActorAbilities.AB_MANATHRUST) self.player:useAbility(ActorAbilities.AB_FIREFLASH)
end, end,
_LEFT = function() self.player:move(self.player.x - 1, self.player.y ) end, _LEFT = function() self.player:move(self.player.x - 1, self.player.y ) end,
......
...@@ -63,26 +63,28 @@ function _M:project(t, x, y, damtype, dam) ...@@ -63,26 +63,28 @@ function _M:project(t, x, y, damtype, dam)
if dam < 0 then return end if dam < 0 then return end
local typ = Target:getType(t) local typ = Target:getType(t)
-- Stop at range or on block
local lx, ly = x, y local lx, ly = x, y
if typ.stop_block then local l = line.new(self.x, self.y, x, y)
local l = line.new(self.x, self.y, x, y) lx, ly = l()
lx, ly = l() while lx and ly do
while lx and ly do if typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then break
if typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then break end elseif game.level.map:checkEntity(lx, ly, Map.TERRAIN, "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 if typ.range and math.sqrt((self.x-lx)^2 + (self.y-ly)^2) > typ.range then break end
-- Deam damage: beam -- Deam damage: beam
if typ.line then DamageType:get(damtype).projector(self, lx, ly, damtype, dam) end if typ.line then DamageType:get(damtype).projector(self, lx, ly, damtype, dam) end
lx, ly = l() lx, ly = l()
end
end 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 if typ.ball then
print(lx, ly, typ.ball)
core.fov.calc_circle(lx, ly, typ.ball, function(self, px, py) core.fov.calc_circle(lx, ly, typ.ball, function(self, px, py)
-- Deam damage: ball -- Deam damage: ball
DamageType:get(damtype).projector(self, px, py, damtype, dam) 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) end, function()end, self)
DamageType:get(damtype).projector(self, lx, ly, damtype, dam) DamageType:get(damtype).projector(self, lx, ly, damtype, dam)
elseif typ.cone then elseif typ.cone then
......
-- Mana spells -- Mana spells
newAbilityType{ type="spell/arcane", name = "arcane" } 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{ newAbility{
name = "Manathrust", name = "Manathrust",
type = "spell/arcane", type = "spell/arcane",
mana = 15, mana = 10,
tactical = { tactical = {
ATTACK = 10, ATTACK = 10,
}, },
action = function(self) action = function(self)
local t = {type="ball", range=20, radius=4} local t = {type="bolt", range=20}
local x, y = self:getTarget(t) local x, y = self:getTarget(t)
if not x or not y then return nil end if not x or not y then return nil end
self:project(t, x, y, DamageType.ARCANE, 10 + self:getMag()) self:project(t, x, y, DamageType.ARCANE, 10 + self:getMag())
...@@ -19,5 +24,48 @@ newAbility{ ...@@ -19,5 +24,48 @@ newAbility{
info = function(self) info = function(self)
return ([[Conjures up mana into a powerful bolt doing %0.2f arcane damage", 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()) 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,
} }
...@@ -7,7 +7,7 @@ return { ...@@ -7,7 +7,7 @@ return {
persistant = true, persistant = true,
generator = { generator = {
map = { map = {
class= "engine.generator.map.Empty", class= "engine.generator.map.Rooms",
floor = "FLOOR", floor = "FLOOR",
wall = "WALL", wall = "WALL",
up = "UP", up = "UP",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment