Jump to content

Add new bonus to item_attr table -> bonus to be added via change/add bonus items


Recommended Posts

  • Premium

Hello, 

I've added strong against metins/bosses, and now, I am trying to add em to item_attr.

The goal is to make what is a bonus that I can add manually to an item, to be "addable" by add/change bonus items, if that makes sense?

Now I do not know what that implies, any ideas/suggestions would be much apreciated!

PS. I did try to add a new row in the table with APPLY_ATTBONUS_METIN, no luck tho.

Thanks

 

Tutorial by Owsap

Server Source

Spoiler
/// 1. @ game/char.cpp
// Search @ void CHARACTER::PointChange
	default:
		sys_err("CHARACTER::PointChange: %s: unknown point change type %d", GetName(), type);
		return;

// Add above
	case POINT_MY_NEW_BONUS:
		SetPoint(type, GetPoint(type) + amount);
		val = GetPoint(type);
		break;

/// 2. @ game/char.cpp
// Search
	default:
		sys_err("Unknown apply type %d name %s", bApplyType, GetName());
		break;

// Add above
	case APPLY_MY_NEW_BONUS:
		PointChange(aApplyInfo[bApplyType].bPointType, iVal);
		break;

/// 3. @ game/char.h
// Search @ enum EPointTypes
	//POINT_MAX_NUM = 255 common/length.h

// Add above
	POINT_MY_NEW_BONUS,

/// 4. @ game/constants.cpp
// Extend aApplyInfo[MAX_APPLY_NUM] with
	{ POINT_MY_NEW_BONUS, }, // APPLY_MY_NEW_BONUS

// Example
	{ POINT_RESIST_PENETRATE, }, // APPLY_ANTI_PENETRATE_PCT, 91
	{ POINT_MY_NEW_BONUS, }, // APPLY_MY_NEW_BONUS
};

/// 5. @ game/constants.cpp
// Search @ TValueName c_aApplyTypeNames[] =
	{ NULL, 0 }

// Add above
	{ "MY_NEW_BONUS", APPLY_MY_NEW_BONUS },

/// 6. Example
/*
* Now it all depends on what you want to do with this bonus.
* I will give you an example of how this bonus could be applied for Metin Stones.
*/
/// @ game/battle.cpp
// Search @ int CalcAttBonus
		iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_MONSTER)) / 100;

// Add below
		if (pkVictim->IsStone())
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_MY_NEW_BONUS)) / 100;

/// 7. @ db/ProtoReader.cpp
// Search @ get_Item_ApplyType_Value and extend arApplyType[] with
		"APPLY_MY_NEW_BONUS",

// Example
		"APPLY_ANTI_PENETRATE_PCT",
		"APPLY_MY_NEW_BONUS",
	};

 

We can do the MySQL part now since we have finished with the server part.
MySQL

Spoiler
/*
* Search @ Database (Use Navicat, it's a great piece of software.)
*	player.item_attr
*
* 1. Edit / Design table.
*
* 2. Extended the "apply" row "Values" with "MY_NEW_BONUS".
*
* 3. Save table.
*
* 4. Open player.item_attr table and add the new bonus type.
*
*	apply			prob	lv1	lv2	lv3	lv4	lv5	weapon	body ...
*	MY_NEW_BONUS	1		2	4	6	10	15	0		0	 ...
*
* 5. You can also do the same procedure above for the item_attr_rare (this table is for the 6/7 bonus)
*
*/

 

Now let's move on to the Client Source.
Client Source

Spoiler
/// 1. @ GameLib/ItemData.h
// Search @ enum EApplyTypes
		MAX_APPLY_NUM = 255,

// Add above
		APPLY_MY_NEW_BONUS,

/// 2. @ UserInterface/Packet.h
// Search @ enum EPointTypes
	// 클라이언트 포인트
	POINT_MIN_WEP = 200,

// Add above
	POINT_MY_NEW_BONUS,

