From e5fb2921311624e4657119874df5f0732a5ca567 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Mon, 14 Nov 2011 08:58:53 +0000 Subject: [PATCH] hihi git-svn-id: http://svn.net-core.org/repos/t-engine4@4647 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/data/keybinds/move.lua | 6 +++ game/modules/tome/class/Game.lua | 11 ++-- game/modules/tome/class/Player.lua | 21 ++++++-- .../tome/data/gfx/particles/notice_enemy.lua | 54 +++++++++++++++++++ game/modules/tome/data/keybinds/tome.lua | 8 --- .../talents/techniques/combat-training.lua | 2 +- 6 files changed, 84 insertions(+), 18 deletions(-) create mode 100644 game/modules/tome/data/gfx/particles/notice_enemy.lua diff --git a/game/engines/default/data/keybinds/move.lua b/game/engines/default/data/keybinds/move.lua index 184bd117d8..30a03ce246 100644 --- a/game/engines/default/data/keybinds/move.lua +++ b/game/engines/default/data/keybinds/move.lua @@ -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", +} diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index b192449a54..7d44d291cc 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -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 diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index e537de450f..828e9a411c 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -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" diff --git a/game/modules/tome/data/gfx/particles/notice_enemy.lua b/game/modules/tome/data/gfx/particles/notice_enemy.lua new file mode 100644 index 0000000000..031b9281ef --- /dev/null +++ b/game/modules/tome/data/gfx/particles/notice_enemy.lua @@ -0,0 +1,54 @@ +-- 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 diff --git a/game/modules/tome/data/keybinds/tome.lua b/game/modules/tome/data/keybinds/tome.lua index 3363ef887b..5e589c5f69 100644 --- a/game/modules/tome/data/keybinds/tome.lua +++ b/game/modules/tome/data/keybinds/tome.lua @@ -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", -} - diff --git a/game/modules/tome/data/talents/techniques/combat-training.lua b/game/modules/tome/data/talents/techniques/combat-training.lua index 60ad2e8771..7e1cab393b 100644 --- a/game/modules/tome/data/talents/techniques/combat-training.lua +++ b/game/modules/tome/data/talents/techniques/combat-training.lua @@ -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 +} -- GitLab