rendered paste bodyIndex: src/game/GameObject.cpp
===================================================================
--- src/game/GameObject.cpp (revision 5320)
+++ src/game/GameObject.cpp (working copy)
@@ -49,6 +49,7 @@
m_spawnedByDefault = true;
m_usetimes = 0;
m_spellId = 0;
+ m_charges=0;
}
GameObject::~GameObject()
Index: src/game/GameObject.h
===================================================================
--- src/game/GameObject.h (revision 5320)
+++ src/game/GameObject.h (working copy)
@@ -166,6 +166,8 @@
void Delete();
void SetSpellId(uint32 id) { m_spellId = id;}
uint32 GetSpellId() const { return m_spellId;}
+ void SetCharges(uint32 charges) { m_charges=charges; }
+ uint32 GetCharges() { return m_charges; }
void getFishLoot(Loot *loot);
uint32 GetGoType() const { return GetUInt32Value(GAMEOBJECT_TYPE_ID); }
@@ -196,6 +198,7 @@
GridReference<GameObject> &GetGridRef() { return m_gridRef; }
protected:
+ uint32 m_charges;
uint32 m_spellId;
time_t m_respawnTime; // (secs) time of next respawn (or despawn if GO have owner()),
uint32 m_respawnDelayTime; // (secs) if 0 then current GO state no dependent from timer
Index: src/game/SpellEffects.cpp
===================================================================
--- src/game/SpellEffects.cpp (revision 5320)
+++ src/game/SpellEffects.cpp (working copy)
@@ -1339,6 +1339,13 @@
pGameObj->SetOwnerGUID(m_caster->GetGUID() );
pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() );
pGameObj->SetSpellId(m_spellInfo->Id);
+ if(pGameObj->GetGoType() == GAMEOBJECT_TYPE_SPELLCASTER)
+ {
+ if(pGameObj->GetGOInfo()->data1 > 0)
+ pGameObj->SetCharges(pGameObj->GetGOInfo()->data1);
+ else
+ pGameObj->SetCharges(m_spellInfo->rangeIndex);
+ }
DEBUG_LOG("AddObject at SpellEfects.cpp EffectDummy\n");
MapManager::Instance().GetMap(creatureTarget->GetMapId(), pGameObj)->Add(pGameObj);
@@ -3808,7 +3815,15 @@
int32 duration = GetSpellDuration(m_spellInfo);
pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0);
pGameObj->SetSpellId(m_spellInfo->Id);
+ if(pGameObj->GetGoType() == GAMEOBJECT_TYPE_SPELLCASTER)
+ {
+ if(pGameObj->GetGOInfo()->data1 > 0)
+ pGameObj->SetCharges(pGameObj->GetGOInfo()->data1);
+ else
+ pGameObj->SetCharges(m_spellInfo->rangeIndex);
+ }
+
m_caster->AddGameObject(pGameObj);
MapManager::Instance().GetMap(pGameObj->GetMapId(), pGameObj)->Add(pGameObj);
//END
@@ -4103,6 +4118,13 @@
int32 duration = GetSpellDuration(m_spellInfo);
pGameObj->SetRespawnTime(duration > 0 ? duration/1000 : 0);
pGameObj->SetSpellId(m_spellInfo->Id);
+ if(pGameObj->GetGoType() == GAMEOBJECT_TYPE_SPELLCASTER)
+ {
+ if(pGameObj->GetGOInfo()->data1 > 0)
+ pGameObj->SetCharges(pGameObj->GetGOInfo()->data1);
+ else
+ pGameObj->SetCharges(m_spellInfo->rangeIndex);
+ }
pGameObj->SetLootState(GO_CLOSED);
m_caster->AddGameObject(pGameObj);
@@ -4615,6 +4637,13 @@
pGameObj->SetUInt32Value(GAMEOBJECT_LEVEL, m_caster->getLevel() );
pGameObj->SetSpellId(m_spellInfo->Id);
+ if(pGameObj->GetGoType() == GAMEOBJECT_TYPE_SPELLCASTER)
+ {
+ if(pGameObj->GetGOInfo()->data1 > 0)
+ pGameObj->SetCharges(pGameObj->GetGOInfo()->data1);
+ else
+ pGameObj->SetCharges(m_spellInfo->rangeIndex);
+ }
DEBUG_LOG("AddObject at SpellEfects.cpp EffectTransmitted\n");
//m_caster->AddGameObject(pGameObj);
Index: src/game/SpellHandler.cpp
===================================================================
--- src/game/SpellHandler.cpp (revision 5320)
+++ src/game/SpellHandler.cpp (working copy)
@@ -289,11 +289,18 @@
info = obj->GetGOInfo();
if(info)
{
+ sLog.outError("Object entry: %u, charges: %u cast spells, check it", obj->GetEntry(), obj->GetCharges());
spellId = info->data0;
if (spellId == 0)
spellId = info->data3;
-
- //guid=_player->GetGUID();
+ if(uint32 charges_cur = obj->GetCharges())
+ {
+ if(!--charges_cur)
+ obj->Delete();
+ else
+ obj->SetCharges(--charges_cur);
+ }
+ sLog.outError("Object entry: %u, charges: %u cansel cast spells", obj->GetEntry(), obj->GetCharges());
}
break;
Index: src/shared/Database/DBCStructure.h
===================================================================
--- src/shared/Database/DBCStructure.h (revision 5320)
+++ src/shared/Database/DBCStructure.h (working copy)
@@ -446,7 +446,7 @@
uint32 manaCostPerlevel; // 36
uint32 manaPerSecond; // 37
uint32 manaPerSecondPerLevel; // 38
- uint32 rangeIndex; // 39
+ uint32 rangeIndex; // 39 // Charges
float speed; // 40
uint32 modalNextSpell; // 41
uint32 StackAmount; // 42