/// 3. @ UserInterface/PythonItemModule.cpp
// Search
	PyModule_AddIntConstant(poModule, "APPLY_PENETRATE_PCT", CItemData::APPLY_PENETRATE_PCT);

// Add below
	PyModule_AddIntConstant(poModule, "APPLY_MY_NEW_BONUS", CItemData::APPLY_MY_NEW_BONUS);

/// 4. @ UserInterface/PythonPlayerModule.cpp
// Search
	PyModule_AddIntConstant(poModule, "POINT_PENETRATE_PCT", POINT_PENETRATE_PCT);

// Add below
	PyModule_AddIntConstant(poModule, "POINT_MY_NEW_BONUS", POINT_MY_NEW_BONUS);

 

Let's not forget our special tool, DumpProto.
DumpProto

Spoiler
/// 1. @ dump_proto/ItemCSVReader.cpp
// Search @ int get_Item_ApplyType_Value and extend arApplyType[] with
		"APPLY_MY_NEW_BONUS",

// Example
		"APPLY_ANTI_PENETRATE_PCT",
		"APPLY_MY_NEW_BONUS",
	};

 

Last but not least your client needs to read the new bonus type.

Client Root

Spoiler
''' 1. @ root/uiToolTip.py '''
# Search @ class ItemToolTip
	AFFECT_DICT = {

# Extend with
		item.APPLY_MY_NEW_BONUS : localeInfo.TOOLTIP_APPLY_MY_NEW_BONUS,

 

And finally, your bonus needs a name.

Client Locale

Spoiler
-- 1. @ locale/x/locale_game.txt
-- Add inside
TOOLTIP_APPLY_MY_NEW_BONUS	TOOLTIP_APPLY_ATTBONUS_WARRIOR	My New Bonus +%d%%	SA

 

⚠ Following the order of the points and apply types are very important, make sure every modification is in order since an incorent order may read another bonus.

  • Metin2 Dev 2
  • kekw 1
  • Angry 1
  • Good 1
  • Love 2
Link to comment
Share on other sites

  • Honorable Member

Here is a rather "complete" tutorial and I hope you understand.

First, let's start with the Server Source.

Server Source

Spoiler
/// 1. @ game/char.cpp
// Search @ void CHARACTER::PointChange
	default:
		sys_err("CHARACTER::PointChange: %s: unknown point change type %d", GetName(), type);
		return;

// Add above
	case POINT_MY_NEW_BONUS:
		SetPoint(type, GetPoint(type) + amount);
		val = GetPoint(type);
		break;

/// 2. @ common/length.h
// Search
	MAX_APPLY_NUM,

// Add above
	APPLY_MY_NEW_BONUS,

/// 3. @ game/char.cpp
// Search
	default:
		sys_err("Unknown apply type %d name %s", bApplyType, GetName());
		break;

// Add above
	case APPLY_MY_NEW_BONUS:
		PointChange(aApplyInfo[bApplyType].bPointType, iVal);
		break;

/// 4. @ game/char.h
// Search @ enum EPointTypes
	//POINT_MAX_NUM = 255 common/length.h

// Add above
	POINT_MY_NEW_BONUS,

/// 5. @ game/constants.cpp
// Extend aApplyInfo[MAX_APPLY_NUM] with
	{ POINT_MY_NEW_BONUS, }, // APPLY_MY_NEW_BONUS

// Example
	{ POINT_RESIST_PENETRATE, }, // APPLY_ANTI_PENETRATE_PCT, 91
	{ POINT_MY_NEW_BONUS, }, // APPLY_MY_NEW_BONUS
};

/// 6. @ game/constants.cpp
// Search @ TValueName c_aApplyTypeNames[] =
	{ NULL, 0 }

// Add above
	{ "MY_NEW_BONUS", APPLY_MY_NEW_BONUS },


