Jump to content
metin2dev
xP3NG3Rx

[GF] Race height of actors

Recommended Posts

Hello.

Today I'd like to share this little stuff what I reversed from the official binary a month ago.
This will fix the positions of textails(name position changes by every update packet on the main character), and also the position of the emotions when you are on a mount :).
I've made a little demonstration video where you can see a private server without the fix, my fixxed version and the official aswell.

 

1. Client/bin/playersettingmodule.py

Spoiler

1. Add the following code above of the loadGameDataDict declaration:


# SetRaceHeight
def __LoadRaceHeight():
	try:
		lines = open("race_height.txt", "r").readlines()
	except IOError:
		return

	for line in lines:
		tokens = line[:-1].split("\t")
		if len(tokens) == 0 or not tokens[0]:
			continue

		vnum = int(tokens[0])
		height = float(tokens[1])

		chrmgr.SetRaceHeight(vnum, height)

2. Add the following line below of the dict or extend it however you want:


loadGameDataDict.update({"RACE_HEIGHT": __LoadRaceHeight,})

2.1 extension:


	"RACE_HEIGHT" : __LoadRaceHeight,

 

2. Client/bin/introLoading.py

Spoiler

1. Paste the following line below of the self.__LoadNPC() in the DEBUG_LoadData function:


		self.__LoadRaceHeight()

2. Add the following line below of the self.loadStepList definition in the LoadData function:


		self.loadStepList+=[(98, ui.__mem_func__(self.__LoadRaceHeight)),]

2.1 or extend it:


			(98, ui.__mem_func__(self.__LoadRaceHeight)),

3. Add the following function after the __LoadNPC function or anywhere you want:
 


	def __LoadRaceHeight(self):
		playerSettingModule.LoadGameData("RACE_HEIGHT")

 

3. Place the race_height.txt from the official client into the yours and pack it in the root.
4. Client/UserInterface/PythonCharacterManagerModule.cpp

Spoiler

1. Add the new function to the module:


PyObject * chrmgrSetRaceHeight(PyObject* poSelf, PyObject* poArgs)
{
	int iRaceIndex;
	if (!PyTuple_GetInteger(poArgs, 0, &iRaceIndex))
		return Py_BadArgument();
	float fRaceHeight = 0.0f;
	if (!PyTuple_GetFloat(poArgs, 1, &fRaceHeight))
		return Py_BadArgument();

	CRaceManager::Instance().SetRaceHeight(iRaceIndex, fRaceHeight);
	return Py_BuildNone();
}

And to the methodlist:


		{ "SetRaceHeight",				chrmgrSetRaceHeight,					METH_VARARGS },

 

5. Client/GameLib/RaceManager.h

Spoiler

1. Add these new functions as public:


		void SetRaceHeight(int iVnum, float fHeight);
		float GetRaceHeight(int iVnum);

2. And define the new map which will stores the informations as protected:


		std::map<int, float>				m_kMap_iRaceKey_fRaceAdditionalHeight;

 

6. Client/GameLib/RaceManager.cpp

Spoiler

1. Add the new functions anywhere you want:


void CRaceManager::SetRaceHeight(int iVnum, float fHeight)
{
	m_kMap_iRaceKey_fRaceAdditionalHeight.insert(std::map<int, float>::value_type(iVnum, fHeight));
}

float CRaceManager::GetRaceHeight(int iVnum)
{
	std::map<int, float>::iterator it = m_kMap_iRaceKey_fRaceAdditionalHeight.find(iVnum);
	if (m_kMap_iRaceKey_fRaceAdditionalHeight.end() == it)
		return 0.0f;

	return it->second;
}

 

7. Client/UserInterface/InstanceBase.h

Spoiler

1. Paste the following definition of function below of the definition of GetDistance as public:


		float					GetBaseHeight();

 

8. Client/UserInterface/InstanceBase.cpp

Spoiler

0. Add to the includes:


#include "../gamelib/RaceManager.h"

1. Add the function anywhere you want:


float CInstanceBase::GetBaseHeight()
{
	CActorInstance* pkHorse = m_kHorse.GetActorPtr();
	if (!m_kHorse.IsMounting() || !pkHorse)
		return 0.0f;

	DWORD dwHorseVnum = m_kHorse.m_pkActor->GetRace();
	if ((dwHorseVnum >= 20101 && dwHorseVnum <= 20109) ||
		(dwHorseVnum == 20029 || dwHorseVnum == 20030))
		return 100.0f;

	float fRaceHeight = CRaceManager::instance().GetRaceHeight(dwHorseVnum);
	if (fRaceHeight == 0.0f)
		return 100.0f;
	else
		return fRaceHeight;
}

 

