Lokean wrote:
I am surprised that this worked at all (you're implying it does work with Steady Shot?). As far as I can tell, the code never actually acquires or forces a target. It shouldn't be able to successfully use any archery talent unless you've already used a talent on them manually in order to acquire the target.
Well, targets were already acquired in the previous codes in autoarcher script. The variable "targetinrange" should be the target.
And yes. Every other archer talents are working and I am currently in the middle of playthrough - with ToME 1.5.10 and forbidden cult addon no less.
It is just that activating useTalent+T_SHOOT with valid(...well. At least functional) target does not seem to be functioning as it should.(I have T_SHOOT disabled. please refer to the code below)
But if you wish to see the script in the larger scale including target acquisition, here it is:
Quote:
--Seen enemy array
local seen = {}
local px = self.player.x
local py = self.player.y
--Find and store all seen enemies
core.fov.calc_circle(
px,
py,
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[#seen + 1] = {x=x, y=y, actor=actor}
end
end,
nil
)
--No enemies to attack. Time to autoExplore
if #seen == 0 then
self.key:triggerVirtual("RUN_AUTO")
return
end
--Switch to the closest target, but look out for high rank enemies!
target = seen[1]
if target.actor.rank > tonumber(config.settings.tome.hypr.auto.maxrank) then self.log("Stopping - strong enemy detected.") return end
for i = 2, #seen do
if seen[i].actor.rank > tonumber(config.settings.tome.hypr.auto.maxrank) then self.log("Stopping - strong enemy detected.") return end
if (seen[i].x - px) ^ 2 + (seen[i].y - py) ^ 2 < (target.x - px) ^ 2 + (target.y - py) ^ 2 then target = seen[i] end
end
--Respond to the enemy
local tx = target.x
local ty = target.y
--If ranged and in range, try to shoot
if self.player:hasArcheryWeapon() and self.player:isNear(tx, ty, self.player:getTalentRange(self.player:getTalentFromId(self.player.T_SHOOT))) then
local validammo = game.player:hasAmmo()
--Ammo check
if not validammo then
self.player:useTalent(self.player.T_SHOOT, nil, nil, false, target) --Let the game provide the error
return
end
--Check if there is enough ammo
if validammo.combat.shots_left == 0 then
--Reload
self.player:useTalent(self.player.T_RELOAD)
return
end
local shots = {
--autoatcher codes didn't have the new code, replaced with
self.player.T_FRAGMENTATION_SHOT,
self.player.T_STEADY_SHOT,
self.player.T_PIN_DOWN,
self.player.T_CALLED_SHOTS,
self.player.T_EXPLOSIVE_SHOT,
self.player.T_VITAL_SHOT,
self.player.T_SHADOW_SHOT
--disabled shoot because it is not working
--self.player.T_SHOOT
}
--Shoot the target with the lowest cooldown shots possible, otherwise just the regular one
for i,v in ipairs(shots) do
if self.player:knowTalent(v) and not self.player:isTalentCoolingDown(v) and self.player:preUseTalent(self.player:getTalentFromId(v), true, true) then
self.player:useTalent(v, nil, nil, false, target) -- this will trip over if v==self.player.T_SHOOT
--.player:forceUseTalent(self.player.T_SHOOT, {ignore_cd=true, force_target=target}) -- this one doesn't work either
--self.log("Firing...")
return
end
end
--No shots fired..? =(
self.log("Unable to fire any shots")
return
end