Jump to content

Player's Alignment logic


Recommended Posts

Hi devs, can someone explain me how the alignment system works on the database? For example I have a player with 1257 alignment on the database and in-game the alignment is 108. How can I convert the database alignment to the in-game alignment? For example I want to do this while I'm getting information from the player.player table:

Spoiler

if (player.alignment > 3999 && player.alignment < 8001)

{

    alignmentlabel.Text = "Good";

}

Can someone explain me this logic please? How 1257 = 108?

Thanks in advance :)

Link to comment
Share on other sites

[File: /Src/server/game/src/char.cpp]

//1.) Search:

			addPacket.sAlignment = m_iAlignment / 10;

//2.) Replace with:

			addPacket.sAlignment = m_iAlignment;

//1.) Search:

	pack.sAlignment	= m_iAlignment / 10;

//2.) Replace with:

	pack.sAlignment	= m_iAlignment;

[File: /Src/server/game/src/char_battle.cpp]

//1.) Search:

void CHARACTER::UpdateAlignment(int iAmount)
{
	bool bShow = false;

	if (m_iAlignment == m_iRealAlignment)
		bShow = true;

	int i = m_iAlignment / 10;

	m_iRealAlignment = MINMAX(-200000, m_iRealAlignment + iAmount, 200000);

	if (bShow)
	{
		m_iAlignment = m_iRealAlignment;

		if (i != m_iAlignment / 10)
			UpdatePacket();
	}
}

//2.) Replace with:

void CHARACTER::UpdateAlignment(int iAmount)
{
	bool bShow = false;

	if (m_iAlignment == m_iRealAlignment)
		bShow = true;

	int i = m_iAlignment;

	m_iRealAlignment = MINMAX(-20000, m_iRealAlignment + iAmount, 20000);

	if (bShow)
	{
		m_iAlignment = m_iRealAlignment;

		if (i != m_iAlignment)
			UpdatePacket();
	}
}

 

Now you'll get the real values, for example if your align in the game is 17214 in the database will show 17214 work good, before to make that  he show multiplied by *10 equals with 172 140 in database.

Now this is a check what you want:

	if (GetRealAlignment() > 3999 && GetRealAlignment() < 8001)
	{
		ChatPacket(CHAT_TYPE_INFO, "<Debug> Alignment loaded: %u", GetRealAlignment());
	}

 

  • Love 1
Link to comment
Share on other sites

Ohh and i forgot this:

[File: /Src/server/game/src/questlua_pc.cpp]

//1.) Search:

	int pc_get_real_alignment(lua_State* L)
	{
		lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetRealAlignment()/10);
		return 1;
	}
	int pc_get_alignment(lua_State* L)
	{
		lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetAlignment()/10);
		return 1;
	}
	int pc_change_alignment(lua_State * L)
	{
		int alignment = (int)(lua_tonumber(L, 1)*10);
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();

		ch->UpdateAlignment(alignment);
		return 0;
	}

//2.) Replace with:

	int pc_get_real_alignment(lua_State* L)
	{
		lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetRealAlignment());
		return 1;
	}
	int pc_get_alignment(lua_State* L)
	{
		lua_pushnumber(L, CQuestManager::instance().GetCurrentCharacterPtr()->GetAlignment());
		return 1;
	}
	int pc_change_alignment(lua_State * L)
	{
		int alignment = (int)(lua_tonumber(L, 1));
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
		ch->UpdateAlignment(alignment);
		return 0;
	}

 

Edited by VegaS
questlua_pc.cpp
  • Love 1
Link to comment
Share on other sites

2 minutes ago, Mind Rapist said:

Btw in this line did you mean -200.000, m_iRealAlignment + iAmount; 200.000 or -20.000, m_iRealAlignment + iAmount; 20.000

Oh ya ya , i forgot, sorry again.

	m_iRealAlignment = MINMAX(-200000, m_iRealAlignment + iAmount, 200000);

Replace with:

	m_iRealAlignment = MINMAX(-20000, m_iRealAlignment + iAmount, 20000);

 

Haste makes waste, haha. xD

  • Love 1
Link to comment
Share on other sites

2 hours ago, ds_aim said:

004f7007a3804b35918ee886b6ec4efc.png

Align 890 it means 89 ingame .

 

2 hours ago, VegaS said:

Now you'll get the real values, for example if your align in the game is 17214 in the database will show 17214 work good, before to make that  he show multiplied by *10 equals with 172 140 in database.

 

Already i say that noob, next time read carefully the information and code..so please stop to make spam xD

Edited by Metin2 Dev
Core X - External 2 Internal
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.