1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 16:57:16 +01:00
SqMod/source/Misc/Weapon.hpp

294 lines
11 KiB
C++
Raw Normal View History

2015-09-30 02:56:11 +02:00
#ifndef _MISC_WEAPON_HPP_
#define _MISC_WEAPON_HPP_
// ------------------------------------------------------------------------------------------------
#include "Shared.hpp"
// ------------------------------------------------------------------------------------------------
namespace SqMod {
/* ------------------------------------------------------------------------------------------------
* Class responsible for managing and interacting with weapon models.
*/
2015-09-30 02:56:11 +02:00
class CWeapon : public IdentifierStorage< CWeapon, SQMOD_WEAPONID_CAP >
{
public:
/* --------------------------------------------------------------------------------------------
* Helper member for times when a null reference to an instance of this type is needed.
*/
2015-09-30 02:56:11 +02:00
static const CWeapon NIL;
/* --------------------------------------------------------------------------------------------
* Default constructor.
*/
2015-09-30 02:56:11 +02:00
CWeapon() noexcept;
/* --------------------------------------------------------------------------------------------
* Construct an instance of this type and reference the model specified.
*/
2015-09-30 02:56:11 +02:00
CWeapon(SQInt32 id) noexcept;
/* --------------------------------------------------------------------------------------------
* Construct an instance of this type and reference the model specified.
*/
2015-09-30 02:56:11 +02:00
CWeapon(SQInt32 id, SQInt32 ammo) noexcept;
/* --------------------------------------------------------------------------------------------
* Construct an instance of this type and reference the model extracted from the specified name.
*/
2015-09-30 02:56:11 +02:00
CWeapon(const SQChar * name, SQInt32 id, SQInt32 ammo) noexcept;
/* --------------------------------------------------------------------------------------------
* Copy constructor.
*/
2015-09-30 02:56:11 +02:00
CWeapon(const CWeapon & w) noexcept;
/* --------------------------------------------------------------------------------------------
* Move constructor.
*/
2015-09-30 02:56:11 +02:00
CWeapon(CWeapon && w) noexcept;
/* --------------------------------------------------------------------------------------------
* Destructor.
*/
2015-09-30 02:56:11 +02:00
~CWeapon() noexcept;
/* --------------------------------------------------------------------------------------------
* Copy assignment operator.
*/
2015-09-30 02:56:11 +02:00
CWeapon & operator = (const CWeapon & w) noexcept;
/* --------------------------------------------------------------------------------------------
* Move assignment operator.
*/
2015-09-30 02:56:11 +02:00
CWeapon & operator = (CWeapon && w) noexcept;
/* --------------------------------------------------------------------------------------------
* Model identifier assignment operator.
*/
2015-09-30 02:56:11 +02:00
CWeapon & operator = (SQInt32 id) noexcept;
/* --------------------------------------------------------------------------------------------
* Equality comparison operator.
*/
2015-09-30 02:56:11 +02:00
bool operator == (const CWeapon & w) const noexcept;
/* --------------------------------------------------------------------------------------------
* Inequality comparison operator.
*/
2015-09-30 02:56:11 +02:00
bool operator != (const CWeapon & w) const noexcept;
/* --------------------------------------------------------------------------------------------
* Less than comparison operator.
*/
2015-09-30 02:56:11 +02:00
bool operator < (const CWeapon & w) const noexcept;
/* --------------------------------------------------------------------------------------------
* Greater than comparison operator.
*/
2015-09-30 02:56:11 +02:00
bool operator > (const CWeapon & w) const noexcept;
/* --------------------------------------------------------------------------------------------
* Less than or equal comparison operator.
*/
2015-09-30 02:56:11 +02:00
bool operator <= (const CWeapon & w) const noexcept;
/* --------------------------------------------------------------------------------------------
* Greater than or equal comparison operator.
*/
2015-09-30 02:56:11 +02:00
bool operator >= (const CWeapon & w) const noexcept;
/* --------------------------------------------------------------------------------------------
* Implicit conversion to model identifier.
*/
operator SQInt32 () const noexcept
{
return m_ID;
}
/* --------------------------------------------------------------------------------------------
* Implicit conversion to boolean.
*/
operator bool () const noexcept
{
return IsWeaponValid(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Negation operator.
*/
bool operator ! () const noexcept
{
return !IsWeaponValid(m_ID);
}
/* --------------------------------------------------------------------------------------------
* Used by the script to compare two instances of this type.
*/
2015-09-30 02:56:11 +02:00
SQInteger Cmp(const CWeapon & w) const noexcept;
/* --------------------------------------------------------------------------------------------
* Convert this type to a string.
*/
2015-09-30 02:56:11 +02:00
const SQChar * ToString() const noexcept;
/* --------------------------------------------------------------------------------------------
* Retrieve the identifier referenced by this instance.
*/
2015-09-30 02:56:11 +02:00
SQInteger GetID() const noexcept;
/* --------------------------------------------------------------------------------------------
* Change the identifier referenced by this instance.
*/
2015-09-30 02:56:11 +02:00
void SetID(SQInt32 id) noexcept;
/* --------------------------------------------------------------------------------------------
* Set the identifier that this insance should reference and
* get a reference to the instance to chain operations.
*/
2015-09-30 02:56:11 +02:00
CWeapon & SetnGet(SQInt32 id) noexcept;
/* --------------------------------------------------------------------------------------------
* Retrieve the global tag.
*/
2015-09-30 02:56:11 +02:00
const SQChar * GetGlobalTag() const noexcept;
/* --------------------------------------------------------------------------------------------
* Change the global tag.
*/
2015-09-30 02:56:11 +02:00
void SetGlobalTag(const SQChar * tag) const noexcept;
/* --------------------------------------------------------------------------------------------
* Retrieve the global data.
*/
2015-09-30 02:56:11 +02:00
SqObj & GetGlobalData() const noexcept;
/* --------------------------------------------------------------------------------------------
* Change the global data.
*/
2015-09-30 02:56:11 +02:00
void SetGlobalData(SqObj & data) const noexcept;
/* --------------------------------------------------------------------------------------------
* Retrieve the local tag.
*/
2015-09-30 02:56:11 +02:00
const SQChar * GetLocalTag() const noexcept;
/* --------------------------------------------------------------------------------------------
* Change the local tag.
*/
2015-09-30 02:56:11 +02:00
void SetLocalTag(const SQChar * tag) noexcept;
/* --------------------------------------------------------------------------------------------
* Retrieve the local data.
*/
2015-09-30 02:56:11 +02:00
SqObj & GetLocalData() noexcept;
/* --------------------------------------------------------------------------------------------
* Change the local data.
*/
2015-09-30 02:56:11 +02:00
void SetLocalData(SqObj & data) noexcept;
/* --------------------------------------------------------------------------------------------
* See whether the referenced model identifier is valid.
*/
2015-09-30 02:56:11 +02:00
bool IsValid() const noexcept;
/* --------------------------------------------------------------------------------------------
* Retrieve the name of the referenced model.
*/
2015-09-30 02:56:11 +02:00
const SQChar * GetName() const noexcept;
/* --------------------------------------------------------------------------------------------
* Change the identifier of the referenced model.
*/
void SetName(const SQChar * name) noexcept;
/* --------------------------------------------------------------------------------------------
* Retrieve the ammount of ammo associated with this instance.
*/
2015-09-30 02:56:11 +02:00
SQInteger GetAmmo() const noexcept;
/* --------------------------------------------------------------------------------------------
* Change the ammount of ammo associated with this instance.
*/
2015-09-30 02:56:11 +02:00
void SetAmmo(SQInt32 amount) noexcept;
/* --------------------------------------------------------------------------------------------
* See whether the referenced weapon identifier points to a weapon that may not be used by
* another player to perform a kill. Such as a player fall, drown, explosion etc.
*/
2015-09-30 02:56:11 +02:00
bool IsNatural() const noexcept;
/* --------------------------------------------------------------------------------------------
* Retrieve the value in the specified field from the weapon data.
*/
2015-09-30 02:56:11 +02:00
SQFloat GetDataValue(SQInt32 field) const noexcept;
/* --------------------------------------------------------------------------------------------
* Change the value in the specified field from the weapon data.
*/
2015-09-30 02:56:11 +02:00
void SetDataValue(SQInt32 field, SQFloat value) const noexcept;
/* --------------------------------------------------------------------------------------------
* Reset the data for the referenced weapon identifier.
*/
2015-09-30 02:56:11 +02:00
void ResetData() const noexcept;
/* --------------------------------------------------------------------------------------------
* Reset the foe;d data data for the referenced weapon identifier.
*/
2015-09-30 02:56:11 +02:00
void ResetData(SQInt32 field) const noexcept;
/* --------------------------------------------------------------------------------------------
* See whether the data at the specified field was modified.
*/
2015-09-30 02:56:11 +02:00
bool IsDataModified(SQInt32 field) const noexcept;
/* --------------------------------------------------------------------------------------------
* Set the weapon of the specified player instance to the referenced weapon identifier.
*/
2015-09-30 02:56:11 +02:00
void SetOn(const Reference< CPlayer > & player) const noexcept;
/* --------------------------------------------------------------------------------------------
* Give the referenced weapon identifier to the specified player instance.
*/
2015-09-30 02:56:11 +02:00
void GiveTo(const Reference< CPlayer > & player) const noexcept;
/* --------------------------------------------------------------------------------------------
* Set the weapon of the specified player instance to the referenced weapon identifier.
*/
2015-09-30 02:56:11 +02:00
void SetOn(const Reference< CPlayer > & player, SQInt32 ammo) const noexcept;
/* --------------------------------------------------------------------------------------------
* Give the referenced weapon identifier to the specified player instance.
*/
2015-09-30 02:56:11 +02:00
void GiveTo(const Reference< CPlayer > & player, SQInt32 ammo) const noexcept;
2015-09-30 02:56:11 +02:00
private:
/* --------------------------------------------------------------------------------------------
* The identifier of the referenced model.
*/
2015-09-30 02:56:11 +02:00
SQInt32 m_ID;
/* --------------------------------------------------------------------------------------------
* The ammo associated with this instance.
*/
2015-09-30 02:56:11 +02:00
SQInt32 m_Ammo;
/* --------------------------------------------------------------------------------------------
* The local tag associated with this instance
*/
2015-09-30 02:56:11 +02:00
SqTag m_Tag;
/* --------------------------------------------------------------------------------------------
* The local data associated with this instance.
*/
2015-09-30 02:56:11 +02:00
SqObj m_Data;
};
} // Namespace:: SqMod
#endif // _MISC_WEAPON_HPP_