Page 1 of 1

How to use talent T_SHOOT?

Posted: Thu Jun 07, 2018 1:40 am
by Masterwalker
I got nostalgic but not eager enough to click myself all the way.

So I got up and booted up game with Auto archer addon. After some time, surprise surprise. It doesn't work properly.
But not because the addon themselves are old. It is because of this line:

(replaced the talent with actual code)
self.player:useTalent(self.player.T_SHOOT, nil, nil, false, targetInRange)

All other talents can be used with useTalent, so why is T_SHOOT an issue? (presumably new patch changed shoot function somehow, probably the archer rework)
What are the actual command that can actually be used only for T_SHOOT?


Here is the error saved in the player file:

d["talent_error"]={["turn"]=8,
["x"]=7,
["uid"]=3860,
["err"]="/engine/interface/ActorTalents.lua:295: /engine/interface/ActorTalents.lua:343: bad argument #2 to 'gsub' (string/function/table expected)",
["y"]=20,
["Actor"]=loadObject('mod.class.Player-0x10cb0798'),
["name"]="aaaa",
["T_SHOOT"]={["points"]=1,
["no_unlearn_last"]=true,
["id"]="T_SHOOT",
["requires_target"]=true,
["speed"]="archery",
["__ATOMIC"]=true,
["short_name"]="SHOOT",
["hide"]=true,
["addon"]={["possessor_tweaks"]={["Rngd"]=true,
}

Re: How to use talent T_SHOOT?

Posted: Thu Jun 07, 2018 5:37 pm
by Lokean
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.

Re: How to use talent T_SHOOT?

Posted: Thu Jun 07, 2018 11:46 pm
by Masterwalker
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:
--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.actor.rank > tonumber(config.settings.tome.hypr.auto.maxrank) then self.log("Stopping - strong enemy detected.") return end
if (seen.x - px) ^ 2 + (seen.y - py) ^ 2 < (target.x - px) ^ 2 + (target.y - py) ^ 2 then target = seen 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

Re: How to use talent T_SHOOT?

Posted: Fri Jun 08, 2018 4:13 pm
by Lokean
Masterwalker wrote:Well, targets were already acquired in the previous codes in autoarcher script. The variable "targetinrange" should be the target.
So, I think the problem probably is down to the age of the addon. I'm not a dev or anything, but the function does a lot of overhead in order to replicate engine functionality, which suggests it's very out of date. I can provide a fix, simply by silencing the error, but it's obviously still wrong.

Code: Select all

if self.player:knowTalent(v) and not self.player:isTalentCoolingDown(v) and self.player:preUseTalent(self.player:getTalentFromId(v), true, true) then
	self.player:forceUseTalent(v, {force_target=target, silent=true})
	return
end
Give that a try and see if it produces any exciting new errors or weird behaviour.

Re: How to use talent T_SHOOT?

Posted: Sat Jun 09, 2018 1:47 am
by Masterwalker
So that's what silent does! I tried to lift the ForceUseTalent shooting code from the threaded combat(Warden's Call) but it caused the same error, as you can see the commented out command above.

I did not really expected the code to work at all - since it is 1.1.0 era code. However, since the code is suppose to be standalone from other function I had some expectation. Steady shot working was a good sign that code itself was still functional to some extent.

With silent=true it does not cause any error and game functions perfectly well. Thank you.
And if the same code(it is basically same code in Warden's Call) is used without huge issue in the current game, I will count that as functional code.

Re: How to use talent T_SHOOT?

Posted: Sat Jun 09, 2018 7:49 am
by Lokean
If you're playing this with an actual archer then you probably want to add a control structure to check if you can currently benefit from Marked (either you're a sniper under concealment, or the selected target is marked) and use a different table of talents in that case. And also have it enter concealment before auto-explore.

Re: How to use talent T_SHOOT?

Posted: Sun Jun 10, 2018 4:22 pm
by Masterwalker
hmm, well. Apparently superload.lua cannot use hasEffect function(getting "hasEffect = -1" error) so I can't check if target has mark or not.

I could dig around to find the function then load it manually, then again - too much work.