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

fix projectile

Fix store selling not updating after object identification


git-svn-id: http://svn.net-core.org/repos/t-engine4@948 51575b47-30f0-44d4-a5cc-537603b46e54
parent c586d4b7
No related branches found
No related tags found
No related merge requests found
......@@ -87,7 +87,7 @@ function _M:move(x, y, force)
self:addParticles(Particles.new(self.travel_particle, 1, nil))
self.travel_particle = nil
end
-- Update particle emitters attached to that actor
local del = {}
for e, _ in pairs(self.__particles) do
......@@ -137,20 +137,20 @@ end
--- Called by the engine when the projectile can move
function _M:act()
if self.dead then return false end
while self:enoughEnergy() and not self.dead do
if self.project then
local x, y, act, stop = self.src:projectDoMove(self.project.def.typ, self.project.def.x, self.project.def.y, self.x, self.y)
local x, y, act, stop = self.src:projectDoMove(self.project.def.typ, self.project.def.x, self.project.def.y, self.x, self.y, self.project.def.start_x, self.project.def.start_y)
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)
game.level:removeEntity(self)
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)
game.level:removeEntity(self)
self.dead = true
end
end
end
return true
end
......
......@@ -179,16 +179,19 @@ function _M:projectile(t, x, y, damtype, dam, particles)
-- if type(dam) == "number" and dam < 0 then return end
local typ = Target:getType(t)
local proj = require(self.projectile_class):makeProject(self, t.display, {x=x, y=y, damtype=damtype, tg=t, typ=typ, dam=dam, particles=particles})
local proj = require(self.projectile_class):makeProject(self, t.display, {x=x, y=y, start_x = t.x or self.x, start_y = t.y or self.y, damtype=damtype, tg=t, typ=typ, dam=dam, particles=particles})
game.zone:addEntity(game.level, proj, "projectile", self.x, self.y)
end
function _M:projectDoMove(typ, x, y, srcx, srcy)
function _M:projectDoMove(typ, tgtx, tgty, x, y, srcx, srcy)
-- Stop at range or on block
local lx, ly = x, y
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 l = line.new(srcx, srcy, tgtx, tgty)
local lx, ly = srcx, srcy
-- Look for our current position
while lx and ly and not (lx == x and ly == y) do lx, ly = l() end
-- Now get the next position
if lx and ly then lx, ly = l() end
if lx and ly then
if not typ.no_restrict then
if typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then return lx, ly, false, true
......@@ -200,7 +203,7 @@ function _M:projectDoMove(typ, x, y, srcx, srcy)
if typ.line then return lx, ly, true, false end
end
-- Ok if we are at the end
if (not lx and not ly) or (lx == x and ly == y) then return lx, ly, false, true end
if (not lx and not ly) then return lx, ly, false, true end
return lx, ly, false, false
end
......@@ -249,6 +252,7 @@ function _M:projectDoStop(typ, tg, damtype, dam, particles, lx, ly, tmp)
end, function()end, nil)
addGrid(lx, ly)
elseif typ.cone then
local initial_dir = lx and util.getDir(lx, ly, x, y) or 5
core.fov.calc_beam(lx, ly, typ.cone, initial_dir, typ.cone_angle, function(_, px, py)
-- Deal damage: cone
addGrid(px, py)
......
......@@ -580,7 +580,7 @@ function _M:setupCommands()
self.player:forceLevelup(50)
self.player.esp.all = 1
self.player.esp.range = 50
self:changeLevel(1, "tol-falas")
self:changeLevel(1, "vor-pride")
-- self.player:grantQuest("escort-duty")
end
end,
......
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