9. Client/UserInterface/InstanceBaseEffect.cpp

Spoiler

1. Replace the fTextTailHeight definition of variable in the AttachTextTail function with this:


		float fTextTailHeight = GetBaseHeight() + 10.0f;

2. Replace the following in the SetEmoticon function:


		v3Pos.z += float(m_GraphicThingInstance.GetHeight());

With this:


		v3Pos.z += float(GetBaseHeight() + m_GraphicThingInstance.GetHeight());

Twice!!! The are two times this line, replace both of them!
 

10. Client/UserInterface/PythonTextTail.cpp

Spoiler

1. Replace the following code in the RegisterChatTail function:


	TTextTail * pTextTail = RegisterTextTail(VirtualID,
											 c_szChat,
											 pCharacterInstance->GetGraphicThingInstancePtr(),
											 pCharacterInstance->GetGraphicThingInstanceRef().GetHeight() + 10.0f,
											 c_TextTail_Chat_Color);

With this:
 


	TTextTail * pTextTail = RegisterTextTail(VirtualID,
											 c_szChat,
											 pCharacterInstance->GetGraphicThingInstancePtr(),
											 pCharacterInstance->GetGraphicThingInstanceRef().GetHeight() + pCharacterInstance->GetBaseHeight() + 10.0f,
											 c_TextTail_Chat_Color);

 

11. Client/GameLib/ActorInstance.cpp

Spoiler

0. Add the following to the includes:


#include "RaceManager.h"

1. Replace the whole GetHeight function with this:


float CActorInstance::GetHeight()
{
	DWORD dwRace = GetRace();
	float fRaceHeight = CRaceManager::instance().GetRaceHeight(dwRace);
	if (fRaceHeight == 0.0f)
	{
		fRaceHeight = CGraphicThingInstance::GetHeight();
		CRaceManager::instance().SetRaceHeight(dwRace, fRaceHeight);
	}

	return fRaceHeight;
}

 

 

I hope you like it, and if you find any problem just let me know in this topic.

Edited by xP3NG3Rx
Edited by #11.0 #8.0
  • Like 30
  • Thanks 6

Share this post


Link to post
Share on other sites

I've modified def __LoadRaceHeight for my own purpose, here it is in case someone needs it:

Spoiler

def __LoadRaceHeight():
	directory = "npcheight.txt"
	try:
		lines = open(directory, "r").readlines()
	except IOError:
		return

	#import dbg
	for line in lines:
		try: # to avoid problems .. (paranoia)
			tokens = line[:-1].split("\t")
			#dbg.TraceError("__LoadRaceHeight tokens %s" % (str(tokens)))

			if len(tokens) <= 1 or not tokens[0]:
				continue

			if tokens[0].find("#") != -1:
				continue
			if tokens[1].find("#") != -1:
				tokens[1] = tokens[1].split("#")[0].replace("\s","")
			if tokens[1].find("#") != -1:
				continue

			vnum = int(tokens[0])
			height = float(tokens[1])
			#dbg.TraceError("__LoadRaceHeight %d %s" % (vnum,tokens[1]))
			chrmgr.SetRaceHeight(vnum, height)
		except:
			import dbg
			dbg.TraceError("I could not read the lines of %s" % directory)

 

I wanted to use comment tags inside the .txt file :D

Spoiler

# horse
20030	220.00
20101	220.00
20102	220.00
20103	220.00
20104	220.00
20105	220.00
20106	220.00
20107	220.00
20108	220.00
20109	220.00

# shop
30000	150.00

# mount
20212	0.01 # uff.. the mounts need to have 0.01
29212	0.01

# dragon
2493	300.00

 

 

EDIT:

iI think I was too sleepy at 4 AM when I wrote this reply, I didn't think I could modifty it into a dictionary :facepalm:

def __LoadRaceHeight():
	Dict = npcheight.NPC_HEIGHT

	for k,v in Dict.items():
		chrmgr.SetRaceHeight(k, v)
