Difference between revisions of "AI War 2:Journal Entries"

From Arcen Wiki
Jump to navigation Jump to search
(Created page with "'''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 b...")
 
Line 1: Line 1:
'''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.
+
= Hey! =
 +
'''The content that used to be on this page has moved to "[[AI War 2: Custom Text Messages To The Player | Custom Text Messages To The Player]]"''', as that's really a less-formal and chat-embedded type of journal entry.  It also requires some custom coding.  That was the only way to do things prior to us adding in the actual codified journal entries with their dedicated sidebar, etc.
  
'''A:''' Sure -- it's super easy, thankfully, and just piggybacking on our existing code for sending players messages.
+
= Thew New Style Of Journal Entries =
  
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:
+
These were introduced in version 2.03x of the game.
  
            World_AIW2.Instance.QueueLogMessageCommand( "Not enough energy to place " + typeToPlace.DisplayName, JournalEntryImportance.NeverLogCentrally, "CannotDoThatThing", context );
+
== Creating New Journal Entries ==
  
There are several overloads, but it's the new NeverLogCentrally that matters.
+
So, you want to write journal entry or five?  Depending on your goals and how you want these to appear, there are various ways you can call them.  But no matter what, the basics of how you create one is always the same. That's what we will cover here, field by field:
  
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:
+
=== unique_id ===
  
            World_AIW2.Instance.QueueLogMessageCommand( "Human Resistance Fighters arriving to reinforce " + targetPlanet.Name, JournalEntryImportance.Normal, "HumanResistanceFightersWarpInNeutralPlanet" , Context );
+
This is a series of ASCII characters (a string), and it's the one thing stored in savegamesThis entry is longer than most, but please read it.
  
They have an importance of normal.
+
* '''Uniqueness:'''
 +
** This really does need to be unique!
 +
** If you give your entry an obvious ID like unique_id="GolemFound", then it's a pretty good bet that somebody else will do that also at some point.
 +
** If you're a modder, then generic IDs are a really great way to wind up with lots of errors when people try to load your mod and someone else's at the same time.
 +
** Putting your initials or handle is certainly a good way to make it truly unique: CMP_x4000_FirstTime_HiveGolemName would be an example of something that someone else is unlikely to EVER accidentally reuse.
  
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 messagesSo these should be used for mid-tier importance stuffSomething that's important maybe for a few hours, I guess, but not an absolute turning point in the game.
+
* '''Brevity:'''
 +
** "CMP_x4000_FirstTime_HiveGolem" is fine from a uniqueness standpoint, but at 29 characters it's awful from a brevity standpoint.
 +
** Each character in the name is saved into the savegame, raw, at a rate of 1 byte per character.
 +
** How many journal entries will we really be saving? Probably not that many, compared to something like shipsBut let's be reasonable everywhere we can.
 +
** Adopting something much more brief like "CMP4_1st_HiveGol" is 16 characters, but just as readable to me, and just as likely to be unique.
  
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.
+
Striking a balance is a good idea.  "CP4FirHivGo" is even more brief, and still likely unique, but incomprehensible.
 
 
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 eventsUnless 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 );
 

Revision as of 14:12, 28 April 2020

Hey!

The content that used to be on this page has moved to " Custom Text Messages To The Player", as that's really a less-formal and chat-embedded type of journal entry. It also requires some custom coding. That was the only way to do things prior to us adding in the actual codified journal entries with their dedicated sidebar, etc.

Thew New Style Of Journal Entries

These were introduced in version 2.03x of the game.

Creating New Journal Entries

So, you want to write journal entry or five? Depending on your goals and how you want these to appear, there are various ways you can call them. But no matter what, the basics of how you create one is always the same. That's what we will cover here, field by field:

unique_id

This is a series of ASCII characters (a string), and it's the one thing stored in savegames. This entry is longer than most, but please read it.

  • Uniqueness:
    • This really does need to be unique!
    • If you give your entry an obvious ID like unique_id="GolemFound", then it's a pretty good bet that somebody else will do that also at some point.
    • If you're a modder, then generic IDs are a really great way to wind up with lots of errors when people try to load your mod and someone else's at the same time.
    • Putting your initials or handle is certainly a good way to make it truly unique: CMP_x4000_FirstTime_HiveGolemName would be an example of something that someone else is unlikely to EVER accidentally reuse.
  • Brevity:
    • "CMP_x4000_FirstTime_HiveGolem" is fine from a uniqueness standpoint, but at 29 characters it's awful from a brevity standpoint.
    • Each character in the name is saved into the savegame, raw, at a rate of 1 byte per character.
    • How many journal entries will we really be saving? Probably not that many, compared to something like ships. But let's be reasonable everywhere we can.
    • Adopting something much more brief like "CMP4_1st_HiveGol" is 16 characters, but just as readable to me, and just as likely to be unique.

Striking a balance is a good idea. "CP4FirHivGo" is even more brief, and still likely unique, but incomprehensible.