Structs:UserCmd

From ZDoom Wiki
Jump to navigation Jump to search

The UserCmd struct contains data related to the player's current inputs. This struct is defined as native, meaning the internals are handled in the C++ part of the engine and custom versions of this struct cannot be created.

Usage

Each player has their own UserCmd struct which is accessible with the cmd field of the PlayerInfo struct of that player.

Fields

  • uint buttons
A bit field that contains the currently pressed buttons from the list below.
To check if a specific button is pressed, bitwise operators must be used, for example if (<playerInfoPointer>.cmd.buttons & BT_ATTACK) will return true if the Fire button is present among any other possible buttons.
  • int16 pitch
(Need more info)
  • int16 yaw
(Need more info)
  • int16 roll
(Need more info)
  • int16 forwardmove
The value of the forward/backward input in the -32.767–32.767range. The range is there to account for the possible use of analog input, like gamepads.
  • int16 sidemove
The value of the leftward/rightward input in the -32.767–32.767range. The range is there to account for the possible use of analog input, like gamepads.
  • int16 upmove
The value of the downward/upward input in the -32.767–32.767range. The range is there to account for the possible use of analog input, like gamepads.

Buttons

The buttons field can contain the same internal button names as the ones that can be obtained by GetPlayerInput:

Internal name in ZScript or ACS Corresponding action
BT_FORWARD Walk forward
BT_BACK Walk backward
BT_LEFT Turn left
BT_RIGHT Turn right
BT_MOVELEFT Strafe left
BT_MOVERIGHT Strafe right
BT_ATTACK Fire primary
BT_ALTATTACK Fire secondary
BT_USE Use/Open
BT_JUMP Jump
BT_CROUCH Crouch
BT_TURN180 180-degree turn
BT_RELOAD Reload weapon
BT_ZOOM Zoom weapon
BT_SPEED Run/walk modifier
BT_RUN Run/walk state
BT_STRAFE Strafe modifier
BT_LOOKUP Look up (Keyboard)
BT_LOOKDOWN Look down (Keyboard)
BT_MOVEUP Swim/fly upward
BT_MOVEDOWN Swim/fly downward
BT_SHOWSCORES Show multiplayer scoreboard
BT_USER1 User-defined button 1
BT_USER2 User-defined button 2
BT_USER3 User-defined button 3
BT_USER4 User-defined button 4