by Caligari87 » Fri Jul 02, 2021 8:09 am
I'll throw another use case on the stack since I rolled my own trying to solve a similar issue.
I have a "modular" mod pack, which I've designed so players can load the entire mod as one unified whole, or easily separate out just the parts they want. But of course this causes problems if one of these "sub-mods" depends on another one that isn't loaded.
For example, one of my modules gives the player a flashlight inventory item. Another module gives monsters some enhanced AI mechanics, including the ability to use the same flashlight item as the player. But if the AI mod is loaded and the flashlight isn't, errors occur.
So I wrote a system in the "core" submod (common routines used by all the mods) that allows the AI mod to send "intents" such as "toggle flashlight" to a global "bulletin board", and the flashlight to look for these intents and toggle accordingly.
Details spoilered since my
implementation is irrelevant to the one discussed in this thread, but just for context.
Spoiler:
The implementation:
Ugly as Sin core_intents.zsc
AI monster example of sending intent:
Code: Select all
// More likely to activate in darker areas
if (random[aillm](0,192) > lightlevel) { UaS.SendIntent("LLM_Toggle", "On", owner); }
else { UaS.SendIntent("LLM_Toggle", "Off", owner); }
Flashlight receiving intents:
Code: Select all
void ProcessIntents() {
UaS_Intent oi;
oi = UaS.GetIntent("LLM_Toggle", owner);
if (oi) {
if (oi.Payload ~== "On") { activated = true; }
else if (oi.Payload ~== "Off") { activated = false; }
else { ToggleSwitch(); }
oi.Clear();
}
oi = UaS.GetIntent("LLM_ModeSwitch", owner);
if (oi) {
int m = oi.Payload.ToInt(10);
switch(m) {
case 0: modeLaser = 0; modeLight = 1; break;
case 1: modeLaser = 1; modeLight = 0; break;
case 2: modeLaser = 1; modeLight = 1; break;
case 3: modeLaser = 0; modeLight = 3; break;
}
oi.Clear();
}
}
If this was implemented into GZDoom I could save some code and probably be more efficient. I think one main thing I like about mine is that it includes several fields like separating the intent name and payload string, sender/receiver pointers, timeouts, etc. Not sure how generically useful those might be or if they can be achieved with MC's system.

I'll throw another use case on the stack since I rolled my own trying to solve a similar issue.
I have a "modular" mod pack, which I've designed so players can load the entire mod as one unified whole, or easily separate out just the parts they want. But of course this causes problems if one of these "sub-mods" depends on another one that isn't loaded.
For example, one of my modules gives the player a flashlight inventory item. Another module gives monsters some enhanced AI mechanics, including the ability to use the same flashlight item as the player. But if the AI mod is loaded and the flashlight isn't, errors occur.
So I wrote a system in the "core" submod (common routines used by all the mods) that allows the AI mod to send "intents" such as "toggle flashlight" to a global "bulletin board", and the flashlight to look for these intents and toggle accordingly.
Details spoilered since my [i]implementation[/i] is irrelevant to the one discussed in this thread, but just for context.
[spoiler]The implementation: [url=https://github.com/caligari87/Ugly-as-Sin/blob/master/core/module/core_intents.zsc]Ugly as Sin [c]core_intents.zsc[/c][/url]
AI monster example of sending intent:
[code]// More likely to activate in darker areas
if (random[aillm](0,192) > lightlevel) { UaS.SendIntent("LLM_Toggle", "On", owner); }
else { UaS.SendIntent("LLM_Toggle", "Off", owner); }[/code]
Flashlight receiving intents:
[code]void ProcessIntents() {
UaS_Intent oi;
oi = UaS.GetIntent("LLM_Toggle", owner);
if (oi) {
if (oi.Payload ~== "On") { activated = true; }
else if (oi.Payload ~== "Off") { activated = false; }
else { ToggleSwitch(); }
oi.Clear();
}
oi = UaS.GetIntent("LLM_ModeSwitch", owner);
if (oi) {
int m = oi.Payload.ToInt(10);
switch(m) {
case 0: modeLaser = 0; modeLight = 1; break;
case 1: modeLaser = 1; modeLight = 0; break;
case 2: modeLaser = 1; modeLight = 1; break;
case 3: modeLaser = 0; modeLight = 3; break;
}
oi.Clear();
}
}[/code][/spoiler]
If this was implemented into GZDoom I could save some code and probably be more efficient. I think one main thing I like about mine is that it includes several fields like separating the intent name and payload string, sender/receiver pointers, timeouts, etc. Not sure how generically useful those might be or if they can be achieved with MC's system.
8-)