Issue with creating a new player class

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
graeyeye
Posts: 3
Joined: Sun Jan 19, 2025 5:49 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11

Issue with creating a new player class

Post by graeyeye »

I am trying to make a new default player class with a custom starting weapon, but when I try to launch gzdoom it only returns "No player classes defined".
The code for the class itself is

Code: Select all

class Praetorian : DoomPlayer
{

Player.StartItem "Fist"
Player.StartItem "AssaultRifle"
Player.StartItem "Clip" 50
}
And the code for the mapinfo is

Code: Select all

GameInfo
{
playerclasses = Praetorian
}
Any help would be much appreciated
User avatar
Enjay
 
 
Posts: 26701
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Issue with creating a new player class

Post by Enjay »

The only obvious thing I can see is that normally the name of the player class is in quotes. i.e.

Code: Select all

playerclasses = "Praetorian"
graeyeye
Posts: 3
Joined: Sun Jan 19, 2025 5:49 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11

Re: Issue with creating a new player class

Post by graeyeye »

I added quotes and it still brought up "no classes defined"

Update: After some research, I added a zscript to include the class file, but now it says
Script Error Line 3
Unexpected "."
Expecting Identifier
User avatar
Enjay
 
 
Posts: 26701
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Issue with creating a new player class

Post by Enjay »

I didn't realise that you hadn't included a file called ZScript.

Anyway, the following should work.
Note, I've included stuff to set the weapon slots. If you were just using the default weapons, you wouldn't need that. I'm not even sure that you will need to define all slots. Perhaps you only need to define the one that you will be changing. I didn't know what slot you wanted the assault rifle on, so I just guessed. Anyway, feel free to edit that bit to suit your needs.

ZScript:

Code: Select all

class Praetorian : DoomPlayer
{
	Default
	{
		Player.StartItem "AssaultRifle";
		Player.StartItem "Fist";
		Player.StartItem "Clip", 50;
		
		Player.WeaponSlot 1, "Fist", "Chainsaw";
		Player.WeaponSlot 2, "Pistol";
		Player.WeaponSlot 3, "Shotgun", "SuperShotgun";
		Player.WeaponSlot 4, "Chaingun", "AssaultRifle";
		Player.WeaponSlot 5, "RocketLauncher";
		Player.WeaponSlot 6, "PlasmaRifle";
		Player.WeaponSlot 7, "BFG9000";
	}
}
Mapinfo

Code: Select all

GameInfo
{
	playerclasses = "Praetorian"
}
graeyeye
Posts: 3
Joined: Sun Jan 19, 2025 5:49 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11

Re: Issue with creating a new player class

Post by graeyeye »

Yep, this works perfectly, thank you so much!

Return to “Scripting”