Using ZScript to create custom player states
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!)
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!)
-
Arctangent
- Posts: 1235
- Joined: Thu Nov 06, 2014 1:53 pm
Re: Using ZScript to create custom player states
Most likely is that you didn't tell the game to actually use the new player actor, as ZDoom doesn't make assumptions about what player classes you want active ( otherwise, since all native actor data is valid for all games, you'd get the player classes for Heretic and Hexen in Doom, not to mention if you created a base class for a bunch of new player classes then that'd automatically get sucked in too ). You can define what player classes are in use in the GameInfo block of MAPINFO, specifically with the playerclasses property.
-
vAethor
- Posts: 93
- Joined: Wed May 10, 2017 4:10 pm
Re: Using ZScript to create custom player states
I found my problem, and that was I had my "3DPlayer" code in a separate script that I was going to call from within the main Zscript lump, but never did. I also moved all my player sprites up a directory, into the main Sprites directory instead of the "Player" subdirectory. For now at least, so I don't need to specify the paths every single time I call a sprite.Arctangent wrote:Most likely is that you didn't tell the game to actually use the new player actor, as ZDoom doesn't make assumptions about what player classes you want active ( otherwise, since all native actor data is valid for all games, you'd get the player classes for Heretic and Hexen in Doom, not to mention if you created a base class for a bunch of new player classes then that'd automatically get sucked in too ). You can define what player classes are in use in the GameInfo block of MAPINFO, specifically with the playerclasses property.
Now my 3DPlayer script is inside the main Zscript.txt lump, and I added this in Zmapinfo:
Code: Select all
// Set up the 3D Player
gameinfo
{
playerclasses = "3DPlayer"
}Script error,
3Dmoveset.pk3:zscript.txt"line 2:
Unexpected integer constant
Expecting identifier
Now quite sure how to fix it yet.
That code looks handy. I presume this could be used to invoke different states and animations, if available, for running, walking slowly, etc. but correct me if I'm wrong.Matt wrote:EDIT: An example might be in order. Here's the entire "see" state sequence from HD's playerpawn. "A_CheckSeeState()" is a function that checks a bunch of things that must happen when the player first takes a step, and then sets the playerpawn's state depending on various factors. "runwalksprint" is a custom variable that is modified elsewhere.Code: Select all
see: ---- A 0 A_CheckSeeState(); #### ABCD 4; goto spawn; seestun: #### ABCD random(2,10) A_GiveInventory("IsMoving",2); goto spawn; seewalk: #### ABCD 6{ if(height>40 && runwalksprint<0)A_TakeInventory("IsMoving",5); } goto spawn; seesprint: ---- A 4 A_TakeInventory("PowerFrightener"); #### B 2; #### C 4; #### D 2; goto spawn;
I'll play around with this later.
-
hideousdestructor
- Posts: 9696
- Joined: Sun Jan 04, 2004 5:37 pm
- Preferred Pronouns: They/Them
- Operating System Version (Optional): Debian Bullseye
- Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Re: Using ZScript to create custom player states
Open up your zscript.txt in a text editor (Notepad++ or Geany, *not* Notepad or Wordpad) and see what line 2 is... if you can't see anything in or around that line that should fail to parse, post it.vAethor wrote:I tried running it and I got this error:
Script error,
3Dmoveset.pk3:zscript.txt"line 2:
Unexpected integer constant
Expecting identifier
-
vAethor
- Posts: 93
- Joined: Wed May 10, 2017 4:10 pm
Re: Using ZScript to create custom player states
I just downloaded and installed Notepad++ (damn, I think I'm gonna be using this a lot, it looks handy for both Doom scripting and my more general coding,) I set the language/syntax highlighting to C++, like so:Matt wrote:Open up your zscript.txt in a text editor (Notepad++ or Geany, *not* Notepad or Wordpad) and see what line 2 is... if you can't see anything in or around that line that should fail to parse, post it.vAethor wrote:I tried running it and I got this error:
Script error,
3Dmoveset.pk3:zscript.txt"line 2:
Unexpected integer constant
Expecting identifier

Now what did you want me to do again? FYI I copied and pasted the contents from Zscript.txt into a new Notepad++ document, as you can see here.
-
Xaser
-

- Posts: 10774
- Joined: Sun Jul 20, 2003 12:15 pm
Re: Using ZScript to create custom player states
I don't think class names are allowed to start with a number. Try changing it to "ThreeDeePlayer" and see if it works.
-
vAethor
- Posts: 93
- Joined: Wed May 10, 2017 4:10 pm
Re: Using ZScript to create custom player states
You are right, I changed it to "ThreeDPlayer" but now I have another error, and it isn't even telling me what line of code it's on, and what lump it's in.
Missing displayname for player class 'ThreeDPlayer'
Execution could not continue.
No player classes defined.
Missing displayname for player class 'ThreeDPlayer'
Execution could not continue.
No player classes defined.
-
Cherno
- Posts: 1339
- Joined: Tue Dec 06, 2016 11:25 am
Re: Using ZScript to create custom player states
From the PlayerPawn zDoom wiki page:
Player.DisplayName string
This is the identification string of the player class. It is used in addplayerclass KEYCONF command, in playerclass console variable, in skin definitions, and in menus. Each player class used in game must have an unique display name!
-
vAethor
- Posts: 93
- Joined: Wed May 10, 2017 4:10 pm
Re: Using ZScript to create custom player states
Cherno wrote:From the PlayerPawn zDoom wiki page:
Player.DisplayName string
This is the identification string of the player class. It is used in addplayerclass KEYCONF command, in playerclass console variable, in skin definitions, and in menus. Each player class used in game must have an unique display name!
Code: Select all
Default
{
// NOTE: Custom PlayerPawns NEED a unique display name to run!
Player.DisplayName "Marine";
}But now the only problem is the other states aren't able to be called yet it seems. I push the fire button on my controller and he doesn't shoot.
I am guessing this has to do with my not fully defining the Missile and Melee states yet. Hmm, perhaps Matt's code example from several posts ago might give me some answers on how to get his attack states to work.
I have not forgotten about jumping yet, I just need to get the basics working first.
-
Arctangent
- Posts: 1235
- Joined: Thu Nov 06, 2014 1:53 pm
Re: Using ZScript to create custom player states
Missile and Melee states by default are only used when the player, respectively, fires their weapon and calls A_GunFlash ( usually via their weapon ). If you're not using the standard weapon system, then you'll have to write your own attack code into your PlayerPawn, most likely through overriding CheckWeaponFire or FireWeapon.
-
vAethor
- Posts: 93
- Joined: Wed May 10, 2017 4:10 pm
Re: Using ZScript to create custom player states
Sounds good, I think I'll write my own attack states. I can easily look up Decorate functions off the wiki and apply them, and now that I know Zscript can be used just like Decorate I feel less daunted by learning it. But I'll probably still need help with other tings as they come up.Arctangent wrote:Missile and Melee states by default are only used when the player, respectively, fires their weapon and calls A_GunFlash ( usually via their weapon ). If you're not using the standard weapon system, then you'll have to write your own attack code into your PlayerPawn, most likely through overriding CheckWeaponFire or FireWeapon.
Edit: I just looked at the link you sent, yikes, definitely gonna need help understanding that. I certainly know functions, structs, datatypes, etc. from C++, but applying them to Doom scripting is something I will need to get used to. And some of these types like "virtual," "meta" or "native" I *definitely* don't know at all yet. I did just find the shared/player script in the GZdoom pack file though, and will probably be referring to that a lot.