ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Wed Jun 20, 2018 7:31 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Jun 07, 2018 1:40 am 
Offline

Joined: Tue Jun 17, 2014 2:29 pm
Posts: 4
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,
}


Top
 Profile  
 
PostPosted: Thu Jun 07, 2018 5:37 pm 
Offline
Higher

Joined: Sun Dec 10, 2017 12:27 am
Posts: 77
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.


Top
 Profile  
 
PostPosted: Thu Jun 07, 2018 11:46 pm 
Offline

Joined: Tue Jun 17, 2014 2:29 pm
Posts: 4
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


Top
 Profile  
 
PostPosted: Fri Jun 08, 2018 4:13 pm 
Offline
Higher

Joined: Sun Dec 10, 2017 12:27 am
Posts: 77
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:
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.


Top
 Profile  
 
PostPosted: Sat Jun 09, 2018 1:47 am 
Offline

Joined: Tue Jun 17, 2014 2:29 pm
Posts: 4
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.


Top
 Profile  
 
PostPosted: Sat Jun 09, 2018 7:49 am 
Offline
Higher

Joined: Sun Dec 10, 2017 12:27 am
Posts: 77
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.


Top
 Profile  
 
PostPosted: Sun Jun 10, 2018 4:22 pm 
Offline

Joined: Tue Jun 17, 2014 2:29 pm
Posts: 4
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group