The format is as follows, separated by '|':
- Name of a replacing actor
- Name of an actor being replaced
- Weight of the actor
Once everything is collected, it creates a list that can be used by CheckReplacement() in event handlers.
What addons or other mods that wish to utilize a service must do, is set up a simple service with a partial name match based on what the mod author specifies. In my case, it's just called DESpawner. Any object inheriting from Service with that included in the name will be iterated through.
- Code: Select all • Expand view
Class DESpawnerService : Service
{
static const String list[] =
{ // <Replacer|Replaced|Weight >
"DEImp|DoomImp|10",
"DEStoneImp|DoomImp|1"
};
private play int Index;
override String Get(String r)
{
Name req = r;
if (req == 'Next')
{
if (Index < list.Size())
return list[Index++];
}
else if (req == 'Reset')
{
Index = 0;
}
return "";
}
}
For mod makers, the most relevant part involves using ServiceIterator and Service's Get() function, but the full example has been included for convenience. While this sample does load without errors, I've not yet tested to make sure it goes without a hitch (particularly, I'm not sure if TOK_SKIPEMPTY means delimiters are not recorded. I'm also not entirely certain if string's Replace() function treats tabs/spaces the same so the code will look a little wild).
- Code: Select all • Expand view
Class DESpawnerContainer play
{
Class<Actor> Replacer, Replacee;
Int Weight;
}
Class DESpawners play
{
Array<DESpawnerContainer> Info;
void SetupSpawners()
{
// Finds services by partial names.
ServiceIterator it = ServiceIterator.Find("DESpawner");
Service s;
Array<String> str; str.Clear();
Info.Clear();
// Now go through and call each service that has 'DESpawner' in the name.
while (s = it.Next())
{
s.Get("Reset");
String inf = "";
while ((inf = s.Get("Next")) && inf.Length() > 0) //Keeps going until Next returns "".
{
str.Clear();
inf.Split(str, "|", TOF_SKIPEMPTY);
if (str.Size() != 3) continue; //Incorrectly formatted.
Class<Actor> Check = str[0];
if (!Check) continue; // Bad replacer.
Check = str[1];
if (!Check) continue; // Bad replacee.
int w = str[2].ToInt();
if (w < 1) continue; // No weight, so don't add.
// Valid, so record it and keep going.
let fo = new('DESpawnerContainer');
fo.Replacer = str[0];
fo.Replacee = str[1];
fo.Weight = w;
Info.Push(fo);
}
}
}
}
-----
The whole system, as m8f has stated, is all about removing mod dependencies where applicable, and/or interfacing with another based on certain aspects. Not everything can be made independent, but you can create custom spawners that are flexible, or maybe even purchase menu entries with prices/requirements.