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

"hit warning" displays the direction of incomming ranged attacks

git-svn-id: http://svn.net-core.org/repos/t-engine4@714 51575b47-30f0-44d4-a5cc-537603b46e54
parent 602eabd8
No related branches found
No related tags found
No related merge requests found
......@@ -190,6 +190,16 @@ function _M:onTakeHit(value, src)
local sx, sy = game.level.map:getTileToScreen(self.x, self.y)
game.flyers:add(sx, sy, 30, (rng.range(0,2)-1) * 0.5, 2, "LOW HEALTH!", {255,0,0}, true)
end
-- Hit direction warning
if src.x and src.y and (self.x ~= src.x or self.y ~= src.y) then
local range = math.floor(core.fov.distance(src.x, src.y, self.x, self.y))
if range > 1 then
local angle = math.atan2(src.y - self.y, src.x - self.x)
game.level.map:particleEmitter(self.x, self.y, 1, "hit_warning", {angle=math.deg(angle)})
end
end
return ret
end
......
-- ToME - Tales of Middle-Earth
-- Copyright (C) 2009, 2010 Nicolas Casalini
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
--
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
angle = angle or 0
return { generator = function()
local ad = rng.range(-30, 30) + angle
local a = math.rad(ad)
local r = rng.range(15, 16)
return {
life = 8,
size = 4, sizev = -0.1, sizea = 0,
x = r * math.cos(a), xv = 0, xa = 0,
y = r * math.sin(a), yv = 0, ya = 0,
dir = 0, dirv = 0, dira = 0,
vel = 0, velv = 0, vela = 0,
r = rng.range(160, 220)/255, rv = rng.range(0, 10), ra = 0,
g = 0, gv = 0, ga = 0,
b = 0, bv = rng.range(0, 10), ba = 0,
a = rng.range(70, 255)/255, av = 0, aa = 0,
}
end, },
function(self)
self.nb = (self.nb or 0) + 1
if self.nb < 4 then
self.ps:emit(10)
end
end,
100
No preview for this file type
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