Structs:WeaponSlots

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


The WeaponSlots struct contains functions that interact with weapon slots. PlayerInfo has a pointer to this an instance of this struct in its weapons field. As such, to access it from a PlayerPawn, for example, use player.weapons.

Methods

All WeaponSlots methods are defined as native, meaning their inner workings are handled on the C++ side of the engine.

Static

  • static void SetupWeaponSlots(PlayerPawn pp)
Sets up weapon slots for the specified PlayerPawn. PlayerPawn actors call this function on themselves in their PostBeginPlay.

Dynamic

These methods have to be called on a pointer to a WeaponSlots instance. One is always created for each player and stored in the weapons field of their PlayerInfo struct. As such, these methods require the player.weapons. prefix to be called.

  • bool, int, int LocateWeapon(class<Weapon> weap)
Checks whether the specified weapon class is assigned to a slot. Has 3 return values:
1. bool — true if the weapon is assigned to a slot
2. int — the number of the slot the weapon is assigned to (from 0 to 9, but 0 is actually the 10th slot in order)
3. int — the index of the weapon (i.e. its position in the slot, starting with 0).
  • class<Weapon> GetWeapon(int slot, int index)
Returns the class of a weapon in the specified slot and index.
  • int SlotSize(int slot)
Returns the number of weapons assigned to the specified slot.