SetGender feature in Toolset
Winternite
Member Posts: 11
So changing gender via script doesn't seem possible, could we perhaps at some time in the future have a SetGender(0) and (1)? Would open up some interesting stuff for onspawn randomizing whether a random guard or commoner should be male or female.
1
Comments
Sadly this is still a problem when using spawn systems that rely on specific templates/resrefs. An issue I've run into myself.
Or I might be totally wrong.
B.
Template to JSON
Change a value by key in the JSON
JSON to object at the desired location
Haven't tried it yet, but in theory any field in an object can be changed without having a specific script function (a bit like having access to a GFF editor from a script), providing you don't mind making a new object before deleting the old one.
The GFF function and keyword to be used can be determined by opening the UTC with GFF Editor.
The only thing I don't understand is that although the change to FactionID seems to work (as reported by JsonDump), the NPC still spawns as hostile - hence ChangeToStandardFaction.
In the past, the process was very buggy in my experience - changing body parts, colour, phenotype, clothing etc with sundry ad hoc function calls needed a lot of tweaking to avoid invisible or misaligned parts.
In principle, what we can do now is make all those changes in the JSON prior to spawning, which, in theory, ought to be rendered by the engine exactly like a fixed template.
Time will tell.
If you compare the jsons before and after ChangeToStandardFaction() you’ll see that FactionID has changed from 1 to 2.
Setting FactionID to 2 right away would create a non-hostile NPC.
I'm thinking of reading appereance & gender. If app is one of the playeable type and gender is set to both apply a gender change. Doing so I can set bandits to apply a gender change based on a random check, but bypass that for example in a Drow priestess or a non playeable race that lacks female models.
The functions are not in the Lexicon yet, but they are referenced in Lexicon Json function examples.
Once included, you can see a list in the toolset by filtering on GFF.
Usage is pretty intuitive if you're used to working with GFF files.
Hopefully, this is a unusual(?) case - in my experience, GFF fields normally have the same values as NWScript.
Also I realized I could use the JSONpointer fnc to get the "Gender" value once I got it jsonized. The same goes for the other check I mentioned.
Verified - see example.
Gonna have to try that script out, I have no knowledge of json and how it would even work in NWN, but sufficient to say adding this:
To onspawn of a creature should determine its gender? Looking for a 50% chance to be either one or the other.
TR