void DynamicObject::Delete() { SendObjectDeSpawnAnim(GetGUID()); SendDestroyObject(GetGUID()); ObjectAccessor::Instance().AddObjectToRemoveList(this); }
void GameObject::Refresh() { // not refresh despawned not casted GO (despawned casted GO destroyed in all cases anyway) if(m_respawnTime > 0 && !GetOwnerGUID()) return; SendDestroyObject(GetGUID()); MapManager::Instance().GetMap(GetMapId(), this)->Add(this); }
void GameObject::Delete() { SendObjectDeSpawnAnim(GetGUID()); SetUInt32Value(GAMEOBJECT_STATE, 1); SetUInt32Value(GAMEOBJECT_FLAGS, m_flags); SendDestroyObject(GetGUID()); //TODO: set timestamp ObjectAccessor::Instance().AddObjectToRemoveList(this); }
void Totem::UnSummon() { if (m_type == TOTEM_LAST_BURST) this->CastSpell(this, m_spell, true); SendObjectDeSpawnAnim(GetGUID()); SendDestroyObject(GetGUID()); CombatStop(); RemoveAurasDueToSpell(m_spell); Unit *owner = this->GetOwner(); if (owner) owner->RemoveAurasDueToSpell(m_spell); ObjectAccessor::Instance().AddObjectToRemoveList(this); }
void Summon::OnPreRemoveFromWorld() { if (owner == NULL) return; if (GetCreatedBySpell() != 0) owner->RemoveAura(GetCreatedBySpell()); if (summonslot != -1) owner->summonhandler.RemoveSummonFromSlot(summonslot, false); else owner->summonhandler.RemoveSummon(this); summonslot = -1; owner = NULL; SendDestroyObject(); }
void GameObject::Update(uint32 p_time) { if (GUID_HIPART(GetGUID()) == HIGHGUID_TRANSPORT) { //((Transport*)this)->Update(p_time); return; } switch (m_lootState) { case GO_NOT_READY: if (GetGoType()==17) { // fishing code (bobber ready) if( time(NULL) > m_respawnTime - FISHING_BOBBER_READY_TIME ) { // splash bobber (bobber ready now) Unit* caster = GetOwner(); if(caster && caster->GetTypeId()==TYPEID_PLAYER) { SetUInt32Value(GAMEOBJECT_STATE, 0); SetUInt32Value(GAMEOBJECT_FLAGS, 32); UpdateData udata; WorldPacket packet; BuildValuesUpdateBlockForPlayer(&udata,((Player*)caster)); udata.BuildPacket(&packet); ((Player*)caster)->GetSession()->SendPacket(&packet); WorldPacket data; data.Initialize(SMSG_GAMEOBJECT_CUSTOM_ANIM); data << GetGUID(); data << (uint32)(0); ((Player*)caster)->SendMessageToSet(&data,true); } m_lootState = GO_CLOSED; // can be succesfully open with some chance } return; } m_lootState = GO_CLOSED; // for not bobber is same as GO_CLOSED // NO BREAK case GO_CLOSED: if (m_respawnTime > 0) // timer on { if (m_respawnTime <= time(NULL)) // timer expired { m_respawnTime = 0; m_SkillupList.clear(); switch (GetGoType()) { case GAMEOBJECT_TYPE_FISHINGNODE: // can't fish now { Unit* caster = GetOwner(); if(caster && caster->GetTypeId()==TYPEID_PLAYER) { if(caster->m_currentSpell) { caster->m_currentSpell->SendChannelUpdate(0); caster->m_currentSpell->finish(false); } WorldPacket data; data.Initialize(SMSG_FISH_NOT_HOOKED); ((Player*)caster)->GetSession()->SendPacket(&data); } m_lootState = GO_LOOTED; // can be delete return; } case GAMEOBJECT_TYPE_DOOR: SetUInt32Value (GAMEOBJECT_FLAGS, m_flags); SetUInt32Value (GAMEOBJECT_STATE, 1); break; case GAMEOBJECT_TYPE_TRAP: break; default: if(GetOwnerGUID()) // despawn timer { m_respawnTime = 0; Delete(); return; } // respawn timer MapManager::Instance().GetMap(GetMapId(), this)->Add(this); break; } } } break; case GO_OPEN: break; case GO_LOOTED: if(GetOwnerGUID()) { m_respawnTime = 0; Delete(); return; } loot.clear(); SetLootState(GO_CLOSED); SendDestroyObject(GetGUID()); m_respawnTime = time(NULL) + m_respawnDelayTime; // if option not set then object will be ssaved at grif unload if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY)) SaveRespawnTime(); break; } SpellEntry const *createSpell = m_spellId ? sSpellStore.LookupEntry(m_spellId) : NULL; if (!createSpell) return; int i; for (i = 0; i < 3; i++) if (createSpell->Effect[i] == SPELL_EFFECT_SUMMON_OBJECT_SLOT1) break; if (i<3) { // traps CellPair p(MaNGOS::ComputeCellPair(GetPositionX(),GetPositionY())); Cell cell = RedZone::GetZone(p); cell.data.Part.reserved = ALL_DISTRICT; Unit* owner = GetOwner(); if (!owner) { m_respawnTime = 0; // to prevent save respawn timer Delete(); return; } Unit* ok = NULL; // pointer to appropriate target if found any float radius = GetRadius(sSpellRadiusStore.LookupEntry(createSpell->EffectRadiusIndex[i])); MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck u_check(this, owner, radius); MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck> checker(ok, u_check); CellLock<GridReadGuard> cell_lock(cell, p); // search unfriedly creature { TypeContainerVisitor<MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, GridTypeMapContainer > grid_object_checker(checker); cell_lock->Visit(cell_lock, grid_object_checker, *MapManager::Instance().GetMap(GetMapId(), this)); } // or unfriendly player/pet if(!ok) { TypeContainerVisitor<MaNGOS::UnitSearcher<MaNGOS::AnyUnfriendlyUnitInObjectRangeCheck>, WorldTypeMapContainer > world_object_checker(checker); cell_lock->Visit(cell_lock, world_object_checker, *MapManager::Instance().GetMap(GetMapId(), this)); } if (ok) { owner->CastSpell(ok, GetGOInfo()->sound3, true); m_respawnTime = 0; // to prevent save respawn timer Delete(); } } if (m_usetimes >= 5) { m_respawnTime = 0; // to prevent save respawn timer Delete(); } }