PDA

View Full Version : New Skill Not Working With Effects



UrsaTeddy
October 8th, 2020, 23:47
Greetings All,

I am currently building a new campaign world in FGU.

Some races gain Skill d4 in racial skills (ex. Human, Steppes gains Riding d4).

The way I am doing this is using the Skill Racial Ability and using [Riding +1d] in its effects line.

However for a Skill that I have created (ex. Crafting), the system does not recognise [Crafting +1d].

Am I missing something? Is there some code somewhere I need to change to "activate" this?

In addition, if I do not load the SWADE Players Guide and create a new Fighting skill manually (assume a bare bones FGU with no other material loaded), then [Fighting +1d] does not work either.

This would imply that the effects line is looking for very specific data somewhere.

Any ideas?

ApesAmongUs
October 9th, 2020, 01:43
Are you, maybe trying this on characters who are unskilled in that particular skill? The way the skills work is it searches for a skill by name and if it find it, it applies the bonus to the character. If it doesn't find the skill when it looks for it, it instead uses the "unskilled" skill. If the character hasn't been given the skill, there is no way for an effect to find it.

So, if I set a skill to d4 and then add [crafting +1d] in a racial ability it does, correctly, increase it to a d6. But it doesn't add the first d4. Now, it does work with Fighting, which doesn't actually make sense to me. I'm going to investigate that. So, yea, it does seem to maintain a list somewhere.

UrsaTeddy
October 9th, 2020, 05:46
Are you, maybe trying this on characters who are unskilled in that particular skill? The way the skills work is it searches for a skill by name and if it find it, it applies the bonus to the character. If it doesn't find the skill when it looks for it, it instead uses the "unskilled" skill. If the character hasn't been given the skill, there is no way for an effect to find it.

So, if I set a skill to d4 and then add [crafting +1d] in a racial ability it does, correctly, increase it to a d6. But it doesn't add the first d4. Now, it does work with Fighting, which doesn't actually make sense to me. I'm going to investigate that. So, yea, it does seem to maintain a list somewhere.

Actually your statement is not how it works in my version of FGU and the SWADE ruleset (fully updated as of today). I have had this work for Language, Focus, anything from the original list of skills.

However for a skill that I created from scratch it will not do this.

So I am curious to know what/where in the ruleset, or perhaps the Players Guide itself there is coding that may be doing this for only those skills in the Players Guide.

I have for example created an option in the Settings window that turns on/off character creation via the new Campaign World. For now it is focused on Skills, and if you state On then it wipes the core skills and relies on the Racial template for the skills you begin with, whereas if you state Off, you get the Core skills.

However I cannot for the life of me find anything that deals with what we are discussing here. I have a suspicion that it has to do with the <skills> node that is loaded in the Players Guide, however I do not know enough about Modules to confirm that.

ApesAmongUs
October 9th, 2020, 12:09
Yea, that's why I said it doesn't make sense to me. From how it works for effects, it does work that way, but not for racial abilities. They (and edges) are added differently than the temporary combat effects. From looking into it, a skill list is defined in manager_skill.lua. So, it seems like you should be able to define a new skill by adding -

local ATTRIBUTE_SMARTS = "smarts"
SkillManager.registerSkill("Crafting", ATTRIBUTE_SMARTS)

- to the onInit of an extension, but it doesn't work for me. Either there is a second step after registering to create the list, or there is a second list of official skills being maintained somewhere. Still looking.

UrsaTeddy
October 9th, 2020, 12:46
Yea, that's why I said it doesn't make sense to me. From how it works for effects, it does work that way, but not for racial abilities. They (and edges) are added differently than the temporary combat effects. From looking into it, a skill list is defined in manager_skill.lua. So, it seems like you should be able to define a new skill by adding -

local ATTRIBUTE_SMARTS = "smarts"
SkillManager.registerSkill("Crafting", ATTRIBUTE_SMARTS)

- to the onInit of an extension, but it doesn't work for me. Either there is a second step after registering to create the list, or there is a second list of official skills being maintained somewhere. Still looking.

I have already unregistered all of those skills and registered my new list of skills via an Extension (which also does the Core Skills modification).

It makes no change AND it stops something like [Fighting +1d] from working unless I load the SWADE Players Guide.

So confusion.

ApesAmongUs
October 9th, 2020, 16:19
That's what's craziest to me. If it were a separate list, then unregistering then should do nothing. If it's the same list, then registering a new one should do something. After work, I'm going to try just unregistering 1 skill and seeing if the others continue to work. I have the suspicion that removing even one will break them all, because that would be the result that would make the least sense to me.

