コード例 #1
0
ファイル: GameObject.cpp プロジェクト: Sylica2013/Antrix
bool GameObject::Load(GOSpawn *spawn)
{
	if(!CreateFromProto(spawn->entry,0,spawn->x,spawn->y,spawn->z,spawn->facing))
		return false;

	spawnid = spawn->id;
	m_spawn = spawn;
	SetFloatValue(GAMEOBJECT_ROTATION,spawn->o);
	SetFloatValue(GAMEOBJECT_ROTATION_01 ,spawn->o1);
	SetFloatValue(GAMEOBJECT_ROTATION_02 ,spawn->o2);
	SetFloatValue(GAMEOBJECT_ROTATION_03 ,spawn->o3);
	SetUInt32Value(GAMEOBJECT_FLAGS,spawn->flags);
//	SetUInt32Value(GAMEOBJECT_LEVEL,spawn->level);
	SetUInt32Value(GAMEOBJECT_STATE,spawn->state);	
	if(spawn->faction)
	{
		SetUInt32Value(GAMEOBJECT_FACTION,spawn->faction);
		m_faction = sFactionTmpStore.LookupEntry(spawn->faction);
		if(m_faction)
			m_factionDBC = sFactionStore.LookupEntry(m_faction->Faction);
	}
	SetFloatValue(OBJECT_FIELD_SCALE_X,spawn->scale);
	_LoadQuests();
	CALL_GO_SCRIPT_EVENT(this, OnCreate)();
	CALL_GO_SCRIPT_EVENT(this, OnSpawn)();

	InitAI();

	_LoadQuests();
	return true;
}
コード例 #2
0
ファイル: GameObject.cpp プロジェクト: Chero/abcwow
void GameObject::Despawn(uint32 time)
{
	if(!IsInWorld())
		return;

	loot.items.clear();

	//This is for go get deleted while looting
	if(m_spawn)
	{
		SetUInt32Value(GAMEOBJECT_STATE, m_spawn->state);
		SetUInt32Value(GAMEOBJECT_FLAGS, m_spawn->flags);
	}

	CALL_GO_SCRIPT_EVENT(this, OnDespawn)();

	if(time)
	{
		/* Get our originiating mapcell */
		MapCell * pCell = m_mapCell;
		ASSERT(pCell);
		pCell->_respawnObjects.insert( ((Object*)this) );
		sEventMgr.RemoveEvents(this);
		sEventMgr.AddEvent(m_mapMgr, &MapMgr::EventRespawnGameObject, this, pCell, EVENT_GAMEOBJECT_ITEM_SPAWN, time, 1, 0);
		Object::RemoveFromWorld(false);
		m_respawnCell=pCell;
	}
	else
	{
		Object::RemoveFromWorld(true);
		ExpireAndDelete();
	}
}
コード例 #3
0
ファイル: GameObject.cpp プロジェクト: Sylica2013/Antrix
void GameObject::Spawn()
{
	if(!this->IsInWorld())
		AddToWorld();
	
	CALL_GO_SCRIPT_EVENT(this, OnSpawn)();
}
コード例 #4
0
ファイル: GameObject.cpp プロジェクト: arcticdev/arctic-test
bool GameObject::Load(GOSpawn *spawn)
{
	if(!CreateFromProto(spawn->entry,0,spawn->x,spawn->y,spawn->z,spawn->facing,spawn->orientation1,spawn->orientation2,spawn->orientation3,spawn->orientation4))
		return false;

	m_phaseMode = spawn->phase;
	m_spawn = spawn;
	SetUInt32Value(GAMEOBJECT_FLAGS,spawn->flags);
	SetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_STATE, spawn->state);
	if(spawn->faction)
	{
		SetUInt32Value(GAMEOBJECT_FACTION,spawn->faction);
		m_faction = dbcFactionTemplate.LookupEntry(spawn->faction);
		if(m_faction)
			m_factionDBC = dbcFaction.LookupEntry(m_faction->Faction);
	}
	SetFloatValue(OBJECT_FIELD_SCALE_X,spawn->scale);

	if( spawn->flags & GO_FLAG_IN_USE || spawn->flags & GO_FLAG_LOCKED )
		SetByte(GAMEOBJECT_BYTES_1, GAMEOBJECT_BYTES_ANIMPROGRESS, 100);

	CALL_GO_SCRIPT_EVENT(TO_GAMEOBJECT(this), OnCreate)();

	_LoadQuests();
	return true;
}
コード例 #5
0
ファイル: GameObject.cpp プロジェクト: Sylica2013/Antrix
void GameObject::Despawn(uint32 time)
{
	loot.items.clear();

	//This is for go get deleted while looting
	if(m_spawn)
	{
		SetUInt32Value(GAMEOBJECT_STATE, m_spawn->state);
		SetUInt32Value(GAMEOBJECT_FLAGS, m_spawn->flags);
	}

	WorldPacket data(SMSG_GAMEOBJECT_DESPAWN_ANIM, 8);
	data << GetGUID();
	SendMessageToSet(&data,true);

	if(this->IsInWorld())
		RemoveFromWorld();
  
	if(time)
	{
		sEventMgr.AddEvent(this, &GameObject::Spawn, EVENT_GAMEOBJECT_ITEM_SPAWN, time, 1);
	}
	CALL_GO_SCRIPT_EVENT(this, OnDespawn)();
}
コード例 #6
0
ファイル: MapCell.cpp プロジェクト: AscNHalf/AscNHalf
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();
				}
			}
		}
	}
}
コード例 #7
0
void MapCell::LoadObjects(CellSpawns * sp)
{
	_loaded = true;
	Instance * pInstance = _mapmgr->pInstance;

	if(sp->CreatureSpawns.size())//got creatures
	{
		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;*/
			}

			Creature * 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())
				{
					delete c;
					continue;
				}

				c->PushToWorld(_mapmgr);
			}
			else
				delete c;//missing proto or smth of that kind
		}
	}

	if(sp->GOSpawns.size())//got GOs
	{
		for(GOSpawnList::iterator i=sp->GOSpawns.begin();i!=sp->GOSpawns.end();i++)
		{
			GameObject * go=_mapmgr->CreateGameObject((*i)->entry);
			if(go->Load(*i))
			{
				//uint32 state = go->GetUInt32Value(GAMEOBJECT_STATE);

				// FIXME - burlex
				/*
				if(pInstance && pInstance->FindObject((*i)->stateNpcLink))
				{
					go->SetUInt32Value(GAMEOBJECT_STATE, (state ? 0 : 1));
				}*/			   

				go->m_loadedFromDB = true;
				go->PushToWorld(_mapmgr);
				CALL_GO_SCRIPT_EVENT(go, OnSpawn)();
			}
			else
				delete go;//missing proto or smth of that kind
		}
	}
}
コード例 #8
0
ファイル: MiscHandler.cpp プロジェクト: Sylica2013/Antrix
void WorldSession::HandleAutostoreLootItemOpcode( WorldPacket & recv_data )
{
	if(!_player->IsInWorld()) return;
//	uint8 slot = 0;
	uint32 itemid = 0;
	uint32 amt = 1;
	uint8 lootSlot = 0;
	uint8 error = 0;
	SlotResult slotresult;

	Item *add;
	Loot *pLoot = NULL;

	if(_player->isCasting())
		_player->InterruptSpell();
	GameObject * pGO = NULL;
	Creature * pCreature = NULL;

	if(UINT32_LOPART(GUID_HIPART(GetPlayer()->GetLootGUID())) == HIGHGUID_UNIT)
	{
		pCreature = _player->GetMapMgr()->GetCreature((uint32)GetPlayer()->GetLootGUID());
		if (!pCreature)return;
		pLoot=&pCreature->loot;	
	}
	else if(UINT32_LOPART(GUID_HIPART(_player->GetLootGUID())) == HIGHGUID_GAMEOBJECT)
	{
		pGO = _player->GetMapMgr()->GetGameObject((uint32)GetPlayer()->GetLootGUID());
		if(!pGO)return;
		pLoot=&pGO->loot;
	}else if( (UINT32_LOPART(GUID_HIPART(_player->GetLootGUID())) == HIGHGUID_ITEM) )
	{
		Item *pItem = _player->GetItemInterface()->GetItemByGUID(_player->GetLootGUID());
		if(!pItem)
			return;
		pLoot = pItem->loot;
	}

	if(!pLoot) return;

	recv_data >> lootSlot;
	if (lootSlot >= pLoot->items.size())
	{
		sLog.outDebug("AutoLootItem: Player %s might be using a hack! (slot %d, size %d)",
						GetPlayer()->GetName(), lootSlot, pLoot->items.size());
		return;
	}

	amt = pLoot->items.at(lootSlot).iItemsCount;

	if (!amt)//Test for party loot
	{  
		GetPlayer()->GetItemInterface()->BuildInventoryChangeError(NULL, NULL,INV_ERR_ALREADY_LOOTED);
		return;
	} 
	itemid = pLoot->items.at(lootSlot).item.itemid;
	ItemPrototype* it = ItemPrototypeStorage.LookupEntry(itemid);

	if((error = _player->GetItemInterface()->CanReceiveItem(it, 1)))
	{
		_player->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, error);
		return;
	}

	if(pGO)
		CALL_GO_SCRIPT_EVENT(pGO, OnLootTaken)(_player, it);
	else if(pCreature)
		CALL_SCRIPT_EVENT(pCreature, OnLootTaken)(_player, it);

	add = GetPlayer()->GetItemInterface()->FindItemLessMax(itemid, amt, false);
	sHookInterface.OnLoot(_player, pCreature, 0, itemid);
	if (!add)
	{
		slotresult = GetPlayer()->GetItemInterface()->FindFreeInventorySlot(it);
		if(!slotresult.Result)
		{
			GetPlayer()->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL);
			return;
		}
	
		sLog.outDebug("AutoLootItem MISC");
		Item *item = objmgr.CreateItem( itemid, GetPlayer());
	   
		item->SetUInt32Value(ITEM_FIELD_STACK_COUNT,amt);
		uint32 rndprop=pLoot->items.at(lootSlot).iRandomProperty;
		if(rndprop)
			item->SetUInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID,rndprop);
		item->ApplyRandomProperties();

		GetPlayer()->GetItemInterface()->SafeAddItem(item,slotresult.ContainerSlot, slotresult.Slot);
		
		if (it->Class == 12)		// Quest item
			sQuestMgr.OnPlayerItemPickup(GetPlayer(),item);
	}
	else 
	{	
		add->SetCount(add->GetUInt32Value(ITEM_FIELD_STACK_COUNT) + amt);
		add->m_isDirty = true;
		if (it->Class == 12)		// Quest item
			sQuestMgr.OnPlayerItemPickup(GetPlayer(),add);
	}

	pLoot->items.at(lootSlot).iItemsCount=0;
	// this gets sent to all looters
	WorldPacket data(1);
	data.SetOpcode(SMSG_LOOT_REMOVED);
	data << lootSlot;
	Player * plr;
	for(LooterSet::iterator itr = pLoot->looters.begin(); itr != pLoot->looters.end(); ++itr)
	{
		if((plr = _player->GetMapMgr()->GetPlayer(*itr)))
			plr->GetSession()->SendPacket(&data);
	}

    WorldPacket idata;
    if(it->Class == ITEM_CLASS_QUEST)
    {
        uint32 pcount = _player->GetItemInterface()->GetItemCount(it->ItemId, true);
		BuildItemPushResult(&idata, _player->GetGUID(), ITEM_PUSH_TYPE_LOOT, amt, itemid, pLoot->items.at(lootSlot).iRandomProperty,0xFF,0,0xFFFFFFFF,pcount);
    }
    else BuildItemPushResult(&idata, _player->GetGUID(), ITEM_PUSH_TYPE_LOOT, amt, itemid, pLoot->items.at(lootSlot).iRandomProperty);

	if(_player->InGroup())
		_player->GetGroup()->SendPacketToAll(&idata);
	else
		SendPacket(&idata);
}
コード例 #9
0
ファイル: INGEvents.cpp プロジェクト: AscNHalf/AscNHalf
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();
					}
				}
			}
		}
	}
}
コード例 #10
0
ファイル: GameObject.cpp プロジェクト: Chero/abcwow
void GameObject::Spawn(MapMgr * m)
{
	PushToWorld(m);	
	CALL_GO_SCRIPT_EVENT(this, OnSpawn)();
}