Jump to content

Hide specific npc vnum from atlas


Recommended Posts

En 21/11/2018 a las 16:09, iFreakTime~.~ dijo:

Hello all. I want to hide a npc vnum from atlas map, as example: npc 9004 from atlas.

I want this because of: 

EX7C8GE.jpg

Open ../game/src/regen.cpp and search:

				else if (p->m_table.bType == CHAR_TYPE_NPC || p->m_table.bType == CHAR_TYPE_WARP || p->m_table.bType == CHAR_TYPE_GOTO)
				{
					SECTREE_MANAGER::instance().InsertNPCPosition(lMapIndex,
							p->m_table.bType,
							p->m_table.szLocaleName,
							(regen->sx+regen->ex) / 2 - base_x,
							(regen->sy+regen->ey) / 2 - base_y);
				}

And do some like that:

				else if (p->m_table.bType == CHAR_TYPE_NPC || p->m_table.bType == CHAR_TYPE_WARP || p->m_table.bType == CHAR_TYPE_GOTO)
				{
					if (regen->vnum != 9004)
					{
						SECTREE_MANAGER::instance().InsertNPCPosition(lMapIndex,
								p->m_table.bType,
								p->m_table.szLocaleName,
								(regen->sx+regen->ex) / 2 - base_x,
								(regen->sy+regen->ey) / 2 - base_y);
					}
				}

Or if you want to hide more than one npc, you can do something like that:

				else if (p->m_table.bType == CHAR_TYPE_NPC || p->m_table.bType == CHAR_TYPE_WARP || p->m_table.bType == CHAR_TYPE_GOTO)
				{
					int hideList[] = {9004,9099}; // here you must add the vnums
					std::vector<int> H(hideList, hideList + sizeof(hideList)/sizeof(hideList[0]));
					if (find(H.begin(),H.end(),regen->vnum) == H.end())
					{
						SECTREE_MANAGER::instance().InsertNPCPosition(lMapIndex,
								p->m_table.bType,
								p->m_table.szLocaleName,
								(regen->sx+regen->ex) / 2 - base_x,
								(regen->sy+regen->ey) / 2 - base_y);
					}
				}

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 3
Link to comment
Share on other sites

1 godzinę temu, xUniverse napisał:

Open ../game/src/regen.cpp and search:


				else if (p->m_table.bType == CHAR_TYPE_NPC || p->m_table.bType == CHAR_TYPE_WARP || p->m_table.bType == CHAR_TYPE_GOTO)
				{
					SECTREE_MANAGER::instance().InsertNPCPosition(lMapIndex,
							p->m_table.bType,
							p->m_table.szLocaleName,
							(regen->sx+regen->ex) / 2 - base_x,
							(regen->sy+regen->ey) / 2 - base_y);
				}

And do some like that:


				else if (p->m_table.bType == CHAR_TYPE_NPC || p->m_table.bType == CHAR_TYPE_WARP || p->m_table.bType == CHAR_TYPE_GOTO)
				{
					if (regen->vnum != 9004)
					{
						SECTREE_MANAGER::instance().InsertNPCPosition(lMapIndex,
								p->m_table.bType,
								p->m_table.szLocaleName,
								(regen->sx+regen->ex) / 2 - base_x,
								(regen->sy+regen->ey) / 2 - base_y);
					}
				}

If you need to hide more than one npc, you can make a list with the vnums and check if the list doesn't contain regen->vnum.

lol, only remove form atlas, noo dont spawn npc xD

 

I think in Client/UserInterface/PythonMiniMap.cpp in Update method 

'else if (pkInstEach->IsNPC())'  change to 'else if (pkInstEach->IsNPC() && pkInstEach->GetRace() != 9004)'

however, it will be pretty if you add new type of mob and not in PythonMiniMap.cpp

Link to comment
Share on other sites

hace 14 horas, hachiwari dijo:

lol, only remove form atlas, noo dont spawn npc xD

It doesn't remove the spawn. The spawn continues.

See that: else if (p->m_table.bType == CHAR_TYPE_NPC || p->m_table.bType == CHAR_TYPE_WARP || p->m_table.bType == CHAR_TYPE_GOTO) doesn't include CHAR_TYPE_MONSTER and monsters are spawned.

-------------------------------------

What it does?

Basically we don't add the position of npc with vnum 9004 to m_mapNPCPosition[lMapIndex] (it isn't related with the spawn), so when the game send the packet of npc's positions in each map, it will not contain the position of npc with vnum 9004 and it isn't marked in atlas.

You can prove this by seeing the next functions:

InsertNPCPosition in sectree_manager.cpp:

void SECTREE_MANAGER::InsertNPCPosition(long lMapIndex, BYTE bType, const char* szName, long x, long y)
{
	m_mapNPCPosition[lMapIndex].push_back(npc_info(bType, szName, x, y));
}

