2015-09-30 02:56:11 +02:00
|
|
|
#ifndef _MISC_WEAPON_HPP_
|
|
|
|
#define _MISC_WEAPON_HPP_
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
#include "Shared.hpp"
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
|
namespace SqMod {
|
|
|
|
|
2015-10-29 21:58:49 +01:00
|
|
|
/* ------------------------------------------------------------------------------------------------
|
|
|
|
* 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:
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* 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;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Default constructor.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon();
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Construct an instance of this type and reference the model specified.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon(SQInt32 id);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Construct an instance of this type and reference the model specified.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon(SQInt32 id, SQInt32 ammo);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Construct an instance of this type and reference the model extracted from the specified name.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon(const SQChar * name, SQInt32 id, SQInt32 ammo);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy constructor.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon(const CWeapon & w);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move constructor.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon(CWeapon && w);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Destructor.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
~CWeapon();
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Copy assignment operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon & operator = (const CWeapon & w);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Move assignment operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon & operator = (CWeapon && w);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Model identifier assignment operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon & operator = (SQInt32 id);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Equality comparison operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator == (const CWeapon & w) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Inequality comparison operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator != (const CWeapon & w) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Less than comparison operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator < (const CWeapon & w) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Greater than comparison operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator > (const CWeapon & w) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Less than or equal comparison operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator <= (const CWeapon & w) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Greater than or equal comparison operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator >= (const CWeapon & w) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2015-11-01 04:36:03 +01:00
|
|
|
* Implicit conversion to weapon identifier.
|
2015-10-29 21:58:49 +01:00
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
operator SQInt32 () const
|
2015-10-29 21:58:49 +01:00
|
|
|
{
|
|
|
|
return m_ID;
|
|
|
|
}
|
|
|
|
|
2015-11-01 04:36:03 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Implicit conversion to weapon identifier.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
operator Int64 () const
|
2015-11-01 04:36:03 +01:00
|
|
|
{
|
|
|
|
return _SCI64(m_ID);
|
|
|
|
}
|
|
|
|
|
2015-10-29 21:58:49 +01:00
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Implicit conversion to boolean.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
operator bool () const
|
2015-10-29 21:58:49 +01:00
|
|
|
{
|
|
|
|
return IsWeaponValid(m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Negation operator.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool operator ! () const
|
2015-10-29 21:58:49 +01:00
|
|
|
{
|
|
|
|
return !IsWeaponValid(m_ID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Used by the script to compare two instances of this type.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInteger Cmp(const CWeapon & w) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Convert this type to a string.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
const SQChar * ToString() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the identifier referenced by this instance.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInteger GetID() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Change the identifier referenced by this instance.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetID(SQInt32 id);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the identifier that this insance should reference and
|
|
|
|
* get a reference to the instance to chain operations.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
CWeapon & SetnGet(SQInt32 id);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the global tag.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
const SQChar * GetGlobalTag() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Change the global tag.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetGlobalTag(const SQChar * tag) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the global data.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
SqObj & GetGlobalData() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Change the global data.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetGlobalData(SqObj & data) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the local tag.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
const SQChar * GetLocalTag() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Change the local tag.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetLocalTag(const SQChar * tag);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the local data.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
SqObj & GetLocalData();
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Change the local data.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetLocalData(SqObj & data);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* See whether the referenced model identifier is valid.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool IsValid() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the name of the referenced model.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
const SQChar * GetName() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Change the identifier of the referenced model.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetName(const SQChar * name);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the ammount of ammo associated with this instance.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
SQInteger GetAmmo() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Change the ammount of ammo associated with this instance.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetAmmo(SQInt32 amount);
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* 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-11-01 04:48:01 +01:00
|
|
|
bool IsNatural() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Retrieve the value in the specified field from the weapon data.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
SQFloat GetDataValue(SQInt32 field) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Change the value in the specified field from the weapon data.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetDataValue(SQInt32 field, SQFloat value) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Reset the data for the referenced weapon identifier.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void ResetData() const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Reset the foe;d data data for the referenced weapon identifier.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void ResetData(SQInt32 field) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* See whether the data at the specified field was modified.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
bool IsDataModified(SQInt32 field) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the weapon of the specified player instance to the referenced weapon identifier.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetOn(const Reference< CPlayer > & player) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Give the referenced weapon identifier to the specified player instance.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void GiveTo(const Reference< CPlayer > & player) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Set the weapon of the specified player instance to the referenced weapon identifier.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void SetOn(const Reference< CPlayer > & player, SQInt32 ammo) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Give the referenced weapon identifier to the specified player instance.
|
|
|
|
*/
|
2015-11-01 04:48:01 +01:00
|
|
|
void GiveTo(const Reference< CPlayer > & player, SQInt32 ammo) const;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
2015-09-30 02:56:11 +02:00
|
|
|
private:
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* The identifier of the referenced model.
|
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
SQInt32 m_ID;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* The ammo associated with this instance.
|
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
SQInt32 m_Ammo;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* The local tag associated with this instance
|
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
SqTag m_Tag;
|
2015-10-29 21:58:49 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* The local data associated with this instance.
|
|
|
|
*/
|
2015-09-30 02:56:11 +02:00
|
|
|
SqObj m_Data;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // Namespace:: SqMod
|
|
|
|
|
|
|
|
#endif // _MISC_WEAPON_HPP_
|