Skip to content

RACE (The Random Content Engine)

Grisgram edited this page Jun 24, 2022 · 24 revisions

Introduction

Race comes with a bunch of functions that shall 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 be called.
  • Functions that start with two underscores __race are internal functions and should not be called directly.

In addition, Race offers some #macro definitions that shall help you create better readable code.
They follow the same scheme: Some start with RACE_ and are here for you to be used, some are internal and start with __RACE.

How RACE works

Race is organized in 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 go through them, one by one.
So, read on in Race File Specifications.

Macros

Macro Description
RACE_TABLE_QUERIED Holds the struct of the topmost table, that started the current query.
RACE_TABLE_CURRENT Holds the struct of the table where the dropped item here is contained in.
RACE_ITEM_DROPPED Holds the race struct (race_result_entry) that just dropped.

The RACE_TABLE_* macros _may_hold the same value, but in a recursive scenario, they might be different.

Getting started

Raptor Modules

Clone this wiki locally