NPC_HEIGHT = {
	# horse
	20030 : 220.00,
	20101 : 220.00,
	20102 : 220.00,
	20103 : 220.00,
	20104 : 220.00,
	20105 : 220.00,
	20106 : 220.00,
	20107 : 220.00,
	20108 : 220.00,
	20109 : 220.00,
	# shop
	30000 : 150.00,
	# mount
	20212 : 0.01, # uff.. the mounts need to have 0.01
	29212 : 0.01,
	# dragon
	2493 : 300.00,
}

 

  • Like 5

Share this post


Link to post
Share on other sites

I have 4 errors:

16> InstanceBase.cpp (48): error C2653: "CRaceManager": not a class name or namespace name
16> InstanceBase.cpp (48): error C2228: left ".GetRaceHeight" must be of type struct/union
16> InstanceBase.cpp (48): error C3861: "instance": id was not found
198	IntelliSense: name followed by '::' must be a class or namespace name

nSJEeJF.png

Can anyone help?

Share this post


Link to post
Share on other sites
2 hours ago, Tatsumaru said:

I have 4 errors:


16> InstanceBase.cpp (48): error C2653: "CRaceManager": not a class name or namespace name
16> InstanceBase.cpp (48): error C2228: left ".GetRaceHeight" must be of type struct/union
16> InstanceBase.cpp (48): error C3861: "instance": id was not found
198	IntelliSense: name followed by '::' must be a class or namespace name

nSJEeJF.png

Can anyone help?

#include "../gamelib/RaceManager.h"
  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

good has worked for me, since I do not get
This function
 

v3Pos.z += float(m_GraphicThingInstance.GetHeight());

Share this post


Link to post
Share on other sites
4 hours ago, Meruem said:

good has worked for me, since I do not get
This function
 


v3Pos.z += float(m_GraphicThingInstance.GetHeight());

33145781_220445875225715_879935895399458

  • Like 1

Share this post


Link to post
Share on other sites
49 minutes ago, avertuss said:

Idk why but my client getting crash after login without errors in syserr when i have added python side. 

are you sure that you packed the text file in your root package?

On 5/15/2018 at 11:47 PM, xP3NG3Rx said:

3. Place the race_height.txt from the official client into the yours and pack it in the root.

 

Share this post


Link to post
Share on other sites

I think there are some "bugs". If u mount for example the power mounts the texttail is floating miles above you. Also if you're not riding a mount the texttail above them ("XZY's Horse") is also miles above them. Maybe you can take a look for this "bugs". But nice release anyway.

Thanks P3ng3r

Share this post


Link to post
Share on other sites

i added some new values to race_height.txt such as mounts as the name appears in the air 

but it dosent work , had to add them in source not sure if the race_height.txt is even working 

Share this post


Link to post
Share on other sites
On 5/28/2018 at 2:43 AM, PeaceMaker said:

i added some new values to race_height.txt such as mounts as the name appears in the air 

but it dosent work , had to add them in source not sure if the race_height.txt is even working 

yup same here, tried adding values and changing existing values, I even tried to delete all the data, and nothing changes in game.

Share this post


Link to post
Share on other sites

 

La 26.05.2018 la 21:57, Tryn a spus:

I think there are some "bugs". If u mount for example the power mounts the texttail is floating miles above you. Also if you're not riding a mount the texttail above them ("XZY's Horse") is also miles above them. Maybe you can take a look for this "bugs". But nice release anyway.

Thanks P3ng3r

 

La 29.05.2018 la 12:28, 3bd0 a spus:

yup same here, tried adding values and changing existing values, I even tried to delete all the data, and nothing changes in game.

Use what exygo posted.

 

If you want the dictionary in the same file, you'll have to modify 

 

Dict = npcheight.NPC_HEIGHT

to 

Dict = NPC_HEIGHT

Open instancebase.cpp and search for->

	if ((dwHorseVnum >= 20101 && dwHorseVnum <= 20109) ||
		(dwHorseVnum == 20029 || dwHorseVnum == 20030))
		return 100.0f;

Make a new case under it and put your mounts vnums, in my case it is:

	if ((dwHorseVnum >= 20110 || dwHorseVnum <= 20266))
		return 50.0f;

Then, enter PlayerSettingModule.py and use Exygo's dict as this for mounts->

    20110 : 160.00,
    20111 : 160.00,
    20112 : 160.00,
    20113 : 160.00,
    20114 : 160.00,
    20115 : 160.00,
    ...............
    20266 : 160,00,

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×