Jump to content

Hide Players on OX


Recommended Posts

M2 Download Center

This is the hidden content, please
( Internal )

entity_view.cpp

 

		void operator () (LPENTITY ent)
		{
			// 오브젝트가 아닌 것은 거리를 계산하여 거리가 멀면 추가하지 않는다.
			if (!ent->IsType(ENTITY_OBJECT))
				if (DISTANCE_APPROX(ent->GetX() - m_me->GetX(), ent->GetY() - m_me->GetY()) > dwViewRange)
					return;

#ifdef HIDDEN_OX
			if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
			{
					LPCHARACTER chMe = (LPCHARACTER)m_me;
					LPCHARACTER chEnt = (LPCHARACTER)ent;
					if (chMe->IsPC() && chEnt->IsPC() && !chMe->IsGM() && !chEnt->IsGM() && chMe->GetMapIndex() == 113 && chEnt->GetMapIndex() == 113)
						return;		
			}
#endif

 

  • Metin2 Dev 27
  • Good 5
  • Love 1
  • Love 18
Link to comment
Share on other sites

  • Forum Moderator
On 9/25/2019 at 1:50 AM, ManiacRobert said:
Spoiler
		void operator () (LPENTITY ent)
		{
			// 오브젝트가 아닌 것은 거리를 계산하여 거리가 멀면 추가하지 않는다.
			if (!ent->IsType(ENTITY_OBJECT))
				if (DISTANCE_APPROX(ent->GetX() - m_me->GetX(), ent->GetY() - m_me->GetY()) > dwViewRange)
					return;

#ifdef HIDDEN_OX
			if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
			{
					LPCHARACTER chMe = (LPCHARACTER)m_me;
					LPCHARACTER chEnt = (LPCHARACTER)ent;
					if (chMe->IsPC() && chEnt->IsPC() && !chMe->IsGM() && !chEnt->IsGM() && chMe->GetMapIndex() == 113 && chEnt->GetMapIndex() == 113)
						return;		
			}
#endif

 

 

Since already is a check for distance, is impossible that the entity to be in another map, so is enough to check if you're in the map.

This is the hidden content, please

Edited by VegaS™
  • Metin2 Dev 38
  • Dislove 1
  • Good 8
  • Love 2
  • Love 16
Link to comment
Share on other sites

  • Gold

Could it look like this?

Spoiler

class CFuncViewInsert
{
	private:
		int dwViewRange;

	public:
		LPENTITY m_me;

		CFuncViewInsert(LPENTITY ent) :
			dwViewRange(VIEW_RANGE + VIEW_BONUS_RANGE),
			m_me(ent)
		{
		}

		void operator () (LPENTITY ent)
		{
			// żŔşęÁ§Ć®°ˇ ľĆ´Ń °ÍŔş °Ĺ¸®¸¦ °č»ęÇĎż© °Ĺ¸®°ˇ ¸Ö¸é Ăß°ˇÇĎÁö ľĘ´Â´Ů.
			if (!ent->IsType(ENTITY_OBJECT))
				if (DISTANCE_APPROX(ent->GetX() - m_me->GetX(), ent->GetY() - m_me->GetY()) > dwViewRange)
					return;

			// łŞ¸¦ ´ë»óżˇ Ăß°ˇ
			m_me->ViewInsert(ent);

			// µŃ´Ů Äł¸ŻĹ͸é
			if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
			{
				LPCHARACTER chMe = (LPCHARACTER) m_me;
				LPCHARACTER chEnt = (LPCHARACTER) ent;

				// ´ë»óŔĚ NPC¸é StateMachineŔ» Ų´Ů.
				if (chMe->IsPC() && !chEnt->IsPC() && !chEnt->IsWarp() && !chEnt->IsGoto())
					chEnt->StartStateMachine();
			}

			if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
			{
				const LPCHARACTER chMe = static_cast<LPCHARACTER>(m_me);
				const LPCHARACTER chEnt = static_cast<LPCHARACTER>(ent);

				if (chMe->GetMapIndex() == 113 && !chMe->IsGM() && !chEnt->IsGM())
					return;
			}
		}
};

 

Or I can remove some parts and in final it will look like this?

Spoiler

class CFuncViewInsert
{
	private:
		int dwViewRange;

	public:
		LPENTITY m_me;

		CFuncViewInsert(LPENTITY ent) :
			dwViewRange(VIEW_RANGE + VIEW_BONUS_RANGE),
			m_me(ent)
		{
		}

		void operator () (LPENTITY ent)
		{
			// żŔşęÁ§Ć®°ˇ ľĆ´Ń °ÍŔş °Ĺ¸®¸¦ °č»ęÇĎż© °Ĺ¸®°ˇ ¸Ö¸é Ăß°ˇÇĎÁö ľĘ´Â´Ů.
			if (!ent->IsType(ENTITY_OBJECT))
				if (DISTANCE_APPROX(ent->GetX() - m_me->GetX(), ent->GetY() - m_me->GetY()) > dwViewRange)
					return;

			// łŞ¸¦ ´ë»óżˇ Ăß°ˇ
			m_me->ViewInsert(ent);

			// µŃ´Ů Äł¸ŻĹ͸é
			// ´ë»óŔĚ NPC¸é StateMachineŔ» Ų´Ů.
			if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
			{
				const LPCHARACTER chMe = static_cast<LPCHARACTER>(m_me);
				const LPCHARACTER chEnt = static_cast<LPCHARACTER>(ent);

				if (chMe->IsPC() && !chEnt->IsPC() && !chEnt->IsWarp() && !chEnt->IsGoto())
					chEnt->StartStateMachine();

				if (chMe->GetMapIndex() == 113 && !chMe->IsGM() && !chEnt->IsGM())
					return;
			}
		}
};

 

I'm not sure if this part has some another functionality and if I should preserve this piece of code:

Spoiler

if (chMe->IsPC() && !chEnt->IsPC() && !chEnt->IsWarp() && !chEnt->IsGoto())
	chEnt->StartStateMachine();

 

 

I'll be always helpful! 👊 

Link to comment
Share on other sites

  • Forum Moderator
29 minutes ago, ReFresh said:

Could it look like this?

No, you need to add the condition before inserting the entity.

Spoiler

class CFuncViewInsert
{
	private:
		int dwViewRange;

	public:
		LPENTITY m_me;

		CFuncViewInsert(LPENTITY ent) :
			dwViewRange(VIEW_RANGE + VIEW_BONUS_RANGE),
			m_me(ent)
		{
		}

		void operator () (LPENTITY ent)
		{
			// 오브젝트가 아닌 것은 거리를 계산하여 거리가 멀면 추가하지 않는다.
			if (!ent->IsType(ENTITY_OBJECT))
				if (DISTANCE_APPROX(ent->GetX() - m_me->GetX(), ent->GetY() - m_me->GetY()) > dwViewRange)
					return;
				
#ifdef HIDDEN_OX
			if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
			{
				const LPCHARACTER chMe = static_cast<LPCHARACTER>(m_me);
				const LPCHARACTER chEnt = static_cast<LPCHARACTER>(ent);

				if (chMe->GetMapIndex() == OXEVENT_MAP_INDEX && !chMe->IsGM() && !chEnt->IsGM())
					return;		
			}
#endif
			// 나를 대상에 추가
			m_me->ViewInsert(ent);

			// 둘다 캐릭터면
			if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
			{
				LPCHARACTER chMe = (LPCHARACTER) m_me;
				LPCHARACTER chEnt = (LPCHARACTER) ent;

				// 대상이 NPC면 StateMachine을 킨다.
				if (chMe->IsPC() && !chEnt->IsPC() && !chEnt->IsWarp() && !chEnt->IsGoto())
					chEnt->StartStateMachine();
			}
		}
};

 

Don't forget:

  • entity_view.cpp
#include "OXEvent.h"
  • service.h
#define HIDDEN_OX

 

 

Link to comment
Share on other sites

La 01.10.2019 la 4:18, ReFresh a spus:

@VegaS™ Is there another way to do it without the #ifdef? I don't want to define something in services.h. I hate these defines. Everytime you add something, you must open the services.h and add define to make it work. xd

Just remove #ifdef and #endif with delete button.

Link to comment
Share on other sites

  • 3 years later...
On 9/25/2019 at 4:29 AM, VegaS™ said:

Since already is a check for distance, is impossible that the entity to be in another map, so is enough to check if you're in the map.

 

Hidden Content

 

#ifdef HIDDEN_OX
			if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
			{
				const LPCHARACTER chMe = static_cast<LPCHARACTER>(m_me);
				const LPCHARACTER chEnt = static_cast<LPCHARACTER>(ent);

				if (chMe->GetMapIndex() == OXEVENT_MAP_INDEX && !chMe->IsGM() && !chEnt->IsGM())
					return;		
			}
#endif

Also, you should put the correct/ordered conditions, first one should be if the entity is on the map, if not that means the rest of the checks like if's GM, etc will not run, why you would check the first time if the entity is player, then if the player is game master then the map (the most important), there's no logic. Even if is a player or another type, the GetMapIndex works for all, belongs to the CHARACTER class, so, don't be afraid to use it as the first condition.
Also, you don't need the IsPC check, already you did inside of IsGM, if the server running in test mode, the function will return true, if the gm_level != 0, will return true, otherwise return false < another entity than a player in this case, so with that way the players are visible to map since test_server is enabled too.

 

    • As a player you will see just the GM, no players, no (Nameless Flowers 20358) < NPCs
    • As a GM you will see everything

 

hello

How is it possible to see only the members who are in a group party? 

if (chMe->GetMapIndex() == OXEVENT_MAP_INDEX && !chMe->GetParty() && !chEnt->GetParty())

not work for me with GetParty()) 

any help for party ?

 

  • Love 1
Link to comment
Share on other sites

  • 1 month later...
#ifdef HIDDEN_OX
            if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
            {
                const LPCHARACTER chMe = static_cast<LPCHARACTER>(m_me);
                const LPCHARACTER chEnt = static_cast<LPCHARACTER>(ent);

                if (chMe->GetMapIndex() == OXEVENT_MAP_INDEX && !chMe->IsGM() && !chEnt->IsGM())
                {
                    if (!chMe->GetParty() || chMe->GetParty() != chEnt->GetParty())
                        return;    
                }
            }
#endif

 

  • Metin2 Dev 1
Link to comment
Share on other sites

22 hours ago, MityQ said:
#ifdef HIDDEN_OX
            if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
            {
                const LPCHARACTER chMe = static_cast<LPCHARACTER>(m_me);
                const LPCHARACTER chEnt = static_cast<LPCHARACTER>(ent);

                if (chMe->GetMapIndex() == OXEVENT_MAP_INDEX && !chMe->IsGM() && !chEnt->IsGM())
                {
                    if (!chMe->GetParty() || chMe->GetParty() != chEnt->GetParty())
                        return;    
                }
            }
#endif

 

It works perfectly

How can I see only my team?

I don't want them to see other teams

Link to comment
Share on other sites

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.