Meteor 2 Scripting Functions
Weapon
int getWeapon(int objectID)
Get the specified object current weapon slot index.

Example
// show player current weapon slot index
print(getWeapon(PLAYER_OBJECT));

Comments
If the object was not found -1 is returned.

See also
setWeapon clampWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotItemName getWeaponSlotsCount

void setWeapon(int objectID, int slotIndex)
Set the specified object current weapon slot index (local player or server only).

Example
// select weapon slot 2 (PDW)
setWeapon(PLAYER_OBJECT, 2);

See also
getWeapon clampWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotItemName getWeaponSlotsCount setAutoWeaponSwitchingEnabled

void clampWeapon(int objectID)
Clamp an object's current weapon index to a valid (and owned for players) weapon slot (local player or server only).

Example
// take away player PDW
giveItem(getLocalPlayer(), "PDW", -1);

// ensure player's current weapon is valid
clampWeapon(PLAYER_OBJECT);

Comments
Use this function to ensure an object's current weapon is valid, especially after removing player weapons.

See also
getWeapon setWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotItemName getWeaponSlotsCount

bool hasWeapon(int objectID, weaponItemName string)
Determine if an object has a specific weapon.

Example
// does player have a PDW?
print("Player has PDW: " + hasWeapon(PLAYER_OBJECT, "PDW"));

Comments
This function is normally used for player objects.

See also
getWeapon setWeapon clampWeapon getWeaponSlotItemNumber getWeaponSlotItemName getWeaponSlotsCount

int getWeaponSlotItemNumber(int objectID, int slotIndex)
Get the item type index for an object weapon slot.

Example
// print player slot 0 item number
print(getWeaponSlotItemNumber(PLAYER_OBJECT, 0));

Comments
Returns -1 if the object or slot is invalid.

See also
getWeapon setWeapon clampWeapon hasWeapon getWeaponSlotItemName getWeaponSlotsCount

string getWeaponSlotItemName(int objectID, int slotIndex)
Get the item type name for a player weapon slot.

Example
// print weapon item name for slot 0
print(getWeaponSlotItemName(PLAYER_OBJECT, 0));

Comments
Returns empty string if the object or slot is invalid.

See also
getWeapon setWeapon clampWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotsCount

int getWeaponSlotsCount(int objectID)
Get the number of weapon slots an object has.

Example 1
// show number of player weapon slots
print("Player has " + getWeaponSlotsCount(PLAYER_OBJECT) + " weapon slots");

Example 2
// loop through weapon slots and display information
for(int i=0; i<getWeaponSlotsCount(PLAYER_OBJECT); i++)
{
    print(i + ": " + getWeaponSlotItemName(PLAYER_OBJECT, i));
}

See also
getWeapon setWeapon clampWeapon hasWeapon getWeaponSlotItemNumber getWeaponSlotItemName hasLinkedWeapons

bool hasLinkedWeapons(int objectID)
Determine if an object has linked weapons (all turrets fire at the same time).

Example
// show player linked weapon mounts status
if(hasLinkedWeapons(PLAYER_OBJECT))
    print("Linked weapon mounts");
else
    print("Selectable weapon mounts");

See also
getWeaponSlotsCount

float getWeaponAimingAngle(int objectID, int slotIndex=-1)
Get the aiming angle of a specified turret.

Example
// show aiming angle of player or player vehicle current weapon
print("Current slot angle: " + getWeaponAimingAngle(PLAYER_OBJECT));

// show aiming angles of player vehicle first and second turrets
print("Slot 0: " + getWeaponAimingAngle(PLAYER_OBJECT, 0));
print("Slot 1: " + getWeaponAimingAngle(PLAYER_OBJECT, 1));

Comments
slotIndex is optional (leave empty or pass < 0 to use current weapon). When passing < 0 for linked weapon mount objects the first weapon angle is returned.
slotIndex is 0 based. If slotIndex is invalid the object angle is returned.
Result is in degrees (e.g. north = 0, east = 90, south = 180, west = 270).

See also
getWeaponWorldPos getWeapon

vector2 getWeaponMountWorldPos(int objectID, int slotIndex=-1)
Get the world position of a specified turret mounting point.

Example
// show world pos of player or player vehicle current weapon
print("Current slot pos: " + getWeaponMountWorldPos(PLAYER_OBJECT));

// show world mounting positions of player vehicle first and second turrets
print("Slot 0: " + getWeaponMountWorldPos(PLAYER_OBJECT, 0));
print("Slot 1: " + getWeaponMountWorldPos(PLAYER_OBJECT, 1));

Comments
slotIndex is optional (leave empty or pass < 0 to use current weapon).
slotIndex is 0 based. If slotIndex is invalid the object position is returned.

See also
getWeaponFireWorldPos getWeaponAimingAngle getWeapon

vector2 getWeaponFireWorldPos(int objectID, int slotIndex=-1)
Get the world position of a specified turret firing point (end of barrel).

Example
// show world pos of player or player vehicle current weapon
print("Current slot pos: " + getWeaponMountFirePos(PLAYER_OBJECT));

// show world firing positions of player vehicle first and second turrets
print("Slot 0: " + getWeaponMountFirePos(PLAYER_OBJECT, 0));
print("Slot 1: " + getWeaponMountFirePos(PLAYER_OBJECT, 1));

Comments
slotIndex is optional (leave empty or pass < 0 to use current weapon).
slotIndex is 0 based. If slotIndex is invalid the object position is returned.

See also
getWeaponMountWorldPos getWeaponAimingAngle getWeapon

bool getAutoWeaponSwitchingEnabled(int objectID)
Determine if auto weapon switching is enabled for an object.

Example
// print if auto weapon switching is enabled for object ID 1
print(getAutoWeaponSwitchingEnabled(1));

See also
setAutoWeaponSwitchingEnabled

void setAutoWeaponSwitchingEnabled(int objectID, bool enable)
Enable or disable auto weapon switching for an object.

Example
// disable auto weapon switching for object ID 1
if(isServer())
{
    setAutoWeaponSwitchingEnabled(1, false);
}

Comments
Server only.
Non player objects periodically switch between weapon mounts if the mounts are not linked. Use this function to enable or disable this behaviour.

See also
getAutoWeaponSwitchingEnabled setWeapon


Index

Generated on the 23 November 2024 at 08:20:45 (UK Time)