Creating new player classes

From ZDoom Wiki
Jump to navigation Jump to search

Choosing player classes in-game

Choosing a player class through the game's GUI can occur in two instances:

  • When starting a new game (a class menu will popup inbetween choosing 'new game' and 'skill level')
  • When changing the (Multi-)Player Setup in the Options menu

Defining player classes for your project

Adding player class code

First thing you have to do is to create new actor in ZScript or DECORATE (deprecated) inheriting from PlayerPawn or any of its subclasses (such as DoomPlayer). It is recommended to inherit from the subclass the closest to what you want to do, for example a replacement of the Doom marine should inherit from the Doom player.

ZScript:

class MyPlayer : DoomPlayer
{
  ...
}

DECORATE (deprecated):

actor MyPlayer : DoomPlayer
{
  ...
}

Making player class available in the menu

Contrarily to simple actor replacement, you cannot use the replaces keyword here, because player pawns are not spawned like other actors. Instead, you must define access to this class in MAPINFO, with a GameInfo section:

GameInfo
{
   PlayerClasses = "MyPlayer"
}

Note: This definition goes into the Gameinfo block of the MAPINFO lump, NOT in the GAMEINFO lump.

If you have several classes, you can list them all, separated by commas. You can also keep the original classes as well. If there are at least two classes, the player will have a class selection screen when starting a new game.

GameInfo
{
   PlayerClasses = "MyPlayer", "DoomPlayer" // Defines 2 classes for the player to choose from
}

With older versions of ZDoom, the GameInfo method is not available. Instead, KEYCONF can be used: (deprecated)

// This command clears the player classes' list.
clearplayerclasses

// Add your player class to the list
addplayerclass MyPlayer

// Add standard Doom player to the list, but make it accessible only via player setup menu (i.e. hide from 'New Game' choice)
addplayerclass DoomPlayer nomenu