Editing Race Text and XP Penalties (TOME Addon)

Moderator: Moderator

Post Reply
Message
Author
Steven Aus
Archmage
Posts: 350
Joined: Sat Dec 13, 2014 3:38 pm

Editing Race Text and XP Penalties (TOME Addon)

#1 Post by Steven Aus »

How do I edit the Race Text and XP penalties for a particular race and subrace? I have located where newBirthDescriptor is defined, but I'm not sure how to replace the text and the xp penalty if the addon is running. I'd rather just edit it after it is defined rather than superloading it. Also, it would be great to know how to edit or add just part of the text string, but that's not essential.

For example, this is what I want the description to be for Shalore:

Code: Select all

desc = {
		"Shaloren elves have close ties with the magic of the world, and produced in the past many great mages.",
		"Yet they remain quiet and try to hide their magic from the world, for they remember too well the Spellblaze - and the Spellhunt that followed.",
		"They possess the #GOLD#Grace of the Eternals#WHITE# talent which allows them a boost of speed every once in a while.",
		"#GOLD#Stat modifiers:",
		"#LIGHT_BLUE# * -2 Strength, +1 Dexterity, +0 Constitution",
		"#LIGHT_BLUE# * +2 Magic, +3 Willpower, +1 Cunning",
		"#GOLD#Life per level:#LIGHT_BLUE# 9",
		"#GOLD#Experience penalty:#LIGHT_BLUE# 35%",
	}
and for Thalore:

Code: Select all

desc = {
		"Thaloren elves have spent most of the ages hidden within their forests, seldom leaving them.",
		"The ages of the world passed by and yet they remained unchanged.",
		"Their affinity for nature and their reclusion have made them great protectors of the natural order, often opposing their Shaloren cousins.",
		"They possess the #GOLD#Wrath of the Woods#WHITE# talent, which allows them a boost to the damage both inflicted and resisted once in a while.",
		"#GOLD#Stat modifiers:",
		"#LIGHT_BLUE# * +2 Strength, +3 Dexterity, +1 Constitution",
		"#LIGHT_BLUE# * -2 Magic, +1 Willpower, +0 Cunning",
		"#GOLD#Life per level:#LIGHT_BLUE# 11",
		"#GOLD#Experience penalty:#LIGHT_BLUE# 25%",
	}
And of course the experience penalty field is just:

experience = 1.35,

or

experience = 1.25

respectively.


Based on my persistent dungeons addon that I made for Zizzo's T2 remake, my current hooks code is this:

Code: Select all

local Zone = require "engine.Zone"                       -> These need to
local GameOptions = require "mod.dialogs.GameOptions"  -> be replaced

class:bindHook("TOME:load", function(self, data)
	if  type(config.settings.tome.xppenaltytweak) == 'nil' then
    config.settings.tome.xppenaltytweak = true
	end
	Birther?:edit?Definition('/data-xppenaltytweak/elf.lua') etc.
end)

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

Re: Editing Race Text and XP Penalties (TOME Addon)

#2 Post by Zizzo »

Once you're inside the ToME:load hook, you don't really need to do anything elaborate; you can just modify the descriptor definition in place. You'll want something like:

Code: Select all

class:bindHook("TOME:load", function(self, data)
  local Birther = require 'engine.Birther'
  local shalore = Birther:getBirthDescriptor('subrace', 'Shalore')
  shalore.experience = 1.35
  shalore.desc[8] = "#GOLD#Experience penalty:#LIGHT_BLUE# 35%"
end)
(This code is untested, of course; caveat emptor.) I've done this sort of thing before to modify talent definitions.
"Blessed are the yeeks, for they shall inherit Arda..."

Steven Aus
Archmage
Posts: 350
Joined: Sat Dec 13, 2014 3:38 pm

Re: Editing Race Text and XP Penalties (TOME Addon)

#3 Post by Steven Aus »

I tested it, and even when I put the require line at the top it didn't show any change in the New Game screen. So there must be something else stopping it (I don't know whether it would still do the experience change if it didn't do the text change, but if I had to guess I would say no).

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

Re: Editing Race Text and XP Penalties (TOME Addon)

#4 Post by Zizzo »

Steven Aus wrote:I tested it, and even when I put the require line at the top it didn't show any change in the New Game screen.
[sound F/X: source diving] Ah, sorry, Birther:newBirthDescriptor() folds the desc{} table into a single string during the loading process, so table access won't work (I'm surprised it didn't throw an error, actually…). You could modify the field in place with string.gsub(), I suppose (or just replace it wholesale with another string).
"Blessed are the yeeks, for they shall inherit Arda..."

Steven Aus
Archmage
Posts: 350
Joined: Sat Dec 13, 2014 3:38 pm

Re: Editing Race Text and XP Penalties (TOME Addon)

#5 Post by Steven Aus »

I tried replacing the whole string, and using string.gsub, however it still shows the old text. Is there anything preventing the text I'm trying to edit from being edited? And I wonder if the experience change is working? I tried starting a Thalore character but I couldn't see any place where the experience penalty was listed.

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

Re: Editing Race Text and XP Penalties (TOME Addon)

#6 Post by Zizzo »

[sound F/X: testing] Well, the attached quick mockup addon appears to successfully modify the description of Shaloren in the character creation dialog (for testing, I made the word "Shaloren" blue and changed the described exp penalty to 42%).
Attachments
tome-birth_test.zip
(951 Bytes) Downloaded 135 times
"Blessed are the yeeks, for they shall inherit Arda..."

Steven Aus
Archmage
Posts: 350
Joined: Sat Dec 13, 2014 3:38 pm

Re: Editing Race Text and XP Penalties (TOME Addon)

#7 Post by Steven Aus »

I found the main reason it wasn't working.

I had:

class:bindHook('TOME:load', function(self, data)

instead of:

class:bindHook('ToME:load', function(self, data)

So obviously lua is case sensitive. :)


Question: why do other mods register on the character sheet online, but when I create a new game using this mod, it doesn't? Does it need to be marked by a dev or get some votes or something?

https://te4.org/games/addons/tome/racexptweak

Post Reply