My understanding of the Mods for characters are that they are to be used for temp effects to the character, to change stats/name etc etc temporarily while still retaining the actual values in the main fields! Otherwise it would always be a issue of retaining the field, and holding its value elsewhere until the value is needed to go back to!
My advice, never change the main fields, use the mods for temp changes that revert back to original values! I've never set them to "" or null so I don't think I know off hand if that could be a potential fix as the fields should be protected from bad values being passed!
I was curious and decided to take a look at Incognito.cs (a fifth level spell) it temp changes the character name and such to disguise them, as expected we see the NameMod being used, no direct changing of Name.
Here we set random name for player while incognito,
Caster.NameMod = Caster.Female ? NameList.RandomName("female") : NameList.RandomName("male");
side note : this code can be simplified,
Caster.NameMod = NameList.RandomName(Caster.Female ? "female" : "male");
And if you still don't understand the ?, it means if true do this ( or : ) do that if false
here is a long form of writing this same code,
if (Caster.Female == true)
{
Caster.NameMod = NameList.RandomName("female");
}
else
{
Caster.NameMod = NameList.RandomName("male");
}
Then once the timer(spell) ends we revert it back by nulling out the mod.
So without digging further I can tell from looking at this, the NameMod when set to anything but null, overrides the Name Field.
Seeing this I would add the following line to the script I provided above to clear the NameMod as well as setting the Name!
if (badPlayerList.Count > 0)
{
for (int i = 0; i < badPlayerList.Count; i++)
{
badPlayerList[i].Name = "Bad Player" + i;
badPlayerList[i].NameMod = null; //Add this line to also reset the NameMod to default value!
}
}
Another side note for anyone that runs into a string using $, if you get a error, it is because you are not using the latest c# code, $ was added to the string for us to do inline values in the string, so if you have int VALUE = 5; string TEST= $"some text = {VALUE}"; the output would be, some text = 5. But remove the $ and the output will be, some text = {VALUE} .... so make sure when fixing these strings if they are issues due to the coding version, that you unpack the string to an older format, like string TEST = "some text = " + VALUE; or use string format. But don't overlook the value being past as it could effect the result you expect! I convert the Bad Payer string above for you as I saw that you overlooked the importance of the $. Which caused the players all getting the same name Bad Player{i}, when they should be Bad Player0, Bad Player1, Bad Player 2 and Bad Player3.