Jump to content

C++ Change only Attr Value


Recommended Posts

Peace!

The following question: Is it possible to rewrite the Attr Change / Add function so that the Switcher only switches the values and not equal to Type and Values?
If the maximum attribute you can have on a weapon (etc), the particular attribute wanted to be able to change only the values through a "switcher".
My problem is that the general problem of the function is that the types & values are set to (0) and calculated by "int i = 0; i <cnt; ++".
I would like to let the guys on it so that only the values are changed.
But if I remove the query, IG does not happen anymore.

For level 1 through 5, ask which bonus level can be used, just "(rand ()% 4) + 1" for random generation.

My snippet currently looks like this.
Maybe one of the Big Brains has an idea.
I thank you in advance !!
sorry for my bad English.. xP

Greetings.

Spoiler

XrKZNMp.png

oCjg1Eu.png



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

// Add this function prototype to public in item.h
		void		ChangeAttributeValue();
// Add this function in item_attribute.cpp or item.cpp
void CItem::ChangeAttributeValue()
{
	int attrCount = GetAttributeCount();
	if(attrCount == 0)
		return;
	
	int iAttributeSet = GetAttributeSetIndex();
	if (iAttributeSet < 0)
		return;

	for(int k = 0; k < attrCount; k++)
	{
		int attr_idx = GetAttributeType(k);
		
		const TItemAttrTable & r = g_map_itemAttr[attr_idx];
		int nLevel = number(1, r.bMaxLevelBySet[iAttributeSet]);
		long lVal = r.lValues[MIN(4, nLevel - 1)];
		
		if (lVal)
			SetAttribute(k, attr_idx, lVal);
	}
}

// In char_item.cpp just go to the item you want to be the changer and replace:
item2->ChangeAttribute
// With
item2->ChangeAttributeValue();

 

  • Love 1
Link to comment
Share on other sites

vor 21 Stunden schrieb Johnny69:

// Add this function prototype to public in item.h
		void		ChangeAttributeValue();
// Add this function in item_attribute.cpp or item.cpp
void CItem::ChangeAttributeValue()
{
	int attrCount = GetAttributeCount();
	if(attrCount == 0)
		return;
	
	int iAttributeSet = GetAttributeSetIndex();
	if (iAttributeSet < 0)
		return;

	for(int k = 0; k < attrCount; k++)
	{
		int attr_idx = GetAttributeType(k);
		
		const TItemAttrTable & r = g_map_itemAttr[attr_idx];
		int nLevel = number(1, r.bMaxLevelBySet[iAttributeSet]);
		long lVal = r.lValues[MIN(4, nLevel - 1)];
		
		if (lVal)
			SetAttribute(k, attr_idx, lVal);
	}
}

// In char_item.cpp just go to the item you want to be the changer and replace:
item2->ChangeAttribute
// With
item2->ChangeAttributeValue();

 

Thanks duded ?

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.