// ------------------------------------------------------------------------------------------------------------------------------------------------------ void CGPartyListAll(int pnumber) { PMSG_PARTYLISTCOUNT pCount; PMSG_PARTYLIST pList; BYTE sendbuf[512]; int lOfs = 0; int number; if( pnumber < 0 ) return; if( gParty.IsParty(pnumber) == FALSE ) return; C1HeadSet((LPBYTE)&pCount, 0x42, sizeof(pCount)); pCount.Result = false; pCount.Count = gParty.GetCount(pnumber); if( pCount.Count == 0 ) return; pCount.Result = true; lOfs += sizeof(pCount); for ( int n=0;n<MAX_USER_IN_PARTY;n++) { number = gParty.m_PartyInfo[pnumber].Number[n]; if( number >= 0 ) { if( gObjIsConnected(&gObj[number]) == TRUE ) { memset(&pList, 0, sizeof(pList)); memcpy(pList.szId, gObj[number].Name, MAX_ACCOUNT_LEN); pList.Number = n; pList.MapNumber = gObj[number].MapNumber; pList.X = gObj[number].X; pList.Y = gObj[number].Y; pList.Life = gObj[number].Life; pList.MaxLife = gObj[number].MaxLife; memcpy(&sendbuf[lOfs], &pList, sizeof(pList)); lOfs += sizeof(pList); } } } pCount.h.size = lOfs; memcpy(sendbuf, &pCount, sizeof(pCount)); for ( int n=0;n<MAX_USER_IN_PARTY;n++) { number = gParty.m_PartyInfo[pnumber].Number[n]; if( number >= 0 ) { gSendProto.DataSend(number, sendbuf, lOfs); } } }
// ------------------------------------------------------------------------------------------------------------------------------------------------------ void GCPartyDelUserSend(int aIndex) { PMSG_PARTYDELUSERSEND pMsg; C1HeadSet((LPBYTE)&pMsg, 0x43, sizeof(pMsg)); gSendProto.DataSend(aIndex, (LPBYTE)&pMsg, pMsg.h.size); }
// ------------------------------------------------------------------------------------------------------------------------------------------------------ void PartyClass::PartyMemberLifeSend(int Number) { if ( IsParty(Number) == FALSE ) return; // ----- PMSG_DEFAULT_COUNT pCount; PMSG_PARTYLIFEALL pList; // ----- int aIndex; int lOfs = 0; char SendBuff[512]; // ----- C1HeadSet((LPBYTE)&pCount, 0x44, sizeof(pCount)); // ----- pCount.Count = m_PartyInfo[Number].Count; // ----- lOfs += sizeof(pCount); // ----- for ( int i = 0; i<MAX_USER_IN_PARTY ; i++ ) { if ( (m_PartyInfo[Number].Number[i] >= 0 ) && (m_PartyInfo[Number].DbNumber[i] >= 0) ) { aIndex = m_PartyInfo[Number].Number[i]; // ----- if ( gObjIsConnected(aIndex) != PLAYER_EMPTY ) { pList.Number = (i*16) & 0xF0 ; pList.Number |= (BYTE)(gObj[aIndex].Life / ((gObj[aIndex].MaxLife + gObj[aIndex].AddLife) / 10)) & 0x0F; // ----- memcpy(&SendBuff[lOfs], &pList, 1); // ----- lOfs++; } else { m_PartyInfo[Number].Number[i] = -1; m_PartyInfo[Number].DbNumber[i] = -1; // ----- m_PartyInfo[Number].Count--; } } } // ----- pCount.h.size = lOfs; // ----- memcpy(SendBuff, &pCount, sizeof(pCount)); // ----- for ( int i=0 ; i<MAX_USER_IN_PARTY ; i++ ) { aIndex = m_PartyInfo[Number].Number[i]; // ----- if ( aIndex >= 0 ) { gSendProto.DataSend(aIndex, (unsigned char*)SendBuff, lOfs); } } }
// ------------------------------------------------------------------------------------------------------------------------------------------------------ void CGPartyList(int aIndex) { PMSG_PARTYLISTCOUNT pCount; PMSG_PARTYLIST pList; BYTE sendbuf[512]; int lOfs = 0; if( !PacketCheckTime(&gObj[aIndex])) return; C1HeadSet((LPBYTE)&pCount, 0x42, sizeof(pCount)); pCount.Count = 0; pCount.Result = false; int number; int pnumber = gObj[aIndex].PartyNumber ; if( pnumber >= 0 ) pCount.Count = gParty.GetCount(pnumber); lOfs += sizeof(pCount); if( pCount.Count != 0 ) { for ( int n=0;n<MAX_USER_IN_PARTY;n++) { number = gParty.m_PartyInfo[pnumber].Number[n]; if( number >= 0 ) { if( gObjIsConnected(&gObj[number]) == TRUE ) { memset(&pList, 0, sizeof(pList)); memcpy(pList.szId, gObj[number].Name, MAX_ACCOUNT_LEN); pList.Number = n; pList.MapNumber = gObj[number].MapNumber; pList.X = gObj[number].X; pList.Y = gObj[number].Y; pList.Life = gObj[number].Life; pList.MaxLife = gObj[number].MaxLife + gObj[number].AddLife; memcpy(&sendbuf[lOfs], &pList, sizeof(pList)); lOfs += sizeof(pList); } } } pCount.Result = true; } pCount.h.size = lOfs; memcpy(sendbuf, &pCount, sizeof(pCount)); gSendProto.DataSend(aIndex, (LPBYTE)&sendbuf, lOfs); }
// ------------------------------------------------------------------------------------------------------------------------------------------------------- void CNotice::MakeNotice(LPVOID lpMessage, BYTE SubCode, BYTE Type, LPSTR Message) { int NoticeLen = NULL; // ----- PMSG_NOTICE * pNotice = (PMSG_NOTICE *)lpMessage; // ----- pNotice->type = Type; // ----- wsprintf(pNotice->Notice, Message); // ----- NoticeLen = (strlen(pNotice->Notice) + sizeof(PMSG_NOTICE) - sizeof(pNotice->Notice) + 1); // ----- C1HeadSet((LPBYTE)pNotice, SubCode, NoticeLen); }
// ------------------------------------------------------------------------------------------------------------------------------------------------------ void CGPartyRequestRecv(PMSG_PARTYREQUEST * lpMsg, int aIndex) { int number = MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL); PMSG_PARTYREQUESTSEND pMsg; if ( number < 0 || number > OBJMAX-1) return; if (!PacketCheckTime(&gObj[aIndex])) return; if ( !gObjIsConnected(&gObj[number])) { ::GCResultSend(aIndex, 0x41, 0x03); return; } if ( gObj[aIndex].CloseCount >= 0 || gObj[number].CloseCount >= 0 ) { ::GCResultSend(aIndex, 0x41, 0x00); return; } if ( gObj[number].GenFamily != gObj[aIndex].GenFamily ) { ::GCServerMsgStringSend("Can't make party with different gen member", aIndex, 1); return; } if ( gUser.ChaosCastleMapRange(gObj[aIndex].MapNumber) == true ) { ::GCServerMsgStringSend(lMsg.Get(MSGGET(4, 198)), aIndex, 1); return; } if ( IT_MAP_RANGE(gObj[aIndex].MapNumber) ) { ::GCServerMsgStringSend("Can't make party in Illusion Temple", aIndex, 1); return; } #if (FOREIGN_GAMESERVER==1) if ( szAuthKey[4] != AUTHKEY4 ) DestroyGIocp(); #endif //LogAddL("Party result : %d %d %d %d", gObj[aIndex].CloseCount, gObj[number].CloseCount, gObj[aIndex].Connected, gObj[number].Connected); //LogAddL("%s %s", gObj[aIndex].Name, gObj[number].Name); if ( gObj[aIndex].m_IfState.use > 0 ) { ::GCResultSend(aIndex, 0x41, 0x00); return; } if ( gObj[number].m_IfState.use > 0 ) { ::GCResultSend(aIndex, 0x41, 0x00); return; } if ( (gObj[number].m_Option &1) != TRUE ) { ::GCResultSend(aIndex, 0x41, 0x01); return; } if ( gObj[aIndex].PartyNumber >= 0 ) { int iUserIndex; int iDbNumber; gParty.GetIndexUser(gObj[aIndex].PartyNumber, 0, iUserIndex, iDbNumber); if ( iUserIndex < 0 || ( iUserIndex != aIndex && gObj[aIndex].DBNumber != iDbNumber ) ) { ::GCResultSend(aIndex, 0x41, 0x00); return; } } if ( gObj[aIndex].PartyTargetUser >= 0 ) return; if ( gObj[number].PartyNumber >= 0 ) { ::GCResultSend(aIndex, 0x41, 0x04); return; } if ( gObj[number].PartyTargetUser >= 0 ) { ::GCResultSend(aIndex, 0x41, 0x00); return; } int maxlevel = 0; int minlevel = 0; /*if ( gObj[number].PartyNumber >= 0 ) { if ( gParty.GetLevel( gObj[number].PartyNumber, maxlevel, minlevel) == TRUE ) { int limmaxlevel; int limmaxlevel2; if ( maxlevel > gObj[number].Level ) limmaxlevel = maxlevel; else limmaxlevel = gObj[number].Level; if ( maxlevel < gObj[number].Level ) limmaxlevel2 = maxlevel; else limmaxlevel2 = gObj[number].Level; if ( (limmaxlevel - limmaxlevel2) > MAX_PARTY_LEVEL_DIFFERENCE ) { ::GCResultSend(aIndex, 0x41, 0x05); // Restricted level for the party is %d // DEATHWAY FIX HERE LogAdd(lMsg.Get(MSGGET(2, 189)), gObj[aIndex].Name, gObj[aIndex].Level, gObj[number].Name, gObj[number].Level); return; } int limminlevel; int limminlevel2; if ( maxlevel > gObj[number].Level ) limminlevel = minlevel; else limminlevel = gObj[number].Level; if ( maxlevel < gObj[number].Level ) limminlevel2 = minlevel; else limminlevel2 = gObj[number].Level; if ( (limminlevel - limminlevel2) > MAX_PARTY_LEVEL_DIFFERENCE ) { ::GCResultSend(aIndex, 0x41, 0x05); // Restricted level for the party is %d // DEATHWAY FIX HERE LogAdd(lMsg.Get(MSGGET(2, 189)), gObj[aIndex].Name, gObj[aIndex].Level, gObj[number].Name, gObj[number].Level); return; } } } else { short sMaxMinLevel[2]; if ( gObj[aIndex].Level > gObj[number].Level ) sMaxMinLevel[1] = gObj[aIndex].Level; else sMaxMinLevel[1] = gObj[number].Level; if ( gObj[aIndex].Level < gObj[number].Level ) sMaxMinLevel[0] = gObj[aIndex].Level; else sMaxMinLevel[0] = gObj[number].Level; if ( (sMaxMinLevel[1]- sMaxMinLevel[0]) >MAX_PARTY_LEVEL_DIFFERENCE) { ::GCResultSend(aIndex, 0x41, 0x05); // Restricted level for the party is %d // DEATHWAY FIX HERE LogAdd(lMsg.Get(MSGGET(2, 189)), gObj[aIndex].Name, gObj[aIndex].Level, gObj[number].Name, gObj[number].Level); return; } }*/ gObj[aIndex].m_IfState.use = TRUE; gObj[aIndex].m_IfState.type = 2; gObj[aIndex].m_IfState.state = 0; gObj[number].m_IfState.use = TRUE; gObj[number].m_IfState.type = 2; gObj[number].m_IfState.state = 0; gObj[aIndex].TargetNumber = number; gObj[number].TargetNumber = aIndex; gObj[aIndex].m_InterfaceTime = GetTickCount(); gObj[number].m_InterfaceTime = GetTickCount(); gObj[aIndex].PartyTargetUser = number; C1HeadSet((LPBYTE)&pMsg, 0x40, sizeof(pMsg)); pMsg.NumberH = SET_NUMBERH(aIndex); pMsg.NumberL = SET_NUMBERL(aIndex); gSendProto.DataSend(number, (LPBYTE)&pMsg, pMsg.h.size); }
BOOL CJewelOfHarmonySystem::MakeSmeltingStoneItem(LPOBJ lpObj) { if ( this->m_bSystemMixSmeltingStone != TRUE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13,53)), lpObj->m_Index, 1); return TRUE; } lpObj->ChaosLock = TRUE; int iValidItemCount = 0; int iInvalidItemCount = 0; int iMakeSmeltingStoneMixPrice = 0; PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(pMsg)); pMsg.Result = 0; int iItemPos = -1; for ( int n=0;n<CHAOS_BOX_SIZE;n++) { if ( lpObj->pChaosBox[n].IsItem() == TRUE ) { if ( this->IsEnableToMakeSmeltingStoneItem(&lpObj->pChaosBox[n]) == TRUE ) { iValidItemCount++; iItemPos = n; } else { iInvalidItemCount++; } } } if ( iValidItemCount != 1 || iInvalidItemCount || iItemPos == -1 ) { gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } int JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE; BOOL bIsItemNormal = TRUE; if ( lpObj->pChaosBox[iItemPos].IsExtItem() == TRUE ) { bIsItemNormal = FALSE; JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE = this->m_iRateMixSmeltingStoneExt; } else { bIsItemNormal = TRUE; JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE = this->m_iRateMixSmeltingStoneNor; } iMakeSmeltingStoneMixPrice = this->m_iZenForMixSmeltingStone; int iChaosTaxMoney = iMakeSmeltingStoneMixPrice * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100; if ( iChaosTaxMoney < 0 ) iChaosTaxMoney = 0; iMakeSmeltingStoneMixPrice += iChaosTaxMoney; if ( iMakeSmeltingStoneMixPrice < 0 ) iMakeSmeltingStoneMixPrice = 0; if ( lpObj->Money < iMakeSmeltingStoneMixPrice ) { pMsg.Result = 2; gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } lpObj->Money -= iMakeSmeltingStoneMixPrice; g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney); GCMoneySend(lpObj->m_Index, lpObj->Money); LogChaosItem(lpObj, "JewelOfHarmony][Smelt Item Mix"); CLog.LogAdd("[JewelOfHarmony][Smelt Item Mix] - Mix Start"); int iRate = rand() % 100; BYTE Socket[5]; Socket[0] = 0xFF; Socket[1] = 0xFF; Socket[2] = 0xFF; Socket[3] = 0xFF; Socket[4] = 0xFF; if ( iRate < JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE ) { int iItemType; if ( bIsItemNormal == TRUE ) iItemType = this->JEWEL_OF_HARMONY_SMELT_NOR_ITEMINDEX; else iItemType = this->JEWEL_OF_HARMONY_SMELT_EXT_ITEMINDEX; ItemSerialCreateSend(lpObj->m_Index, 255, 0, 0, iItemType, 0, 1, 0, 0, 0, lpObj->m_Index, 0, 0, Socket); gObjInventoryCommit(lpObj->m_Index); CLog.LogAdd("[JewelOfHarmony][Smelt Item Mix] Smelting Stone Normal[%d] Mix Success [%s][%s], Money(%d-%d) Rate(%d/%d)", bIsItemNormal, lpObj->AccountID, lpObj->Name, lpObj->Money, iMakeSmeltingStoneMixPrice, iRate, JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE); } else { gChaosBox.ChaosBoxInit(lpObj); GCUserChaosBoxSend(lpObj, 0); gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); CLog.LogAdd("[JewelOfHarmony][Smelt Item Mix] Smelting Stone Normal[%d] Mix Fail [%s][%s], Money : %d-%d Rate(%d/%d)", bIsItemNormal, lpObj->AccountID, lpObj->Name, lpObj->Money, iMakeSmeltingStoneMixPrice, iRate, JEWEL_OF_HARMONY_MAKE_SMELTINGSTONE_RATE); } lpObj->ChaosLock = FALSE; return TRUE; }
void CJewelOfHarmonySystem::PurityJewelOfHarmony(LPOBJ lpObj) { if ( this->m_bSystemPrutiyJewel != TRUE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13, 50)), lpObj->m_Index, 1); return; } if ( this->IsEnableToUsePuritySystem() == FALSE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13, 50)), lpObj->m_Index, 1); CLog.LogAdd("[JewelOfHarmony][%s][%s] Not Purtiy Time ", lpObj->AccountID, lpObj->Name); return; } lpObj->ChaosLock = TRUE; // Chaos Lock was Enabled int iJewelOfHarmonyItemCount = 0; int iInvalidItemCount = 0; int iChaosMixPrice = 0; PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(PMSG_CHAOSMIXRESULT)); pMsg.Result = CB_ERROR; for ( int n =0;n<CHAOS_BOX_SIZE;n++) { if ( lpObj->pChaosBox[n].IsItem() == TRUE ) { if ( lpObj->pChaosBox[n].m_Type == this->JEWEL_OF_HARMONY_ITEMINDEX ) { iJewelOfHarmonyItemCount++; } else { iInvalidItemCount++; } } } if ( iInvalidItemCount > 0 || iJewelOfHarmonyItemCount !=1 ) { gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return; } iChaosMixPrice = this->m_iZenForPurity; int iChaosTaxMoney = iChaosMixPrice * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100; if (iChaosTaxMoney < 0 ) iChaosTaxMoney = 0; iChaosMixPrice += iChaosTaxMoney; if ( iChaosMixPrice < 0 ) iChaosMixPrice = 0; if ( lpObj->Money < iChaosMixPrice ) { pMsg.Result = CB_NOT_ENOUGH_ZEN; gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return; } lpObj->Money -= iChaosMixPrice; g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney); GCMoneySend(lpObj->m_Index, lpObj->Money); LogChaosItem(lpObj, "JewelOfHarmony][Purity"); CLog.LogAdd("[JewelOfHarmony][Purity] - Mix Start"); BYTE Socket[5]; Socket[0] = 0xFF; Socket[1] = 0xFF; Socket[2] = 0xFF; Socket[3] = 0xFF; Socket[4] = 0xFF; int iRate = rand() % 100; if ( iRate < this->m_iRatePuritySuccess ) { int iItemType = this->JEWEL_OF_HARMONY_PURITY_ITEMINDEX; ItemSerialCreateSend(lpObj->m_Index, -1, 0, 0, iItemType, 0, 1, 0, 0, 0, lpObj->m_Index, 0, 0, Socket); gObjInventoryCommit(lpObj->m_Index); CLog.LogAdd("[JewelOfHarmony][Purity] Purity Success [%s][%s] Rate %d/%d", lpObj->AccountID, lpObj->Name, iRate, this->m_iRatePuritySuccess); } else { gChaosBox.ChaosBoxInit(lpObj); GCUserChaosBoxSend(lpObj, 0); gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); CLog.LogAdd("[JewelOfHarmony][Purity] Purity Fail [%s][%s] Rate %d/%d", lpObj->AccountID, lpObj->Name, iRate, this->m_iRatePuritySuccess); } // Chaos Lock was Disabled lpObj->ChaosLock = FALSE; }
BOOL CJewelOfHarmonySystem::RestoreStrengthenItem(LPOBJ lpObj) { if ( this->m_bSystemRestoreStrengthen != TRUE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13,54)), lpObj->m_Index, 1); return TRUE; } lpObj->ChaosLock = TRUE; PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(pMsg)); pMsg.Result = 0; int iStrengtenItemCount = 0; int iInvalidItemCount = 0; CItem * pItem = NULL; for ( int n=0;n<CHAOS_BOX_SIZE;n++) { if ( lpObj->pChaosBox[n].IsItem() == TRUE ) { if ( this->IsStrengthenByJewelOfHarmony(&lpObj->pChaosBox[n]) == TRUE ) { iStrengtenItemCount++; pItem = &lpObj->pChaosBox[n]; } } } if ( iStrengtenItemCount != 1 ) { gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } int iItemOption = this->GetItemStrengthenOption(pItem); int iItemOptionLevel = this->_GetItemOptionLevel(pItem); int JEWEL_OF_HARMONY_RETORE_NEEDZEN = this->_GetZenForRestoreItem(pItem); if ( JEWEL_OF_HARMONY_RETORE_NEEDZEN < 0 ) { gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } int iChaosTaxMoney = JEWEL_OF_HARMONY_RETORE_NEEDZEN * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100; if ( iChaosTaxMoney < 0 ) iChaosTaxMoney = 0; JEWEL_OF_HARMONY_RETORE_NEEDZEN += iChaosTaxMoney; if ( JEWEL_OF_HARMONY_RETORE_NEEDZEN < 0 ) JEWEL_OF_HARMONY_RETORE_NEEDZEN = 0; if ( lpObj->Money < JEWEL_OF_HARMONY_RETORE_NEEDZEN ) { pMsg.Result = 2; gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } lpObj->Money -= JEWEL_OF_HARMONY_RETORE_NEEDZEN; g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney); GCMoneySend(lpObj->m_Index, lpObj->Money); LogChaosItem(lpObj, "JewelOfHarmony][Restore Item"); CLog.LogAdd("[JewelOfHarmony][Restore Item] - Restore Start"); CLog.LogAdd("[JewelOfHarmony][Restore Item] Restore Strengtened Item [%s][%s] Name[%s] ItemType[%d] Serial[%d] OptionType[%d] OptionLevel [%d] Money %d-%d", lpObj->AccountID, lpObj->Name, pItem->GetName(), pItem->m_Type, pItem->m_Number, iItemOption, iItemOptionLevel, lpObj->Money, JEWEL_OF_HARMONY_RETORE_NEEDZEN); pItem->m_JewelOfHarmonyOption = 0; GCUserChaosBoxSend(lpObj, 0); this->ShowStrengthenOption(pItem); lpObj->ChaosLock = FALSE; return TRUE; }
void CChaosCard::ChaosCardMix(LPOBJ lpObj) { lpObj->ChaosLock = TRUE; int iChaosCardCount = 0; int iChaosMoney = 0; int iInvalidItemCount = 0; PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg.h, 0x86, sizeof(PMSG_CHAOSMIXRESULT)); pMsg.Result = CB_ERROR; for ( int n=0;n<CHAOS_BOX_SIZE;n++) { if ( lpObj->pChaosBox[n].IsItem() == TRUE ) { if ( lpObj->pChaosBox[n].m_Type == ITEMGET(14,54) ) { iChaosCardCount++; } else { iInvalidItemCount++; } } } if ( iChaosCardCount == 0 ) { return; } if ( iInvalidItemCount > 0 ) { return; } if ( iChaosCardCount > 1 ) { MsgOutput(lpObj->m_Index,"[ChaosCard]: Can only use 1 card at the same time"); gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return; } LogChaosItem(lpObj,"ChaosCard"); CLog.LogAdd("[ChaosCard] Chaos Mix Start"); lpObj->ChaosSuccessRate = 100; BYTE Socket[5]; Socket[0] = 0xFF; Socket[1] = 0xFF; Socket[2] = 0xFF; Socket[3] = 0xFF; Socket[4] = 0xFF; if ( (rand()%100) < lpObj->ChaosSuccessRate ) { int ItemNum = ITEMGET(14,14); int Level = 0; ItemSerialCreateSend(lpObj->m_Index, -1, 0, 0, ItemNum, Level, 0, 0, 0, 0, -1, 0, 0, Socket); ::gObjInventoryCommit(lpObj->m_Index); CLog.LogAdd("[ChaosCard] [%s][%s] CBMix Success %d ", lpObj->AccountID, lpObj->Name, lpObj->ChaosSuccessRate); } else { gChaosBox.ChaosBoxInit(lpObj); ::GCUserChaosBoxSend(lpObj, 1); gSendProto.DataSend(lpObj->m_Index, (UCHAR*)&pMsg, pMsg.h.size); CLog.LogAdd("[ChaosCard] [%s][%s] CBMix Fail %d ", lpObj->AccountID, lpObj->Name, lpObj->ChaosSuccessRate); lpObj->ChaosLock = FALSE; } }
BOOL CItem380System::ChaosMix380ItemOption(LPOBJ lpObj) { if ( this->m_bSystemFor380ItemOption != TRUE ) { GCServerMsgStringSend(lMsg.Get(MSGGET(13,55)), lpObj->m_Index, 1); lpObj->bIsChaosMixCompleted = false; return FALSE; } lpObj->ChaosLock = TRUE; int iValidItemCount = 0; int iJewelOfHarmony = 0; int iJewelOfSuho = 0; int iInvalidItemCount = 0; int iMixPrice = 0; int iCharmOfLuckCount = 0; PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg, 0x86, sizeof(pMsg)); pMsg.Result = 0; CItem * pTargetItem = NULL; int iPosOfJewelOfHarmony= -1; int iPosOfJewelOfSuho= -1; for ( int n=0;n<CHAOS_BOX_SIZE;n++) { if ( lpObj->pChaosBox[n].IsItem() == TRUE ) { if ( this->Is380Item(&lpObj->pChaosBox[n]) == TRUE && this->Is380OptionItem(&lpObj->pChaosBox[n]) == FALSE && lpObj->pChaosBox[n].m_Level > 3 && (lpObj->pChaosBox[n].m_Option3<<2) > 3) { iValidItemCount++; pTargetItem = &lpObj->pChaosBox[n]; } else if ( g_kJewelOfHarmonySystem.IsJewelOfHarmonyPurity(lpObj->pChaosBox[n].m_Type) == TRUE ) { iJewelOfHarmony++; iPosOfJewelOfHarmony = n; } else if ( lpObj->pChaosBox[n].m_Type == ITEMGET(14, 31) ) { iJewelOfSuho++; iPosOfJewelOfSuho = n; } else if ( lpObj->pChaosBox[n].m_Type == ITEMGET(14,53) ) { iCharmOfLuckCount += (int)lpObj->pChaosBox[n].m_Durability; } else { iInvalidItemCount++; } } } if ( iInvalidItemCount || iValidItemCount != 1 || iJewelOfHarmony != 1 || iJewelOfSuho != 1 || pTargetItem == NULL || iPosOfJewelOfHarmony == -1 || iPosOfJewelOfSuho == -1 || iCharmOfLuckCount > 10 ) { gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } iMixPrice = this->m_iNeedZenFor380Option; int iChaosTaxMoney = iMixPrice * g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index) / 100; if ( iChaosTaxMoney < 0 ) iChaosTaxMoney = 0; iMixPrice += iChaosTaxMoney; if ( iMixPrice < 0 ) iMixPrice = 0; if ( lpObj->Money < iMixPrice ) { pMsg.Result = 2; gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); lpObj->ChaosLock = FALSE; return FALSE; } lpObj->Money -= iMixPrice; g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney); GCMoneySend(lpObj->m_Index, lpObj->Money); LogChaosItem(lpObj, "380Item][Item Mix"); CLog.LogAdd("[380Item][Item Mix] - Mix Start"); int iRate = rand() % 100; int iRateSuccess = this->m_iRateSuccessRateForMix1; if ( pTargetItem->m_Level < 7 ) iRateSuccess = this->m_iRateSuccessRateForMix1; else if ( pTargetItem->m_Level < 10 ) iRateSuccess = this->m_iRateSuccessRateForMix2; else if ( pTargetItem->m_Level < 16 ) iRateSuccess = this->m_iRateSuccessRateForMix3; iRateSuccess += iCharmOfLuckCount; lpObj->pChaosBox[iPosOfJewelOfHarmony].Clear(); lpObj->pChaosBoxMap[iPosOfJewelOfHarmony] = -1; lpObj->pChaosBox[iPosOfJewelOfSuho].Clear(); lpObj->pChaosBoxMap[iPosOfJewelOfSuho] = -1; if ( iRate < iRateSuccess ) { this->_SetOption(pTargetItem, TRUE); GCUserChaosBoxSend(lpObj, 0); CLog.LogAdd("[380Item][ItemMix] Mix Success [%s][%s], Money(%d-%d) Rate(%d/%d) Option(%d,%d) OptionValue(%d,%d)", lpObj->AccountID, lpObj->Name, lpObj->Money, iMixPrice, iRate, iRateSuccess, this->m_itemOption[(pTargetItem->m_Type )].m_Option1, this->m_itemOption[(pTargetItem->m_Type )].m_Option2, this->m_itemOption[(pTargetItem->m_Type )].m_Value1, this->m_itemOption[(pTargetItem->m_Type )].m_Value2); } else { GCUserChaosBoxSend(lpObj, 0); gSendProto.DataSend(lpObj->m_Index, (LPBYTE)&pMsg, pMsg.h.size); CLog.LogAdd("[380Item][ItemMix] Mix Fail [%s][%s], Money(%d-%d) Rate(%d/%d)", lpObj->AccountID, lpObj->Name, lpObj->Money, iMixPrice, iRate, iRateSuccess); } lpObj->ChaosLock = FALSE; return TRUE; }
// ----------------------------------------------------------------------------------------------------------------------- void CItemSocket::NewMix4(LPOBJ lpObj,BYTE info) { int ItemCount = 0; int ItemSlot = 0; lpObj->ChaosLock = 1; for(int n=0;n < CHAOS_BOX_SIZE;n++) { if( ItemAttribute[lpObj->pChaosBox[n].m_Type].SocketItem > 0 && lpObj->pChaosBox[n].m_ItemSocket[info] < 0xFE) { ItemCount++; ItemSlot = n; } } PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg.h,0x86,sizeof(pMsg)); if(ItemCount != 1) { lpObj->ChaosLock = 0; pMsg.Result = CB_INCORRECT_MIX_ITEMS; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); return; } lpObj->ChaosMoney = 1000000; int TaxMoney = (lpObj->ChaosMoney*g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index))/100; lpObj->ChaosMoney += TaxMoney; if(lpObj->Money < lpObj->ChaosMoney) { lpObj->ChaosLock = 0; pMsg.Result = CB_NOT_ENOUGH_ZEN; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); return; } lpObj->Money -= lpObj->ChaosMoney; GCMoneySend(lpObj->m_Index,lpObj->Money); g_CastleSiegeSync.AddTributeMoney(TaxMoney); CItem item = lpObj->pChaosBox[ItemSlot]; item.m_ItemSocket[info] = 0xFE; pMsg.Result = CB_SUCCESS; ItemByteConvert(pMsg.ItemInfo,item); gChaosBox.ChaosBoxInit(lpObj); gObjChaosBoxInsertItemPos(lpObj->m_Index,item,0,-1); gObjChaosItemSet(lpObj->m_Index,0,1); gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); lpObj->ChaosLock = 0; }
// ----------------------------------------------------------------------------------------------------------------------- void CItemSocket::SeedCalc(LPOBJ lpObj,BYTE info) { int ChaosCount = 0; int CreationCount = 0; int SeedSphereCount = 0; int SeedSphereType = 0; int SeedSphereLevel = 0; int SeedSphereOption = 0; int ItemCount = 0; int ItemSlot = 0; lpObj->ChaosLock = 1; for(int n=0;n < CHAOS_BOX_SIZE;n++) { if(lpObj->pChaosBox[n].IsItem() == 0) { continue; } if(lpObj->pChaosBox[n].m_Type == ITEMGET(12,15)) { ChaosCount++; } else if(lpObj->pChaosBox[n].m_Type == ITEMGET(14,22)) { CreationCount++; } else if(lpObj->pChaosBox[n].m_Type >= ITEMGET(12,100) && lpObj->pChaosBox[n].m_Type <= ITEMGET(12,129)) { SeedSphereCount++; SeedSphereType = gItemSocket.CalculateSeedType(lpObj->pChaosBox[n].m_Type); // From 1 to 6 SeedSphereLevel = gItemSocket.CalculateSeedLevel(lpObj->pChaosBox[n].m_Type); // From 0 to 4 SeedSphereOption = lpObj->pChaosBox[n].m_Level; } else if( ItemAttribute[lpObj->pChaosBox[n].m_Type].SocketItem != 0 && lpObj->pChaosBox[n].m_ItemSocket[info] == 0xFE) { ItemCount++; ItemSlot = n; } } PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg.h,0x86,sizeof(pMsg)); if(ChaosCount != 1 || CreationCount != 1 || SeedSphereCount != 1 || ItemCount != 1) { lpObj->ChaosLock = 0; pMsg.Result = CB_INCORRECT_MIX_ITEMS; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); return; } lpObj->ChaosMoney = 1000000; int TaxMoney = (lpObj->ChaosMoney*g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index))/100; lpObj->ChaosMoney += TaxMoney; if(lpObj->Money < lpObj->ChaosMoney) { lpObj->ChaosLock = 0; pMsg.Result = CB_NOT_ENOUGH_ZEN; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); return; } BYTE option = gItemSocket.CalculateSeedOption(SeedSphereType,SeedSphereLevel,SeedSphereOption); if(option == 0xFE) { lpObj->ChaosLock = 0; pMsg.Result = CB_ERROR; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); return; } lpObj->Money -= lpObj->ChaosMoney; GCMoneySend(lpObj->m_Index,lpObj->Money); g_CastleSiegeSync.AddTributeMoney(TaxMoney); CItem item = lpObj->pChaosBox[ItemSlot]; item.m_ItemSocket[info] = option; pMsg.Result = CB_SUCCESS; ItemByteConvert(pMsg.ItemInfo,item); gChaosBox.ChaosBoxInit(lpObj); gObjChaosBoxInsertItemPos(lpObj->m_Index,item,0,-1); gObjChaosItemSet(lpObj->m_Index,0,1); gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); lpObj->ChaosLock = 0; }
// ----------------------------------------------------------------------------------------------------------------------- void CItemSocket::SeedSphere(LPOBJ lpObj) { int ChaosCount = 0; int CreationCount = 0; int SeedCount = 0; int SeedType = 0; int SeedLevel = 0; int SphereCount = 0; int SphereType = 0; lpObj->ChaosLock = 1; for(int n=0;n < CHAOS_BOX_SIZE;n++) { if(lpObj->pChaosBox[n].IsItem() == 0) { continue; } if(lpObj->pChaosBox[n].m_Type == ITEMGET(12,15)) { ChaosCount++; } else if(lpObj->pChaosBox[n].m_Type == ITEMGET(14,22)) { CreationCount++; } else if(lpObj->pChaosBox[n].m_Type >= ITEMGET(12,60) && lpObj->pChaosBox[n].m_Type <= ITEMGET(12,66)) { SeedCount++; SeedType = lpObj->pChaosBox[n].m_Type - ITEMGET(12,60); // From 0 to 5 SeedLevel = lpObj->pChaosBox[n].m_Level; } else if(lpObj->pChaosBox[n].m_Type >= ITEMGET(12,70) && lpObj->pChaosBox[n].m_Type <= ITEMGET(12,74)) { SphereCount++; SphereType = lpObj->pChaosBox[n].m_Type - ITEMGET(12,70); // From 0 to 4 } } PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg.h,0x86,sizeof(pMsg)); if(ChaosCount != 1 || CreationCount != 1 || SeedCount != 1 || SphereCount != 1) { lpObj->ChaosLock = 0; pMsg.Result = CB_INCORRECT_MIX_ITEMS; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); return; } lpObj->ChaosSuccessRate = 85-(SphereType*5); lpObj->ChaosMoney = 1000000; int TaxMoney = (lpObj->ChaosMoney*g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index))/100; lpObj->ChaosMoney += TaxMoney; if(lpObj->Money < lpObj->ChaosMoney) { lpObj->ChaosLock = 0; pMsg.Result = CB_NOT_ENOUGH_ZEN; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); return; } lpObj->Money -= lpObj->ChaosMoney; GCMoneySend(lpObj->m_Index,lpObj->Money); g_CastleSiegeSync.AddTributeMoney(TaxMoney); BYTE Socket[5]; Socket[0] = 0xFF; Socket[1] = 0xFF; Socket[2] = 0xFF; Socket[3] = 0xFF; Socket[4] = 0xFF; if((rand()%100) < lpObj->ChaosSuccessRate) { int index = ITEMGET(12,100)+(SphereType*6)+SeedType; int level = SeedLevel; ItemSerialCreateSend(lpObj->m_Index,-1,0,0,index,level,0,0,0,0,-1,0,0,Socket); CLog.LogAdd("[%s][%s] SeedSphere Composite Success - Seed Info ( Index : %d, Level : %d )",lpObj->AccountID,lpObj->Name,index,level); } else { gChaosBox.ChaosBoxInit(lpObj); GCUserChaosBoxSend(lpObj,0); pMsg.Result = 0; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); CLog.LogAdd("[%s][%s] SeedSphere Composite Failed",lpObj->AccountID,lpObj->Name); } lpObj->ChaosLock = 0; }
// ----------------------------------------------------------------------------------------------------------------------- void CItemSocket::SeedExtract(LPOBJ lpObj) //GOOD { int ChaosCount = 0; int HarmonyCount = 0; int CreationCount = 0; int ExcItemCount = 0; int SetItemCount = 0; lpObj->ChaosLock = 1; for(int n=0;n < CHAOS_BOX_SIZE;n++) { if(lpObj->pChaosBox[n].IsItem() == 0) { continue; } if(lpObj->pChaosBox[n].m_Type == ITEMGET(12,15)) { ChaosCount++; } else if(lpObj->pChaosBox[n].m_Type == ITEMGET(14,42)) { HarmonyCount++; } else if(lpObj->pChaosBox[n].m_Type == ITEMGET(14,22)) { CreationCount++; } else if(lpObj->pChaosBox[n].IsExtItem() != 0 && lpObj->pChaosBox[n].m_Level >= 4) { ExcItemCount++; } else if(lpObj->pChaosBox[n].IsSetItem() != 0 && lpObj->pChaosBox[n].m_Level >= 4) { SetItemCount++; } } PMSG_CHAOSMIXRESULT pMsg; C1HeadSet((LPBYTE)&pMsg.h,0x86,sizeof(pMsg)); if(ChaosCount != 1 || HarmonyCount != 1 || CreationCount != 1 || ExcItemCount != 1 || SetItemCount != 1) { lpObj->ChaosLock = 0; pMsg.Result = CB_INCORRECT_MIX_ITEMS; gSendProto.DataSend(lpObj->m_Index,(BYTE*)&pMsg,pMsg.h.size); return; } lpObj->ChaosSuccessRate = 90; lpObj->ChaosMoney = 1000000; int TaxMoney = (lpObj->ChaosMoney* g_CastleSiegeSync.GetTaxRateChaos(lpObj->m_Index))/100; lpObj->ChaosMoney += TaxMoney; if(lpObj->Money < lpObj->ChaosMoney) { lpObj->ChaosLock = 0; pMsg.Result = CB_NOT_ENOUGH_ZEN; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); return; } int type = rand()%6; // ---- if ( type < 0 ) { type = 0; } else if ( type > 5 ) { type = 5; } int count = this->GetOptionCount(type); if(count == 0) { lpObj->ChaosLock = 0; pMsg.Result = CB_ERROR; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); CLog.LogAdd("[%s][%s] Seed Extract Mix Failed",lpObj->AccountID,lpObj->Name); return; } lpObj->Money -= lpObj->ChaosMoney; GCMoneySend(lpObj->m_Index,lpObj->Money); g_CastleSiegeSync.AddTributeMoney(TaxMoney); if((rand()%100) < lpObj->ChaosSuccessRate) { int index = ITEMGET(12,60)+type; int level; if ( type == 5 ) { level = 2; } else { level = rand()%count; } BYTE Socket[5]; Socket[0] = 0xFF; Socket[1] = 0xFF; Socket[2] = 0xFF; Socket[3] = 0xFF; Socket[4] = 0xFF; ItemSerialCreateSend(lpObj->m_Index,-1,0,0,index,level,0,0,0,0,-1,0,0,Socket); CLog.LogAdd("[%s][%s] Seed Extract Mix Success - Seed Info ( Index : %d, Level : %d )",lpObj->AccountID,lpObj->Name,index,level); } else { gChaosBox.ChaosBoxInit(lpObj); GCUserChaosBoxSend(lpObj,0); pMsg.Result = CB_ERROR; gSendProto.DataSend(lpObj->m_Index,(BYTE *)&pMsg, pMsg.h.size); CLog.LogAdd("[%s][%s] Seed Extract Mix Failed",lpObj->AccountID,lpObj->Name); } lpObj->ChaosLock = 0; }