From c3ebd424a2b3d199f6330021bb56b36f16b35bf9 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Thu, 20 Jan 2011 17:48:03 +0000 Subject: [PATCH] Channel Staff now ignores friendlies (it will pass over them harmlessly) git-svn-id: http://svn.net-core.org/repos/t-engine4@2449 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engines/default/engine/Target.lua | 38 ++++++++++--------- game/modules/tome/class/interface/Archery.lua | 7 +--- .../tome/data/talents/spells/staff-combat.lua | 12 +++++- 3 files changed, 32 insertions(+), 25 deletions(-) diff --git a/game/engines/default/engine/Target.lua b/game/engines/default/engine/Target.lua index 1f2080dae4..af9c1a3e06 100644 --- a/game/engines/default/engine/Target.lua +++ b/game/engines/default/engine/Target.lua @@ -111,6 +111,26 @@ function _M:display(dispx, dispy) self.display_x, self.display_y = ox, oy end +-- Default type def +target_type = { + range=20, + friendlyfire=true, + block_path = function(typ, lx, ly) + if not typ.no_restrict then + if typ.requires_knowledge and not game.level.map.remembers(lx, ly) and not game.level.map.seens(lx, ly) then return true end + if not typ.pass_terrain and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then return true + -- If we explode due to something other than terrain, then we should explode ON the tile, not before it + elseif typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then return true, lx, ly end + if typ.range and typ.source_actor and typ.source_actor.x and math.sqrt((typ.source_actor.x-lx)^2 + (typ.source_actor.y-ly)^2) > typ.range then return true end + end + -- If we don't block the path, then the explode point should be here + return false, lx, ly + end, + block_radius=function(typ, lx, ly) + return not typ.no_restrict and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") + end +} + -- @return t The target table used by ActorProject, Projectile, GameTargeting, etc. -- @param t Target table used to generate the -- @param t.type The engine-defined type, populates other more complex variables (see below) @@ -131,24 +151,6 @@ function _M:getType(t) if not t then return {} end -- Add the default values t = table.clone(t) - target_type = { - range=20, - friendlyfire=true, - block_path = function(typ, lx, ly) - if not typ.no_restrict then - if typ.requires_knowledge and not game.level.map.remembers(lx, ly) and not game.level.map.seens(lx, ly) then return true end - if not typ.pass_terrain and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then return true - -- If we explode due to something other than terrain, then we should explode ON the tile, not before it - elseif typ.stop_block and game.level.map:checkAllEntities(lx, ly, "block_move") then return true, lx, ly end - if typ.range and typ.source_actor and typ.source_actor.x and math.sqrt((typ.source_actor.x-lx)^2 + (typ.source_actor.y-ly)^2) > typ.range then return true end - end - -- If we don't block the path, then the explode point should be here - return false, lx, ly - end, - block_radius=function(typ, lx, ly) - return not typ.no_restrict and game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") - end - } table.update(t, target_type) -- And now modify for the default types if t.type then diff --git a/game/modules/tome/class/interface/Archery.lua b/game/modules/tome/class/interface/Archery.lua index fcb9f8ee03..11121ae60f 100644 --- a/game/modules/tome/class/interface/Archery.lua +++ b/game/modules/tome/class/interface/Archery.lua @@ -77,12 +77,7 @@ function _M:archeryAcquireTargets(tg, params) for i = 1, params.multishots or 1 do local a if not ammo.infinite then - if self:doesPackRat() then - game.logPlayer(self, "Pack Rat!") - a = self:getInven("QUIVER")[1] - else - a = self:removeObject(self:getInven("QUIVER"), 1) - end + a = self:removeObject(self:getInven("QUIVER"), 1) else a = ammo end diff --git a/game/modules/tome/data/talents/spells/staff-combat.lua b/game/modules/tome/data/talents/spells/staff-combat.lua index 7d41ea57c1..581a087c87 100644 --- a/game/modules/tome/data/talents/spells/staff-combat.lua +++ b/game/modules/tome/data/talents/spells/staff-combat.lua @@ -52,7 +52,17 @@ newTalent{ else explosion = "manathrust" particle = "bolt_arcane" trail = "arcanetrail" damtype = DamageType.ARCANE end - local tg = {type="bolt", range=self:getTalentRange(t), talent=t, display = {particle=particle, trail=trail}} + local tg = {type="bolt", range=self:getTalentRange(t), talent=t, display = {particle=particle, trail=trail}, + -- Like a normal block_path, but goes over friendlies + block_path = function(typ, lx, ly) + local a = game.level.map(lx, ly, engine.Map.ACTOR) + if a and self:reactionToward(a) >= 0 then return false, lx, ly + elseif game.level.map:checkAllEntities(lx, ly, "block_move") then return true, lx, ly end + if typ.range and typ.source_actor and typ.source_actor.x and math.sqrt((typ.source_actor.x-lx)^2 + (typ.source_actor.y-ly)^2) > typ.range then return true end + return false, lx, ly + end, + } + local x, y = self:getTarget(tg) if not x or not y then return nil end -- GitLab