Jump to content

Recommended Posts

I am trying to parse mob names in minimap from clientside and not serverside

 

 

And i am trying modify the following function

Spoiler

bool CPythonMiniMap::GetAtlasInfo(float fScreenX, float fScreenY, std::string & rReturnString, float * pReturnPosX, float * pReturnPosY, DWORD * pdwTextColor, DWORD * pdwGuildID)
{
    float fRealX = (fScreenX - m_fAtlasScreenX) * (m_fAtlasMaxX / m_fAtlasImageSizeX);
    float fRealY = (fScreenY - m_fAtlasScreenY) * (m_fAtlasMaxY / m_fAtlasImageSizeY);

#ifdef TELEPORT_MINIMAP_GM_ENABLE
    *pReturnPosX = fRealX;
    *pReturnPosY = fRealY;
#endif

    //((float) CTerrainImpl::CELLSCALE) * 10.0f
    float fCheckWidth = (m_fAtlasMaxX / m_fAtlasImageSizeX) * 5.0f;
    float fCheckHeight = (m_fAtlasMaxY / m_fAtlasImageSizeY) * 5.0f;

    CInstanceBase * pkInst = CPythonCharacterManager::Instance().GetMainInstancePtr();

    if (pkInst)
    {
        TPixelPosition kInstPos;
        pkInst->NEW_GetPixelPosition(&kInstPos);

        if (kInstPos.x-fCheckWidth<fRealX && kInstPos.x+fCheckWidth>fRealX &&
            kInstPos.y-fCheckHeight<fRealY && kInstPos.y+fCheckHeight>fRealY)
        {
            rReturnString = pkInst->GetNameString();
            *pReturnPosX = kInstPos.x;
            *pReturnPosY = kInstPos.y;
            *pdwTextColor = pkInst->GetNameColor();
            return true;
        }
    }

    m_AtlasMarkInfoVectorIterator = m_AtlasNPCInfoVector.begin();
    while (m_AtlasMarkInfoVectorIterator != m_AtlasNPCInfoVector.end())
    {
        TAtlasMarkInfo & rAtlasMarkInfo = *m_AtlasMarkInfoVectorIterator;

        if (rAtlasMarkInfo.m_fX-fCheckWidth/2<fRealX && rAtlasMarkInfo.m_fX+fCheckWidth>fRealX &&
            rAtlasMarkInfo.m_fY-fCheckWidth/2<fRealY && rAtlasMarkInfo.m_fY+fCheckHeight>fRealY)
        {
            //rReturnString = rAtlasMarkInfo.m_strText;
 

            CPythonNonPlayer::Instance().GetName(rAtlasMarkInfo.m_dwChrVID, rReturnString);
            *pReturnPosX = rAtlasMarkInfo.m_fX;
            *pReturnPosY = rAtlasMarkInfo.m_fY;
            *pdwTextColor = CInstanceBase::GetIndexedNameColor(CInstanceBase::NAMECOLOR_NPC);//m_MarkTypeToColorMap[rAtlasMarkInfo.m_byType];
            return true;
        }
        ++m_AtlasMarkInfoVectorIterator;
    }

    m_AtlasMarkInfoVectorIterator = m_AtlasWarpInfoVector.begin();
    while (m_AtlasMarkInfoVectorIterator != m_AtlasWarpInfoVector.end())
    {
        TAtlasMarkInfo & rAtlasMarkInfo = *m_AtlasMarkInfoVectorIterator;
        if (rAtlasMarkInfo.m_fX-fCheckWidth/2<fRealX && rAtlasMarkInfo.m_fX+fCheckWidth>fRealX &&
            rAtlasMarkInfo.m_fY-fCheckWidth/2<fRealY && rAtlasMarkInfo.m_fY+fCheckHeight>fRealY)
        {
            rReturnString = rAtlasMarkInfo.m_strText;
            *pReturnPosX = rAtlasMarkInfo.m_fX;
            *pReturnPosY = rAtlasMarkInfo.m_fY;
            *pdwTextColor = CInstanceBase::GetIndexedNameColor(CInstanceBase::NAMECOLOR_WARP);//m_MarkTypeToColorMap[rAtlasMarkInfo.m_byType];
 

            return true;
        }
        ++m_AtlasMarkInfoVectorIterator;
    }

    m_AtlasMarkInfoVectorIterator = m_AtlasWayPointInfoVector.begin();
    while (m_AtlasMarkInfoVectorIterator != m_AtlasWayPointInfoVector.end())
    {
        TAtlasMarkInfo & rAtlasMarkInfo = *m_AtlasMarkInfoVectorIterator;
        if (rAtlasMarkInfo.m_fScreenX > 0.0f)
        if (rAtlasMarkInfo.m_fScreenY > 0.0f)
        if (rAtlasMarkInfo.m_fX-fCheckWidth/2<fRealX && rAtlasMarkInfo.m_fX+fCheckWidth>fRealX &&
            rAtlasMarkInfo.m_fY-fCheckWidth/2<fRealY && rAtlasMarkInfo.m_fY+fCheckHeight>fRealY)
        {
            rReturnString = rAtlasMarkInfo.m_strText;
            *pReturnPosX = rAtlasMarkInfo.m_fX;
            *pReturnPosY = rAtlasMarkInfo.m_fY;
            *pdwTextColor = CInstanceBase::GetIndexedNameColor(CInstanceBase::NAMECOLOR_WAYPOINT);//m_MarkTypeToColorMap[rAtlasMarkInfo.m_byType];
        ++m_AtlasMarkInfoVectorIterator;
    }

    TGuildAreaInfoVector::iterator itor = m_GuildAreaInfoVector.begin();
    for (; itor!=m_GuildAreaInfoVector.end(); ++itor)
    {
        TGuildAreaInfo & rInfo = *itor;
        if (fScreenX - m_fAtlasScreenX >= rInfo.fsxRender)
        if (fScreenY - m_fAtlasScreenY >= rInfo.fsyRender)
        if (fScreenX - m_fAtlasScreenX <= rInfo.fexRender)
        if (fScreenY - m_fAtlasScreenY <= rInfo.feyRender)
        {
            if (CPythonGuild::Instance().GetGuildName(rInfo.dwGuildID, &rReturnString))
            {
                *pdwGuildID = rInfo.dwGuildID;
            }
            else
            {
                rReturnString = "empty_guild_area";
            }

            *pReturnPosX = rInfo.lx + rInfo.lwidth/2;
            *pReturnPosY = rInfo.ly + rInfo.lheight/2;
            *pdwTextColor = CInstanceBase::GetIndexedNameColor(CInstanceBase::NAMECOLOR_PARTY);
            return true;
        }
    }

#ifdef ENABLE_SHOW_MAP_BOSS_AND_STONE
    m_AtlasMarkInfoVectorIterator = m_AtlasStoneInfoVector.begin();
    while (m_AtlasMarkInfoVectorIterator != m_AtlasStoneInfoVector.end())
    {
        TAtlasMarkInfo& rAtlasMarkInfo = *m_AtlasMarkInfoVectorIterator;
        if (rAtlasMarkInfo.m_fScreenX > 0.0f)
            if (rAtlasMarkInfo.m_fScreenY > 0.0f)
                if (rAtlasMarkInfo.m_fX - fCheckWidth / 2 < fRealX && rAtlasMarkInfo.m_fX + fCheckWidth > fRealX&&
                    rAtlasMarkInfo.m_fY - fCheckWidth / 2 < fRealY && rAtlasMarkInfo.m_fY + fCheckHeight > fRealY)
                {
                    rReturnString = rAtlasMarkInfo.m_strText;
                    *pReturnPosX = rAtlasMarkInfo.m_fX;
                    *pReturnPosY = rAtlasMarkInfo.m_fY;
                    *pdwTextColor = CInstanceBase::GetIndexedNameColor(CInstanceBase::NAMECOLOR_STONE);
                    return true;
                }
        ++m_AtlasMarkInfoVectorIterator;
    }

    m_AtlasMarkInfoVectorIterator = m_AtlasBossInfoVector.begin();
    while (m_AtlasMarkInfoVectorIterator != m_AtlasBossInfoVector.end())
    {
        TAtlasMarkInfo& rAtlasMarkInfo = *m_AtlasMarkInfoVectorIterator;
        if (rAtlasMarkInfo.m_fScreenX > 0.0f)
            if (rAtlasMarkInfo.m_fScreenY > 0.0f)
                if (rAtlasMarkInfo.m_fX - fCheckWidth / 2 < fRealX && rAtlasMarkInfo.m_fX + fCheckWidth > fRealX&&
                    rAtlasMarkInfo.m_fY - fCheckWidth / 2 < fRealY && rAtlasMarkInfo.m_fY + fCheckHeight > fRealY)
                {
                    rReturnString = rAtlasMarkInfo.m_strText;
                    *pReturnPosX = rAtlasMarkInfo.m_fX;
                    *pReturnPosY = rAtlasMarkInfo.m_fY;
                    *pdwTextColor = CInstanceBase::GetIndexedNameColor(CInstanceBase::NAMECOLOR_BOSS);
                    return true;
                }
        ++m_AtlasMarkInfoVectorIterator;
    }
#endif

    return false;
}
 


I copy pasted and modified this function(PythonNonPlayer.cpp)

Spoiler

bool CPythonNonPlayer::GetName(DWORD dwVnum, std::string & c_pszName)
{
    const TMobTable * p = GetTable(dwVnum);

    if (!p)
    {
        std::cout<<"nullara\n";
        return false;
    }

    c_pszName = convertToString(p->szLocaleName);

    return true;
}

Probably i can't find which field is the vnum of the monster.I debugged the binary and TAtlasMarkInfo's values were

Spoiler

 vid :  [-858993460]
 m_byType :  [3]
 m_dwID :  [-858993460]

Do you know from which packet all these are coming serverside?Can anyone help me with this  😛 ?

Edited by dotMatryx
Link to comment
Share on other sites

  • Premium
5 minutes ago, dotMatryx said:

Yes i've done it.This is only clientside that you sent. I was getting as a parameter an array of char , and when i was trying finding the length of the array , the sizeof(array)/sizeof(char) in function was (pointer's array)/sizeof(char)=>4

 

