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

Fix ActorProject to not call damtype if it's a function over a friendly fire

git-svn-id: http://svn.net-core.org/repos/t-engine4@1567 51575b47-30f0-44d4-a5cc-537603b46e54
parent b1c78bb2
No related branches found
No related tags found
No related merge requests found
......@@ -102,39 +102,30 @@ function _M:project(t, x, y, damtype, dam, particles)
-- Now project on each grid, one type
local tmp = {}
if type(damtype) == "function" then
local stop = false
for px, ys in pairs(grids) do
for py, _ in pairs(ys) do
if particles then
game.level.map:particleEmitter(px, py, 1, particles.type)
end
if damtype(px, py, tg, self) then stop=true break end
end
if stop then break end
end
else
for px, ys in pairs(grids) do
for py, _ in pairs(ys) do
-- Call the projected method of the target grid if possible
if not game.level.map:checkAllEntities(x, y, "projected", self, t, x, y, damtype, dam, particles) then
-- Friendly fire ?
if px == self.x and py == self.y then
if typ.friendlyfire then
DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp)
if particles then
game.level.map:particleEmitter(px, py, 1, particles.type)
end
end
else
DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp)
local stop = false
for px, ys in pairs(grids) do
for py, _ in pairs(ys) do
-- Call the projected method of the target grid if possible
if not game.level.map:checkAllEntities(x, y, "projected", self, t, x, y, damtype, dam, particles) then
-- Friendly fire ?
if px == self.x and py == self.y then
if typ.friendlyfire then
if type(damtype) == "function" then if damtype(px, py, tg, self) then stop=true break end
else DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp) end
if particles then
game.level.map:particleEmitter(px, py, 1, particles.type)
end
end
else
if type(damtype) == "function" then if damtype(px, py, tg, self) then stop=true break end
else DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp) end
if particles then
game.level.map:particleEmitter(px, py, 1, particles.type)
end
end
end
end
if stop then break end
end
return grids
end
......@@ -218,29 +209,23 @@ end
function _M:projectDoAct(typ, tg, damtype, dam, particles, px, py, tmp)
-- Now project on each grid, one type
if type(damtype) == "function" then
if particles and type(particles) == "table" then
game.level.map:particleEmitter(px, py, 1, particles.type)
end
if damtype(px, py, tg, self) then return true end
return false
else
-- Call the projected method of the target grid if possible
if not game.level.map:checkAllEntities(px, py, "projected", self, typ, px, py, damtype, dam, particles) then
-- Friendly fire ?
if px == self.x and py == self.y then
if typ.friendlyfire then
DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp)
if particles and type(particles) == "table" then
game.level.map:particleEmitter(px, py, 1, particles.type)
end
end
else
DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp)
-- Call the projected method of the target grid if possible
if not game.level.map:checkAllEntities(px, py, "projected", self, typ, px, py, damtype, dam, particles) then
-- Friendly fire ?
if px == self.x and py == self.y then
if typ.friendlyfire then
if type(damtype) == "function" then if damtype(px, py, tg, self) then return true end
else DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp) end
if particles and type(particles) == "table" then
game.level.map:particleEmitter(px, py, 1, particles.type)
end
end
else
if type(damtype) == "function" then if damtype(px, py, tg, self) then return true end
else DamageType:get(damtype).projector(self, px, py, damtype, dam, tmp) end
if particles and type(particles) == "table" then
game.level.map:particleEmitter(px, py, 1, particles.type)
end
end
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