Meteor 2 Scripting Functions
Weapon
int getWeapon(int objectID)
Get the specified object current weapon slot index.
print(getWeapon(PLAYER_OBJECT));
If the object was not found -1 is returned.
void setWeapon(int objectID, int slotIndex)
Set the specified object current weapon slot index (local player or server only).
setWeapon(PLAYER_OBJECT, 2);
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).
giveItem(getLocalPlayer(), "PDW", -1);
clampWeapon(PLAYER_OBJECT);
Use this function to ensure an object's current weapon is valid, especially after removing player weapons.
bool hasWeapon(int objectID, weaponItemName string)
Determine if an object has a specific weapon.
print("Player has PDW: " + hasWeapon(PLAYER_OBJECT, "PDW"));
This function is normally used for player objects.
int getWeaponSlotItemNumber(int objectID, int slotIndex)
Get the item type index for an object weapon slot.
print(getWeaponSlotItemNumber(PLAYER_OBJECT, 0));
Returns -1 if the object or slot is invalid.
string getWeaponSlotItemName(int objectID, int slotIndex)
Get the item type name for a player weapon slot.
print(getWeaponSlotItemName(PLAYER_OBJECT, 0));
Returns empty string if the object or slot is invalid.
int getWeaponSlotsCount(int objectID)
Get the number of weapon slots an object has.
print("Player has " + getWeaponSlotsCount(PLAYER_OBJECT) + " weapon slots");
for(int i=0; i<getWeaponSlotsCount(PLAYER_OBJECT); i++)
{
print(i + ": " + getWeaponSlotItemName(PLAYER_OBJECT, i));
}
bool hasLinkedWeapons(int objectID)
Determine if an object has linked weapons (all turrets fire at the same time).
if(hasLinkedWeapons(PLAYER_OBJECT))
print("Linked weapon mounts");
else
print("Selectable weapon mounts");
float getWeaponAimingAngle(int objectID, int slotIndex=-1)
Get the aiming angle of a specified turret.
print("Current slot angle: " + getWeaponAimingAngle(PLAYER_OBJECT));
print("Slot 0: " + getWeaponAimingAngle(PLAYER_OBJECT, 0));
print("Slot 1: " + getWeaponAimingAngle(PLAYER_OBJECT, 1));
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).
vector2 getWeaponMountWorldPos(int objectID, int slotIndex=-1)
Get the world position of a specified turret mounting point.
print("Current slot pos: " + getWeaponMountWorldPos(PLAYER_OBJECT));
print("Slot 0: " + getWeaponMountWorldPos(PLAYER_OBJECT, 0));
print("Slot 1: " + getWeaponMountWorldPos(PLAYER_OBJECT, 1));
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.
vector2 getWeaponFireWorldPos(int objectID, int slotIndex=-1)
Get the world position of a specified turret firing point (end of barrel).
print("Current slot pos: " + getWeaponMountFirePos(PLAYER_OBJECT));
print("Slot 0: " + getWeaponMountFirePos(PLAYER_OBJECT, 0));
print("Slot 1: " + getWeaponMountFirePos(PLAYER_OBJECT, 1));
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.
bool getAutoWeaponSwitchingEnabled(int objectID)
Determine if auto weapon switching is enabled for an object.
print(getAutoWeaponSwitchingEnabled(1));
void setAutoWeaponSwitchingEnabled(int objectID, bool enable)
Enable or disable auto weapon switching for an object.
if(isServer())
{
setAutoWeaponSwitchingEnabled(1, false);
}
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.
Index