Active Member enzi 842 Posted August 17, 2017 Active Member Share Posted August 17, 2017 Hi.. I today tried to add special attr for belts but when i try add bonus with new item it does not do anything.. Here is everything what i add: common/item_length.h USE_BELT_CHANGE_ATTRIBUTE, USE_BELT_ADD_ATTRIBUTE, game/src/char_item.cpp // BELTATTR case USE_BELT_CHANGE_ATTRIBUTE: case USE_BELT_ADD_ATTRIBUTE: { LPITEM item2; if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell))) return false; if (item2->IsExchanging()) return false; if (item2->IsEquipped()) return false; if (ITEM_WEAPON == item2->GetType() || ITEM_ARMOR == item2->GetType() || COSTUME_HAIR == item2->GetSubType() || COSTUME_ACCE == item2->GetSubType()) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can use these bonuses only on belts.")); return false; } switch (item->GetSubType()) { case USE_BELT_ADD_ATTRIBUTE: if (item2->GetAttributeSetIndex() == -1) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("??? ??? ? ?? ??????.")); return false; } if (item2->GetAttributeCount() < 1) { char buf[21]; snprintf(buf, sizeof(buf), "%u", item2->GetID()); item2->AddAttribute(); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have successfully added bonus.")); item->SetCount(item->GetCount() - 1); } else { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can add just a bonus outfit.")); break; } break; case USE_BELT_CHANGE_ATTRIBUTE: if (item2->GetAttributeSetIndex() == -1) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("??? ??? ? ?? ??????.")); return false; } if (item2->GetAttributeCount() == 0) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This suit does not own any bonus.")); return false; } item2->ClearAttribute(); item2->AlterToMagicItem(); item->SetCount(item->GetCount() - 1); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You just changed the bonus.")); break; } } break; game/src/item.cpp 2x case ITEM_BELT: iSecondPct = 50; iThirdPct = 40; break; db/src/ProtoReader.cpp "USE_BELT_CHANGE_ATTRIBUTE", "USE_BELT_ADD_ATTRIBUTE" dump_proto/ItemCSVReader.cpp "USE_BELT_CHANGE_ATTRIBUTE", "USE_BELT_ADD_ATTRIBUTE" server/db/item_proto.txt 70066 ???? ITEM_USE USE_BELT_CHANGE_ATTRIBUTE 1 ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_MYSHOP ITEM_STACKABLE | LOG NONE NONE 0 0 0 0 0 LIMIT_NONE 0 LIMIT_NONE 0 APPLY_NONE 0 APPLY_NONE 0 APPLY_NONE 0 0 0 0 0 0 0 0 0 0 70065 ???? ITEM_USE USE_BELT_ADD_ATTRIBUTE 1 ANTI_DROP | ANTI_SELL | ANTI_GIVE | ANTI_MYSHOP ITEM_STACKABLE | LOG NONE NONE 0 0 0 0 0 LIMIT_NONE 0 LIMIT_NONE 0 APPLY_NONE 0 APPLY_NONE 0 APPLY_NONE 0 0 0 0 0 0 0 0 0 0 GameLib/ItemData.cpp case USE_BELT_CHANGE_ATTRIBUTE: return DEF_STR(USE_BELT_CHANGE_ATTRIBUTE); case USE_BELT_ADD_ATTRIBUTE: return DEF_STR(USE_BELT_ADD_ATTRIBUTE); GameLib/ItemData.h USE_BELT_CHANGE_ATTRIBUTE, USE_BELT_ADD_ATTRIBUTE, root/uiinventory.py "USE_BELT_CHANGE_ATTRIBUTE", "USE_BELT_ADD_ATTRIBUTE" Someone know what can i do bad? Thx Link to comment Share on other sites More sharing options...
Silver Sonitex 1438 Posted August 17, 2017 Silver Share Posted August 17, 2017 Wouldn't it be eaiser if you add few if statements like they did for changers and adders which can be only used on weapons/armours till level 40? Link to comment Share on other sites More sharing options...
Active Member enzi 842 Posted August 17, 2017 Author Active Member Share Posted August 17, 2017 Ye, you are right but i want these other bonuses use to other item type.. Link to comment Share on other sites More sharing options...
Active Member enzi 842 Posted August 18, 2017 Author Active Member Share Posted August 18, 2017 Now i tried edit code in char_item.cpp like that for test: case USE_BELT_ADD_ATTRIBUTE: { LPITEM item2; if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell))) return false; if (item2->IsExchanging()) return false; if (item2->IsEquipped()) return false; if (ITEM_WEAPON == item2->GetType() || ITEM_ARMOR == item2->GetType() || COSTUME_HAIR == item2->GetSubType() ) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can use these bonuses only on belts.")); return false; } if (item2->GetAttributeSetIndex() == -1) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼Ó¼ºÀ» º¯°æÇÒ ¼ö ¾ø´Â ¾ÆÀÌÅÛÀÔ´Ï´Ù.")); return false; } if (item2->GetAttributeCount() >= 3) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("´õÀÌ»ó ÀÌ ¾ÆÀÌÅÛÀ» ÀÌ¿ëÇÏ¿© ¼Ó¼ºÀ» Ãß°¡ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; } if (item2->GetAttributeCount() < 3) { if (number(1, 100) < 30) { while(item2->GetAttributeCount() < number(2, 3)) item2->AddAttribute(); } else { item2->AddAttribute(); } } else { item2->AddAttribute(); } item->SetCount(item->GetCount() - 1); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have successfully added bonus.")); } break; case USE_BELT_CHANGE_ATTRIBUTE: { LPITEM item2; if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell))) return false; if (item2->IsExchanging()) return false; if (item2->IsEquipped()) return false; if (ITEM_WEAPON == item2->GetType() || ITEM_ARMOR == item2->GetType() || COSTUME_HAIR == item2->GetSubType() ) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can use these bonuses only on belts.")); return false; } if (item2->GetAttributeSetIndex() == -1) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼Ó¼ºÀ» º¯°æÇÒ ¼ö ¾ø´Â ¾ÆÀÌÅÛÀÔ´Ï´Ù.")); return false; } if (item2->GetAttributeCount() == 0) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("º¯°æÇÒ ¼Ó¼ºÀÌ ¾ø½À´Ï´Ù.")); return false; } item2->ChangeAttribute(); item->SetCount(item->GetCount() - 1); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You just changed the bonus.")); } break; Now i can use this bonus on SASH and COSTUME ARMOR.. [ye,ye i know i can edit it here if (ITEM_WEAPON == item2->GetType() || ITEM_ARMOR == item2->GetType() || COSTUME_HAIR == item2->GetSubType() ) ] but i edit it on purpose.. but on belt it say me in chat that bulls*it : ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼Ó¼ºÀ» º¯°æÇÒ ¼ö ¾ø´Â ¾ÆÀÌÅÛÀÔ´Ï´Ù.")); I´m totaly done from this Link to comment Share on other sites More sharing options...
Premium Syreldar 1876 Posted August 18, 2017 Premium Share Posted August 18, 2017 On 8/18/2017 at 7:51 PM, enzi said: Now i tried edit code in char_item.cpp like that for test: Hide contents case USE_BELT_ADD_ATTRIBUTE: { LPITEM item2; if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell))) return false; if (item2->IsExchanging()) return false; if (item2->IsEquipped()) return false; if (ITEM_WEAPON == item2->GetType() || ITEM_ARMOR == item2->GetType() || COSTUME_HAIR == item2->GetSubType() ) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can use these bonuses only on belts.")); return false; } if (item2->GetAttributeSetIndex() == -1) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼Ó¼ºÀ» º¯°æÇÒ ¼ö ¾ø´Â ¾ÆÀÌÅÛÀÔ´Ï´Ù.")); return false; } if (item2->GetAttributeCount() >= 3) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("´õÀÌ»ó ÀÌ ¾ÆÀÌÅÛÀ» ÀÌ¿ëÇÏ¿© ¼Ó¼ºÀ» Ãß°¡ÇÒ ¼ö ¾ø½À´Ï´Ù.")); return false; } if (item2->GetAttributeCount() < 3) { if (number(1, 100) < 30) { while(item2->GetAttributeCount() < number(2, 3)) item2->AddAttribute(); } else { item2->AddAttribute(); } } else { item2->AddAttribute(); } item->SetCount(item->GetCount() - 1); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have successfully added bonus.")); } break; case USE_BELT_CHANGE_ATTRIBUTE: { LPITEM item2; if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell))) return false; if (item2->IsExchanging()) return false; if (item2->IsEquipped()) return false; if (ITEM_WEAPON == item2->GetType() || ITEM_ARMOR == item2->GetType() || COSTUME_HAIR == item2->GetSubType() ) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can use these bonuses only on belts.")); return false; } if (item2->GetAttributeSetIndex() == -1) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼Ó¼ºÀ» º¯°æÇÒ ¼ö ¾ø´Â ¾ÆÀÌÅÛÀÔ´Ï´Ù.")); return false; } if (item2->GetAttributeCount() == 0) { ChatPacket(CHAT_TYPE_INFO, LC_TEXT("º¯°æÇÒ ¼Ó¼ºÀÌ ¾ø½À´Ï´Ù.")); return false; } item2->ChangeAttribute(); item->SetCount(item->GetCount() - 1); ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You just changed the bonus.")); } break; Now i can use this bonus on SASH and COSTUME ARMOR.. [ye,ye i know i can edit it here if (ITEM_WEAPON == item2->GetType() || ITEM_ARMOR == item2->GetType() || COSTUME_HAIR == item2->GetSubType() ) ] but i edit it on purpose.. but on belt it say me in chat that bulls*it : ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¼Ó¼ºÀ» º¯°æÇÒ ¼ö ¾ø´Â ¾ÆÀÌÅÛÀÔ´Ï´Ù.")); I´m totaly done from this "Nothing's free in this life. Ignorant people have an obligation to make up for their ignorance by paying those who help them. Either you got the brains or cash, if you lack both you're useless." Syreldar Link to comment Share on other sites More sharing options...
Active Member enzi 842 Posted August 18, 2017 Author Active Member Share Posted August 18, 2017 On 8/18/2017 at 8:56 PM, Syreldar said: Ye, but can you explain me what is bad in this if? Link to comment Share on other sites More sharing options...
Premium Solution Syreldar 1876 Posted August 18, 2017 Premium Solution Share Posted August 18, 2017 5 minutes ago, enzi said: Ye, but can you explain me what is bad in this if? You should study a bit and learn by yourself to debug and look into the code. in item_attribute.cpp: Spoiler int CItem::GetAttributeSetIndex() { if (GetType() == ITEM_WEAPON) { if (GetSubType() == WEAPON_ARROW) return -1; return ATTRIBUTE_SET_WEAPON; } if (GetType() == ITEM_ARMOR) { switch (GetSubType()) { case ARMOR_BODY: return ATTRIBUTE_SET_BODY; case ARMOR_WRIST: return ATTRIBUTE_SET_WRIST; case ARMOR_FOOTS: return ATTRIBUTE_SET_FOOTS; case ARMOR_NECK: return ATTRIBUTE_SET_NECK; case ARMOR_HEAD: return ATTRIBUTE_SET_HEAD; case ARMOR_SHIELD: return ATTRIBUTE_SET_SHIELD; case ARMOR_EAR: return ATTRIBUTE_SET_EAR; } } else if (GetType() == ITEM_COSTUME) { switch (GetSubType()) { case COSTUME_BODY: // ÄÚ½ºÃõ °©¿ÊÀº ÀÏ¹Ý °©¿Ê°ú µ¿ÀÏÇÑ Attribute SetÀ» ÀÌ¿ëÇÏ¿© ·£´ý¼Ó¼º ºÙÀ½ (ARMOR_BODY == COSTUME_BODY) return ATTRIBUTE_SET_BODY; case COSTUME_HAIR: // ÄÚ½ºÃõ Çì¾î´Â ÀÏ¹Ý Åõ±¸ ¾ÆÀÌÅÛ°ú µ¿ÀÏÇÑ Attribute SetÀ» ÀÌ¿ëÇÏ¿© ·£´ý¼Ó¼º ºÙÀ½ (ARMOR_HEAD == COSTUME_HAIR) return ATTRIBUTE_SET_HEAD; #ifdef ENABLE_MOUNT_COSTUME_SYSTEM case COSTUME_MOUNT: break; #endif #ifdef ENABLE_WEAPON_COSTUME_SYSTEM case COSTUME_WEAPON: return ATTRIBUTE_SET_WEAPON; #endif } } return -1; } Basically, if the piece of equipment found is not included in this switch set, it returns -1, The previous if statement, states that if this check returns -1, you can't put any bonuses, which is normal since you normally aren't able to insert bonuses in a belt, thus you have to adapt it. Solution: Add the item attribute to the switchset. 1 "Nothing's free in this life. Ignorant people have an obligation to make up for their ignorance by paying those who help them. Either you got the brains or cash, if you lack both you're useless." Syreldar Link to comment Share on other sites More sharing options...
Active Member enzi 842 Posted August 18, 2017 Author Active Member Share Posted August 18, 2017 12 hours ago, Syreldar said: You should study a bit and learn by yourself to debug and look into the code. in item_attribute.cpp: Hide contents int CItem::GetAttributeSetIndex() { if (GetType() == ITEM_WEAPON) { if (GetSubType() == WEAPON_ARROW) return -1; return ATTRIBUTE_SET_WEAPON; } if (GetType() == ITEM_ARMOR) { switch (GetSubType()) { case ARMOR_BODY: return ATTRIBUTE_SET_BODY; case ARMOR_WRIST: return ATTRIBUTE_SET_WRIST; case ARMOR_FOOTS: return ATTRIBUTE_SET_FOOTS; case ARMOR_NECK: return ATTRIBUTE_SET_NECK; case ARMOR_HEAD: return ATTRIBUTE_SET_HEAD; case ARMOR_SHIELD: return ATTRIBUTE_SET_SHIELD; case ARMOR_EAR: return ATTRIBUTE_SET_EAR; } } else if (GetType() == ITEM_COSTUME) { switch (GetSubType()) { case COSTUME_BODY: // ÄÚ½ºÃõ °©¿ÊÀº ÀÏ¹Ý °©¿Ê°ú µ¿ÀÏÇÑ Attribute SetÀ» ÀÌ¿ëÇÏ¿© ·£´ý¼Ó¼º ºÙÀ½ (ARMOR_BODY == COSTUME_BODY) return ATTRIBUTE_SET_BODY; case COSTUME_HAIR: // ÄÚ½ºÃõ Çì¾î´Â ÀÏ¹Ý Åõ±¸ ¾ÆÀÌÅÛ°ú µ¿ÀÏÇÑ Attribute SetÀ» ÀÌ¿ëÇÏ¿© ·£´ý¼Ó¼º ºÙÀ½ (ARMOR_HEAD == COSTUME_HAIR) return ATTRIBUTE_SET_HEAD; #ifdef ENABLE_MOUNT_COSTUME_SYSTEM case COSTUME_MOUNT: break; #endif #ifdef ENABLE_WEAPON_COSTUME_SYSTEM case COSTUME_WEAPON: return ATTRIBUTE_SET_WEAPON; #endif } } return -1; } Basically, if the piece of equipment found is not included in this switch set, it returns -1, The previous if statement, states that if this check returns -1, you can't put any bonuses, which is normal since you normally aren't able to insert bonuses in a belt, thus you have to adapt it. Solution: Add the item attribute to the switchset. Ye, you are totally right.. I checked this file today.. I tried to create some new ATTRIBUTE_SET for belt (like ATTRIBUTE_SET_BET) + create new table in item_attr but without success because i rly dont know where i need to add that new ATTRIBUTE_SET.. I added it in ClientManagerBoot.cpp.. Is there some othere place where to add it ? EDIT: After little edit in item_attribute.cpp like that: (I´m still searching for some way how to create new ATTRIBUTE_SET) if (GetType() == ITEM_BELT) { return ATTRIBUTE_SET_EAR; } EDIT 2: All fixed for now I have only little problem with client side When i use bonus on item is red but i try to do something in uiinventory.py.. but when someone know what edit in uiinventory just post it here.. Thanks to all Link to comment Share on other sites More sharing options...
Active Member enzi 842 Posted August 19, 2017 Author Active Member Share Posted August 19, 2017 Uiinevntory.py edited.. This one works for switcher.. def __CanChangeBeltAttrList(self, dstSlotPos): dstItemVNum = player.GetItemIndex(dstSlotPos) if dstItemVNum == 0: return False item.SelectItem(dstItemVNum) if item.GetItemType() == item.ITEM_TYPE_BELT: return True return False I tried to add it for adder too but without success.. def __CanAddBeltAttr(self, dstSlotPos): dstItemVNum = player.GetItemIndex(dstSlotPos) if dstItemVNum == 0: return False item.SelectItem(dstItemVNum) if not item.GetItemType() in (item.ITEM_TYPE_BELT): return False attrCount = 0 for i in xrange(player.METIN_SOCKET_MAX_NUM): if player.GetItemAttribute(dstSlotPos, i) != 0: attrCount += 1 if attrCount<4: return True return False Is there something bad? Fixxed: def __CanAddBeltAttr(self, dstSlotPos): dstItemVNum = player.GetItemIndex(dstSlotPos) if dstItemVNum == 0: return False item.SelectItem(dstItemVNum) if item.GetItemType() == item.ITEM_TYPE_BELT: return True attrCount = 0 for i in xrange(player.METIN_SOCKET_MAX_NUM): if player.GetItemAttribute(dstSlotPos, i) != 0: attrCount += 1 if attrCount<4: return True return False Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now