Skip to content
Snippets Groups Projects
Commit 679dfa83 authored by dg's avatar dg
Browse files

fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@1499 51575b47-30f0-44d4-a5cc-537603b46e54
parent 62ee7556
No related branches found
No related tags found
No related merge requests found
......@@ -150,7 +150,15 @@ function _M:act()
if x and y then self:move(x, y) end
if act then self.src:projectDoAct(self.project.def.typ, self.project.def.tg, self.project.def.damtype, self.project.def.dam, self.project.def.particles, self.x, self.y, self.tmp_proj) end
if stop then
self.src:projectDoStop(self.project.def.typ, self.project.def.tg, self.project.def.damtype, self.project.def.dam, self.project.def.particles, self.x, self.y, self.tmp_proj)
-- Correct the explosion source position if we exploded on terrain
local radius_x, radius_y
if self.project.def.typ.block_path then
_, radius_x, radius_y = self.project.def.typ:block_path(self.x, self.y)
end
if not radius_x then
radius_x, radius_y = self.old_x, self.old_y
end
self.src:projectDoStop(self.project.def.typ, self.project.def.tg, self.project.def.damtype, self.project.def.dam, self.project.def.particles, radius_x, radius_y, self.tmp_proj)
game.level:removeEntity(self)
self.dead = true
end
......
......@@ -87,19 +87,22 @@ function _M:display(dispx, dispy)
end
self.cursor:toScreen(self.display_x + (self.target.x - game.level.map.mx) * self.tile_w * Map.zoom, self.display_y + (self.target.y - game.level.map.my) * self.tile_h * Map.zoom, self.tile_w * Map.zoom, self.tile_h * Map.zoom)
-- If we reached the end without mishap then both the beam and radius effect should stop here
if s == self.sb then
stopx, stopy = self.target.x, self.target.y
stop_radius_x, stop_radius_y = stopx, stopy
-- Correct the explosion source position if we exploded on terrain
local radius_x, radius_y
if self.target_type.block_path then
_, radius_x, radius_y = self.target_type:block_path(stopx, stopy)
end
if not radius_x then
radius_x, radius_y = stop_radius_x, stop_radius_y
end
if self.target_type.ball and self.target_type.ball > 0 then
core.fov.calc_circle(stop_radius_x, stop_radius_y, self.target_type.ball, function(_, px, py)
core.fov.calc_circle(radius_x, radius_y, self.target_type.ball, function(_, px, py)
self.sg:toScreen(self.display_x + (px - game.level.map.mx) * self.tile_w * Map.zoom, self.display_y + (py - game.level.map.my) * self.tile_h * Map.zoom, self.tile_w * Map.zoom, self.tile_h * Map.zoom)
if self.target_type.block_radius and self.target_type:block_radius(px, py) then return true end
end, function()end, nil)
elseif self.target_type.cone and self.target_type.cone > 0 then
core.fov.calc_beam(stop_radius_x, stop_radius_y, self.target_type.cone, initial_dir, self.target_type.cone_angle, function(_, px, py)
core.fov.calc_beam(radius_x, radius_y, self.target_type.cone, initial_dir, self.target_type.cone_angle, function(_, px, py)
self.sg:toScreen(self.display_x + (px - game.level.map.mx) * self.tile_w * Map.zoom, self.display_y + (py - game.level.map.my) * self.tile_h * Map.zoom, self.tile_w * Map.zoom, self.tile_h * Map.zoom)
if self.target_type.block_radius and self.target_type:block_radius(px, py) then return true end
end, function()end, nil)
......@@ -134,10 +137,13 @@ function _M:getType(t)
block_path = function(typ, lx, ly)
if not typ.no_restrict then
if not game.level.map.remembers(lx, ly) then return true end
if typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then return true
elseif not typ.pass_terrain and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then return true end
if not typ.pass_terrain and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then return true
-- If we explode do to something other than terrain, then we should explode ON the tile, not before it
elseif typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then return true, lx, ly end
if typ.range and typ.source_actor and math.sqrt((typ.source_actor.x-lx)^2 + (typ.source_actor.y-ly)^2) > typ.range then return true end
end
-- If we don't block the path, then the explode point should be here
return false, lx, ly
end,
block_radius=function(typ, lx, ly)
return not typ.no_restrict and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move")
......
......@@ -57,10 +57,10 @@ function _M:project(t, x, y, damtype, dam, particles)
-- Stop at range or on block
local lx, ly = x, y
local stop_radius_x, stop_radius_y = srcx, srcy
local l = line.new(srcx, srcy, x, y)
lx, ly = l()
local initial_dir = lx and coord_to_dir[lx - srcx][ly - srcy] or 5
local stop_radius_x, stop_radius_y = lx, ly
while lx and ly do
if typ.block_path and typ:block_path(lx, ly) then break end
stop_radius_x, stop_radius_y = lx, ly
......@@ -73,15 +73,23 @@ function _M:project(t, x, y, damtype, dam, particles)
-- 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
-- Correct the explosion source position if we exploded on terrain
local radius_x, radius_y
if typ.block_path then
_, radius_x, radius_y = typ:block_path(lx, ly)
end
if not radius_x then
radius_x, radius_y = stop_radius_x, stop_radius_y
end
if typ.ball and typ.ball > 0 then
core.fov.calc_circle(stop_radius_x, stop_radius_y, typ.ball, function(_, px, py)
core.fov.calc_circle(radius_x, radius_y, typ.ball, function(_, px, py)
-- Deal damage: ball
addGrid(px, py)
if typ.block_radius and typ:block_radius(px, py) then return true end
end, function()end, nil)
addGrid(lx, ly)
elseif typ.cone and typ.cone > 0 then
core.fov.calc_beam(stop_radius_x, stop_radius_y, typ.cone, initial_dir, typ.cone_angle, function(_, px, py)
core.fov.calc_beam(radius_x, radius_y, typ.cone, initial_dir, typ.cone_angle, function(_, px, py)
-- Deal damage: cone
addGrid(px, py)
if typ.block_radius and typ:block_radius(px, py) then return true end
......@@ -180,6 +188,10 @@ function _M:projectile(t, x, y, damtype, dam, particles)
game.zone:addEntity(game.level, proj, "projectile", self.x, self.y)
end
-- @return lx x-coordinate the projectile travels to next
-- @return ly y-coordinate the projectile travels to next
-- @return act should we call projectDoAct (usually only for beam)
-- @return stop is this the last (blocking) tile?
function _M:projectDoMove(typ, tgtx, tgty, x, y, srcx, srcy)
-- Stop at range or on block
local l = line.new(srcx, srcy, tgtx, tgty)
......@@ -244,7 +256,7 @@ function _M:projectDoStop(typ, tg, damtype, dam, particles, lx, ly, tmp)
core.fov.calc_circle(lx, ly, typ.ball, function(_, px, py)
-- Deal damage: ball
addGrid(px, py)
if typ.block_radius and typ:block_radius(lx, ly) then return true end
if typ.block_radius and typ:block_radius(px, py) then return true end
end, function()end, nil)
addGrid(lx, ly)
elseif typ.cone and typ.cone > 0 then
......@@ -252,7 +264,7 @@ function _M:projectDoStop(typ, tg, damtype, dam, particles, lx, ly, tmp)
core.fov.calc_beam(lx, ly, typ.cone, initial_dir, typ.cone_angle, function(_, px, py)
-- Deal damage: cone
addGrid(px, py)
if typ.block_radius and typ:block_radius(lx, ly) then return true end
if typ.block_radius and typ:block_radius(px, py) then return true end
end, function()end, nil)
addGrid(lx, ly)
else
......
......@@ -22,7 +22,7 @@ newChat{ id="welcome",
I am Anlinwen Noromiel, head of the Circle of the Wise. Welcome to our city, @playerdescriptor.subclass@. What may I do for you?]],
answers = {
{"I require all the help I can get, not for my sake but for the town of Bree, in the north east of here.", jump="save-bree", cond=function(npc, player) local q = player:hasQuest("lightning-overload") return q and q:isCompleted("saved-bree") and not q:isCompleted("tempest-located") end},
{"I am ready, send me to Urkis!", jump="teleport-urkis", cond=function(npc, player) local q = player:hasQuest("lightning-overload") return q and q:isCompleted("tempest-located") end},
{"I am ready, send me to Urkis!", jump="teleport-urkis", cond=function(npc, player) local q = player:hasQuest("lightning-overload") return q and not q:isEnded("tempest-located") and q:isCompleted("tempest-located") end},
{"Nothing for now, sorry to have took your time. Farewell my lady."},
}
}
......
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