Player

consoledoc.h

More...

Public Static Attributes

int

The move trigger index used for player crouching.

int

The ExtendedMove position/rotation index used for head movements.

int

The move trigger index used to trigger mounted image 0.

int

The move trigger index used to trigger mounted image 1 or alternate fire on mounted image 0.

bool

Disables rendering of all instances of this type.

bool

Disables selection of all instances of this type.

int

The move trigger index used for player jump jetting.

int

The move trigger index used for player jumping.

float

The maximum velocity allowed due to a single impulse.

int

Maximum number of ticks to predict on the client from the last known move obtained from the server.

int

When a warp needs to occur due to the client being too far off from the server, this is the maximum number of ticks we'll allow the client to warp to catch up.

float

Fraction of tick at which instant warp occures on the client.

int

The move trigger index used for player prone pose.

bool

Determines if the player's collision mesh should be rendered.

bool

Determines if mounted shapes are rendered or not.

bool

Determines if the player is rendered or not.

int

The move trigger index used for player sprinting.

int

The move trigger index used to dismount player.

Public Functions

void

Allow all poses a chance to occur.

void
allowCrouching(bool state)

Set if the Player is allowed to crouch.

void
allowJetJumping(bool state)

Set if the Player is allowed to jet jump.

void
allowJumping(bool state)

Set if the Player is allowed to jump.

void
allowProne(bool state)

Set if the Player is allowed to go prone.

void
allowSprinting(bool state)

Set if the Player is allowed to sprint.

void
allowSwimming(bool state)

Set if the Player is allowed to swim.

bool
checkDismountPoint(Point3F oldPos, Point3F pos)

Check if it is safe to dismount at this position.

void

Clears the player's current control object.

void
copyHeadRotation(Player other_player)
int

Get the current object we are controlling.

string
getDamageLocation(Point3F pos)

Get the named damage location and modifier for a given world position.

int

Get the number of death animations available to this player.

string

Get the name of the player's current pose.

string

Get the name of the player's current state.

bool
setActionThread(string name, bool hold, bool fsp)

Set the main action sequence to play for this player.

bool
setArmThread(string name)

Set the sequence that controls the player's arms (dynamically adjusted to match look direction).

bool

Set the object to be controlled by this player.

void
void

setMovementSpeedBias(F32 bias)

Detailed Description

Public Static Attributes

int crouchTrigger 

The move trigger index used for player crouching.

int extendedMoveHeadPosRotIndex 

The ExtendedMove position/rotation index used for head movements.

int imageTrigger0 

The move trigger index used to trigger mounted image 0.

int imageTrigger1 

The move trigger index used to trigger mounted image 1 or alternate fire on mounted image 0.

bool isRenderable 

Disables rendering of all instances of this type.

bool isSelectable 

Disables selection of all instances of this type.

int jumpJetTrigger 

The move trigger index used for player jump jetting.

int jumpTrigger 

The move trigger index used for player jumping.

float maxImpulseVelocity 

The maximum velocity allowed due to a single impulse.

int maxPredictionTicks 

Maximum number of ticks to predict on the client from the last known move obtained from the server.

int maxWarpTicks 

When a warp needs to occur due to the client being too far off from the server, this is the maximum number of ticks we'll allow the client to warp to catch up.

float minWarpTicks 

Fraction of tick at which instant warp occures on the client.

int proneTrigger 

The move trigger index used for player prone pose.

bool renderCollision 

Determines if the player's collision mesh should be rendered.

This is mainly used for the tools and debugging.

bool renderMyItems 

Determines if mounted shapes are rendered or not.

Used on the client side to disable the rendering of all Player mounted objects. This is mainly used for the tools or debugging.

bool renderMyPlayer 

Determines if the player is rendered or not.

Used on the client side to disable the rendering of all Player objects. This is mainly for the tools or debugging.

int sprintTrigger 

The move trigger index used for player sprinting.

int vehicleDismountTrigger 

The move trigger index used to dismount player.

Public Functions

allowAllPoses()

Allow all poses a chance to occur.

This method resets any poses that have manually been blocked from occuring. This includes the regular pose states such as sprinting, crouch, being prone and swimming. It also includes being able to jump and jet jump. While this is allowing these poses to occur it doesn't mean that they all can due to other conditions. We're just not manually blocking them from being allowed.

allowCrouching(bool state)

Set if the Player is allowed to crouch.

The default is to allow crouching unless there are other environmental concerns that prevent it. This method is mainly used to explicitly disallow crouching at any time. Parameters:

state

Set to true to allow crouching, false to disable it.

allowJetJumping(bool state)

Set if the Player is allowed to jet jump.

The default is to allow jet jumping unless there are other environmental concerns that prevent it. This method is mainly used to explicitly disallow jet jumping at any time. Parameters:

state

Set to true to allow jet jumping, false to disable it.

allowJumping(bool state)

Set if the Player is allowed to jump.

The default is to allow jumping unless there are other environmental concerns that prevent it. This method is mainly used to explicitly disallow jumping at any time. Parameters:

state

Set to true to allow jumping, false to disable it.

allowProne(bool state)

Set if the Player is allowed to go prone.

The default is to allow being prone unless there are other environmental concerns that prevent it. This method is mainly used to explicitly disallow going prone at any time. Parameters:

state

Set to true to allow being prone, false to disable it.

allowSprinting(bool state)

Set if the Player is allowed to sprint.

The default is to allow sprinting unless there are other environmental concerns that prevent it. This method is mainly used to explicitly disallow sprinting at any time. Parameters:

state

Set to true to allow sprinting, false to disable it.

allowSwimming(bool state)

Set if the Player is allowed to swim.

