Extend beams caused by Arcane Combat
Posted: Mon Jan 03, 2011 5:42 am
Grey and I were talking about Arcane Blades and he suggested having the beam spells (Flame at lvl 5, Lightning at all levels) extend past the first target until they met a friendly target (don't want to kill those escorts!) or a wall. I have updated the arcane combat section in Combat.lua below and tested it. What do you think?
EDIT: I have been playing with this and it is a lot of fun to see a flame beam fly across the map.
EDIT: I have been playing with this and it is a lot of fun to see a flame beam fly across the map.

Code: Select all
-- Autospell cast
if hitted and not target.dead and self:knowTalent(self.T_ARCANE_COMBAT) and self:isTalentActive(self.T_ARCANE_COMBAT) and rng.percent(20 + self:getTalentLevel(self.T_ARCANE_COMBAT) * (1 + self:getDex(9, true))) then
local spells = {}
if self:knowTalent(self.T_FLAME) then spells[#spells+1] = self.T_FLAME end
if self:knowTalent(self.T_LIGHTNING) then spells[#spells+1] = self.T_LIGHTNING end
local tid = rng.table(spells)
if tid then
-- Extending beam target, assumes a maximum range of 20
local current_angle = math.atan2((target.y - self.y), (target.x - self.x)) + math.pi
target_x = self.x - math.floor(0.5 + (20 * math.cos(current_angle)))
target_y = self.y - math.floor(0.5 + (20 * math.sin(current_angle)))
local l = line.new(self.x, self.y, target_x, target_y)
local lx, ly = l()
target_x, target_y = lx, ly
-- Check for terrain and friendly actors
while lx and ly do
local actor = game.level.map(lx, ly, engine.Map.ACTOR)
if actor and (self:reactionToward(actor) >= 0) then
break
elseif game.level.map:checkEntity(lx, ly, engine.Map.TERRAIN, "block_move") then
target_x, target_y = lx, ly
break
end
target_x, target_y = lx, ly
lx, ly = l()
end
print("[ARCANE COMBAT] autocast ",self:getTalentFromId(tid).name)
local old_cd = self:isTalentCoolingDown(self:getTalentFromId(tid))
self:forceUseTalent(tid, {ignore_energy=true, force_target={x=target_x, y=target_y, __no_self=true}})
-- Do not setup a cooldown
if not old_cd then
self.talents_cd[tid] = nil
end
self.changed = true
end
end