void CGrenade::DangerSoundThink( void ) { if (!IsInWorld()) { UTIL_Remove( this ); return; } CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, pev->velocity.Length( ), 0.2 ); pev->nextthink = gpGlobals->time + 0.2; if (pev->waterlevel != 0) { pev->velocity = pev->velocity * 0.5; } }
void TempSummon::UnSummon() { //ASSERT(!isPet()); if (isPet()) { ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT); ASSERT(!IsInWorld()); return; } Unit* owner = GetSummoner(); if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled) owner->ToCreature()->AI()->SummonedCreatureDespawn(this); AddObjectToRemoveList(); }
void Player::SendChatMessage(const char *format, ...) { if (!IsInWorld()) return; if (format) { va_list ap; char str [2048]; va_start(ap, format); vsnprintf(str, 2048, format, ap); va_end(ap); ChatHandler(GetSession()).SendSysMessage(str); } }
void TempSummon::RemoveFromWorld() { if (!IsInWorld()) return; if (m_Properties) if (uint32 slot = m_Properties->Slot) if (Unit* owner = GetSummoner()) if (owner->m_SummonSlot[slot] == GetGUID()) owner->m_SummonSlot[slot] = 0; //if (GetOwnerGUID()) // sLog.outError("Unit %u has owner guid when removed from world", GetEntry()); Creature::RemoveFromWorld(); }
void Transport::AddPassenger(WorldObject* passenger) { if (!IsInWorld()) return; if (_passengers.insert(passenger).second) { passenger->SetTransport(this); passenger->m_movementInfo.AddMovementFlag(MOVEMENTFLAG_ONTRANSPORT); passenger->m_movementInfo.transport.guid = GetGUID(); TC_LOG_DEBUG("entities.transport", "Object %s boarded transport %s.", passenger->GetName().c_str(), GetName().c_str()); if (Player* plr = passenger->ToPlayer()) sScriptMgr->OnAddPassenger(this, plr); } }
void Item::RemoveFromWorld() { // if we have an owner->send destroy if( m_owner != NULL ) { DestroyForPlayer( m_owner ); } if( !IsInWorld() ) return; m_mapMgr->RemoveObject( TO_OBJECT(this), false ); m_mapMgr = NULLMAPMGR; // update our event holder event_Relocate(); }
void Player::Reputation_OnTalk(FactionDBC * dbc) { // set faction visible if not visible if(!dbc || dbc->RepListId < 0) return; FactionReputation * rep = reputationByListId[dbc->RepListId]; if(!rep) return; if(!Visible(rep->flag)) { SetFlagVisible(rep->flag); if(IsInWorld()) m_session->OutPacket(SMSG_SET_FACTION_VISIBLE, 4, &dbc->RepListId); } }
void Item::RemoveFromWorld() { // if we have an owner->send destroy if( m_owner != NULL ) { DestroyForPlayer( m_owner ); } if( !IsInWorld() ) return; mSemaphoreTeleport = true; m_mapMgr->RemoveObject( this, false ); m_mapMgr = NULL; // update our event holder event_Relocate(); }
void CGrenade::DangerSoundThink( void ) { if( !IsInWorld( )) { UTIL_Remove( this ); return; } CSoundEnt::InsertSound( bits_SOUND_DANGER, GetAbsOrigin() + GetAbsVelocity() * 0.5, GetAbsVelocity().Length( ), 0.2 ); pev->nextthink = gpGlobals->time + 0.2; if( pev->waterlevel != 0 ) { Vector vecVelocity = GetAbsVelocity(); vecVelocity *= 0.5f; SetAbsVelocity( vecVelocity ); } }
void Vehicle::Despawn(uint32 delay, uint32 respawntime) { if(delay) { sEventMgr.AddEvent(TO_VEHICLE(this), &Vehicle::Despawn, (uint32)0, respawntime, EVENT_VEHICLE_RESPAWN, delay, 1,0); return; } if(!IsInWorld()) return; if(respawntime) { for(int i = 0; i < 8; i++) { if(m_passengers[i] != NULL) { if(m_passengers[i]->IsPlayer()) // Remove any passengers RemovePassenger(m_passengers[i]); else m_passengers[i]->Destruct(); } } /* get the cell with our SPAWN location. if we've moved cell this might break :P */ MapCell * pCell = m_mapMgr->GetCellByCoords(m_spawnLocation.x, m_spawnLocation.y); if(!pCell) pCell = m_mapCell; ASSERT(pCell); pCell->_respawnObjects.insert(TO_OBJECT(this)); sEventMgr.RemoveEvents(this); sEventMgr.AddEvent(m_mapMgr, &MapMgr::EventRespawnVehicle, TO_VEHICLE(this), pCell, EVENT_VEHICLE_RESPAWN, respawntime, 1, 0); Unit::RemoveFromWorld(false); m_position = m_spawnLocation; m_respawnCell=pCell; } else { Unit::RemoveFromWorld(true); SafeDelete(); } }
void TempSummon::UnSummon() { //ASSERT(!isPet()); if (isPet()) { if (((Pet*)this)->getPetType() == HUNTER_PET) ((Pet*)this)->Remove(PET_SLOT_ACTUAL_PET_SLOT); else ((Pet*)this)->Remove(PET_SLOT_OTHER_PET); ASSERT(!IsInWorld()); return; } Unit* owner = GetSummoner(); if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled) owner->ToCreature()->AI()->SummonedCreatureDespawn(this); AddObjectToRemoveList(); }
void Player::Reputation_OnTalk(FactionDBC* dbc) { // set faction visible if not visible if(dbc == NULL || dbc->RepListId < 0) return; FactionReputation* rep = reputationByListId[dbc->RepListId]; if(rep == NULL) return; if(SetFlagVisible(rep->flag, true) && IsInWorld()) { m_session->OutPacket(SMSG_SET_FACTION_VISIBLE, 4, &dbc->RepListId); #ifdef OPTIMIZED_PLAYER_SAVING save_Reputation(); #endif } }
void TempSummon::RemoveFromWorld() { if (!IsInWorld()) return; if (m_Properties) { int32 slot = m_Properties->Slot; if (slot > 0) if (Unit* owner = GetSummoner()) if (owner->m_SummonSlot[slot] == GetGUID()) owner->m_SummonSlot[slot] = 0; } //if (GetOwnerGUID()) // TC_LOG_ERROR("entities.unit", "Unit %u has owner guid when removed from world", GetEntry()); Creature::RemoveFromWorld(); }
Item::~Item() { sEventMgr.RemoveEvents( this ); EnchantmentMap::iterator itr; for( itr = Enchantments.begin(); itr != Enchantments.end(); ++itr ) { if( itr->second.Enchantment->type == 0 && itr->second.Slot == 0 && itr->second.ApplyTime == 0 && itr->second.Duration == 0 ) { delete itr->second.Enchantment; itr->second.Enchantment = NULL; } } if( IsInWorld() ) RemoveFromWorld(); m_owner = NULL; }
void CBaseGrenade::DangerSoundThink( void ) { if (!IsInWorld()) { Remove( ); return; } #if !defined( CLIENT_DLL ) CSoundEnt::InsertSound ( SOUND_DANGER, GetAbsOrigin() + GetAbsVelocity() * 0.5, GetAbsVelocity().Length( ), 0.2, this ); #endif SetNextThink( gpGlobals->curtime + 0.2 ); if (GetWaterLevel() != 0) { SetAbsVelocity( GetAbsVelocity() * 0.5 ); } }
void DynamicObject::Remove() { // remove aura from all targets DynamicObjectList::iterator jtr = targets.begin(); DynamicObjectList::iterator jend = targets.end(); Unit * target; while(jtr != jend) { target = GetMapMgr() ? GetMapMgr()->GetUnit(*jtr) : NULL; ++jtr; if (target != NULL) target->RemoveAura(m_spellProto->Id); } if(IsInWorld()) RemoveFromWorld(true); delete this; }
void AreaTrigger::RemoveFromWorld() { ///- Remove the AreaTrigger from the accessor and from all lists of objects in world if (IsInWorld()) { _isRemoved = true; if (Unit* caster = GetCaster()) caster->_UnregisterAreaTrigger(this); // Handle removal of all units, calling OnUnitExit & deleting auras if needed HandleUnitEnterExit({}); _ai->OnRemove(); WorldObject::RemoveFromWorld(); GetMap()->GetObjectsStore().Remove<AreaTrigger>(GetGUID()); } }
void CGib::WaitTillLand() { if (!IsInWorld()) { UTIL_Remove(this); return; } if (pev->velocity == g_vecZero) { SetThink(&CBaseEntity::SUB_StartFadeOut); pev->nextthink = gpGlobals->time + m_lifeTime; #ifndef REGAMEDLL_FIXES if (m_bloodColor != DONT_BLEED) CSoundEnt::InsertSound(bits_SOUND_MEAT, pev->origin, 384, 25); #endif } else pev->nextthink = gpGlobals->time + 0.5f; }
void CGrenade :: FragThink( void ) { if (!IsInWorld()) { UTIL_Remove( this ); return; } StudioFrameAdvance( ); pev->nextthink = gpGlobals->time + 0.1; CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin + pev->velocity * (pev->dmgtime - gpGlobals->time), 400, 0.1 ); if (pev->waterlevel != 0) { pev->velocity = pev->velocity * 0.5; pev->framerate = 0.2; } }
void Item::Destructor() { sEventMgr.RemoveEvents( shared_from_this() ); EnchantmentMap::iterator itr; for( itr = Enchantments.begin(); itr != Enchantments.end(); ++itr ) { if( itr->second.Enchantment->type == 0 && itr->second.Slot == 0 && itr->second.ApplyTime == 0 && itr->second.Duration == 0 ) { delete itr->second.Enchantment; itr->second.Enchantment = NULL; } } if( IsInWorld() ) RemoveFromWorld(); m_owner = NULLPLR; Object::Destructor(); }
void Pet::AddSpell(SpellEntry * sp) { // Cast on self if we're a passive spell if(sp->Attributes & 64) { Spell * spell = new Spell(this, sp, true, false); SpellCastTargets targets(this->GetGUID()); spell->prepare(&targets); mSpells[sp] = 0x0100; } else { mSpells[sp] = DEFAULT_SPELL_STATE; // Create the AI_Spell CreateAISpell(sp); } if(IsInWorld()) SendSpellsToOwner(); }
void DynamicObject::RemoveFromWorld() { // Remove the dynamicObject from the accessor if (IsInWorld()) { if (m_isWorldObject) { if (Unit *caster = GetCaster()) { if (caster->GetTypeId() == TYPEID_PLAYER) ((Player*)caster)->SetViewpoint(this, false); } else { sLog->outCrash("DynamicObject::RemoveFromWorld cannot find viewpoint owner"); } } WorldObject::RemoveFromWorld(); sObjectAccessor->RemoveObject(this); } }
void CMGrenade :: TumbleThink( void ) { if (!IsInWorld()) { UTIL_Remove( this->edict() ); return; } StudioFrameAdvance( ); pev->nextthink = gpGlobals->time + 0.1; if (pev->dmgtime <= gpGlobals->time) { SetThink( Detonate ); } if (pev->waterlevel != 0) { pev->velocity = pev->velocity * 0.5; pev->framerate = 0.2; } }
void Pet::AddToWorld() { ///- Register the pet for guid lookup if (!IsInWorld()) { ///- Register the pet for guid lookup sObjectAccessor->AddObject(this); Unit::AddToWorld(); AIM_Initialize(); } // Prevent stuck pets when zoning. Pets default to "follow" when added to world // so we'll reset flags and let the AI handle things if (GetCharmInfo() && GetCharmInfo()->HasCommandState(COMMAND_FOLLOW)) { GetCharmInfo()->SetIsCommandAttack(false); GetCharmInfo()->SetIsAtStay(false); GetCharmInfo()->SetIsFollowing(false); GetCharmInfo()->SetIsReturning(false); } }
void Player::HandleClusterRemove() { #ifdef CLUSTERING RemoveAllAuras(); if (IsInWorld()) RemoveFromWorld(); sEventMgr.AddEvent(this, &Player::Destructor, EVENT_UNK, 30000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT | EVENT_FLAG_DELETES_OBJECT); if (GetSession() != NULL) { GetSession()->SetPlayer(NULL); if (GetSession()->GetSocket() != NULL) { uint32 sessionid = GetSession()->GetSocket()->GetSessionId(); sClusterInterface.DestroySession(sessionid); } SetSession(NULL); } objmgr.RemovePlayer(this); #endif }
void AreaTrigger::InitCircularMovement(AreaTriggerCircularMovementInfo const& cmi, uint32 timeToTarget) { // Circular movement requires either a center position or an attached unit ASSERT(cmi.Center.is_initialized() || cmi.PathTarget.is_initialized()); // should be sent in object create packets only m_uint32Values[AREATRIGGER_TIME_TO_TARGET] = timeToTarget; _circularMovementInfo = cmi; _circularMovementInfo->TimeToTarget = timeToTarget; _circularMovementInfo->ElapsedTimeForMovement = 0; if (IsInWorld()) { WorldPackets::AreaTrigger::AreaTriggerRePath reshape; reshape.TriggerGUID = GetGUID(); reshape.AreaTriggerCircularMovement = _circularMovementInfo; SendMessageToSet(reshape.Write(), true); } }
void TempSummon::UnSummon(uint32 msTime) { if (msTime) { ForcedUnsummonDelayEvent *pEvent = new ForcedUnsummonDelayEvent(*this); m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime)); return; } //ASSERT(!isPet()); if (isPet()) { ((Pet*) this)->Remove(PET_SLOT_OTHER_PET); ASSERT(!IsInWorld()); return; } Unit* owner = GetSummoner(); if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled) owner->ToCreature()->AI()->SummonedCreatureDespawn(this); AddObjectToRemoveList(); }
void ActorRigid::RemoveFromWorld() { if( !IsInWorld() ) return; try{ Physics::PhysicsManager* PhysMan = Entresol::GetSingletonPtr()->GetPhysicsManager(); btSoftRigidDynamicsWorld* BWorld = PhysMan->_GetPhysicsWorldPointer(); BWorld->removeRigidBody(this->PhysicsRigidBody); DetachAllChildren(); }catch (...) { Entresol::GetSingletonPtr()->Log("Failed to locate PhysicsManager While Destructing ActorRigid. This is not a problem if already shutting down."); } //first remove any collision metadata /*if( !CurrentCollisions.empty() ) { PhysMan->RemoveCollisionsContainingActor(this); }// */ this->DetachFromGraphics(); }
void AreaTrigger::Remove() { if (IsInWorld()) { // TODO: Find a better place for this SpellInfo const* m_spellInfo = sSpellMgr->GetSpellInfo(GetUInt32Value(AREATRIGGER_FIELD_SPELL_ID)); if (!m_spellInfo) return; switch (m_spellInfo->Id) { case 116011: // Rune of Power : Remove the buff if caster is still in radius if (m_caster && m_caster->HasAura(116014)) m_caster->RemoveAura(116014); break; } SendObjectDeSpawnAnim(GetGUID()); RemoveFromWorld(); AddObjectToRemoveList(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFWeaponBaseGrenadeProj::DetonateThink( void ) { if ( !IsInWorld() ) { Remove( ); return; } if ( gpGlobals->curtime > m_flCollideWithTeammatesTime && m_bCollideWithTeammates == false ) { m_bCollideWithTeammates = true; } if ( gpGlobals->curtime > m_flDetonateTime ) { Detonate(); return; } SetNextThink( gpGlobals->curtime + 0.2 ); }