GameSkill

From ZDoom Wiki
Jump to: navigation, search

int GameSkill (void)

Usage

Returns the skill level of the current game.

Return value

The skill level of the current game. For script readability there are skill levels defined in zdefs.acs as follows:

  • SKILL_VERY_EASY = 0
“I'm Too Young to Die” in Doom.
  • SKILL_EASY = 1
“Hey, Not Too Rough" in Doom.
  • SKILL_NORMAL = 2
“Hurt Me Plenty” in Doom.
  • SKILL_HARD = 3
“Ultra-Violence” in Doom.
  • SKILL_VERY_HARD = 4
“Nightmare!” in Doom.

These are ordered 0 through 4 so all operators will work. For example, skills which are <= SKILL_NORMAL are very easy, easy and normal.

Examples

This script takes the TID of a boss monster and applies different effects depending on the skill. Easier skills get a quarter health boss. Harder skills get a half health boss. Nightmare gets a full strength boss which is invisible. Although this example is somewhat unbalanced, this command can help to finely tune skill levels.

script 1 (int boss)
{
    if (GameSkill () <= SKILL_EASY)
        SetActorProperty (boss, APROP_HEALTH, 1000);
    else if (GameSkill () < SKILL_VERY_HARD)
        SetActorProperty (boss, APROP_HEALTH, 2000);
    else
        SetActorProperty (boss, APROP_RENDERSTYLE, STYLE_FUZZY);
}

This example increases the amount of Imps that get spawned at the MapSpot with the matching TID, starting with the base count provided, and adding the factor amount for every skill level beyond SKILL_VERY_EASY. The return value from SpawnSpotFacing is analyzed to determine the success of the spawn attempt.

script 1 (int tid, int base, int factor)
{
    int count = base + GameSkill() * factor;
    while (count)
    {
        if (SpawnSpotFacing("DoomImp", tid))
        {
            SpawnSpot("TeleportFog", tid);
            count--;
        }
        delay(35);
    }
}