/// 7. Example
/*
* Now it all depends on what you want to do with this bonus.
* I will give you an example of how this bonus could be applied for Metin Stones.
*/
/// @ game/battle.cpp
// Search @ int CalcAttBonus
		iAtk += (iAtk * pkAttacker->GetPoint(POINT_ATTBONUS_MONSTER)) / 100;

// Add below
		if (pkVictim->IsStone())
			iAtk += (iAtk * pkAttacker->GetPoint(POINT_MY_NEW_BONUS)) / 100;

/// 8. @ db/ProtoReader.cpp
// Search @ get_Item_ApplyType_Value and extend arApplyType[] with
		"APPLY_MY_NEW_BONUS",

// Example
		"APPLY_ANTI_PENETRATE_PCT",
		"APPLY_MY_NEW_BONUS",
	};

 

We can do the MySQL part now since we have finished with the server part.
MySQL

Spoiler
/*
* Search @ Database (Use Navicat, it's a great piece of software.)
*	player.item_attr
*
* 1. Edit / Design table.
*
* 2. Extended the "apply" row "Values" with "MY_NEW_BONUS".
*
* 3. Save table.
*
* 4. Open player.item_attr table and add the new bonus type.
*
*	apply			prob	lv1	lv2	lv3	lv4	lv5	weapon	body ...
*	MY_NEW_BONUS	1		2	4	6	10	15	0		0	 ...
*
* 5. You can also do the same procedure above for the item_attr_rare (this table is for the 6/7 bonus)
*
*/

 

Now let's move on to the Client Source.
Client Source

Spoiler
/// 1. @ GameLib/ItemData.h
// Search @ enum EApplyTypes
		MAX_APPLY_NUM = 255,

// Add above
		APPLY_MY_NEW_BONUS,

/// 2. @ UserInterface/Packet.h
// Search @ enum EPointTypes
	// 클라이언트 포인트
	POINT_MIN_WEP = 200,

// Add above
	POINT_MY_NEW_BONUS,

/// 3. @ UserInterface/PythonItemModule.cpp
// Search
	PyModule_AddIntConstant(poModule, "APPLY_PENETRATE_PCT", CItemData::APPLY_PENETRATE_PCT);

// Add below
	PyModule_AddIntConstant(poModule, "APPLY_MY_NEW_BONUS", CItemData::APPLY_MY_NEW_BONUS);

/// 4. @ UserInterface/PythonPlayerModule.cpp
// Search
	PyModule_AddIntConstant(poModule, "POINT_PENETRATE_PCT", POINT_PENETRATE_PCT);

// Add below
	PyModule_AddIntConstant(poModule, "POINT_MY_NEW_BONUS", POINT_MY_NEW_BONUS);

 

Let's not forget our special tool, DumpProto.
DumpProto

Spoiler
/// 1. @ dump_proto/ItemCSVReader.cpp
// Search @ int get_Item_ApplyType_Value and extend arApplyType[] with
		"APPLY_MY_NEW_BONUS",

// Example
		"APPLY_ANTI_PENETRATE_PCT",
		"APPLY_MY_NEW_BONUS",
	};

 

Last but not least your client needs to read the new bonus type.

Client Root

Spoiler
''' 1. @ root/uiToolTip.py '''
# Search @ class ItemToolTip
	AFFECT_DICT = {

# Extend with
		item.APPLY_MY_NEW_BONUS : localeInfo.TOOLTIP_APPLY_MY_NEW_BONUS,

 

And finally, your bonus needs a name.

Client Locale

Spoiler
-- 1. @ locale/x/locale_game.txt
-- Add inside
TOOLTIP_APPLY_MY_NEW_BONUS	TOOLTIP_APPLY_ATTBONUS_WARRIOR	My New Bonus +%d%%	SA

 

⚠ Following the order of the points and apply types are very important, make sure every modification is in order since an incorent order may read another bonus.

 

Sincerely, Owasp.

Edited by Owsap
Updated tutorial.
  • Metin2 Dev 1
  • Love 3
  • Love 3
Link to comment
Share on other sites

  • 2 years later...

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.