esmdev
October 9th, 2020, 17:00
So awhile back in 5E, in order to make it so you could look up the skill by clicking the skill icon on a character sheet, I had to edit the module XML and change the header and footer for the skills to <HACKING> and </HACKING> instead of the skill ID #. Not sure if this will help you, but it is the only thing I can think of. I'd say try whatever the first skill in your XML and see if that works for that skill. Oh, also it needed to be uppercase.

Took me awhile to find the link but here is more info:

https://www.fantasygrounds.com/forums/showthread.php?42217-Custom-skills

Still not sure it will fix the problem but it might.

ApesAmongUs
October 10th, 2020, 01:59
Yea, that format looks totally different than anything I see in the SW set. I searched for one of the less common skills (used Research instead of Fighting which I would find everywhere) and the term only appeared twice in the SW ruleset. One in the registerskill function we were just talking about and the second time in the manager that did updates from older SW rulesets, since that particular skill changed names between editions. There is no place in any of the xml files that references the skills by name, only in the lua files. Going by what UrsaTeddy said, it might be in the manuals, but I didn't know they affected anything but display. Does SavageWorlds.pak inherit anything from SWD.pak? I haven't tried looking in there.

UrsaTeddy
October 10th, 2020, 09:15
So awhile back in 5E, in order to make it so you could look up the skill by clicking the skill icon on a character sheet, I had to edit the module XML and change the header and footer for the skills to <HACKING> and </HACKING> instead of the skill ID #. Not sure if this will help you, but it is the only thing I can think of. I'd say try whatever the first skill in your XML and see if that works for that skill. Oh, also it needed to be uppercase.

Took me awhile to find the link but here is more info:

https://www.fantasygrounds.com/forums/showthread.php?42217-Custom-skills

Still not sure it will fix the problem but it might.

I have tried naming the nodes likes this previously ... I created a module to see if that was the problem ... manually edited the XML of that module to match the style of the SWADE Players Guide (technically I want to replace the SWADE Players Guide in this situation) and it still does not work.

This has me baffled to the point of where I think there MUST be something in the Players Guide that is actually causing some kind of code change, or at least a data source change that is then affecting the effects [] of a racial ability.

UrsaTeddy
October 10th, 2020, 09:22
Yea, that format looks totally different than anything I see in the SW set. I searched for one of the less common skills (used Research instead of Fighting which I would find everywhere) and the term only appeared twice in the SW ruleset. One in the registerskill function we were just talking about and the second time in the manager that did updates from older SW rulesets, since that particular skill changed names between editions. There is no place in any of the xml files that references the skills by name, only in the lua files. Going by what UrsaTeddy said, it might be in the manuals, but I didn't know they affected anything but display. Does SavageWorlds.pak inherit anything from SWD.pak? I haven't tried looking in there.

I do not own the SWD.pak personally.

I bought FGU and the SWADE ruleset only.

For a straight up 'by the manual" it works as expected, the minute I start monkeying around with it, it breaks.

I have written extensions previously to do multiple things and they work. I can create options to trigger on/off, I have created options to change the names of stats (visual name versus internal name only) by user entry in the options panel. I have made extensions that modify the character sheet to some degree, however certain things elude me.

However this is the craziest thing I have seen. Load in a module and it somehow makes something work.

ApesAmongUs
October 10th, 2020, 11:36
I do not own the SWD.pak personally.

Well damn. At least that saves the distraction of going down that rabbit hole.

UrsaTeddy
October 10th, 2020, 12:44
Well damn. At least that saves the distraction of going down that rabbit hole.

A further update to this "problem" - I made a copy of the SWAD_PG.MOD file, unzipped it and replaced the skill list with my skill list.

In a new campaign I loaded in my extension that simply unregisters SWADE skills and registers my new skill list, it also removes the common skills list.

I then loaded the copied module.

I then created a new race that grants [Skill +1d] for a new skill and for an old skill (even though it is technically a new skill), in addition I added a new skill for an old common skill (Notice in this case) at +1d.

Then I created a new character and set their race to the new race, their skill list (which was empty to begin with) had three new skills added at d4 as expected. The new skill, the new (old) skill, the new (old) common skill.

I then unloaded the "fake" module, manually created the skills and new race, and just like in my development campaign, none of this is working.

So there is definitely some kind of correlation between that players guide and what is going on.

ApesAmongUs
October 11th, 2020, 02:48
OK, I think the racial effects are being added by function importAbilityEffects(rActor, nodeAbility) in manager_character.lua.

It's a long function but this section appears to add effects for skills:

