Yardım new attribute method

Konu sahibi bu konuda soru soruyor. Sorusu ile ilgili bilgisi olanların yanıtlamasını bekliyor.

Yasser600

Üye
Üye
Mesaj
19
Beğeni
3
Puan
430
Ticaret Puanı
0
Hi everyone
The first item creates the first and second bonus
The second item creates the third and fourth bonus
But (GetAttributeCount) the two item cannot be made compatible
So are there any other ideas for bonus
Here is the code so you can better understand what I mean
Kod:
                    case USE_ADD_COSTUME_ARMOR:
                        {
                            LPITEM item2;
                            if ((!IsValidItemPosition(DestCell)) || (!(item2 = GetItem(DestCell))))
                                return false;
                           
                            if (item2->IsEquipped())
                                BuffOnAttr_RemoveBuffsFromItem(item2);
                           
                            if ((item2->IsExchanging()) || (item2->IsEquipped()))
                                return false;

                            if (item2->GetAttributeSetIndex() == -1)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot carry out the operation!"));
                                return false;
                            }

                            if ((item2->GetSubType() != COSTUME_BODY)){
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot carry out the operation!"));
                                return false;
                            }

                            const BYTE applyType = item->GetValue(0);
                            const long applyValue = item->GetValue(1);
                            if (applyType == APPLY_NONE)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("UPS! Something has gone wrong. Get in touch with an administrator."));
                                return false;
                            }
                            const BYTE subTypeFlag = item2->GetBonusFlag();
                            if (item->GetValue(2) != 0 && subTypeFlag != 0)
                            {
                                if (!IS_SET(item->GetValue(2), 1 << subTypeFlag))
                                {
                                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot use this object in this item."));
                                    return false;
                                }
                            }
                            const BYTE maxAttrCount = item2->GetBonusMaxAttr();
                            if (item2->GetAttributeCount() >= maxAttrCount)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add more bonus to this object!"));
                                return false;
                            }
                            else if(item2->HasAttr(applyType))
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This bonus is already added to the object."));
                                return false;
                            }
                            if (item2->GetAttributeCount() < 2){                                               
                                item2->AddAttribute(applyType, applyValue);
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have added a successful bonus!"));
                            }
                            else
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("you cant add more bonus by this item"));
                                return false;
                            }
                           
                            item->SetCount(item->GetCount() - 1);
                            return true;
                           
                        }
                        break;

                    case USE_ADD_COSTUME_ARMOR2:
                        {
                            LPITEM item2;
                            if ((!IsValidItemPosition(DestCell)) || (!(item2 = GetItem(DestCell))))
                                return false;
                           
                            if (item2->IsEquipped())
                                BuffOnAttr_RemoveBuffsFromItem(item2);
                           
                            if ((item2->IsExchanging()) || (item2->IsEquipped()))
                                return false;

                            if (item2->GetAttributeSetIndex() == -1)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot carry out the operation!"));
                                return false;
                            }

                            if ((item2->GetSubType() != COSTUME_BODY)){
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot carry out the operation!"));
                                return false;
                            }

                            const BYTE applyType = item->GetValue(0);
                            const long applyValue = item->GetValue(1);
                            if (applyType == APPLY_NONE)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("UPS! Something has gone wrong. Get in touch with an administrator."));
                                return false;
                            }
                            const BYTE subTypeFlag = item2->GetBonusFlag();
                            if (item->GetValue(2) != 0 && subTypeFlag != 0)
                            {
                                if (!IS_SET(item->GetValue(2), 1 << subTypeFlag))
                                {
                                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot use this object in this item."));
                                    return false;
                                }
                            }
                            const BYTE maxAttrCount = item2->GetBonusMaxAttr();
                            if (item2->GetAttributeCount() >= maxAttrCount)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add more bonus to this object!"));
                                return false;
                            }
                            else if(item2->HasAttr(applyType))
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This bonus is already added to the object."));
                                return false;
                            }
                            if (item2->GetAttributeCount() < 2){                                                
                                item2->AddAttribute(applyType, applyValue);
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have added a successful bonus!"));
                            }
                            else
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("you cant add more bonus by this item"));
                                return false;
                            }
                            item->SetCount(item->GetCount() - 1);
                            return true;
                           
                        }
                        break;
 
Biraz detay verebilir misin? Aldığın hatalar vb.
Tam olarak anlayamadım.
 
Bir iteme, sıralı bir şekilde farklı sayılarda bonus vermek istiyorsan bunun için bu case bloklarına ihtiyacın yok.

