Jump to content

Need help in Cpp function


Go to solution Solved by danio475,

Recommended Posts

Hi guys I need to edit this funcion :

(Item.cpp) game src

	else if (GetWearFlag() & WEARABLE_UNIQUE)
	{
		if (ch->GetWear(WEAR_UNIQUE1))
			return WEAR_UNIQUE2;
		else
			return WEAR_UNIQUE1;
		
	}

I need just to add WEAR_UNIQUE3, and WEAR_UNIQUE4 because I want to expand Unique slots by sacrifice Ring slots, thanks for help ;) 

 

@@Edit somebody know how to edit it for 4 Unique slots?. Because without this game using only first two slots :v 

Link to comment
Share on other sites

  • Solution

solved by myself you have to define 16 if's with options to wear it's something like that :

 

	if (ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE2;
	if (!ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE2;
	if (ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE2;

 

 

There is a final function : 

else if (GetWearFlag() & WEARABLE_UNIQUE)
{
	if (!ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE1;
	if (!ch->GetWear(WEAR_UNIQUE1) && ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE1;
	if (!ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE1;
	if (!ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE1;
	if (!ch->GetWear(WEAR_UNIQUE1) && ch->GetWear(WEAR_UNIQUE2) && ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE1;
	if (!ch->GetWear(WEAR_UNIQUE1) && ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE1;
	if (!ch->GetWear(WEAR_UNIQUE1) && ch->GetWear(WEAR_UNIQUE2) && ch->GetWear(WEAR_UNIQUE3) && ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE1;
	if (!ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && ch->GetWear(WEAR_UNIQUE3) && ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE1;
	
	if (ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE2;
	if (ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE2;
	if (ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE2;
	if (ch->GetWear(WEAR_UNIQUE1) && !ch->GetWear(WEAR_UNIQUE2) && ch->GetWear(WEAR_UNIQUE3) && ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE2;

	
	
	if (ch->GetWear(WEAR_UNIQUE1) && ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE3;
	if (ch->GetWear(WEAR_UNIQUE1) && ch->GetWear(WEAR_UNIQUE2) && !ch->GetWear(WEAR_UNIQUE3) && ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE3;
	
	if (ch->GetWear(WEAR_UNIQUE1) && ch->GetWear(WEAR_UNIQUE2) && ch->GetWear(WEAR_UNIQUE3) && !ch->GetWear(WEAR_UNIQUE4))
		return WEAR_UNIQUE4;

}

 

 

 

the result : https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif.html 

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

21 hours ago, danio475 said:

@Syreldar that's why I asked for help on dev... I'm a totally beginner in cpp and I just do that as I can... idk why you're so rude before edition

else if (GetWearFlag() & WEARABLE_UNIQUE)
	{
		int wear[4] = { WEAR_UNIQUE1, WEAR_UNIQUE2, WEAR_UNIQUE3, WEAR_UNIQUE4 };

		for (int i = 0; i <= 3; i++)
		{
			if (!ch->GetWear(wear[i]))
				break;
		}

		return wear[i];
	}

Didn't test but should work as well.

  • Love 1
Link to comment
Share on other sites

@danio475 Where is scope of break in this loop?

You did a loop and check if not wear stop the loop without do nothing, so this loop not have sense.

	return wear[i];

You can't do that because "i" is not declared.

Should look like this what you say.

else if (GetWearFlag() & WEARABLE_UNIQUE)
{
	BYTE WEAR_EQ_LIST[4] = { 
		WEAR_UNIQUE1,	WEAR_UNIQUE2, 
		WEAR_UNIQUE3,	WEAR_UNIQUE4 
	};

	for (BYTE i=0; i<_countof(WEAR_EQ_LIST); i++)
	{
		BYTE bCell = WEAR_EQ_LIST[i];
		if (!ch->GetWear(bCell))
			return bCell;
	}
}

 

  • Love 1
Link to comment
Share on other sites

@Tasho

Thanks for reply i'll test your code but I have one question about mine version.

 

So, in my code is any (except tons of IF's ) problem? Like any bug, core downer or something? ;p I know it's write really bad but I always preffer to try find solution by myself, not only ask on dev or other boards for help ^^. Once again thanks for code

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.