PlayerClass

From ZDoom Wiki
Jump to navigation Jump to search

int PlayerClass (int playernumber)

Usage

Returns the number of the player's player class. The corresponding numbers are in the order of how they are entered into the MAPINFO or KEYCONF lumps (MAPINFO comes first). To see the numbers during runtime use the playerclasses console command to output all the classes into the console. If the returned number is -1 that means the activator was either a monster or out of player range.

While not too useful, the following constants are given for the hexen classes:

  • CLASS_FIGHTER - Fighter (0)
  • CLASS_CLERIC - Cleric (1)
  • CLASS_MAGE - Mage (2)

Examples

This example script (works for Hexen only) just prints the player class of the activator using the PlayerNumber function:

#include "zcommon.acs"
script 1 (void)
{
      switch(PlayerClass(PlayerNumber()))
      {
            case CLASS_FIGHTER:
                 print(s:"You are a fighter!");
                 break;
            case CLASS_CLERIC:
                 print(s:"You are a cleric!");
                 break;
            case CLASS_MAGE:
                 print(s:"You are a mage!");
                 break;
            case -1:
                 //monster activated the script but we do not care about that
            default:
                 //something happened but we are just gonna break
                 break;
        }
}