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::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; }
BYTE CIllusionTempleEvent::TicketMix(int iIndex, int iLevel, int iCharmCount) { if( OBJMAX_RANGE( iIndex ) == FALSE ) { return FALSE; } if( IT_MAP_RANGE( iLevel + (MAP_INDEX_ILLUSIONTEMPLE1 - 1)) == FALSE ) { return FALSE; } int Empty = 0; PMSG_CHAOSMIXRESULT pMsg; PHeadSetB((LPBYTE)&pMsg,0x86,sizeof(pMsg)); pMsg.Result = 0; gObj[iIndex].ChaosLock = TRUE; LogAddTD("[Illusion Temple] Mix Chaos Mix Start (Account:%s, Name:%s, Level:%d)", gObj[iIndex].AccountID,gObj[iIndex].Name,iLevel); char szTmp[23]; wsprintf(szTmp,"IllusionTemple Mix,%d",iLevel); g_ChaosBox.LogChaosItem(&gObj[iIndex],szTmp); int MixRate = IT_TicketRate[-1 + iLevel]; if( MixRate < 0 || MixRate > 100 ) { DataSend(iIndex,(LPBYTE)&pMsg,pMsg.h.size); LogAddTD("[Illusion Temple] Mix Chaos Mix Failed - MixRate Out of Bound (Account:%s, Name:%s, Level:%d)", gObj[iIndex].AccountID,gObj[iIndex].Name,iLevel); return FALSE; } if ( g_CrywolfSync.GetOccupationState() == 0 && g_iCrywolfApplyMvpBenefit ) { MixRate += g_CrywolfSync.GetPlusChaosRate(); } int iNeedChaosMoney = IT_TicketZen[-1 + iLevel]; int iChaosTaxMoney = (int)((__int64)iNeedChaosMoney * (__int64)g_CastleSiegeSync.GetTaxRateChaos(iIndex) / (__int64)100); if ( iChaosTaxMoney < 0 ) { iChaosTaxMoney = 0; } iNeedChaosMoney += iChaosTaxMoney; if ( iNeedChaosMoney < 0 ) { DataSend(iIndex,(LPBYTE)&pMsg,pMsg.h.size); LogAddTD("[Illusion Temple] Mix Chaos Mix Failed - MixMoney< 0 (Account:%s, Name:%s, Level:%d).", gObj[iIndex].AccountID,gObj[iIndex].Name,iLevel); return false; } if ( ( gObj[iIndex].Money - iNeedChaosMoney ) < 0 ) { pMsg.Result = 11; DataSend(iIndex,(LPBYTE)&pMsg,pMsg.h.size); LogAddTD("[Illusion Temple] Mix Chaos Mix Failed - Not Enough Money (Account:%s, Name:%s, Level:%d)", gObj[iIndex].AccountID,gObj[iIndex].Name,iLevel); return false; } gObj[iIndex].Money -= iNeedChaosMoney; g_CastleSiegeSync.AddTributeMoney(iChaosTaxMoney); GCMoneySend(iIndex, gObj[iIndex].Money); MixRate += iCharmCount; if( rand() % 100 < MixRate ) { #if( __4GAMERS__ == 1 ) g_Achievements.GD_UpdateMixData(&gObj[iIndex], true); #endif int Item = ITEMGET(13,51); ItemSerialCreateSend(iIndex,0xFF,0,0,Item,iLevel,0,0,0,0,-1,0,0); LogAddTD("[Illusion Temple] [%s][%s] CBMix Success %d Money : %d-%d, CharmRate : %d", gObj[iIndex].AccountID,gObj[iIndex].Name,MixRate,gObj[iIndex].Money,iNeedChaosMoney,iCharmCount); } else { #if( __4GAMERS__ == 1 ) g_Achievements.GD_UpdateMixData(&gObj[iIndex], false); #endif g_ChaosBox.ChaosBoxInit(&gObj[iIndex]); GCUserChaosBoxSend(&gObj[iIndex], 0); DataSend(iIndex,(LPBYTE)&pMsg,pMsg.h.size); LogAddTD("[Illusion Temple] [%s][%s] CBMix Fail %d Money : %d-%d, CharmRate : %d", gObj[iIndex].AccountID,gObj[iIndex].Name,MixRate,gObj[iIndex].Money,iNeedChaosMoney,iCharmCount); return FALSE; } gObjInventoryCommit(iIndex); return TRUE; }