AI War 2:Custom Text Messages To The Player

From Arcen Wiki
Jump to navigation Jump to search

Hey!

Do you really mean " Journal Entries", in the sense of those things that are defined in xml and new in version 2.040 of the game and further? If so, click that link. Those are what you should be using for long-term, detailed journal entries. And as a bonus, they don't require any custom code from you.

What is presented below is an older form of "journal entry," which is just embedded in the chat log. It can be useful to do that sort of thing at various points as well, but those are... less robust. The journal entries that we're referring to at the above link is instead like uncovering little wiki entries, almost, that show up in a dedicated tab in your sidebar as you play.

Original Q&A

Q: Do you have sample code for how to emit different journal entries? For example, I'd like a permanent journal entry at game start when you have allied marauders that basically explain how marauders work, and that they can build Raiders if they have their own planets.

A: Sure -- it's super easy, thankfully, and just piggybacking on our existing code for sending players messages.

1. First off, to have something show up in the sidebar log for a second and then NOT go to the journal (aka behavior up until now), you need to do this sort of thing:

            World_AIW2.Instance.QueueLogMessageCommand( "Not enough energy to place " + typeToPlace.DisplayName, JournalEntryImportance.NeverLogCentrally, "CannotDoThatThing", context );

There are several overloads, but it's the new NeverLogCentrally that matters.

2. Taking a step up from that, let's log it to the journal but consider it no more important than the average chat message. So if the players are chatting heavily in multiplayer via text chat for some reason, this will get knocked off the list fast. These are any of the overloads of the method, but along these lines:

            World_AIW2.Instance.QueueLogMessageCommand( "Human Resistance Fighters arriving to reinforce " + targetPlanet.Name, JournalEntryImportance.Normal, "HumanResistanceFightersWarpInNeutralPlanet"  , Context );

They have an importance of normal.

3. Next step up is stuff to "keep longer." When it culls the list of journal entries down to 50, it first clears all the normal ones, then only starts clearing the oldest of these keeplonger ones if there are still more than 50 messages. So these should be used for mid-tier importance stuff. Something that's important maybe for a few hours, I guess, but not an absolute turning point in the game.

Actually, your thing that explains how marauders work I feel like falls under this category -- it probably won't disappear in a regular game, at least not for a lot of hours (think of the flow of messages here, you'd have to have more than 50 keeplonger or neverdiscard messages all in there clogging stuff up for this to ever go away.

You could even make the argument that you might just want to use Normal importance, so that it disappears if 50 more messages or chats get sent. How long is this really relevant? Etc. But I think that for the intro message at least, it being keeplonger might make sense. Most other events that aren't absolutely pivotal to the game (even things like a spire relic being captured) should probably just be normal events. Unless they're the sort of things a player might look back on and go "where did I hit X milestones in my quest?"

            World_AIW2.Instance.QueueLogMessageCommand("A Scourge Nemesis has spawned in the galaxy!", JournalEntryImportance.KeepLonger, null);

4. The strongest type is never discard, which stays absolutely forever. You won the game, the game majorly majorly changed in a way that happens almost never, etc. Ideally there would not be more than maybe 10 of these in a game so there's still 40 journal spots for the other things. Also ideally, the total of keeplonger and neverdiscard would never be more than 25-30 in a game, or else I'll need to let the journal be longer than it is now. We can figure that out as we go.

But an example:

            World_AIW2.Instance.QueueLogMessageCommand( "The AI Civil War has begun", JournalEntryImportance.NeverDiscard, "", Context );