Example #1
0
int16 QuestManager::unique_spawn(int npc_type, int grid, int unused, float x, float y, float z, float heading) {
	Mob *other = entity_list.GetMobByNpcTypeID(npc_type);
	if(other != NULL) {
		return(other->GetID());
	}


	NPCType* tmp = 0;
	if ((tmp = Database::Instance()->GetNPCType(npc_type)))
	{

		NPC* npc = new NPC(tmp, 0, x, y, z, heading);


		npc->AddLootTable();
		entity_list.AddNPC(npc,true);
		// Quag: Sleep in main thread? ICK!
		// Sleep(200);
		// Quag: check is irrelevent, it's impossible for npc to be 0 here
		// (we're in main thread, nothing else can possibly modify it)
//		if(npc != 0) {
			if(grid > 0)
			{
				// HarakiriFIXME npc->AssignWaypoints(grid);
			}
			npc->SendPosUpdate();
//		}
		return(npc->GetID());
	}
	return(0);
}
Example #2
0
//----------------------------------------------------------------------------
void DataBaseEngine::ProcessNpcProp(const EngineEvent &ent)
{
	EngineEvent e;
	std::map<std::string, int>::const_iterator npcID = 
		ent.miData.find("NPC_ID_REQ");
	std::map<std::string, int>::const_iterator id = ent.miData.find("ID");

	assert(npcID != ent.miData.end() && id != ent.miData.end());

	NPC n = GetNPCByID(npcID->second);
	
	std::ostringstream archiveStream;
	boost::archive::text_oarchive archive(archiveStream);
	archive << n;
	const std::string &s = archiveStream.str();
	e.mType = EngineEvent::NPC_PROP;
	e.msData["NPC_PROP"] = s;
	e.miData["ID"] = id->second;
	e.miData["NPC_ID"] = n.GetID();

	SendMessageToNet(e);
}