Jump to content

Hi.

Member
  • Posts

    5
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Hi.

  1. Hi,

    This is a item witch can change dragon soul attributes, I made it with subtype but you can easily do it by vnum. Here you have the case for subtype:
    (If in DragonSoul.h function PutAttributes is on private move it on public.)

     

    Spoiler
    
    #ifdef USE_CHANGE_ATTRIBUTE_DS
    					case USE_C_ATTRIBUTE_DS:
    					{
    						LPITEM pDS;
    						if (!IsValidItemPosition(DestCell) || !(pDS = GetItem(DestCell)))
    							return false;
     
    						if (pDS->IsExchanging() || pDS->IsEquipped())
    						{
    							ChatPacket(CHAT_TYPE_INFO, "Alchimia este echipata, dezechipeaz-o pentru a folosi bonusul.");
    							return false;
    						}
     
    						if (pDS->IsDragonSoul())
    						{
    							pDS->ClearAttribute();
    							DSManager::instance().PutAttributes(pDS);
    							item->SetCount(item->GetCount() - 1);
    							ChatPacket(CHAT_TYPE_INFO, "Bonusul a fost schimbat cu succes.");
    						}
    						else
    						{
    							ChatPacket(CHAT_TYPE_INFO, "Itemul se poate folosi doar pe alchimie.");
    							return false;
    						}
    					}
    #endif

     

    https://pastebin.com/0cNA0Xtj

    • Metin2 Dev 12
    • Confused 1
    • Scream 1
    • Good 4
    • Love 2
    • Love 4
  2. Hello everyone,

    What this can do ? This item can set a fix attribute that you set from item_proto (value0 and value1). This is just an example, it's made just for costume_body, if you want to make it for something else just make a new subtype.

    (1) Open char_item.cpp and search this:

    case USE_RESET_COSTUME_ATTR:

    After this case put this:

    #ifdef SET_ATT_ITEM
    					case USE_SET_ATT_COSTUME :
    					{
    						LPITEM item2;
    						if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
    							return false;
     
    						if (item2->IsEquipped())
    						{
    							BuffOnAttr_RemoveBuffsFromItem(item2);
    						}
     
    						if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
    							return false;
     
    						if ((item2->GetType() == ITEM_COSTUME) && (item2->GetSubType() == COSTUME_BODY))
    						{
    							if (item2->GetAttributeCount() < 2)
    							{
    								if (item2->HasAttr(item->GetValue(0)))
    								{
    									ChatPacket(CHAT_TYPE_INFO, "You can't add the same bonus two times.");
    									return false;
    								}
    								item2->AddAttribute(item->GetValue(0), item->GetValue(1));
    								ChatPacket(CHAT_TYPE_INFO, "The bonus has been added successfully.");
     
    								item->SetCount(item->GetCount() - 1);
    							}
    							else
    							{
    								ChatPacket(CHAT_TYPE_INFO, "Adding bonus failed. You can only add two bonuses on your costume!");
    							}
    						}
    						else
    						{
    							ChatPacket(CHAT_TYPE_INFO, "The bonus goes only on the costume!");
    						}
    					}
    					break;
     
    #endif

    (2) Open item_length.h and search this:

    enum EUseSubTypes

    Add in the end:

    USE_SET_ATT_COSTUME,

    [(Don't forget to put on service.h/CommonDefines.h this: #define SET_ATT_ITEM ) if you don't want "define" just remove the "#ifdef SET_ATT_ITEM from  char_item ]

    (3) DB, Open ProtoReader.cpp and searchi:

    static string arSub3[] = {

    Add in the end: 

    "USE_SET_ATT_COSTUME"

    (4) Binary source, Gamelib, Open ItemData.h and search:

    enum EUseSubTypes

    Add in the end: 

    USE_SET_ATT_COSTUME,

    (5) Gamelib, Open ItemData.cpp and search:

     }
        return "USE_UNKNOWN_TYPE";

    Before this add:

    case USE_SET_ATT_COSTUME:
    
    	return DEF_STR(USE_SET_ATT_COSTUME);

    (6) Userinterface, Open PythonItemModule.cpp and search:

    PyModule_AddIntConstant(poModule, "USE_SPECIAL",                CItemData::USE_SPECIAL);

    Put this after:

    PyModule_AddIntConstant(poModule, "USE_SET_ATT_COSTUME",                CItemData::USE_SET_ATT_COSTUME);

    (7) Open uiinventory.py from root and search:

    class InventoryWindow(ui.ScriptWindow):

    After this we need to have:

    USE_TYPE_TUPLE = ("USE_CLEAN_SOCKET", "USE_CHANGE_ATTRIBUTE", "USE_ADD_ATTRIBUTE", "USE_ADD_ATTRIBUTE2", "USE_ADD_ACCESSORY_SOCKET", "USE_PUT_INTO_ACCESSORY_SOCKET", "USE_PUT_INTO_BELT_SOCKET", "USE_PUT_INTO_RING_SOCKET")

    In this list we add in the end this:

    , "USE_SET_ATT_COSTUME"

    (8) In uiinventory.py search:

    elif "USE_ADD_ATTRIBUTE2" == useType:

    After this elif we need to add this:

    		elif "USE_SET_ATT_COSTUME" == useType:
    			if self.__CanSetItemAttr(dstSlotPos):
    				return True

    (9) In uiinventory search:

    def __CanAddItemAttr(self, dstSlotPos):

    After this def, add this: 

    	def __CanSetItemAttr(self, dstSlotPos):
    		dstItemVNum = player.GetItemIndex(dstSlotPos)
    		if dstItemVNum == 0:
    			return False
     
    		item.SelectItem(dstItemVNum)
     
    		if not item.GetItemType() in (item.ITEM_TYPE_COSTUME):
    			return False
     
    		attrCount = 0
    		for i in xrange(player.METIN_SOCKET_MAX_NUM):
    			if player.GetItemAttribute(dstSlotPos, i) != 0:
    				attrCount += 1
     
    		if attrCount<2:
    			return True
     
    		return False

    (10) Open tooltip.py and search :

    elif item.USE_ABILITY_UP == itemSubType:

    From

    elif item.ITEM_TYPE_USE == itemType: 

    After this:

    elif item.USE_ABILITY_UP == itemSubType:

    We need to add this:

    			elif item.USE_SET_ATT_COSTUME == itemSubType:
    				type = item.GetValue(0)
    				value = item.GetValue(1)
     
    				if value:
    					affectString = self.__GetAffectString(type, value)
    					if affectString:
    						affectColor = self.__GetAttributeColor(0, value)
    						self.AppendTextLine(affectString, affectColor)

    After you completed all the steps above create a new item with type ITEM_USE and subtype USE_SET_ATT_COSTUME.

    Here are some examples of items:

    50898	축복의 구슬	ITEM_USE	USE_SET_ATT_COSTUME	1	ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_STACK | ANTI_MYSHOP	ITEM_QUEST | LOG	NONE	NONE	0	0	0	0	0	LIMIT_NONE	0	LIMIT_NONE	0	APPLY_NONE	0	APPLY_NONE	0	APPLY_NONE	0	1	2000	0	0	0	0	0	0	0
    50897	축복의 구슬	ITEM_USE	USE_SET_ATT_COSTUME	1	ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_STACK | ANTI_MYSHOP	ITEM_QUEST | LOG	NONE	NONE	0	0	0	0	0	LIMIT_NONE	0	LIMIT_NONE	0	APPLY_NONE	0	APPLY_NONE	0	APPLY_NONE	0	17	10	0	0	0	0	0	0	0
    50896	축복의 구슬	ITEM_USE	USE_SET_ATT_COSTUME	1	ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_STACK | ANTI_MYSHOP	ITEM_QUEST | LOG	NONE	NONE	0	0	0	0	0	LIMIT_NONE	0	LIMIT_NONE	0	APPLY_NONE	0	APPLY_NONE	0	APPLY_NONE	0	15	10	0	0	0	0	0	0	0

     

    Video :
    https://www.youtube.com/watch?v=728yoPapNCw

    I hope i didn't forgot anything .

    Have a nice day.

    • Metin2 Dev 4
    • Love 3
  3. M2 Download Center

    This is the hidden content, please
    ( Internal )

    Hello,

    What make this? Extend time for some items, what items you want, i make for costume body & hair.


    (1.1)Open char_item.cpp and search :

     

    case USE_TIME_CHARGE_FIX:

     

    (1.2)After this case put this:

    #ifdef EXTEND_TIME_COSTUME
    					case USE_EXTEND_TIME:
    						{
    							LPITEM item2;
     
    							if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
    								return false;
     
    							if (item2->IsExchanging() || item2->IsEquipped())
    							{
    								ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use this item when you exchange or when your object is equipped."));
    								return false;
    							}
     
    							if (item2->GetType() != ITEM_COSTUME || (item2->GetSubType() != COSTUME_BODY && item2->GetSubType() != COSTUME_HAIR))
    							{
    								ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use this item for this object."));
    								return false;
    							}
     
    							item2->SetSocket(0, item2->GetSocket(0) + item->GetValue(0));
    							item->SetCount(item->GetCount() - 1);
    							ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Extended time was added!"));
    						}
    						break;
    #endif

     

    (2.1) Go in DB in ProteReader.cpp and search:

    static string arSub3[] = {

    (2.2) At the end of this list we add:
     

    "USE_EXTEND_TIME", 

    (3.1) Go in common, open item_length.h and search:

    enum EUseSubTypes

    (3.2) In this enum going the last line and put this:
     

    USE_EXTEND_TIME,

    (4.1) Binary, in GameLib -> ItemData.h and search :
     

    enum EUseSubTypes

    (4.2)In this enum going the last line and put this:
     

    USE_EXTEND_TIME,

    (5.1) Userinterface, in PythonItemModule.cpp and search: 

     

    PyModule_AddIntConstant(poModule, "USE_SPECIAL",				CItemData::USE_SPECIAL);

     

    (5.2) After this line put this:

    PyModule_AddIntConstant(poModule, "USE_EXTEND_TIME",				CItemData::USE_EXTEND_TIME);

     

    Done with game/binary source.

    (1.1) Open root, in uiinventory.py and search:

    def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos):

     

    (1.2) On this def put this:

     

    		dstItemVnum = player.GetItemIndex(dstItemSlotPos)
    		if dstItemVnum != 0:
    			item.SelectItem(srcItemVID)
    			srcItemType = item.GetItemType()
    			srcItemSubType = item.GetItemSubType()
    			item.SelectItem(dstItemVnum)
    			if srcItemType == item.ITEM_TYPE_USE and srcItemSubType == item.USE_EXTEND_TIME and item.GetItemType() == item.ITEM_TYPE_COSTUME and (item.GetItemSubType() == item.COSTUME_TYPE_BODY or item.GetItemSubType() == item.COSTUME_TYPE_HAIR):
    				self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)

     

    P.S: If you want Window Dialog make this: 

    Spoiler

     

    Skip Step (1.2) , and make this step:

     

    
    
    
    		dstItemVnum = player.GetItemIndex(dstItemSlotPos)
    		if dstItemVnum != 0:
    			item.SelectItem(srcItemVID)
    			srcItemType = item.GetItemType()
    			srcItemSubType = item.GetItemSubType()
    			item.SelectItem(dstItemVnum)
    			if srcItemType == item.ITEM_TYPE_USE and srcItemSubType == item.USE_EXTEND_TIME and item.GetItemType() == item.ITEM_TYPE_COSTUME and (item.GetItemSubType() == item.COSTUME_TYPE_BODY or item.GetItemSubType() == item.COSTUME_TYPE_HAIR):
    				self.questionDialog = uiCommon.QuestionDialog()
    				self.questionDialog.SetText("Vrei sa adaugi timp pe acest obiect?")
    				self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.ExtendTime))
    				self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
    				self.questionDialog.Open()
    				self.questionDialog.src = srcItemSlotPos
    				self.questionDialog.dst = dstItemSlotPos

     

    But you need to put before this:

    
    
    
    
    def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos):

    This:

    
    
    
    	def	ExtendTime(self):
    		self.__SendUseItemToItemPacket(self.questionDialog.src, self.questionDialog.dst)
    		self.OnCloseQuestionDialog()

     

    (1.3) Search:

    def __IsUsableItemToItem(self, srcItemVNum, srcSlotPos):

    (1.4) On this def put this:

    		if srcItemVNum != 0:
    			item.SelectItem(srcItemVNum)
    			if item.GetItemType() == item.ITEM_TYPE_USE and item.GetItemSubType() == item.USE_EXTEND_TIME:
    				return True

     

    (1.5) Search:

    def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos):

     

    (1.6) On this def put this: 

    		dstItemVnum = player.GetItemIndex(dstSlotPos)
    		if dstItemVnum != 0:
    			item.SelectItem(srcItemVNum)
    			srcItemType = item.GetItemType()
    			srcItemSubType = item.GetItemSubType()
    			item.SelectItem(dstItemVnum)
     
    			if srcItemType == item.ITEM_TYPE_USE and srcItemSubType == item.USE_EXTEND_TIME and item.GetItemType() == item.ITEM_TYPE_COSTUME and (item.GetItemSubType() == item.COSTUME_TYPE_BODY or item.GetItemSubType() == item.COSTUME_TYPE_HAIR):
    				return True

     

    Done.

    How to do item: You make a new item with type ITEM_USE and subtype USE_EXTEND_TIME and you put time you want on your item in Value0 (in seconds).

     

    Whit this methor you just make a new item for diferent times.

    About define EXTEND_TIME_COSTUME, you can remove it or you can add it in service.h (I use this define, you can use another).

    I don't think a screen or a video is needed.

    • Metin2 Dev 18
    • Good 6
    • Love 16
×
×
  • 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.