RACE (The Random Content Engine) - Grisgram/gml-raptor GitHub Wiki

Introduction

Race comes with a bunch of functions that will make your life easier when it comes to random content.
RACE will help you with your game development in all of these situations (and more!):

  • Generate Random Maps
  • Drop Loot (Chests, Daily Login Bonus, Dying Monsters, ...)
  • Spawn Monsters
  • Fill any board/array with random objects
  • Roll dice

But the most important thing about RACE is:

The elements have different chances to be picked. It is a weighted randomizer!

In general, there are two types of functions:

  • Functions that start with race_ are end-user-functions and are here for you to call.
  • Functions that start with two underscores __race are internal functions and should not be called directly.

How Race works

Race is organized into tables (loot-tables). These are created in .json files.
An example table is contained in the project template in the file race/demotable.json in the Included Files folder. This demo file contains all the most important options you have with a RaceTable:

  • Different item types to drop
  • The Enabled, Unique, Always and Chance flags
  • Custom attributes
  • Table link references
  • Table copy references

Don't get confused about all these new terms. We will go through them one by one.

Race and Savegames

As I said on the landing page of the wiki, the systems of raptor work closely together. This is especially true for Race and the Savegame System. If you already read the pages about Savegames, you know that every Saveable object contains a data member that holds all values which will be part of the savegame file.

I also mentioned, that all RaceObjects automatically save their data in the savegame. Well, we know that software does nothing automatically unless a developer tells it to do so. In this case, the automatic saving is implemented as data.race_data. Each RaceObject instance adds a race_data struct in the data struct of the Saveable object. The following pages will explain the contents of race_data in detail. Read on.

How to drop things

This is as easy as invoking the race_query(table, layer); method, or simply call query on a RaceTable object in your room (Spawner objects jump to mind... If they were RaceTables, they would create their instances on the fly when they spawn something. No further code required!).

With the knowledge that dropping loot is a one-liner, you'll have a powerful randomization tool at your disposal by the end of this section. Let's read on in Race File Specifications.

⚠️ **GitHub.com Fallback** ⚠️