T4modules-4emodule 3
4Emodule Part 3: Race and Class features
t4modules t4modules | t4modules module howto guides
Part 2's lua file got pretty long, making it hard to find things and to maintain. In this part, we will be defining talents by using multiple files.
Track down your /data/talents.lua file and clear it out. Replace it with this:
load("/data/talents/features/features.lua")
Now create the directory and file /data/talents/features/features.lua with the following contents:
newTalentType{ type="base/class", name = "class", hide = true, description = "The basic talents defining a class." }
newTalentType{ type="base/race", name = "race", hide = true, description = "The various racial bonuses a character can have." }
-- common load("/data/talents/features/proficiency.lua")
-- racial load("/data/talents/features/dwarf.lua") load("/data/talents/features/eladrin.lua")
-- class load("/data/talents/features/fighter.lua") load("/data/talents/features/ranger.lua")
This structure allows us to keep all race and class feature talents together in the features directory, and each individual race or class gets assigned its own file for its feature definitions.
Beware however, you need to actually create these files, even if they are empty, or your module will be unable to start.
/data/talents/features/fighter.lua:
newTalent{
name = "Fighter One-Handed Weapon Talent",
short_name = "Fighter One Handed",
type = { "base/class", 1 },
info = "Attack bonus when using one-handed weapons",
mode = "passive",
hide = true,
}
newTalent{ name = "Fighter Two-Handed Weapon Talent", short_name = "Fighter Two Handed", type = { "base/class", 1 }, info = "Attack bonus when using two-handed weapons", mode = "passive", hide = true, }
newTalent{ name = "Combat Superiority", type = { "base/class", 1 }, info = "Gain a bonus to opportinity attacks equal to wisdom modifier.", mode = "passive", hide = true, }
Not too impressive, since they are all passive abilities. Alone, they do not do anything, but the code can test for then (such as before swinging a one-handed weapon) and decide what their effects are.
T-Engine will interpret these files and create talent variables in the ActorTalents object for you. To refer to them again, such as when assigning during birth, you should take the short_name (or name if no short_name is defined), uppercase it, replace its spaces with _'s and append a T_ to the front. In this way the talent "Fighter One Handed" becomes ActorTalents.T_FIGHTER_ONE_HANDED.