[1.1.3] Automatic archery talent choice (alpha)
Posted: Sun Dec 29, 2013 10:39 pm
This addon creates a new talent that chooses between Shoot, Steady Shot, Multishot, Piercing Shot, Dual Shot, and Relaxed Shot automatically, depending on a few simple factors. It's a small quality of life hack that makes archers a bit easier to use well. Attached below, and here's the relevant code as well:
Code: Select all
newTalent{
name = "Smart Shoot",
type = {"technique/archery-base", 1},
no_energy = "fake",
hide = "always",
innate = true,
points = 1,
range = 1,
message = false,
no_break_stealth = true, -- stealth is broken in attackTarget
no_reload_break = true,
requires_target = true,
target = {type="hit", range=1},
tactical = { ATTACK = { PHYSICAL = 1 } },
no_unlearn_last = true,
ignored_by_hotkeyautotalents = true,
action = function(self, t)
local t = self.T_RELAXED_SHOT
local t2 = self:getTalentFromId(t)
if self:knowTalent(t2) and not self:isTalentCoolingDown(t2) and self.max_stamina - self.stamina > (12 + self:getTalentLevel(t) * 8) then
self:forceUseTalent(t,{})
return true
end
t = self.T_MULTISHOT
t2 = self:getTalentFromId(t)
if self:knowTalent(t2) and not self:isTalentCoolingDown(t2) and self.stamina > t2.stamina and self:hasArcheryWeapon("sling")then
self:forceUseTalent(t,{})
return true
end
t = self.T_STEADY_SHOT
t2 = self:getTalentFromId(t)
if self:knowTalent(t2) and not self:isTalentCoolingDown(t2) and self.stamina > t2.stamina then
self:forceUseTalent(t,{})
return true
end
t = self.T_PIERCING_ARROW
t2 = self:getTalentFromId(t)
if self:knowTalent(t2) and not self:isTalentCoolingDown(t2) and self.stamina > t2.stamina and self:hasArcheryWeapon("bow") then
self:forceUseTalent(t,{})
return true
end
t = self.T_DUAL_ARROWS
t2 = self:getTalentFromId(t)
if self:knowTalent(t2) and not self:isTalentCoolingDown(t2) and self:hasArcheryWeapon("bow") then
self:forceUseTalent(t,{})
return true
end
t = self.T_SHOOT
t2 = self:getTalentFromId(t)
self:forceUseTalent(t,{})
return true
end,
info = function(self, t)
return ([[Shoot good!]])
end,
}