I’ve got a bunch of NPC fidgets and other messages generated by sources other than the player’s action. Is there a convenient pattern for handling this a la combineReports.t
?
For reports generated by the player action that turn you can always add a report manager via gAction.callAfterActionMain()
(or by tweaking afterActionMain()
on specific actions, which is what combineReports.t
does). But for NPC fidgets, output from daemons, and so on this doesn’t work, as they’re generally generated too late in the turn order.
Sample thing:
#charset "us-ascii"
#include <adv3.h>
#include <en_us.h>
startRoom: Room 'Void'
"This is a featureless void. "
roomDaemon() {
if(!(libGlobal.totalTurns % 3))
extraReport('The room daemon ruminates. ');
}
;
+me: Person;
+alice: Person 'alice' 'Alice'
"She looks like the first person you'd turn to in a problem."
isHer = true
isProperName = true
;
++AgendaItem
initiallyActive = true
invokeItem() {
extraReport('Alice alliterates. ');
}
;
+bob: Person 'bob' 'Bob'
"He looks like a Robert, only shorter. "
isHim = true
isProperName = true
;
++AgendaItem
initiallyActive = true
invokeItem() {
if(!(libGlobal.totalTurns % 2))
extraReport('Bob bloviates. ');
}
;
versionInfo: GameID;
gameMain: GameMainDef initialPlayerChar = me;
This has three fidgets/barks generated at different intervals (Alice alliterates every turn, Bob bloviates every other turn, and the room daemon ruminates every third turn). What I want to do is implement some mechanism by which these reports are combined on turns in which more than one is generated.
My first attempt was to create a report manager in the rough form of actionReportManager
from combineReports.t
, and call it in e.g. startRoom.roomDaemon()
. Something like:
fidgetReportManager: object
afterActionMain() {
// Report managing goes here
}
activate() {
gAction.callAfterActionMain(self);
}
;
startRoom: Room 'Void'
"This is a featureless void. "
roomDaemon() {
// THIS DOES NOT WORK!
fidgetReportManager.activate();
if(!(libGlobal.totalTurns % 3))
extraReport('The room daemon ruminates. ');
}
;
But roomDaemon()
isn’t called until after any afterActionMain()
s have been called.
Is an output filter the closest thing to a “global” report manager provided natively by adv3? Or am I missing something obvious?