BOOL CShop::InsertItem(int type, int index, int level, int dur, int op1, int op2 ,int op3) { int itemp; int width; int height; int x; int y; int blank; blank = -1; itemp = type * MAX_SUBTYPE_ITEMS + index; if ( itemp < 0 ) { MsgBox("Error in creating item at shop %s %d", __FILE__, __LINE__); return false; } ItemGetSize(itemp, width, height); if ( width < 0 || height < 0 ) { MsgBox("Error in getting item size in shop %s %d", __FILE__, __LINE__); return FALSE; } for ( y=0;y<15;y++) { for ( x=0;x<8;x++) { if ( this->ShopInventoryMap[x + y*8] == 0 ) { blank = this->InentoryMapCheck(x, y, width, height); if ( blank >= 0 ) { goto skiploop; } } } } if ( blank < 0 ) { MsgBox("error-L2 : %s %d", __FILE__, __LINE__); return FALSE; } skiploop: this->m_item[blank].m_Level = level; if ( dur == 0 ) { dur = ItemGetDurability(ITEMGET(type, index), level, 0, 0); } this->m_item[blank].m_Durability = dur; this->m_item[blank].Convert(itemp, op1, op2, op3, 0, 0, 0, CURRENT_DB_VERSION); this->m_item[blank].Value(); this->SendItemData[this->SendItemDataLen] = blank; this->SendItemDataLen++; ItemByteConvert((LPBYTE)&this->SendItemData[this->SendItemDataLen], this->m_item[blank]); this->SendItemDataLen += 7; this->ItemCount++; this->Type.push_back(type); this->Index.push_back(index); this->Level.push_back(level); this->Dur.push_back(dur); this->Opt1.push_back(op1); this->Opt2.push_back(op2); this->Opt3.push_back(op3); return TRUE; }
BOOL CJewelOfHarmonySystem::StrengthenItemByJewelOfHarmony(LPOBJ lpObj, int source, int target) { if ( this->m_bSystemStrengthenItem == FALSE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13, 52)), lpObj->m_Index, 1); return FALSE; } if ( source < 0 || source > MAIN_INVENTORY_SIZE-1 ) return FALSE; if ( target < 0 || target > MAIN_INVENTORY_SIZE-1 ) return FALSE; if ( lpObj->pInventory[source].IsItem() == FALSE ) return FALSE; if ( lpObj->pInventory[target].IsItem() == FALSE ) return FALSE; CItem * pSource = &lpObj->pInventory[source]; CItem * pTarget = &lpObj->pInventory[target]; if ( this->IsStrengthenByJewelOfHarmony(pTarget) == TRUE ) { CLog.LogAdd("[JewelOfHarmony][Strengten Item] Already Strengtened [%s][%s]", lpObj->AccountID, lpObj->Name); return FALSE; } if (pTarget->IsSetItem() == TRUE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13, 44)), lpObj->m_Index, 1); CLog.LogAdd("[JewelOfHarmony][Strengten Item] SetItem not enable to Strengtened [%s][%s]", lpObj->AccountID, lpObj->Name); return FALSE; } int iItemType = this->_GetItemType(pTarget); if ( iItemType == JEWELOFHARMONY_ITEM_TYPE_NULL ) { CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d] Invalid ItemType[%d]", lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iItemType); return FALSE; } int iItemOption = this->_GetSelectRandomOption(pTarget, iItemType); if ( iItemOption == AT_JEWELOFHARMONY_NOT_STRENGTHEN_ITEM ) { CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail - NOT OPTION [%s][%s] Name[%s] Type[%d] Serial[%d] ItemType[%d]", lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iItemType); return FALSE; } int iItemOptionLevel = this->m_itemOption[iItemType][iItemOption].iRequireLevel; int iSuccessRate = rand() % 100; if ( iSuccessRate >= this->m_iRateStrengthenSuccess ) { CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Fail [%s][%s] Name[%s] Type[%d] Serial[%d] Rate (%d/%d)", lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iSuccessRate, this->m_iRateStrengthenSuccess); GCServerMsgStringSend(lMsg.Get(MSGGET(13, 45)), lpObj->m_Index, 1); return TRUE; } this->_MakeOption(pTarget, iItemOption, iItemOptionLevel); CLog.LogAdd("[JewelOfHarmony][Strengten Item] Strenghten Success [%s][%s] Name[%s] Type[%d] Serial[%d] Rate (%d/%d) Option %d OptionLevel %d", lpObj->AccountID, lpObj->Name, pTarget->GetName(), pTarget->m_Type, pTarget->m_Number, iSuccessRate, this->m_iRateStrengthenSuccess, iItemOption, iItemOptionLevel); GCServerMsgStringSend(lMsg.Get(MSGGET(13, 46)), lpObj->m_Index, 1); gObjMakePreviewCharSet(lpObj->m_Index); float levelitemdur = (float)ItemGetDurability(lpObj->pInventory[target].m_Type, lpObj->pInventory[target].m_Level, lpObj->pInventory[target].IsExtItem(), lpObj->pInventory[target].IsSetItem()); lpObj->pInventory[target].m_Durability = levelitemdur * lpObj->pInventory[target].m_Durability / lpObj->pInventory[target].m_BaseDurability; lpObj->pInventory[target].Convert(lpObj->pInventory[target].m_Type, lpObj->pInventory[target].m_Option1, lpObj->pInventory[target].m_Option2, lpObj->pInventory[target].m_Option3, lpObj->pInventory[target].m_NewOption, lpObj->pInventory[target].m_SetOption, lpObj->pInventory[target].m_ItemOptionEx,lpObj->pInventory[target].m_ItemSocket); return TRUE; }
bool CustomJewels::Apply(LPOBJ lpObj, int source, int target) { char sbuf[1024]={0}; int TIndex = lpObj->pInventory[target].m_Type; int SIndex = lpObj->pInventory[source].m_Type; if(source < 0 || source > ReadConfig.MAIN_INVENTORY_SIZE(lpObj->m_Index,false)-1 ) { return false; } if(target < 0 || target > ReadConfig.MAIN_INVENTORY_SIZE(lpObj->m_Index,false)-1 ) { return false; } if(lpObj->pInventory[source].IsItem() == 0) { return false; } if(lpObj->pInventory[target].IsItem() == 0) { return false; } if (lpObj->pInventory[target].m_Type >= ITEMGET(12,0)) { GCServerMsgStringSend("Can not aply this jewel to this item!",lpObj->m_Index, 0x01); return false; } if (!gObjJewelUpHackCheck(lpObj,target)) { GCServerMsgStringSend("[Anti-Hack] Shadow Bug Attempt!",lpObj->m_Index, 0x01); if(ReadConfig.AHLog == TRUE) { ANTI_HACK_LOG.Output("[Anti-Hack][Custom Jewel][%s][%s] Shadow Bug Attempt, Item: %d", lpObj->AccountID,lpObj->Name,lpObj->pInventory[target].m_Type); } return false; } BYTE jPos = IsJewel(SIndex); BYTE jSuccess = GetSuccessPosition(SIndex); BYTE jFail = GetFailPosition(SIndex); if(jPos == -1) { LogAddTD("[CJewel] Could not find jewel property with id: %d", SIndex); GCServerMsgStringSend("JEWEL ERROR, contact GM!",lpObj->m_Index, 0x01); return false; } if(jSuccess == -1) { LogAddTD("[CJewel] Could not find jewel success with id: %d", SIndex); GCServerMsgStringSend("JEWEL ERROR, contact GM!",lpObj->m_Index, 0x01); return false; } if(jFail == -1) { LogAddTD("[CJewel] Could not find jewel fail with id: %d", SIndex); GCServerMsgStringSend("JEWEL ERROR, contact GM!",lpObj->m_Index, 0x01); return false; } if(lpObj->pInventory[target].m_Level < this->Property[jPos].MinLevel) { wsprintf(sbuf,"Item level must be higher than %d!",this->Property[jPos].MinLevel); GCServerMsgStringSend(sbuf,lpObj->m_Index, 0x01); return false; } if(lpObj->pInventory[target].m_Level > this->Property[jPos].MaxLevel) { wsprintf(sbuf,"Item level must be lower than %d!",this->Property[jPos].MaxLevel); GCServerMsgStringSend(sbuf,lpObj->m_Index, 0x01); return false; } if(lpObj->pInventory[target].m_Z28Option < this->Property[jPos].MinZ28Option) { wsprintf(sbuf,"Item JOL option minimum is +%d",(this->Property[jPos].MinZ28Option*4)); GCServerMsgStringSend(sbuf,lpObj->m_Index, 0x01); return false; } if(this->Property[jPos].hasToHaveLuck == -1) { if (lpObj->pInventory[target].m_LuckOption != 0) { GCServerMsgStringSend("Item can not have Luck!",lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].hasToHaveLuck > 0) { if (lpObj->pInventory[target].m_LuckOption == 0) { GCServerMsgStringSend("Item has to have Luck!",lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].hasToHaveSkill == -1) { if (lpObj->pInventory[target].m_SkillOption != 0) { GCServerMsgStringSend("Item can not have Skill!",lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].hasToHaveSkill > 0) { if (lpObj->pInventory[target].m_SkillOption == 0) { GCServerMsgStringSend("Item has to have Skill!",lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].hasToBeAncient == -1) { if (lpObj->pInventory[target].m_SetOption != 0) { GCServerMsgStringSend("Item can not be Ancient!",lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].hasToBeAncient > 0) { if (lpObj->pInventory[target].m_SetOption == 0) { GCServerMsgStringSend("Item must be Ancient!",lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].hasToBeExcellent == -1) { if (lpObj->pInventory[target].m_NewOption != 0) { GCServerMsgStringSend("Item can not be Excellent!",lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].hasToBeExcellent > 0) { if (lpObj->pInventory[target].m_NewOption == 0) { GCServerMsgStringSend("Item must be Excellent!",lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].MaxExc != 0) { if(NumOfExcOptions(lpObj->pInventory[target].m_NewOption) >= this->Property[jPos].MaxExc) { wsprintf(sbuf,"Cant add jewel, you have a lot of excellent options, max opt are %d!",this->Property[jPos].MaxExc); GCServerMsgStringSend(sbuf,lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].hasToBeSoketItem == -1) { if(IsSlotItem(lpObj->pInventory[target].m_Type)==1) { GCServerMsgStringSend("Item can not be socket item!",lpObj->m_Index, 0x01); return false; } } if(this->Property[jPos].hasToBeSoketItem == 1) { if(IsSlotItem(lpObj->pInventory[target].m_Type)==0) { GCServerMsgStringSend("This item has to be socket item!",lpObj->m_Index, 0x01); return false; } else { if(this->Property[jPos].MinNumberSokets > 0) { BYTE counter = 0; if (lpObj->pInventory[target].m_ItemSlot1 > 0) counter += 1; if (lpObj->pInventory[target].m_ItemSlot2 > 0) counter += 1; if (lpObj->pInventory[target].m_ItemSlot3 > 0) counter += 1; if (lpObj->pInventory[target].m_ItemSlot4 > 0) counter += 1; if (lpObj->pInventory[target].m_ItemSlot5 > 0) counter += 1; if (this->Property[jPos].MinNumberSokets > counter) { wsprintf(sbuf,"Item minimum socket count is %d",this->Property[jPos].MinNumberSokets); GCServerMsgStringSend(sbuf,lpObj->m_Index, 0x01); return false; } } } } if(this->Property[jPos].MaxNumberSokets != 0) { BYTE counter = 0; if (lpObj->pInventory[target].m_ItemSlot1 > 0) counter += 1; if (lpObj->pInventory[target].m_ItemSlot2 > 0) counter += 1; if (lpObj->pInventory[target].m_ItemSlot3 > 0) counter += 1; if (lpObj->pInventory[target].m_ItemSlot4 > 0) counter += 1; if (lpObj->pInventory[target].m_ItemSlot5 > 0) counter += 1; if(counter >= this->Property[jPos].MaxNumberSokets) { wsprintf(sbuf,"Cant add jewel, you have a lot of socket slots, max slot are %d!",this->Property[jPos].MaxNumberSokets); GCServerMsgStringSend(sbuf,lpObj->m_Index, 0x01); return false; } } //if(MuItemShop.IsCShopItem(aIndex,target) == true) //{ // GCServerMsgStringSend("You can not use the jewel in this item!",lpObj->m_Index, 0x01); // return true; //} LogAddTD("[CJewel][%s][%s] Use %s on item %s (%d)", lpObj->AccountID,lpObj->Name,lpObj->pInventory[source].GetName(),lpObj->pInventory[target].GetName(), lpObj->pInventory[target].m_Number); int _r = rand()%100; if(_r < this->Property[jPos].Rate ) { //Success GCServerMsgStringSend("Jewel Succeded!",lpObj->m_Index, 0x01); LogAddTD("[CJewel][%s][%s] Success %s on item %s (%d) [%d][%d,%d]", lpObj->AccountID,lpObj->Name,lpObj->pInventory[source].GetName(),lpObj->pInventory[target].GetName(), lpObj->pInventory[target].m_Number, TIndex,_r,this->Property[jPos].Rate); if(this->Success[jSuccess].Luck == 1) { lpObj->pInventory[target].m_LuckOption = 1; } if(this->Success[jSuccess].Skill == 1) { lpObj->pInventory[target].m_SkillOption = 1; } if(this->Success[jSuccess].SetItem == 1) { lpObj->pInventory[target].m_SetOption = gSetItemOption.GenSetOption(lpObj->pInventory[target].m_Type); } if(this->Success[jSuccess].Excellent != 63) { if(this->Success[jSuccess].Excellent > 0) { lpObj->pInventory[target].m_NewOption |= this->Success[jSuccess].Excellent; } }else { lpObj->pInventory[target].m_NewOption = 63; } if(this->Success[jSuccess].Level > 0) { if((lpObj->pInventory[target].m_Level + this->Success[jSuccess].Level) > MAX_ITEM_LEVEL) { lpObj->pInventory[target].m_Level = MAX_ITEM_LEVEL; }else { lpObj->pInventory[target].m_Level += this->Success[jSuccess].Level; } } if(this->Success[jSuccess].Sokets > 0) { if ( IsSlotItem(lpObj->pInventory[target].m_Type) ) { for(int k=0;k<this->Success[jSuccess].Sokets;k++) { if (lpObj->pInventory[target].m_ItemSlot1 == 0) lpObj->pInventory[target].m_ItemSlot1 = 0xFF; else if (lpObj->pInventory[target].m_ItemSlot2 == 0) lpObj->pInventory[target].m_ItemSlot2 = 0xFF; else if (lpObj->pInventory[target].m_ItemSlot3 == 0) lpObj->pInventory[target].m_ItemSlot3 = 0xFF; else if (lpObj->pInventory[target].m_ItemSlot4 == 0) lpObj->pInventory[target].m_ItemSlot4 = 0xFF; else if (lpObj->pInventory[target].m_ItemSlot5 == 0) lpObj->pInventory[target].m_ItemSlot5 = 0xFF; } } } if(this->Success[jSuccess].Option > 0) { if((lpObj->pInventory[target].m_Z28Option + this->Success[jSuccess].Option) > 7) { lpObj->pInventory[target].m_Z28Option = 7; }else { lpObj->pInventory[target].m_Z28Option += this->Success[jSuccess].Option; } } } else { //Fail GCServerMsgStringSend("Jewel Failed!",lpObj->m_Index, 0x01); LogAddTD("[CJewel][%s][%s] Fail %s on item %s (%d) [%d][%d,%d]", lpObj->AccountID,lpObj->Name,lpObj->pInventory[source].GetName(),lpObj->pInventory[target].GetName(), lpObj->pInventory[target].m_Number, TIndex,_r,this->Property[jPos].Rate); if(this->Fail[jFail].Destroy == 1) { gObjInventoryItemSet(lpObj->m_Index, target, -1); lpObj->pInventory[target].Clear(); GCInventoryItemDeleteSend(lpObj->m_Index, target, 1); return true; } if(this->Fail[jFail].Luck == -1) { lpObj->pInventory[target].m_LuckOption = 0; } if(this->Fail[jFail].Skill == -1) { lpObj->pInventory[target].m_SkillOption = 0; } if(this->Fail[jFail].SetItem == -1) { lpObj->pInventory[target].m_SetOption = 0; } if(this->Fail[jFail].Excellent < 0) { if(this->Fail[jFail].Excellent == -63) lpObj->pInventory[target].m_NewOption = 0; else if( (lpObj->pInventory[target].m_NewOption&(this->Fail[jFail].Excellent)) ) lpObj->pInventory[target].m_NewOption += (this->Fail[jFail].Excellent); if(lpObj->pInventory[target].m_NewOption < 0) lpObj->pInventory[target].m_NewOption = 0; } if(this->Fail[jFail].Level < 0) { if((lpObj->pInventory[target].m_Level + (this->Fail[jFail].Level)) < 0) { lpObj->pInventory[target].m_Level = 0; }else { lpObj->pInventory[target].m_Level += (this->Fail[jFail].Level); } } if(this->Fail[jFail].Sokets < 0) { if ( IsSlotItem(lpObj->pInventory[target].m_Type) ) { for(int k=0;k<(this->Fail[jFail].Sokets);k++) { if (lpObj->pInventory[target].m_ItemSlot5 > 0) lpObj->pInventory[target].m_ItemSlot5 = 0x00; else if (lpObj->pInventory[target].m_ItemSlot4 > 0) lpObj->pInventory[target].m_ItemSlot4 = 0x00; else if (lpObj->pInventory[target].m_ItemSlot3 > 0) lpObj->pInventory[target].m_ItemSlot3 = 0x00; else if (lpObj->pInventory[target].m_ItemSlot2 > 0) lpObj->pInventory[target].m_ItemSlot2 = 0x00; else if (lpObj->pInventory[target].m_ItemSlot1 > 0) lpObj->pInventory[target].m_ItemSlot1 = 0x00; } } } if(this->Fail[jFail].Option < 0) { if((lpObj->pInventory[target].m_Z28Option + (this->Fail[jFail].Option)) < 0) { lpObj->pInventory[target].m_Z28Option = 0; }else { lpObj->pInventory[target].m_Z28Option += (this->Fail[jFail].Option); } } } float levelitemdur = ItemGetDurability(lpObj->pInventory[target].m_Type,lpObj->pInventory[target].m_Level,lpObj->pInventory[target].IsExtItem(),lpObj->pInventory[target].IsSetItem()); lpObj->pInventory[target].m_Durability = levelitemdur * lpObj->pInventory[target].m_Durability / lpObj->pInventory[target].m_BaseDurability; lpObj->pInventory[target].Convert( lpObj->pInventory[target].m_Type, lpObj->pInventory[target].m_SkillOption, lpObj->pInventory[target].m_LuckOption, lpObj->pInventory[target].m_Z28Option, lpObj->pInventory[target].m_NewOption, lpObj->pInventory[target].m_SetOption, lpObj->pInventory[target].m_ItemOptionEx, CURRENT_DB_VERSION); if(g_kJewelOfHarmonySystem.IsStrengthenByJewelOfHarmony(&lpObj->pInventory[target])== 1) { if(g_kJewelOfHarmonySystem.IsActive(&lpObj->pInventory[target]) == 0) { GCServerMsgStringSend(lMsg.Get(3370),lpObj->m_Index,1); } } return true; }