Nuclide
Software Development Kit for id Technology
|
Skill/Difficulty related APIs. More...
Skill/Difficulty related APIs.
The skill/difficulty APIs are used to retrieve values that differ based on the selected game difficulty setting.
The setting is controlled via the skill
console variable, which is represented by three different modes:
The framework will then query the active skill variables. If a skill value isn't set, a fallback value (defined by your code, querying the API) will be used.
If the console variable skill
is empty, or 0
it will assume the default setting of 2
- which is the medium difficulty.
You can technically query higher values then 3
, just ensure you set them all up in your skill manifest.
Default values are loaded from <gamedir>/cfg/skill_manifest.cfg
.
The format looks like this:
While you can set these in the skill_manifest.cfg
file directly, it is encouraged to put your own values in a separate config.
That way when people mod your game, they can inherit updates from the other, separate config without having to duplicate the variables every time your game updates.
Also, if there is no difference whatsoever between your different skill values, or you don't want to have a concept of difficulty in your game (but still allow players or server operators to change game variables defined through them) you can define a single skill variable in the configs too:
Developers can query the variable set in the skill system using Skill_GetValue():
And entity declarations can query skills like so:
You will see most reference defs use them like so.
Functions | |
void | Skill_Init (void) |
Called by Nuclide in init() before entities, or even EntityDef are initialized. More... | |
float | Skill_GetValue (string, float) |
Return a skill variable's value or return a defaultvalue if it's undefined. More... | |
bool | Skill_ParseConfig (string fileName) |
Parses a specified config file. More... | |
float Skill_GetValue | ( | string | variable, |
float | defaultValue | ||
) |
Return a skill variable's value or return a defaultvalue if it's undefined.
void Skill_Init | ( | void | ) |
Called by Nuclide in init()
before entities, or even EntityDef are initialized.
bool Skill_ParseConfig | ( | string | fileName | ) |
Parses a specified config file.
This should ideally be done before entities spawn. You are only allowed to parse files from a sub-directory such as gamedir/cfg/
. Some directories are blocked by the engine for security reasons.