And SendNPCPosition in the same file:

void SECTREE_MANAGER::SendNPCPosition(LPCHARACTER ch)
{
	LPDESC d = ch->GetDesc();
	if (!d)
		return;

	long lMapIndex = ch->GetMapIndex();

	if (m_mapNPCPosition[lMapIndex].empty())
		return;

	TEMP_BUFFER buf;
	TPacketGCNPCPosition p;
	p.header = HEADER_GC_NPC_POSITION;
	p.count = m_mapNPCPosition[lMapIndex].size();

	TNPCPosition np;

	// TODO m_mapNPCPosition[lMapIndex] 를 보내주세요
	itertype(m_mapNPCPosition[lMapIndex]) it;

	for (it = m_mapNPCPosition[lMapIndex].begin(); it != m_mapNPCPosition[lMapIndex].end(); ++it)
	{
		np.bType = it->bType;
		strlcpy(np.name, it->name, sizeof(np.name));
		np.x = it->x;
		np.y = it->y;
		buf.write(&np, sizeof(np));
	}

	p.size = sizeof(p) + buf.size();

	if (buf.size())
	{
		d->BufferedPacket(&p, sizeof(TPacketGCNPCPosition));
		d->Packet(buf.read_peek(), buf.size());
	}
	else
		d->Packet(&p, sizeof(TPacketGCNPCPosition));
}

Then go to client -> ../UserInterface/PythonNetworkStreamPhaseGame.cpp and see CPythonNetworkStream::RecvNPCList()

bool CPythonNetworkStream::RecvNPCList()
{
	TPacketGCNPCPosition kNPCPosition;
	if (!Recv(sizeof(kNPCPosition), &kNPCPosition))
		return false;

	assert(int(kNPCPosition.size)-sizeof(kNPCPosition) == kNPCPosition.count*sizeof(TNPCPosition) && "HEADER_GC_NPC_POSITION");

	CPythonMiniMap::Instance().ClearAtlasMarkInfo();

	for (int i = 0; i < kNPCPosition.count; ++i)
	{
		TNPCPosition NPCPosition;
		if (!Recv(sizeof(TNPCPosition), &NPCPosition))
			return false;

		CPythonMiniMap::Instance().RegisterAtlasMark(NPCPosition.bType, NPCPosition.name, NPCPosition.x, NPCPosition.y);
	}

	return true;
}

If you can see at the start we get the packet of npc position and in the last lines we mark the position in the atlas: CPythonMiniMap::Instance().RegisterAtlasMark(NPCPosition.bType, NPCPosition.name, NPCPosition.x, NPCPosition.y);

  • Love 2
Link to comment
Share on other sites

Acum 17 ore, xUniverse a spus:

Open ../game/src/regen.cpp and search:


				else if (p->m_table.bType == CHAR_TYPE_NPC || p->m_table.bType == CHAR_TYPE_WARP || p->m_table.bType == CHAR_TYPE_GOTO)
				{
					SECTREE_MANAGER::instance().InsertNPCPosition(lMapIndex,
							p->m_table.bType,
							p->m_table.szLocaleName,
							(regen->sx+regen->ex) / 2 - base_x,
							(regen->sy+regen->ey) / 2 - base_y);
				}

And do some like that:


				else if (p->m_table.bType == CHAR_TYPE_NPC || p->m_table.bType == CHAR_TYPE_WARP || p->m_table.bType == CHAR_TYPE_GOTO)
				{
					if (regen->vnum != 9004)
					{
						SECTREE_MANAGER::instance().InsertNPCPosition(lMapIndex,
								p->m_table.bType,
								p->m_table.szLocaleName,
								(regen->sx+regen->ex) / 2 - base_x,
								(regen->sy+regen->ey) / 2 - base_y);
					}
				}

Or if you want to hide more than one npc, you can do something like that:


				else if (p->m_table.bType == CHAR_TYPE_NPC || p->m_table.bType == CHAR_TYPE_WARP || p->m_table.bType == CHAR_TYPE_GOTO)
				{
					int hideList[] = {9004,9099}; // here you must add the vnums
					std::vector<int> H(hideList, hideList + sizeof(hideList)/sizeof(hideList[0]));
					if (find(H.begin(),H.end(),regen->vnum) == H.end())
					{
						SECTREE_MANAGER::instance().InsertNPCPosition(lMapIndex,
								p->m_table.bType,
								p->m_table.szLocaleName,
								(regen->sx+regen->ex) / 2 - base_x,
								(regen->sy+regen->ey) / 2 - base_y);
					}
				}

 

Thank you. Is working.

NPC spawns and is not show on atlas.

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.