Hello again,
So I'm trying to improve the Bone tree. Bone Spear has been fixed and made better, so now I'm onto Bone Grab. It's already pretty good for Reavers, but I think it could use a little something extra. So my idea was to make it a ranged knockback that lets you choose the direction and range. Reavers can use it for closing distance, and both Corruptors and Reavers can use it for escaping or putting a target into a better position. Here's the very early code, with thanks to psy_wombats as I used his Reversal Throw as a base to build upon:
newTalent{
name = "Bone Grab", short_name = "BONE_GRAB_NEC",
type = {"spell/bones", 2},
require = spells_req1,
points = 5,
mana = 28,
tactical = { DISABLE = 1, CLOSEIN = 3 },
requires_target = true,
cooldown = 12,
getDamage = function(self, t) return self:combatTalentSpellDamage(t, 20, 200) end,
getRange = function(self, t) return math.floor(self:combatTalentLimit(t, 10, 4, 9)) end,
getDuration = function(self, t) return math.floor(self:combatTalentScale(t, 4, 8 )) end,
action = function(self, t)
local tg = {type="hit", 10}
local x, y, target = self:getTarget(tg)
if not x or not y or not target then return nil end
game.logPlayer(self, "Select a direction to pull...")
tg = {type="hit", nolock=true, nowarning=true, range=100, simple_dir_request=true}
x, y = self:getTarget(tg)
if not x then return nil end
if core.fov.distance(target.x, target.y, x, y) > 1 then return nil end
local dam = t.getDamage(self,t)
local dx, dy = (x - target.x), (y - target.y)
-- damage the target
self:project(target, target.x, target.y, DamageType.PHYSICAL, dam)
if target:canBe("pin") then
target:setEffect(target.EFF_PINNED, t.getDuration(self, t), {apply_power=self:combatSpellpower()})
else
game.logSeen(target, "%s resists the bone!", target.name:capitalize())
end
game:playSoundNear(self, "talents/arcane")
-- knockback
local dir = util.coordToDir(dx, dy, 0)
local sides = util.dirSides(dir, 0)
target:knockback(target.x - dx, target.y - dy, t.getRange(self,t), function(t2)
local d = rng.chance(2) and sides.hard_left or sides.hard_right
local sx, sy = util.coordAddDir(t2.x, t2.y, d)
local ox, oy = t2.x, t2.y
t2:knockback(sx, sy, 1, function(t3) return true end)
end)
return true
end,
info = function(self, t)
local dur = t.getDuration(self,t)
return ([[Grab a target and teleport it to your side, pinning it there with a bone rising from the ground for %d turns.
The bone will also deal %0.2f physical damage.
The damage will increase with your Spellpower.]]):
format(dur, damDesc(self, DamageType.PHYSICAL, self:combatTalentSpellDamage(t, 5, 140)))
end,
}
Currently, it kinda works. There's 2 problems though:
1) I can't quite figure out how to make the range based on where you target, rather than a preset amount. I imagine there must be some sort of function to calculate distance between your cursor and the mob, I tried local knockback = xy - target.xy, but that was clearly wrong.
2) During the bit where you select which direction to pull the target, if your cursor strays more than 1 tile away a LUA error will occur. I've put the core.fov.distance in to block that, but obviously without being able to move further I won't be able to implement point 1. Also, there needs to be a way to limit the range of the 2nd target centered not on the player, but on the mob. Otherwise I can see it getting a little messy.
Creating a ranged, targetable, direction-based knockback
Moderator: Moderator