Maybe I am not understanding quite correctly what you are trying to accomplish, but that system already gives the solution to show the name of NPCs/Monsters from the client (you'd need to update the mapName_point.txt file with the coordinates but ye).

Anyway, if you have the vnum (from Penger's topic itself):

const CPythonNonPlayer::TMobTable* c_pMobTable = CPythonNonPlayer::Instance().GetTable(c_dwVnum);
if(c_pMobTable != nullptr)
	auto name = c_pMobTable->szLocaleName;

 

Edited by xXIntelXx
Link to comment
Share on other sites

7 minutes ago, xXIntelXx said:

Maybe I am not understanding quite correctly what you are trying to accomplish, but that system already gives the solution to show the name of NPCs/Monsters from the client (you'd need to update the mapName_point.txt file with the coordinates but ye).

Anyway, if you have the vnum (from Penger's topic itself):

const CPythonNonPlayer::TMobTable* c_pMobTable = CPythonNonPlayer::Instance().GetTable(c_dwVnum);
if(c_pMobTable != nullptr)
	auto name = c_pMobTable->szLocaleName;

 

Spoiler

Without the packet the server will not take care about your atlaswindow anymore, so you have to take care about it by yourself, if you place a new NPC/Warp portal on a map, you have to add it into the text file of the map at clientside. (Easy to write a script which iterates all over the map folder and collect these entries.)

 

I've done it serverside, I just send in the packet of atlas map the vnum of the npc and get the locale_name clientside.

Edited by dotMatryx
Link to comment
Share on other sites

  • Premium

Ok we got it privately, basically the simple solution (keeping the original GetAtlasInfo) would be:

 

void CPythonMiniMap::RegisterAtlasMark(BYTE byType, DWORD dwVnum, const char * c_szName, long lx, long ly)

aAtlasMarkInfo.m_strText = c_szName; here, instead of copying the name, taken from the server:

void CPythonMiniMap::RegisterAtlasMark(BYTE byType, DWORD dwVnum, const char * c_szName, long lx, long ly)
{
	TAtlasMarkInfo aAtlasMarkInfo;

	aAtlasMarkInfo.m_fX = float(lx);
	aAtlasMarkInfo.m_fY = float(ly);
  	
	const CPythonNonPlayer::TMobTable* c_pMobTable = CPythonNonPlayer::Instance().GetTable(c_dwVnum);
	if(c_pMobTable != nullptr)	//if exists in mob_proto, change accordingly
		aAtlasMarkInfo.m_strText = c_pMobTable->szLocaleName;;
	else //otherwise, use the name from server
		aAtlasMarkInfo.m_strText = c_szName;
	aAtlasMarkInfo.m_dwID = dwVnum;

	aAtlasMarkInfo.m_fScreenX = aAtlasMarkInfo.m_fX / m_fAtlasMaxX * m_fAtlasImageSizeX - (float)m_WhiteMark.GetWidth() / 2.0f;
	aAtlasMarkInfo.m_fScreenY = aAtlasMarkInfo.m_fY / m_fAtlasMaxY * m_fAtlasImageSizeY - (float)m_WhiteMark.GetHeight() / 2.0f;

	switch(byType)
	{
		case CActorInstance::TYPE_NPC:
			aAtlasMarkInfo.m_byType = TYPE_NPC;
			m_AtlasNPCInfoVector.push_back(aAtlasMarkInfo);
			break;
		case CActorInstance::TYPE_WARP:
			aAtlasMarkInfo.m_byType = TYPE_WARP;
			{
				int iPos = aAtlasMarkInfo.m_strText.find(" ");
				if (iPos >= 0)
					aAtlasMarkInfo.m_strText[iPos]=0;
				
			}
			m_AtlasWarpInfoVector.push_back(aAtlasMarkInfo);
			break;
	}
}

and that's it, the name will be in the m_AtlasNPCInfoVector or m_AtlasWarpInfoVector

so that in

bool CPythonMiniMap::GetAtlasInfo(float fScreenX, float fScreenY, std::string & rReturnString, float * pReturnPosX, float * pReturnPosY, DWORD * pdwTextColor, DWORD * pdwGuildID)

 

rReturnString = rAtlasMarkInfo.m_strText;

this string would be either the name from mob_proto or the server one, depending on what was saved during the RegisterAtlasMark function.

 

Obviously in this case, the packet should send the vnum as well

Edited by xXIntelXx
  • Metin2 Dev 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.