Thanks to @Proleric guidance i’m almost there on pre-spawn customizing npcs.
In this case using NESS.
The modification goes in the spawn_main.nss.
#include “nw_inc_gff” is needed on top.
// Validate sSpawnTag
if (sTemplate != "")
{
// Spawn
if (nSpawnCamp == TRUE)
{
oSpawned = CampSpawn(oSpawn, sTemplate, lSpawnLocation);
RecordSpawned(oSpawn, oSpawned, lHome, lEntranceExit, fSpawnFacing);
}
else
{
//This is original code replaced by the "if (nObjectType == 1) {..." secuence
//We don't want any customization if oSpawned is not creature.
//oSpawned = CreateObject(nObjectType, sTemplate, lSpawnLocation);
if (nObjectType == 1) {
json jTemplate = TemplateToJson (sTemplate, RESTYPE_UTC);
int iGender = JsonGetInt (GffGetByte (jTemplate, "Gender"));
int iApp = JsonGetInt (GffGetWord (jTemplate, "Appearance_Type"));
if ((iApp > -1 && iApp < 7) && iGender == 2 ) {
jTemplate = GffReplaceByte(jTemplate, "Gender", GENDER_FEMALE);
}
oSpawned = JsonToObject (jTemplate, lSpawnLocation, OBJECT_INVALID, TRUE);
} else {
oSpawned = CreateObject(nObjectType, sTemplate, lSpawnLocation);
}
SpawnDelayDebug(oSpawn, "spawned " + ObjectToString(oSpawned));
RecordSpawned(oSpawn, oSpawned, lHome, lEntranceExit,
fSpawnFacing);
SetupSpawned(oSpawn, oSpawned, lHome, nTimeNow, nWalkToHome);
}
}
}
If Gender isn’t set to Both on the UTC and the appearance isn’t a playable race it won’t change anything.
To do:
Set up a random chance for gender 0/1
Set up a proper soundset & make a workaround for the vanilla spawn system.
B.
PS.:
json voiceSet;
int voiceFile;
json jTemplate = TemplateToJson (sTemplate, RESTYPE_UTC);
int iGender = JsonGetInt (GffGetByte (jTemplate, "Gender"));
int iApp = JsonGetInt (GffGetWord (jTemplate, "Appearance_Type"));
if ((iApp > -1 && iApp < 7) && iGender == 2 ) {
if (d3(1) == 1) {
//female
iGender = 1;
voiceSet = JsonParse ("[357,358,359,360,361]");
} else {
//male
iGender = 0;
voiceSet = JsonParse ("[363,364,365,366,367,368]");
}
//Set up voice set
jTemplate = GffReplaceByte(jTemplate, "Gender", iGender);
voiceFile = JsonGetInt(JsonArrayGet(voiceSet,Random(JsonGetLength(voiceSet))));
jTemplate = GffReplaceWord(jTemplate, "SoundSetFile", voiceFile);
}
To Do
Workaround a solution for the vanilla spawn system.
B.