Ejemplo n.º 1
0
void DropFlag(Player*  pPlayer, uint32 spellID)
{
	if( !pPlayer || spellID != SILITHYST_SPELL )
		return;
	uint32 triggerID = pPlayer->GetTeam() == ALLIANCE ? ALLIANCE_RETURN : HORDE_RETURN;
	// we have to use AreaTrigger.dbc here
	AreaTrigger* pAreaTrigger = AreaTriggerStorage.LookupEntry( triggerID );
	if( pAreaTrigger )
		if( pPlayer->CalcDistance(pAreaTrigger->x,pAreaTrigger->y,pAreaTrigger->z) > 10.0f )
		{
			GameObject* pGo = pPlayer->GetMapMgr()->GetInterface()->SpawnGameObject(SILITHYST_MOUND, pPlayer->GetPositionX(), pPlayer->GetPositionY(), pPlayer->GetPositionZ(), 0, true, 0, 0);
			if( pGo == NULL )
			{
				pGo->Destructor();
				pGo = NULL;
			}
		};
}
Ejemplo n.º 2
0
bool ChatHandler::HandleGODelete(const char *args, WorldSession *m_session)
{
	GameObject* GObj = m_session->GetPlayer()->m_GM_SelectedGO;
	if( !GObj )
	{
		RedSystemMessage(m_session, "No selected GameObject...");
		return true;
	}

	if(GObj->m_spawn != 0 && GObj->m_spawn->entry == GObj->GetEntry())
	{
		uint32 cellx=float2int32(((_maxX-GObj->m_spawn->x)/_cellSize));
		uint32 celly=float2int32(((_maxY-GObj->m_spawn->y)/_cellSize));

		GObj->DeleteFromDB();

		if(cellx < _sizeX && celly < _sizeY)
		{
			CellSpawns * c = GObj->GetMapMgr()->GetBaseMap()->GetSpawnsListAndCreate(cellx, celly);
			GOSpawnList::iterator itr,itr2;
			for(itr = c->GOSpawns.begin(); itr != c->GOSpawns.end();)
			{
				itr2 = itr;
				itr++;
				if((*itr2) == GObj->m_spawn)
				{
					c->GOSpawns.erase(itr2);
					break;
				}
			}
			delete GObj->m_spawn;
			GObj->m_spawn = NULL;
		}
	}
	GObj->Despawn(0);
	GObj->Destructor();
	GObj = NULL;

	m_session->GetPlayer()->m_GM_SelectedGO = NULL;
	return true;
}
Ejemplo n.º 3
0
void MapCell::LoadObjects(CellSpawns * sp)
{
	_loaded = true;
	Instance * pInstance = _mapmgr->pInstance;

	if(sp->CreatureSpawns.size())//got creatures
	{
		Vehicle* v = NULLVEHICLE;
		Creature* c = NULLCREATURE;
		for(CreatureSpawnList::iterator i=sp->CreatureSpawns.begin();i!=sp->CreatureSpawns.end();i++)
		{
			if(pInstance)
			{
				if(pInstance->m_killedNpcs.find((*i)->id) != pInstance->m_killedNpcs.end())
					continue;

/*				if((*i)->respawnNpcLink && pInstance->m_killedNpcs.find((*i)->respawnNpcLink) != pInstance->m_killedNpcs.end())
					continue;*/
			}
			if(!(*i)->eventid)
			{
				if((*i)->vehicle != 0)
				{
				v =_mapmgr->CreateVehicle((*i)->entry);
				if(v == NULLVEHICLE)
					continue;

					v->SetMapId(_mapmgr->GetMapId());
					v->SetInstanceID(_mapmgr->GetInstanceID());
					v->m_loadedFromDB = true;

					if(v->Load(*i, _mapmgr->iInstanceMode, _mapmgr->GetMapInfo()))
					{
						if(!v->CanAddToWorld())
						{
							v->Destructor();
							v = NULLVEHICLE;
							continue;
						}

						v->PushToWorld(_mapmgr);
					}
					else
					{
						v->Destructor();
					}
				}
				else
				{
					c=_mapmgr->CreateCreature((*i)->entry);
					if(c == NULLCREATURE)
						continue;
	
					c->SetMapId(_mapmgr->GetMapId());
					c->SetInstanceID(_mapmgr->GetInstanceID());
					c->m_loadedFromDB = true;

					if(c->Load(*i, _mapmgr->iInstanceMode, _mapmgr->GetMapInfo()))
					{
						if(!c->CanAddToWorld())
						{
							c->Destructor();
							c = NULLCREATURE;
							continue;
						}

						c->PushToWorld(_mapmgr);
					}
					else
					{
						c->Destructor();
					}
				}
			}
		}
	}

	if(sp->GOSpawns.size())//got GOs
	{
		GameObject* go;
		for(GOSpawnList::iterator i=sp->GOSpawns.begin();i!=sp->GOSpawns.end();i++)
		{
			if(!(*i)->eventid)
			{
				go = _mapmgr->CreateGameObject((*i)->entry);
				if(go == NULL)
					continue;
				if(go->Load(*i))
				{
					go->m_loadedFromDB = true;
					go->PushToWorld(_mapmgr);
					CALL_GO_SCRIPT_EVENT(go, OnSpawn)();
				}
				else
				{
					go->Destructor();
				}
			}
		}
	}
}
Ejemplo n.º 4
0
void MapCell::LoadEventIdObjects(CellSpawns * sp, uint8 eventId)
{
	Instance * pInstance = _mapmgr->pInstance;

	if(sp)
	{
		if(sp->CreatureSpawns.size())//got creatures
		{
			Vehicle* v;
			Creature* c;
			for(CreatureSpawnList::iterator i = sp->CreatureSpawns.begin(); i != sp->CreatureSpawns.end(); ++i)
			{
				if(pInstance)
				{
					if(pInstance->m_killedNpcs.find((*i)->id) != pInstance->m_killedNpcs.end())
						continue;
				}
				if((*i)->eventid && (*i)->eventid == eventId)
				{
					if(!((*i)->eventinfo->eventchangesflag & EVENTID_FLAG_SPAWN))
						continue;

					if((*i)->vehicle != 0)
					{
						v=_mapmgr->CreateVehicle((*i)->entry);

						v->SetMapId(_mapmgr->GetMapId());
						v->SetInstanceID(_mapmgr->GetInstanceID());
						v->m_loadedFromDB = true;

						if(v->Load(*i, _mapmgr->iInstanceMode, _mapmgr->GetMapInfo()))
						{
							if(!v->CanAddToWorld())
							{
								v->Destructor();
								continue;
							}

							v->PushToWorld(_mapmgr);
						}
						else
						{
							v->Destructor();
						}
					}
					else
					{
						c = _mapmgr->CreateCreature((*i)->entry);

						c->SetMapId(_mapmgr->GetMapId());
						c->SetInstanceID(_mapmgr->GetInstanceID());
						c->m_loadedFromDB = true;

						if(c->Load(*i, _mapmgr->iInstanceMode, _mapmgr->GetMapInfo()))
						{
							if(!c->CanAddToWorld())
							{
								c->Destructor();
								continue;
							}

							c->PushToWorld(_mapmgr);
						}
						else
						{
							c->Destructor();
						}
					}
				}
			}
		}

		if(sp->GOSpawns.size())//got GOs
		{
			GameObject* go;
			for(GOSpawnList::iterator i = sp->GOSpawns.begin(); i != sp->GOSpawns.end(); ++i)
			{
				if((*i)->eventid && (*i)->eventid == eventId)
				{
					if(!((*i)->eventinfo->eventchangesflag & EVENTID_FLAG_SPAWN))
						continue;
					
					go = _mapmgr->CreateGameObject((*i)->entry);
					if(go == NULL)
						continue;

					if(go->Load(*i))
					{
						go->m_loadedFromDB = true;
						go->PushToWorld(_mapmgr);
						CALL_GO_SCRIPT_EVENT(go, OnSpawn)();
					}
					else
					{
						go->Destructor();
					}
				}
			}
		}
	}
}