mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Core/GameObjects: implement helper to set the charges of gameobjects
This commit is contained in:
@@ -74,6 +74,7 @@ GameObject::GameObject() : WorldObject(false), MapObject(),
|
||||
m_lootState = GO_NOT_READY;
|
||||
m_spawnedByDefault = true;
|
||||
m_usetimes = 0;
|
||||
_charges = 0;
|
||||
m_spellId = 0;
|
||||
m_cooldownTime = 0;
|
||||
m_prevGoState = GO_STATE_ACTIVE;
|
||||
@@ -282,6 +283,7 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, P
|
||||
m_prevGoState = go_state;
|
||||
SetGoState(go_state);
|
||||
SetGoArtKit(artKit);
|
||||
SetCharges(goinfo->GetCharges());
|
||||
|
||||
switch (goinfo->type)
|
||||
{
|
||||
@@ -574,9 +576,9 @@ void GameObject::Update(uint32 diff)
|
||||
SetLootState(GO_ACTIVATED, target);
|
||||
|
||||
}
|
||||
else if (uint32 max_charges = goInfo->GetCharges())
|
||||
else if (_charges)
|
||||
{
|
||||
if (m_usetimes >= max_charges)
|
||||
if (m_usetimes >= _charges)
|
||||
{
|
||||
m_usetimes = 0;
|
||||
SetLootState(GO_JUST_DEACTIVATED); // can be despawned or destroyed
|
||||
|
||||
@@ -201,6 +201,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
|
||||
|
||||
void AddUniqueUse(Player* player);
|
||||
void AddUse() { ++m_usetimes; }
|
||||
void SetCharges(uint32 charges) { _charges = charges; }
|
||||
|
||||
uint32 GetUseCount() const { return m_usetimes; }
|
||||
uint32 GetUniqueUseCount() const { return m_unique_users.size(); }
|
||||
@@ -324,6 +325,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
|
||||
ObjectGuid m_ritualOwnerGUID; // used for GAMEOBJECT_TYPE_SUMMONING_RITUAL where GO is not summoned (no owner)
|
||||
GuidSet m_unique_users;
|
||||
uint32 m_usetimes;
|
||||
uint32 _charges;
|
||||
|
||||
typedef std::map<uint32, ObjectGuid> ChairSlotAndUser;
|
||||
ChairSlotAndUser ChairListSlots;
|
||||
|
||||
Reference in New Issue
Block a user