The format is as follows, separated by '|':
- Name of a replacing actor
- Name of an actor being replaced
- Weight of the actor
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
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 "";
}
}
Code: Select all
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.