for _,nodeLibrarySkill in pairs(SkillManager.getLibrarySkills()) do
local sSkill = DB.getValue(nodeLibrarySkill, "name", "")
local rMod = aEffectTraitMods[StringManager.simplify(sSkill)]
if rMod and rMod.modifier > 0 then
if not SkillManager.getSkill(nodeActor, sSkill) then
local nodeSkills = DB.createChild(nodeActor, "skills")
local nodeSkill = DB.createChild(nodeSkills)
DB.setValue(nodeSkill, "name", "string", sSkill)
DB.setValue(nodeSkill, "link", "windowreference", "sw_referenceskill", nodeLibrarySkill.getNodeName())
rMod.modifier = rMod.modifier - 1
end
end
end

So, for every skill node returned by SkillManager.getLibrarySkills(), it searches for a modifier by name. So, if sSkill = Fighting, it looks in the array aEffectTraitMods["fighting"] which should contain everything in the format "[fighting +xd]" and then inside rMod.modifier, it contains x. So, if there is a matching modifier for the skill AND there is a modifier >0, it adds the skill to the character. I see 2 possible places this could fail to set the skill.

1. SkillManager.getLibrarySkills() does not contain any skills with the name. If you never get sSkill == "crafting", then it will never bother looking for "[crafting +1d]".
2. it does find "Crafting" in SkillManager.getLibrarySkills(), but then when it goes to add the skill to the character, some data is missing. nodeLibrarySkill.getNodeName() is my guess. In the only places I find specific values being set there, the format of that parameter is a string in this format - "reference.skills.thievery@SW Deluxe Player Guide". And, that looks like it is referencing a guide.

Either way, the problem traces back to the first line for _,nodeLibrarySkill in pairs(SkillManager.getLibrarySkills()) do. However "getLibrarySkills works, there must be somewhere that creates this list of library skills first. Reading undocumented code hurts.

UrsaTeddy
October 11th, 2020, 03:27
OK, I think the racial effects are being added by function importAbilityEffects(rActor, nodeAbility) in manager_character.lua.

It's a long function but this section appears to add effects for skills:

for _,nodeLibrarySkill in pairs(SkillManager.getLibrarySkills()) do
local sSkill = DB.getValue(nodeLibrarySkill, "name", "")
local rMod = aEffectTraitMods[StringManager.simplify(sSkill)]
if rMod and rMod.modifier > 0 then
if not SkillManager.getSkill(nodeActor, sSkill) then
local nodeSkills = DB.createChild(nodeActor, "skills")
local nodeSkill = DB.createChild(nodeSkills)
DB.setValue(nodeSkill, "name", "string", sSkill)
DB.setValue(nodeSkill, "link", "windowreference", "sw_referenceskill", nodeLibrarySkill.getNodeName())
rMod.modifier = rMod.modifier - 1
end
end
end

So, for every skill node returned by SkillManager.getLibrarySkills(), it searches for a modifier by name. So, if sSkill = Fighting, it looks in the array aEffectTraitMods["fighting"] which should contain everything in the format "[fighting +xd]" and then inside rMod.modifier, it contains x. So, if there is a matching modifier for the skill AND there is a modifier >0, it adds the skill to the character. I see 2 possible places this could fail to set the skill.

1. SkillManager.getLibrarySkills() does not contain any skills with the name. If you never get sSkill == "crafting", then it will never bother looking for "[crafting +1d]".
2. it does find "Crafting" in SkillManager.getLibrarySkills(), but then when it goes to add the skill to the character, some data is missing. nodeLibrarySkill.getNodeName() is my guess. In the only places I find specific values being set there, the format of that parameter is a string in this format - "reference.skills.thievery@SW Deluxe Player Guide". And, that looks like it is referencing a guide.

Either way, the problem traces back to the first line for _,nodeLibrarySkill in pairs(SkillManager.getLibrarySkills()) do. However "getLibrarySkills works, there must be somewhere that creates this list of library skills first. Reading undocumented code hurts.

I agree. with the hurts part ... part of this issue may be the way the DB auto-creates indexes of format id-0001 instead of using the index method that modules are expected to use to make accessing the data easier.

Part of the problem is that it will find Crafting in a module - there should be an option for "not in a module but in the db.xml of this campaign".

UrsaTeddy
October 12th, 2020, 09:39
I have been doing some more digging/work into this code and it seems to be searching all modules in the modules directory even if they're loaded or not loaded.

When I say all modules, that is all modules that are loadable with the current ruleset, not every single module.

There probably should be a check to see if that module is loaded somewhere in the code ... this is in the SkillManager.getLibrarySkills() function.

That aside ...

I HAVE DONE IT!!

I rewrote the function that was causing the problem and now it reads the skills from the campaign database as I would have expected for a Racial modifier.

I will test it further to see if it works for situations I can think of (and any you can throw at me).