Aşağıdaki basit kodu inceleyebilirsin. Test etmedim ama sana farklı bir fikir verebilir.
Ayrıca "const" türündeki verilerin bu kadar sık kullanımı çok fazla dikkat gerektirir. Bu yüzden kaldırdım, gerektiğinde tekrar kullanabilirsin.
C++:
                        case EXAMPLE:
                        {
                            LPITEM item2;
                            BYTE applyType = item->GetValue(0);
                            long applyValue = item->GetValue(1);
                            BYTE subTypeFlag = item2->GetBonusFlag();
                            BYTE maxAttrCount = item2->GetBonusMaxAttr();
                            
                            if ((!IsValidItemPosition(DestCell)) || (!(item2 = GetItem(DestCell))))
                                return false;
                         
                            if (item2->IsEquipped())
                                BuffOnAttr_RemoveBuffsFromItem(item2);
                         
                            if ((item2->IsExchanging()) || (item2->IsEquipped()))
                                return false;

                            if (item2->GetAttributeSetIndex() == -1)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot carry out the operation!"));
                                return false;
                            }

                            if ((item2->GetSubType() != COSTUME_BODY)){
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot carry out the operation!"));
                                return false;
                            }

                           
                            if (applyType == APPLY_NONE)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("UPS! Something has gone wrong. Get in touch with an administrator."));
                                return false;
                            }

                            if (item->GetValue(2) != 0 && subTypeFlag != 0)
                            {
                                if (!IS_SET(item->GetValue(2), 1 << subTypeFlag))
                                {
                                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot use this object in this item."));
                                    return false;
                                }
                            }
                            if (item2->GetAttributeCount() >= maxAttrCount)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add more bonus to this object!"));
                                return false;
                            }
                            else if(item2->HasAttr(applyType))
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This bonus is already added to the object."));
                                return false;
                            }

                            int max_bonus = item2->GetAttributeCount();
                            if (max_bonus < 4) // 4 = Maksimum bonus sayısı.
                            {
                                if (max_bonus + 2 <= 4) // 4 = Maksimum bonus sayısı.
                                {
                                    for (short i = 0; i < 2; i++) // 2 = bonus sayısı
                                        item2->AddAttribute(applyType, applyValue);
                                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have added two successful bonuses!"));
                                    item->SetCount(item->GetCount() - 1);
                                    return true;
                                }
                                else
                                {
                                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add more than 4 bonuses by this item"));
                                }
                            }
                            else
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have reached the maximum number of bonuses for this item"));
                                return false;
                            }
                        }
                        break;
 
Bir iteme, sıralı bir şekilde farklı sayılarda bonus vermek istiyorsan bunun için bu case bloklarına ihtiyacın yok.

Aşağıdaki basit kodu inceleyebilirsin. Test etmedim ama sana farklı bir fikir verebilir.
Ayrıca "const" türündeki verilerin bu kadar sık kullanımı çok fazla dikkat gerektirir. Bu yüzden kaldırdım, gerektiğinde tekrar kullanabilirsin.
C++:
                        case EXAMPLE:
                        {
                            LPITEM item2;
                            BYTE applyType = item->GetValue(0);
                            long applyValue = item->GetValue(1);
                            BYTE subTypeFlag = item2->GetBonusFlag();
                            BYTE maxAttrCount = item2->GetBonusMaxAttr();
                            if ((!IsValidItemPosition(DestCell)) || (!(item2 = GetItem(DestCell))))
                                return false;
                        
                            if (item2->IsEquipped())
                                BuffOnAttr_RemoveBuffsFromItem(item2);
                        
                            if ((item2->IsExchanging()) || (item2->IsEquipped()))
                                return false;

                            if (item2->GetAttributeSetIndex() == -1)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot carry out the operation!"));
                                return false;
                            }

                            if ((item2->GetSubType() != COSTUME_BODY)){
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot carry out the operation!"));
                                return false;
                            }

                          
                            if (applyType == APPLY_NONE)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("UPS! Something has gone wrong. Get in touch with an administrator."));
                                return false;
                            }

                            if (item->GetValue(2) != 0 && subTypeFlag != 0)
                            {
                                if (!IS_SET(item->GetValue(2), 1 << subTypeFlag))
                                {
                                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot use this object in this item."));
                                    return false;
                                }
                            }
                            if (item2->GetAttributeCount() >= maxAttrCount)
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add more bonus to this object!"));
                                return false;
                            }
                            else if(item2->HasAttr(applyType))
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This bonus is already added to the object."));
                                return false;
                            }

                            int max_bonus = item2->GetAttributeCount();
                            if (max_bonus < 4) // 4 = Maksimum bonus sayısı.
                            {
                                if (max_bonus + 2 <= 4) // 4 = Maksimum bonus sayısı.
                                {
                                    for (short i = 0; i < 2; i++) // 2 = bonus sayısı
                                        item2->AddAttribute(applyType, applyValue);
                                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have added two successful bonuses!"));
                                    item->SetCount(item->GetCount() - 1);
                                    return true;
                                }
                                else
                                {
                                    ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't add more than 4 bonuses by this item"));
                                }
                            }
                            else
                            {
                                ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have reached the maximum number of bonuses for this item"));
                                return false;
                            }
                        }
                        break;
thx i will try
 
Geri
Üst