The default is to allow swimming unless there are other environmental concerns that prevent it. This method is mainly used to explicitly disallow swimming at any time. Parameters:

state

Set to true to allow swimming, false to disable it.

checkDismountPoint(Point3F oldPos, Point3F pos)

Check if it is safe to dismount at this position.

Internally this method casts a ray from oldPos to pos to determine if it hits the terrain, an interior object, a water object, another player, a static shape, a vehicle (exluding the one currently mounted), or physical zone. If this ray is in the clear, then the player's bounding box is also checked for a collision at the pos position. If this displaced bounding box is also in the clear, then checkDismountPoint() returns true. Parameters:

oldPos

The player's current position

pos

The dismount position to check

return:

True if the dismount position is clear, false if not

note:

The player must be already mounted for this method to not assert.

clearControlObject()

Clears the player's current control object.

Returns control to the player. This internally calls Player::setControlObject(0).

%player.clearControlObject();
echo(%player.getControlObject()); //<-- Returns 0, player assumes control
%player.setControlObject(%vehicle);
echo(%player.getControlObject()); //<-- Returns %vehicle, player controls the vehicle now.
note:

If the player does not have a control object, the player will receive all moves from its GameConnection. If you're looking to remove control from the player itself (i.e. stop sending moves to the player) use GameConnection::setControlObject() to transfer control to another object, such as a camera.

copyHeadRotation(Player other_player)

getControlObject()

Get the current object we are controlling.

return:

ID of the ShapeBase object we control, or 0 if not controlling an object.

getDamageLocation(Point3F pos)

Get the named damage location and modifier for a given world position.

the Player object can simulate different hit locations based on a pre-defined set of PlayerData defined percentages. These hit percentages divide up the Player's bounding box into different regions. The diagram below demonstrates how the various PlayerData properties split up the bounding volume:

While you may pass in any world position and getDamageLocation() will provide a best-fit location, you should be aware that this can produce some interesting results. For example, any position that is above PlayerData::boxHeadPercentage will be considered a 'head' hit, even if the world position is high in the sky. Therefore it may be wise to keep the passed in point to somewhere on the surface of, or within, the Player's bounding volume.

note:

This method will not return an accurate location when the player is prone or swimming.

Parameters:
pos

A world position for which to retrieve a body region on this player.

return:

a string containing two words (space separated strings), where the first is a location and the second is a modifier.

Posible locations:
  • head

  • torso

  • legs

Head modifiers:
  • left_back

  • middle_back

  • right_back

  • left_middle

  • middle_middle

  • right_middle

  • left_front

  • middle_front

  • right_front

Legs/Torso modifiers:
  • front_left

  • front_right

  • back_left

  • back_right

getNumDeathAnimations()

Get the number of death animations available to this player.

Death animations are assumed to be named death1-N using consecutive indices.

getPose()

Get the name of the player's current pose.

The pose is one of the following:

  • Stand - Standard movement pose.

  • Sprint - Sprinting pose.

  • Crouch - Crouch pose.

  • Prone - Prone pose.

  • Swim - Swimming pose.

return:

The current pose; one of: "Stand", "Sprint", "Crouch", "Prone", "Swim"

getState()

Get the name of the player's current state.

The state is one of the following:

return:

The current state; one of: "Dead", "Mounted", "Move", "Recover"

isAnimationLocked()

setActionThread(string name, bool hold, bool fsp)

Set the main action sequence to play for this player.

Parameters:

name

Name of the action sequence to set

hold

Set to false to get a callback on the datablock when the sequence ends (PlayerData::animationDone()). When set to true no callback is made.

fsp

True if first person and none of the spine nodes in the shape should animate. False will allow the shape's spine nodes to animate.

return:

True if succesful, false if failed

note:

The spine nodes for the Player's shape are named as follows:

  • Bip01 Pelvis

  • Bip01 Spine

  • Bip01 Spine1

  • Bip01 Spine2

  • Bip01 Neck

  • Bip01 Head

You cannot use setActionThread() to have the Player play one of the motion determined action animation sequences. These sequences are chosen based on how the Player moves and the Player's current pose. The names of these sequences are:

  • root

  • run

  • side

  • side_right

  • crouch_root

  • crouch_forward

  • crouch_backward

  • crouch_side

  • crouch_right

  • prone_root

  • prone_forward

  • prone_backward

  • swim_root

  • swim_forward

  • swim_backward

  • swim_left

  • swim_right

  • fall

  • jump

  • standjump

  • land

  • jet

If the player moves in any direction then the animation sequence set using this method will be cancelled and the chosen mation-based sequence will take over. This makes great for times when the Player cannot move, such as when mounted, or when it doesn't matter if the action sequence changes, such as waving and saluting.

// Place the player in a sitting position after being mounted
%player.setActionThread( "sitting", true, true );

setArmThread(string name)

Set the sequence that controls the player's arms (dynamically adjusted to match look direction).

Parameters:

name

Name of the sequence to play on the player's arms.

return:

true if successful, false if failed.

note:

By default the 'look' sequence is used, if available.

setControlObject(ShapeBase obj)

Set the object to be controlled by this player.

It is possible to have the moves sent to the Player object from the GameConnection to be passed along to another object. This happens, for example when a player is mounted to a vehicle. The move commands pass through the Player and on to the vehicle (while the player remains stationary within the vehicle). With setControlObject() you can have the Player pass along its moves to any object. One possible use is for a player to move a remote controlled vehicle. In this case the player does not mount the vehicle directly, but still wants to be able to control it. Parameters:

obj

Object to control with this player

return:

True if the object is valid, false if not

setLookAnimationOverride(bool flag)

setMovementSpeedBias(float bias)

setMovementSpeedBias(F32 bias)