• Register
Post news RSS TaterTech - Our State Flag System

Welcome to the world of data management in a massive world of data and cats.

Posted by on

Want to know what goes into making a game, and the various tools and technology that are developed to make a video game come to life? We look to help educate you in exactly that with our new series of "TaterTech" articles, each describing a different tool or technology that we have developed or utilized to bring the world of A Purrtato Tail to life!

Ever play a game with a large world and non-linear gameplay and ask yourself, "How the heck does the game know what's going on??". Most games use what are called "State Flags". Let's pretend your cat needs to know if they have been fed or not. If this was a game, the cat could have a State Flag of "Have I Been Fed?". The possible values of this State Flag could be different things, such as "Yes - I Have Been Fed", "No - I Have Not been Fed". The cat would then know, based on the value of the State Flag, if they need to wake you up at 3 in the morning to yell at you because the bottom of their food dish can be seen.

pexels photo 416135SM

Why are you letting me starve to death. You know this means your shoes are forfeit.


A Purrtato Tail is no different - we have a large, non-linear world to explore, with literally thousands s of possible values that the game needs to keep track. Just for example, the main categories of values we need to track include:

  • Unlocked Player Abilities
  • Collected Items / Individual Collected Item Counts / Crafted Item Stats
  • Quest Progress / Completed Quests
  • Player Boosted Stats / Player Buffed Stats
  • Equipped Weapon / Equipped Clothing
  • World Map Discovery Progress
  • Conversation Stats with Hundreds of Characters
  • Player Preference Settings / Player Modified Keybinds
  • Achievement Progress
  • Collected Spherical Link Cards / Spherical Link Card Decks / Spherical Link Game Progress Stats
  • .... and many more.

Those are just the categories... and each of those categories has potentially hundreds upon hundreds of their own internal values to track. That is a gargantuan amount of information to need to manage, modify, and store.

Realizing this could very quickly become a nightmare to maintain, one of the very first things we did back in 2016 was develop the State Flag Manager system. This system allows us to define State Flags that are separated by Category, can have values of different value types, can have just their modified state value saved (for save games), and be easy to modify, maintain, and even change at run-time for testing purposes. We can even have Multi-State Checks!

Allow me to present to you - the State Editor!

stateed1

It may not look like much on its own - but behind the scenes it allows us to track and manage all of that state data in a very easy manner. For example, in this image we have the Items Category open, and can see the state flags of a bunch of game Items. The state flags for these items are all Integer values, allowing us to track how many individually of each item the player has, and what the default value this State Flag has at the start of a brand new game. The specific Item State Flag is then applied to an item in our Item Editor tool (which we'll show off in another blog post) so the game can easily keep track of what is what and what we have.

stateed2

And we can completely track and change these values at run-time from within the editor as well! Here is the exact same value displayed while the game is playing from within the Unity editor. We can see the exact current value of the Cat Gem State Flag, and we could even change it to test or debug different scenarios. And as mentioned, we have multiple flag types that the system can track and store as well...

stateed3

What, no hairball type?


The result here is we can extremely easily add, track, and modify State Flags throughout the entire game. It only takes one line of code to check the value of or change the value of a State Flag, and they can be checked in-bulk via Multi-State Checks to determine if all the State Flags for something like a Quest have reached their needed values, or determine if the requirements to unlock an Achievement have been met.

We even have what are called Callbacks in the State Flag System, which allows other parts of the game to quite literally listen for when State Flag changes are made. This means that we don't need to have something checking on every frame what the value of a specific State Flag is - instead, it can register itself as a listener, and then just be informed of when changes are made. Thanks to these Event Listeners, game elements such as Achievements are entirely automated. The Achievements system knows what Multi-State Checks it needs to watch, and when the entire Multi-State Checks returns a "True" value - meaning all states in it have reached their desired values - the Achievement is automatically unlocked. No fuss, no muss, no kitten-cuts.

If you've been paying attention, you probably noticed we develop easy to use editors for everything... and the Multi-State Checks are no different. In fact, here's that now, editing the State Flags to watch for an achievement called The Fluffy Achievement!

stateed4

At least you don't have to grind much for this one.


What we see here is a Multi-State Check called "The Fluffy Achievement". The Achievement system associates a Multi-State Check with each Achievement, then checks to see if the entire Multi-Value Check returns as True to determine if the Achievement itself is unlocked. This of course goes beyond just Achievements, and is used for a bunch of other game elements including what items a Shopkeeper might have available or what the description of an object is when you Examine it.

So there you have it - our State Flag Manager, in all its glory! It's been really fun to develop and implement - and it's already used in other games as well! Our friends at Glassbottom Games used this State Flag Manager for their title Spartan Fist, it's been used in games at Rocketcat Games, and Super Deluxe used it in their mobile games from 2018! All of our tools like this have been carefully developed to be usable in far more than just one game, and we are thrilled to know other developers are able to use our systems for their own purposes as well.

That does it for this TaterTech entry! What did you think? Want to see more like this, or want to see us talk about a specific tool or system we have developed for A Purrtato Tail? Let us know your thoughts on Twitter or in our Discord!

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

News
Browse
News
New
Post news
Views
76 (1 today)
Share
Related Engines
Unity
Unity Commercial
Related Groups
Cerulean Games, Inc.
Cerulean Games, Inc. Developer & Publisher
Drunk Robot Games
Drunk Robot Games Developer
Unity Games
Unity Games Hobbies & Interests with 1,828 members
Unity3d Discussion
Unity3d Discussion Educational with 28 members