Page 1 of 1

One-line change to a talent?

Posted: Fri Jun 05, 2020 8:35 pm
by visage
It's been years since I last touched modding ToME and I'm just a bit rusty.

I'm pondering making a one-line tweak to a talent (adding "sustain_hate = 0" to Savage Hunter), and I'm wondering if there's a more elegant way to do that than copying the entire talent definition and adding that one line.

Looking at the definition of newTalent(t):

Code: Select all

	table.insert(self.talents_types_def[t.type[1]].talents, t)
Am I correct in thinking that I could access the instantiated talent and update its entry, instead? If so, what would be the Right Way(TM) to do that?

Re: One-line change to a talent?

Posted: Fri Jun 05, 2020 9:24 pm
by Razakai

Code: Select all

Talents.talents_def.T_BLOCK.cooldown = function(self, t)
		return 5
	end
In talents.lua is how I changed block CD in an old addon. Same concept here.

Re: One-line change to a talent?

Posted: Sat Jun 06, 2020 10:15 pm
by Zizzo
visage wrote:Am I correct in thinking that I could access the instantiated talent and update its entry, instead? If so, what would be the Right Way(TM) to do that?
Well, I hope it's not the wrong way, because that's how a lot of my addons have been doing surgery on talents. [sound F/X: source diving] Passive Cooldowns is probably closest to your use case, if you want some code to look at.

But yeah, for what you describe, I'd probably put something like the following in hooks/load.lua:

Code: Select all

class:bindHook('ToME:load', function(self, data)
  local Talents = require 'engine.interface.ActorTalents'
  local TD = Talents.talents_def
  TD.T_SAVAGE_HUNTER.sustain_hate = 0
end)

Re: One-line change to a talent?

Posted: Sat Jun 06, 2020 11:31 pm
by visage
Thanks to both of you!
Zizzo wrote:But yeah, for what you describe, I'd probably put something like the following in hooks/load.lua:
That was well-timed. I'd just settled in to figure out how to make it work when I checked the forums and saw this response... which worked perfectly.

Re: One-line change to a talent?

Posted: Sat Jun 13, 2020 9:33 pm
by visage
Ok, another question.

I've built a simple addon that aims to shorten the game a bit by stripping out floors from a bunch of zones. The thing I'm wondering about is modifying escort allocation to account for the changed number of floors. It looks like I need to iterate through all of the race definitions and alter random_escort_possibilities for each. Is there an elegant way to do that?

Re: One-line change to a talent?

Posted: Sat Jun 13, 2020 11:30 pm
by HousePet
Since you'd have to loop over the race definitions and the subrace definitions to catch them all, and they are all identical anyway, I would consider just putting a Superload wrapper on mod\class\Player\onBirth() and redoing the Escort location assignment with your own revised restrictions after the current code has ran.
(Bonus points if you can stop an East start from being able to get an escort on floor 1 of their "tier1.1" dungeon.)

Re: One-line change to a talent?

Posted: Sun Jun 14, 2020 9:04 pm
by Zizzo
HousePet wrote:Since you'd have to loop over the race definitions and the subrace definitions to catch them all, and they are all identical anyway, I would consider just putting a Superload wrapper on mod\class\Player\onBirth() and redoing the Escort location assignment with your own revised restrictions after the current code has ran.
Yeah, that's what I do in Escort Rescheduling, which is playing in basically the same area.

Re: One-line change to a talent?

Posted: Wed Jul 22, 2020 3:20 am
by visage
Thanks!

Another addon question...

Is there an example out there of a talent that provides a targeting ball but requires that it be centered on an enemy? I thought such existed, but I'm failing to recall what it might be. Alternately, how might I implement that?

Re: One-line change to a talent?

Posted: Wed Jul 22, 2020 10:23 am
by Erenion
Yes, there is. Volley from Archery Prowess (the category is called archery-utility in-code) is such a talent.

Re: One-line change to a talent?

Posted: Wed Jul 22, 2020 1:48 pm
by visage
Erenion wrote:Yes, there is. Volley from Archery Prowess (the category is called archery-utility in-code) is such a talent.
That did the trick; thanks!

Re: One-line change to a talent?

Posted: Fri Jan 14, 2022 7:30 pm
by visage
Zizzo wrote: Sun Jun 14, 2020 9:04 pm
HousePet wrote:Since you'd have to loop over the race definitions and the subrace definitions to catch them all, and they are all identical anyway, I would consider just putting a Superload wrapper on mod\class\Player\onBirth() and redoing the Escort location assignment with your own revised restrictions after the current code has ran.
Yeah, that's what I do in Escort Rescheduling, which is playing in basically the same area.
So, having completely forgotten this thread I was messing around yesterday with tweaking escort distribution and I ran into an issue I don't understand. The following logs that birther is non-nil, but when the original onBirth is run it errors out, complaining that birther is nil.

Code: Select all

local base_onBirth = _M.onBirth
-- change the permitted levels for escorts
function _M:onBirth(birther)
    if birther == nil then
        game.logSeen(self, "onBirth got a nil birther")
    else
	game.logSeen(self, "onBirth got a non-nil birther")
    end
    if world.name == "Maj'Eyal" then
       world.random_escort_possibilities = { {"tier1.1", 1, 2}, {"tier1.2", 1, 2}, {"daikara", 1, 2}, {"old-forest", 1, 2}, {"dreadfell", 1, 2}, {"reknor", 1, 2}, }
    end
    return base_onBirth(birther)
end
return _M
Any ideas on what I'm missing? (I assume it would work to simply copy the definition of onBirth over rather than the above, but this seems like the better approach if viable.)

Re: One-line change to a talent?

Posted: Sat Jan 15, 2022 12:43 am
by HousePet
return base_onBirth(birther) -> return base_onBirth(self, birther)

You need to add self as the first argument to the original function when you do this.

Re: One-line change to a talent?

Posted: Sat Jan 15, 2022 3:34 pm
by visage
HousePet wrote: Sat Jan 15, 2022 12:43 am return base_onBirth(birther) -> return base_onBirth(self, birther)
Seriously, lua?

Thanks, HousePet! That fixed one issue; on to the next! =)