Ejemplo n.º 1
0
void Creature::OnRemoveCorpse()
{
	// time to respawn!
	if (IsInWorld() && (int32)m_mapMgr->GetInstanceID() == m_instanceId)
	{

		sLog.outDetail("Removing corpse of "I64FMT"...", GetGUID());
	   
			if((GetMapMgr()->GetMapInfo() && GetMapMgr()->GetMapInfo()->type == INSTANCE_RAID && this->proto && this->proto->boss) || m_noRespawn)
			{
				RemoveFromWorld(false, true);
			}
			else
			{
				if(proto && proto->RespawnTime)
					RemoveFromWorld(true, false);
				else
					RemoveFromWorld(false, true);
			}
		
	   
		setDeathState(DEAD);

		m_position = m_spawnLocation;
	}
	else
	{
		// if we got here it's pretty bad
	}
}
Ejemplo n.º 2
0
Item::~Item()
{
	if( loot != NULL )
	{
		delete loot;
		loot = NULL;
	}

	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;
		}
	}
	Enchantments.clear();

	if( IsInWorld() )
		RemoveFromWorld();

	m_owner = NULL;
}
Ejemplo n.º 3
0
void Vehicle::DeleteMe()
{
	if(IsInWorld())
		RemoveFromWorld(false, true);

	Destruct();
}
Ejemplo n.º 4
0
void Vehicle::Destruct()
{
	m_ppassengerCount = NULL;
	if( IsInWorld() )
		RemoveFromWorld(false, true);
	Creature::Destruct();
}
Ejemplo n.º 5
0
void DynamicObject::Remove()
{
    if (!IsInWorld())
    {
        delete this;
        return;
    }

    for (std::set< uint64 >::iterator itr = targets.begin(); itr != targets.end(); ++itr)
    {
        uint64 TargetGUID = *itr;

        if (Unit* target = m_mapMgr->GetUnit(TargetGUID))
            target->RemoveAura(m_spellProto->Id);
    }

    WorldPacket data(SMSG_GAMEOBJECT_DESPAWN_ANIM, 8);

    data << GetGUID();
    SendMessageToSet(&data, false);

    if (IsInWorld())
        RemoveFromWorld(true);

    if (u_caster != NULL && m_spellProto->ChannelInterruptFlags != 0)
    {
        u_caster->SetChannelSpellTargetGUID(0);
        u_caster->SetChannelSpellId(0);
    }

    delete this;
}
Ejemplo n.º 6
0
void GameObject::_Expire()
{
	if(IsInWorld())
		RemoveFromWorld(true);

	Destructor();
}
Ejemplo n.º 7
0
//This must be an event to stay in the correct context!
void Player::EventClusterMapChange(uint32 mapid, uint32 instanceid, LocationVector location)
{
	WorldPacket data;
	uint32 status = sInstanceMgr.PreTeleport(mapid, this, instanceid);
	if(status != INSTANCE_OK)
	{
		data.Initialize(SMSG_TRANSFER_ABORTED);
		data << mapid << status;
		GetSession()->SendPacket(&data);
		return;
	}

	if(instanceid)
		m_instanceId = instanceid;

	if(IsInWorld())
		RemoveFromWorld();

	data.Initialize(SMSG_NEW_WORLD);
	data << (uint32)mapid << location << location.o;
	GetSession()->SendPacket( &data );
	SetMapId(mapid);


	SetPlayerStatus(TRANSFER_PENDING);
	m_sentTeleportPosition = location;
	SetPosition(location);
	ResetHeartbeatCoords();
	z_axisposition = 0.0f;
}
Ejemplo n.º 8
0
void Corpse::Despawn()
{
    if (this->IsInWorld())
    {
        RemoveFromWorld(false);
    }
}
Ejemplo n.º 9
0
void Item::Virtual_Destructor()
{
	if( loot != NULL )
	{
		delete loot;
		loot = NULL;
	}

	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;
		}
	}
	Enchantments.clear();

	//don't want to keep context ....
	static_cast< EventableObject* >( this )->Virtual_Destructor();

	if( IsInWorld() )
		RemoveFromWorld();

	m_owner = NULL;
}
Ejemplo n.º 10
0
void DynamicObject::Remove() {
    if (IsInWorld()) {
        SendObjectDeSpawnAnim(GetGUID());
        RemoveFromWorld();
        AddObjectToRemoveList();
    }
}
Ejemplo n.º 11
0
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
    Map const* oldMap = GetMap();
    Relocate(x, y, z);

    for(PlayerSet::const_iterator itr = m_passengers.begin(); itr != m_passengers.end();)
    {
        Player* pPlayer = *itr;
        ++itr;

        if(pPlayer->isDead() && !pPlayer->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
            pPlayer->ResurrectPlayer(1.0f);

        pPlayer->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
    }

    //we need to create and save new Map object with 'newMapid' because if not done -> lead to invalid Map object reference...
    //player far teleport would try to create same instance, but we need it NOW for transport...

    RemoveFromWorld();
    ResetMap();
    Map * newMap = sMapMgr->CreateMap(newMapid, this, 0);
    SetMap(newMap);
    ASSERT(GetMap());
    AddToWorld();

    if(oldMap != newMap)
    {
        UpdateForMap(oldMap);
        UpdateForMap(newMap);
    }

    for(CreatureSet::iterator itr = m_NPCPassengerSet.begin(); itr != m_NPCPassengerSet.end(); ++itr)
        (*itr)->FarTeleportTo(newMap, x, y, z, (*itr)->GetOrientation());
}
Ejemplo n.º 12
0
void Creature::Update( uint32 p_time )
{
	Unit::Update( p_time );
	if(IsTotem() && isDead())
	{
		RemoveFromWorld(false, true);
		delete this;
		return;
	}

	if(m_corpseEvent)
	{
		sEventMgr.RemoveEvents(this);
		if(this->proto==NULL)
			sEventMgr.AddEvent(this, &Creature::OnRemoveCorpse, EVENT_CREATURE_REMOVE_CORPSE, 1000, 1, EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
		else if (this->creature_info->Rank == ELITE_WORLDBOSS)
			sEventMgr.AddEvent(this, &Creature::OnRemoveCorpse, EVENT_CREATURE_REMOVE_CORPSE, TIME_CREATURE_REMOVE_BOSSCORPSE, 1,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
		else if ( this->creature_info->Rank == ELITE_RAREELITE || this->creature_info->Rank == ELITE_RARE)
			sEventMgr.AddEvent(this, &Creature::OnRemoveCorpse, EVENT_CREATURE_REMOVE_CORPSE, TIME_CREATURE_REMOVE_RARECORPSE, 1,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);
		else
			sEventMgr.AddEvent(this, &Creature::OnRemoveCorpse, EVENT_CREATURE_REMOVE_CORPSE, TIME_CREATURE_REMOVE_CORPSE, 1,EVENT_FLAG_DO_NOT_EXECUTE_IN_WORLD_CONTEXT);

		m_corpseEvent=false;
	}
}
Ejemplo n.º 13
0
void Creature::DeleteMe()
{
	if(IsInWorld())
		RemoveFromWorld(false, true);

	delete this;
}
Ejemplo n.º 14
0
Critter::Critter(Type type, const RN::Vector3 &position) :
    _isFixedAndCantHaveChildren(false)
{
    SetPosition(position);
    SetRenderGroup(31);
    SetTag(kWHCritterTag);

    SetType(type);

    NavigationAgent *agent = new NavigationAgent();
    AddAttachment(agent);

    agent->Enable();
    agent->Release();

    RN::MessageCenter::GetSharedInstance()->AddObserver(kWHWorldSpawningStoppedMessage, [this](RN::Message *message) {
        RemoveFromWorld();
    }, this);

    RN::MessageCenter::GetSharedInstance()->AddObserver(RNCSTR("fuckoff"), [this](RN::Message *message) {

        RN::Value *value = static_cast<RN::Value *>(message->GetObject());
        SetTarget(value->GetValue<RN::Vector3>());

    }, this);
}
Ejemplo n.º 15
0
void GameObject::EndFishing(Player* player, bool abort )
{
	Spell * spell = player->GetCurrentSpell();
	
	if(spell)
	{
		if(abort)   // abort becouse of a reason
		{
			//FIXME: here 'failed' should appear over progress bar
			spell->cancel();
		}
		else		// spell ended
		{
			if (!(GetUInt32Value(GAMEOBJECT_FLAGS) & 32)) // if there was no loot
				spell->SendCastResult(SPELL_FAILED_NO_FISH);

			spell->SendChannelUpdate(0);
			spell->finish();

			/*if(this->IsInWorld())
				RemoveFromWorld();
			delete this;*/

			ExpireAndDelete();
			return;
		}
	}
	else // if this is called, and there is no spell so remove the gameobject
	{
		if(this->IsInWorld())
				RemoveFromWorld();
		delete this;
	}
}
Ejemplo n.º 16
0
 void ActorRigid::_Update()
 {
     StickyData* StickyD = GetPhysicsSettings()->GetStickyData();
     if(StickyD->CreationQueue.empty())
         return;
     RemoveFromWorld();
     AddToWorld();
     for( Whole X = 0 ; X < StickyD->CreationQueue.size() ; ++X )
     {
         StickyConstraintConstructionInfo& CurrInfo = StickyD->CreationQueue[X];
         /*ObjectPair NewPair(CurrInfo.ActA,CurrInfo.ActB);
         Collision* Col = Entresol::GetSingletonPtr()->GetPhysicsManager()->GetCollision(&NewPair);
         if(Col) Entresol::GetSingletonPtr()->GetPhysicsManager()->RemoveCollision(Col);//*/
         StickyConstraint* NewSticky = new StickyConstraint(CurrInfo.ActA,CurrInfo.ActB,CurrInfo.TransA,CurrInfo.TransB);
         NewSticky->SetAngularLimitLower(Vector3());
         NewSticky->SetAngularLimitUpper(Vector3());
         NewSticky->SetLinearLimitLower(Vector3());
         NewSticky->SetLinearLimitUpper(Vector3());
         /*NewSticky->SetUpperLinLimit(0.0);
         NewSticky->SetUpperAngLimit(0.0);
         NewSticky->SetLowerLinLimit(0.0);
         NewSticky->SetLowerAngLimit(0.0);//*/
         Entresol::GetSingletonPtr()->GetPhysicsManager()->_GetPhysicsWorldPointer()->addConstraint(NewSticky->GetConstraintBase(),true);
         StickyD->StickyConstraints.push_back(NewSticky);
         CurrInfo.ActA->GetPhysicsSettings()->GetStickyData()->StickyConstraints.push_back(NewSticky);
         NewSticky->GetConstraintBase()->setOverrideNumSolverIterations(100);
     }
     StickyD->CreationQueue.clear();
 }
Ejemplo n.º 17
0
void UWorld::RefreshStreamingLevels( const TArray<class ULevelStreaming*>& InLevelsToRefresh )
{
	// Reassociate levels in case we changed streaming behavior. Editor-only!
	if( GIsEditor )
	{
		// Load and associate levels if necessary.
		FlushLevelStreaming();

		// Remove all currently visible levels.
		for( int32 LevelIndex=0; LevelIndex<InLevelsToRefresh.Num(); LevelIndex++ )
		{
			ULevelStreaming* StreamingLevel = InLevelsToRefresh[LevelIndex];
			ULevel* LoadedLevel = StreamingLevel ? StreamingLevel->GetLoadedLevel() : nullptr;

			if( LoadedLevel &&
				LoadedLevel->bIsVisible )
			{
				RemoveFromWorld( LoadedLevel );
			}
		}

		// Load and associate levels if necessary.
		FlushLevelStreaming();

		// Update the level browser so it always contains valid data
		FEditorSupportDelegates::WorldChange.Broadcast();
	}
}
Ejemplo n.º 18
0
//------------------------------------------------------------------------------
//! Dtor
//! 
CBulletObjectAnimator::~CBulletObjectAnimator()
{
  RemoveFromWorld();
  SAFE_DELETE(bulletMesh);
  SAFE_DELETE(collisionShape);
  SAFE_DELETE(motionState);
  SAFE_DELETE(rigidBody);
}
Ejemplo n.º 19
0
void DynamicObject::Remove()
{
    if (IsInWorld())
    {
        RemoveFromWorld();
        AddObjectToRemoveList();
    }
}
Ejemplo n.º 20
0
void AreaTrigger::Remove()
{
    if (IsInWorld())
    {
        SendObjectDeSpawnAnim(GetGUID());
        RemoveFromWorld();
        AddObjectToRemoveList();
    }
}
Ejemplo n.º 21
0
void GameObject::_Expire()
{
	sEventMgr.RemoveEvents(this);
	if(IsInWorld())
		RemoveFromWorld();

	//sEventMgr.AddEvent(World::getSingletonPtr(), &World::DeleteObject, ((Object*)this), EVENT_DELETE_TIMER, 1000, 1);
	delete this;
}
Ejemplo n.º 22
0
void Pet::PetSafeDelete()
{
    if(this->IsInWorld())
    {
        // remove from world, and delete
        RemoveFromWorld();
    }

    sObjHolder.Delete<Pet>(this);
}
Ejemplo n.º 23
0
void Critter::Splatter()
{
    Retain();
    RemoveFromWorld();

    class Splatter splatter(GetWorldPosition(), _splatterColor);
    splatter.Activate();

    Release();
}
Ejemplo n.º 24
0
void GameObject::Delete()
{
    SendObjectDeSpawnAnim(GetGUID());

    SetUInt32Value(GAMEOBJECT_STATE, 1);
    SetUInt32Value(GAMEOBJECT_FLAGS, m_flags);

    SendDestroyObject(GetGUID());
    //TODO: set timestamp
    RemoveFromWorld();
    ObjectAccessor::Instance().AddObjectToRemoveList(this);
}
Ejemplo n.º 25
0
void DynamicObject::Delete()
{
    if (m_aura)
    {
        // dynObj may be removed in Aura::Remove - we cannot delete there
        // so recheck aura here
        if (!m_aura->IsRemoved())
            m_aura->_Remove(AURA_REMOVE_BY_DEFAULT);
        delete m_aura;
        m_aura = NULL;
    }
    SendObjectDeSpawnAnim(GetGUID());
    RemoveFromWorld();
    AddObjectToRemoveList();
}
Ejemplo n.º 26
0
void Creature::TotemExpire()
{
	if( totemOwner != NULL )
	{
		totemOwner->m_TotemSlots[totemSlot] = 0;
	}
	
	totemSlot = -1;
	totemOwner = NULL;

	if( IsInWorld() )
		RemoveFromWorld(false, true);

	SafeDelete();
}
Ejemplo n.º 27
0
void DynamicObject::Delete()
{
    WorldPacket data;

    data.Initialize(SMSG_GAMEOBJECT_DESPAWN_ANIM);
    data << GetGUID();
    SendMessageToSet(&data,true);

    data.Initialize(SMSG_DESTROY_OBJECT);
    data << GetGUID();
    SendMessageToSet(&data,true);

    m_PeriodicDamage = 0;
    m_PeriodicDamageTick = 0;
    RemoveFromWorld();
    ObjectAccessor::Instance().AddObjectToRemoveList(this);
}
Ejemplo n.º 28
0
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;
}
Ejemplo n.º 29
0
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();
}
Ejemplo n.º 30
0
void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z)
{
    Map const* oldMap = GetMap();
    Relocate(x, y, z);

    // we need to create and save new Map object with 'newMapid' because if not done -> lead to invalid Map object reference...
    // player far teleport would try to create same instance, but we need it NOW for transport...
    RemoveFromWorld();
    ResetMap();
    Map* newMap = sMapMgr->CreateBaseMap(newMapid);
    SetMap(newMap);
    ASSERT(GetMap());
    AddToWorld();

    for (UnitSet::iterator itr = _passengers.begin(); itr != _passengers.end();)
    {
        Unit* passenger = *itr;
        ++itr;

        switch (passenger->GetTypeId())
        {
            case TYPEID_UNIT:
                passenger->ToCreature()->FarTeleportTo(newMap, x, y, z, passenger->GetOrientation());
                break;
            case TYPEID_PLAYER:
                if (passenger->isDead() && !passenger->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST))
                    passenger->ToPlayer()->ResurrectPlayer(1.0f);
                passenger->ToPlayer()->TeleportTo(newMapid, x, y, z, GetOrientation(), TELE_TO_NOT_LEAVE_TRANSPORT);
                break;
        }
    }

    if (oldMap != newMap)
    {
        UpdateForMap(oldMap);
        UpdateForMap(newMap);
    }

    MoveToNextWayPoint();
}