One-line change to a talent?

Have a really dumb question? Ask it here to get help from the experts (or those with too much time on their hands)

Moderator: Moderator

Post Reply
Message
Author
visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

One-line change to a talent?

#1 Post 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?

Razakai
Uruivellas
Posts: 889
Joined: Tue May 14, 2013 3:45 pm

Re: One-line change to a talent?

#2 Post 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.

Zizzo
Sher'Tul Godslayer
Posts: 2521
Joined: Thu Jan 23, 2003 8:13 pm
Location: A shallow water area south of Bree
Contact:

Re: One-line change to a talent?

#3 Post 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)
"Blessed are the yeeks, for they shall inherit Arda..."

visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Re: One-line change to a talent?

#4 Post 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.

visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Re: One-line change to a talent?

#5 Post 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?

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: One-line change to a talent?

#6 Post 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.)
My feedback meter decays into coding. Give me feedback and I make mods.

Zizzo
Sher'Tul Godslayer
Posts: 2521
Joined: Thu Jan 23, 2003 8:13 pm
Location: A shallow water area south of Bree
Contact:

Re: One-line change to a talent?

#7 Post 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.
"Blessed are the yeeks, for they shall inherit Arda..."

visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Re: One-line change to a talent?

#8 Post 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?

Erenion
Archmage
Posts: 319
Joined: Mon Feb 13, 2017 4:43 pm

Re: One-line change to a talent?

#9 Post by Erenion »

Yes, there is. Volley from Archery Prowess (the category is called archery-utility in-code) is such a talent.
Breaking Projection since 1.5

visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Re: One-line change to a talent?

#10 Post 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!

visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Re: One-line change to a talent?

#11 Post 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.)

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

Re: One-line change to a talent?

#12 Post 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.
My feedback meter decays into coding. Give me feedback and I make mods.

visage
Archmage
Posts: 345
Joined: Fri Jan 10, 2014 4:09 pm

Re: One-line change to a talent?

#13 Post 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! =)

Post Reply