(6 intermediate revisions by the same user not shown) | |||
Line 53: | Line 53: | ||
|- | |- | ||
| AMMO_MISSILE | | AMMO_MISSILE | ||
|} | |||
==== <code>PlayerAction</code> enum ==== | |||
{| | |||
|- | |||
| ACTION_MOVE | |||
|- | |||
| ACTION_ROTATE | |||
|- | |||
| ACTION_FIRE | |||
|- | |||
| ACTION_ALL | |||
|} | |} | ||
Line 96: | Line 108: | ||
* Gets or sets the player's battery, as a percentage (int) | * Gets or sets the player's battery, as a percentage (int) | ||
* Usage example: <code>player.battery = 60; // 60 percent battery will be 3 lights on the HUD</code> | * Usage example: <code>player.battery = 60; // 60 percent battery will be 3 lights on the HUD</code> | ||
=== disabledActions === | |||
* Get the player actions that have currently been disabled | |||
* Usage example: check if firing has been disabled | |||
<pre> | |||
if (player.disabledActions & ACTION_FIRE) | |||
{ | |||
// firing has been disabled | |||
} | |||
</pre> | |||
== Methods == | == Methods == | ||
Line 102: | Line 124: | ||
* Instantly kill the player | * Instantly kill the player | ||
* Usage example: <code>player.kill();</code> | * Usage example: <code>player.kill();</code> | ||
=== disableActions(PlayerActions) === | |||
* Disable the player's actions | |||
* Parameter: actions to disable (<code>PlayerAction</code> enum) - note these can be added together | |||
* Usage example: disable player's movement and weapon firing | |||
<pre> | |||
player.disableActions(ACTION_MOVE | ACTION_FIRE); | |||
</pre> | |||
Disable all actions (movement, rotation and firing) | |||
<pre> | |||
player.disableActions(ACTION_ALL); | |||
</pre> | |||
=== enableActions(PlayerActions) === | |||
* Enable the player's actions if they have been disabled | |||
* Parameter: actions to enable (<code>PlayerAction</code> enum) - note these can be added together | |||
* Usage example: enable player's movement and rotation | |||
<pre> | |||
player.enableActions(ACTION_MOVE | ACTION_ROTATE); | |||
</pre> | |||
=== addToHealth(int) === | === addToHealth(int) === | ||
Line 122: | Line 165: | ||
* Parameters: ammo type (AMMO enum), value (int) | * Parameters: ammo type (AMMO enum), value (int) | ||
* Usage example: <code>player.setAmmo(AMMO_PLASMA, 200); // set plasma ammo to 200</code> | * Usage example: <code>player.setAmmo(AMMO_PLASMA, 200); // set plasma ammo to 200</code> | ||
=== hasRedKey() === | |||
* returns <code>true</code> if the player has the red key | |||
* Usage example: | |||
<pre>if (player.hasRedKey()) | |||
{ | |||
.... | |||
} </pre> | |||
=== hasBlueKey() === | |||
* returns <code>true</code> if the player has the blue key | |||
=== hasYellowKey() === | |||
* returns <code>true</code> if the player has the yellow key | |||
=== hasGoggles() === | |||
* returns <code>true</code> if the player has the IR Goggles | |||
=== hasCleats() === | |||
* returns <code>true</code> if the player has the ice cleats | |||
=== hasMask() === | |||
* returns <code>true</code> if the player has the gasmask | |||
=== giveRedKey() === | |||
* adds the red key to the player's inventory | |||
* usage example: <code>player.giveRedKey();</code> | |||
=== giveBlueKey() === | |||
* adds the blue key to the player's inventory | |||
=== giveYellowKey() === | |||
* adds the yellow key to the player's inventory | |||
=== giveGoggles() === | |||
* adds the IR Goggles to the player's inventory | |||
=== giveCleats() === | |||
* adds the ice cleats to the player's inventory | |||
=== giveMask() === | |||
* adds the gas mask to the player's inventory | |||
=== removeRedKey() === | |||
* removes the red key from the player's inventory | |||
* usage example: <code>player.removeRedKey();</code> | |||
=== removeBlueKey() === | |||
* removes the blue key from the player's inventory | |||
=== removeYellowKey() === | |||
* removes the yellow key from the player's inventory | |||
=== removeGoggles() === | |||
* removes the IR Goggles key from the player's inventory | |||
=== removeCleats() === | |||
* removes the ice cleats from the player's inventory | |||
=== removeMask() === | |||
* removes the gas mask from the player's inventory | |||
=== giveCodeKey(int) === | |||
* adds a code key to the inventory | |||
* Parameter: number of code key (1 to 9) | |||
* Usage example: <code>player.giveCodeKey(4);</code> | |||
=== giveItem(ITEM) === | |||
* adds an item to the player's inventory | |||
* Parameter: item type (see <code>ITEM</code> enum) | |||
* Usage example: <code>player.giveItem(PHRIK)</code> | |||
=== hasWeapon(WEAPON) === | |||
* returns <code>true</code> if the player has the weapon | |||
* Parameter: weapon type (see <code>WEAPON</code> enum) | |||
* Usage example: | |||
<pre> | |||
if (player.hasWeapon(FUSION)) | |||
{ | |||
.... | |||
} | |||
</pre> | |||
=== giveWeapon(WEAPON) === | |||
* gives the player a weapon | |||
* Parameter: weapon type (see <code>WEAPON</code> enum) | |||
* Usage example: <code>player.giveWeapon(CONCUSSION);</code> | |||
=== removeWeapon(WEAPON) === | |||
* removes a weapon from the player's inventory | |||
* Parameter: weapon type (see <code>WEAPON</code> enum) | |||
* Usage example: <code>player.removeWeapon(RIFLE);</code> |
Latest revision as of 20:04, 17 April 2025
Documentation for TFE Player Script API.
Enums
ITEM
enum
PLANS |
PHRIK |
NAVA |
DT_WEAPON |
DATATAPE |
ITEM10 |
WEAPON
enum
PISTOL |
RIFLE |
REPEATER |
FUSION |
MORTAR |
CONCUSSION |
CANNON |
AMMO
enum
AMMO_ENERGY |
AMMO_POWER |
AMMO_DETONATOR |
AMMO_SHELL |
AMMO_PLASMA |
AMMO_MINE |
AMMO_MISSILE |
PlayerAction
enum
ACTION_MOVE |
ACTION_ROTATE |
ACTION_FIRE |
ACTION_ALL |
Properties
position
- Get or set
- Gets or sets the player's current position (float3)
- You will not be allowed to move the player outside of a sector
- Usage example: get the current player position and change it to 10 units higher altitude
float3 currentPos = player.position; player.position = {currentPos.x, currentPos.y + 10, currentPos.z};
yaw
- Get or set
- Gets or sets the player's yaw, in degrees (float)
- Usage example: make the player face south
player.yaw = 180;
velocity
- Get or set
- Gets or sets the player's velocity (float3)
- Usage example: set the player's velocity to 100 north + 100 west
player.velocity = {-100.0, 0, 100.0};
- Usage example: set the player's velocity to 50 upwards and 30 south
player.velocity = {0, 50.0, -30.0};
health
- Get or set
- Gets or sets the player's health (int)
- Usage example:
player.health = 80;
shields
- Get or set
- Gets or sets the player's shields (int)
- Usage example:
player.shields = 200;
battery
- Get or set
- Gets or sets the player's battery, as a percentage (int)
- Usage example:
player.battery = 60; // 60 percent battery will be 3 lights on the HUD
disabledActions
- Get the player actions that have currently been disabled
- Usage example: check if firing has been disabled
if (player.disabledActions & ACTION_FIRE) { // firing has been disabled }
Methods
kill()
- Instantly kill the player
- Usage example:
player.kill();
disableActions(PlayerActions)
- Disable the player's actions
- Parameter: actions to disable (
PlayerAction
enum) - note these can be added together - Usage example: disable player's movement and weapon firing
player.disableActions(ACTION_MOVE | ACTION_FIRE);
Disable all actions (movement, rotation and firing)
player.disableActions(ACTION_ALL);
enableActions(PlayerActions)
- Enable the player's actions if they have been disabled
- Parameter: actions to enable (
PlayerAction
enum) - note these can be added together - Usage example: enable player's movement and rotation
player.enableActions(ACTION_MOVE | ACTION_ROTATE);
addToHealth(int)
- Add an amount to the player's health
- Parameter: amount (int)
- Usage example:
player.addToHealth(-30); // subtract 30 from the player's health
addToShields(int)
- Add an amount to the player's shields
- Parameter: amount (int)
- Usage example:
player.addToShields(10);
getAmmo(AMMO)
- returns the current amount of ammo (int)
- Parameter: ammo type (AMMO enum)
- Usage example:
int shells = player.getAmmo(AMMO_SHELL);
setAmmo(AMMO, int)
- sets the ammo to a value
- Parameters: ammo type (AMMO enum), value (int)
- Usage example:
player.setAmmo(AMMO_PLASMA, 200); // set plasma ammo to 200
hasRedKey()
- returns
true
if the player has the red key - Usage example:
if (player.hasRedKey()) { .... }
hasBlueKey()
- returns
true
if the player has the blue key
hasYellowKey()
- returns
true
if the player has the yellow key
hasGoggles()
- returns
true
if the player has the IR Goggles
hasCleats()
- returns
true
if the player has the ice cleats
hasMask()
- returns
true
if the player has the gasmask
giveRedKey()
- adds the red key to the player's inventory
- usage example:
player.giveRedKey();
giveBlueKey()
- adds the blue key to the player's inventory
giveYellowKey()
- adds the yellow key to the player's inventory
giveGoggles()
- adds the IR Goggles to the player's inventory
giveCleats()
- adds the ice cleats to the player's inventory
giveMask()
- adds the gas mask to the player's inventory
removeRedKey()
- removes the red key from the player's inventory
- usage example:
player.removeRedKey();
removeBlueKey()
- removes the blue key from the player's inventory
removeYellowKey()
- removes the yellow key from the player's inventory
removeGoggles()
- removes the IR Goggles key from the player's inventory
removeCleats()
- removes the ice cleats from the player's inventory
removeMask()
- removes the gas mask from the player's inventory
giveCodeKey(int)
- adds a code key to the inventory
- Parameter: number of code key (1 to 9)
- Usage example:
player.giveCodeKey(4);
giveItem(ITEM)
- adds an item to the player's inventory
- Parameter: item type (see
ITEM
enum) - Usage example:
player.giveItem(PHRIK)
hasWeapon(WEAPON)
- returns
true
if the player has the weapon - Parameter: weapon type (see
WEAPON
enum) - Usage example:
if (player.hasWeapon(FUSION)) { .... }
giveWeapon(WEAPON)
- gives the player a weapon
- Parameter: weapon type (see
WEAPON
enum) - Usage example:
player.giveWeapon(CONCUSSION);
removeWeapon(WEAPON)
- removes a weapon from the player's inventory
- Parameter: weapon type (see
WEAPON
enum) - Usage example:
player.removeWeapon(RIFLE);