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

hihi

git-svn-id: http://svn.net-core.org/repos/t-engine4@4647 51575b47-30f0-44d4-a5cc-537603b46e54
parent 1d12c7e5
No related branches found
No related tags found
No related merge requests found
......@@ -129,3 +129,9 @@ defineAction{
group = "movement",
name = "Run diagonally right and down",
}
defineAction{
default = { "sym:_z:false:false:false:false" },
type = "RUN_AUTO",
group = "movement",
name = "Auto-explore",
}
......@@ -1203,19 +1203,22 @@ function _M:setupCommands()
RUN_AUTO = function()
if self.level and self.zone then
local seen = false
local seen = {}
-- Check for visible monsters. Only see LOS actors, so telepathy wont prevent it
core.fov.calc_circle(self.player.x, self.player.y, self.level.map.w, self.level.map.h, self.player.sight or 10,
function(_, x, y) return self.level.map:opaque(x, y) end,
function(_, x, y)
local actor = self.level.map(x, y, self.level.map.ACTOR)
if actor and actor ~= self.player and self.player:reactionToward(actor) < 0 and
self.player:canSee(actor) and self.level.map.seens(x, y) then seen = true end
self.player:canSee(actor) and self.level.map.seens(x, y) then seen[#seen + 1] = {x=x, y=y, actor=actor} end
end, nil)
if self.zone.no_autoexplore or self.level.no_autoexplore then
self.log("You may not auto-explore this level.")
elseif seen then
self.log("You may not auto-explore with hostile enemies in sight!")
elseif #seen > 0 then
self.log("You may not auto-explore with enemies in sight!")
for _, node in ipairs(seen) do
node.actor:addParticles(engine.Particles.new("notice_enemy", 1))
end
elseif not self.player:autoExplore() then
self.log("There is nowhere left to explore.")
end
......
......@@ -548,12 +548,12 @@ function _M:setTarget(target)
end
local function spotHostiles(self)
local seen = false
local seen = {}
-- Check for visible monsters, only see LOS actors, so telepathy wont prevent resting
core.fov.calc_circle(self.x, self.y, game.level.map.w, game.level.map.h, 20, function(_, x, y) return game.level.map:opaque(x, y) end, function(_, x, y)
core.fov.calc_circle(self.x, self.y, game.level.map.w, game.level.map.h, self.sight or 10, function(_, x, y) return game.level.map:opaque(x, y) end, function(_, x, y)
local actor = game.level.map(x, y, game.level.map.ACTOR)
if actor and self:reactionToward(actor) < 0 and self:canSee(actor) and game.level.map.seens(x, y) then
seen = {x=x,y=y,actor=actor}
seen[#seen + 1] = {x=x,y=y,actor=actor}
end
end, nil)
return seen
......@@ -563,7 +563,12 @@ end
-- We can rest if no hostiles are in sight, and if we need life/mana/stamina/psi (and their regen rates allows them to fully regen)
function _M:restCheck()
local spotted = spotHostiles(self)
if spotted then return false, ("hostile spotted (%s%s)"):format(spotted.actor.name, game.level.map:isOnScreen(spotted.x, spotted.y) and "" or " - offscreen") end
if #spotted > 0 then
for _, node in ipairs(spotted) do
node.actor:addParticles(engine.Particles.new("notice_enemy", 1))
end
return false, ("hostile spotted (%s%s)"):format(spotted[1].actor.name, game.level.map:isOnScreen(spotted[1].x, spotted[1].y) and "" or " - offscreen")
end
-- Resting improves regen
for act, def in pairs(game.party.members) do if game.level:hasEntity(act) and not act.dead then
......@@ -619,7 +624,7 @@ end
-- 'ignore_memory' is only used when checking for paths around traps. This ensures we don't remember items "obj_seen" that we aren't supposed to
function _M:runCheck(ignore_memory)
local spotted = spotHostiles(self)
if spotted then return false, ("hostile spotted (%s%s)"):format(spotted.actor.name, game.level.map:isOnScreen(spotted.x, spotted.y) and "" or " - offscreen") end
if #spotted > 0 then return false, ("hostile spotted (%s%s)"):format(spotted[1].actor.name, game.level.map:isOnScreen(spotted[1].x, spotted[1].y) and "" or " - offscreen") end
if self.air_regen < 0 then return false, "losing breath!" end
......@@ -697,6 +702,12 @@ end
function _M:runStopped()
game.level.map.clean_fov = true
self:playerFOV()
local spotted = spotHostiles(self)
if #spotted > 0 then
for _, node in ipairs(spotted) do
node.actor:addParticles(engine.Particles.new("notice_enemy", 1))
end
end
end
--- Activates a hotkey with a type "inventory"
......
-- ToME - Tales of Maj'Eyal
-- Copyright (C) 2009, 2010, 2011 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
base_size = 32
local nb = 0
return { generator = function()
local f = 1.5 - nb/36
local life = 32
local xv = rng.float(-1, 1)
local yv = rng.float(-1, 1)
local tv = math.max(math.abs(xv), math.abs(yv))
xv = 0.9 * base_size / life * xv / tv
yv = 0.9 * base_size / life * yv / tv
return {
trail = 1,
life = life / f,
size = 3, sizev = 0, sizea = 0,
x = -1, xv = xv, xa = -xv / life / f,
y = -1, yv = yv, ya = -yv / life / f,
dir = 0, dirv = 0, dira = 0,
vel = 0, velv = 0, vela = 0,
r = rng.float(0.60, 0.80), rv = 0, ra = 0,
g = 0.08, gv = 0, ga = 0,
b = 0.08, bv = 0, ba = 0,
a = rng.float(0.3, 0.7), av = -0.6 * f / life, aa = 0,
}
end, },
function(self)
if nb == 0 then self.ps:emit(300) end
nb = nb + 1
end,
300, nil, true
......@@ -198,11 +198,3 @@ defineAction{
group = "movement",
name = "Attack diagonally right and down",
}
defineAction{
default = { "sym:_a:false:true:false:false" },
type = "RUN_AUTO",
group = "movement",
name = "Auto-explore",
}
......@@ -144,4 +144,4 @@ newTalent{
return ([[Increases Physical Power by %d. Also increases damage done with exotic weapons by %d%%]]):
format(damage, 100*inc)
end,
}
\ No newline at end of file
}
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