bool OfflineTrade::CheckExchange(LPOBJ lpUser, LPOBJ lpTargetUser, int ItemPos) { if(!strcmp(lpUser->m_szPShopText,WCOIN_SHOP)) { if ( lpTargetUser->GameShop.WCoinP < lpUser->Inventory1[ItemPos].m_iPShopValue ) { LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Lack of Wcoin", lpTargetUser->AccountID, lpTargetUser->Name, lpUser->AccountID, lpUser->Name); GCServerMsgStringSend("Need more WCoin to buy", lpUser->m_Index, 1); return false; } } else if(!strcmp(lpUser->m_szPShopText,SOUL_SHOP)) //Soul check { if ( this->GetSoulCount(lpTargetUser->m_Index) < lpUser->Inventory1[ItemPos].m_iPShopValue ) { LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Lack of Soul", lpTargetUser->AccountID, lpTargetUser->Name, lpUser->AccountID, lpUser->Name); GCServerMsgStringSend("Need more Soul to buy", lpTargetUser->m_Index, 1); return false; } else if( this->EmptyPointInventory(lpUser, lpUser->Inventory1[ItemPos].m_iPShopValue) ) { LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Empty Invintory", lpTargetUser->AccountID, lpTargetUser->Name, lpUser->AccountID, lpUser->Name); GCServerMsgStringSend("Need more Empty Inventory", lpTargetUser->m_Index, 1); return false; } } else { if ( lpTargetUser->Money < lpUser->Inventory1[ItemPos].m_iPShopValue ) { LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Lack of Zen", lpTargetUser->AccountID, lpTargetUser->Name, lpUser->AccountID, lpUser->Name); ::CGPShopAnsBuyItem(lpTargetUser->m_Index, lpUser->m_Index, 0, 7); return false; } if ( gObjCheckMaxZen(lpUser->m_Index, lpUser->Inventory1[ItemPos].m_iPShopValue) == FALSE ) { LogAddTD("[PShop] [%s][%s] PShop Item Buy Request Failed : [%s][%s] Exceeding Zen of the Host", lpTargetUser->AccountID, lpTargetUser->Name, lpUser->AccountID, lpUser->Name); ::CGPShopAnsBuyItem(lpTargetUser->m_Index, lpUser->m_Index, 0, 8); return false; } } return true; }
void CDevilSquareGround::SendScore() { if ( this->m_DevilSquareRankList.size() < 1 ) { return; } BYTE count = 1; int iUserCount = this->m_DevilSquareRankList.size(); int iExp = 0; std::vector<LPOBJ>::iterator Itor = this->m_DevilSquareRankList.begin(); for ( ; Itor != this->m_DevilSquareRankList.end() ; Itor++ ) { memcpy(this->m_DevilSquareScoreInfoTOP10.Score[count].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN); this->m_DevilSquareScoreInfoTOP10.Score[count].TotalScore = (*(Itor))->m_nEventScore; if ( iUserCount <= 6 ) { if ( count < 4 ) // For DS from 0 to 3 { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[count-1][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[count-1][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1]; } } else { int lc5 = count*100/iUserCount; if ( count == 1 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[0][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[0][1]; } else if ( lc5 <= 30 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[1][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[1][1]; } else if ( lc5 <= 50 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[2][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[2][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1]; } } count++; if ( count >= 10 ) { break; } } this->m_DevilSquareScoreInfoTOP10.Count = count; int iSize = count * 24 + 5; PHeadSetB((LPBYTE)&this->m_DevilSquareScoreInfoTOP10, 0x93, iSize); count = 1; Itor = this->m_DevilSquareRankList.begin(); LogAddTD("[DevilSquare] Rank [%d]", this->m_iIndex); for ( ; Itor != this->m_DevilSquareRankList.end(); Itor++ ) { if ( iUserCount <= 6 ) { if ( count < 4 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[count-1][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[count-1][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1]; } } else { int lc7 = count*100/iUserCount; if ( count ==1 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[0][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[0][1]; } else if ( lc7 <= 30 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[1][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[1][1]; } else if ( lc7 <= 50 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[2][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[2][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1]; } } if ( g_CrywolfSync.GetOccupationState() == 1 && g_iCrywolfApplyMvpPenalty != FALSE) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = (this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100; } __int64 iExp64 = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp; CheckItemOptForGetExpEx((*(Itor)),iExp64,TRUE); (*(Itor))->Experience += (DWORD)iExp64; bool ret = gObjLevelUp((*(Itor)), &iExp64, 0, EVENT_TYPE_DEVILSQUARE); (*(Itor))->m_nEventMoney = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen; if ( gObjCheckMaxZen((*(Itor))->m_Index, (*(Itor))->m_nEventMoney) == FALSE ) { int Zen = MAX_ZEN - (*(Itor))->Money; (*(Itor))->Money += Zen; } else { (*(Itor))->Money += (*(Itor))->m_nEventMoney; } GCMoneySend((*(Itor))->m_Index, (*(Itor))->Money); if ( ret == true ) { GCKillPlayerExpSend((*(Itor))->m_Index, (WORD)-1, this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp, 0, 0); } if( count == 1 ) { g_EventItemBagManager.OpenSpecial(EventBagSpecial::DevilSquare1, (*(Itor))->m_Index, (*(Itor))->MapNumber, (*(Itor))->X, (*(Itor))->Y); } else if( count == 2) { g_EventItemBagManager.OpenSpecial(EventBagSpecial::DevilSquare2, (*(Itor))->m_Index, (*(Itor))->MapNumber, (*(Itor))->X, (*(Itor))->Y); } else if( count == 3) { g_EventItemBagManager.OpenSpecial(EventBagSpecial::DevilSquare3, (*(Itor))->m_Index, (*(Itor))->MapNumber, (*(Itor))->X, (*(Itor))->Y); } this->SendRankingInfo((*(Itor))); LogAddTD("Rank :[%d] : [%s][%s][%d][%d][%d]", count, (*(Itor))->AccountID, (*(Itor))->Name, (*(Itor))->m_nEventMoney, (*(Itor))->m_nEventExp, (*(Itor))->m_nEventScore); memcpy(this->m_DevilSquareScoreInfoTOP10.Score[0].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN); this->m_DevilSquareScoreInfoTOP10.Score[0].TotalScore = (*(Itor))->m_nEventScore; this->m_DevilSquareScoreInfoTOP10.MyRank = count; count++; DataSend((*(Itor))->m_Index, (BYTE *)&this->m_DevilSquareScoreInfoTOP10 , iSize); #ifdef POINTEX g_ShopPointEx.AddEventBonus((*(Itor))->m_Index, ShopPointExEvent::DS); #endif #if( __4GAMERS__ == 1 ) g_Achievements.GD_UpdateEventDataDS((*(Itor)), (*(Itor))->m_nEventExp, (*(Itor))->m_nEventScore); #endif (*(Itor))->m_nEventScore = 0; (*(Itor))->m_nEventMoney = 0; (*(Itor))->m_nEventExp = 0; } }
void CDevilSquareGround::SendScore() { if ( this->m_DevilSquareRankList.size() < 1 ) { return; } BYTE count = 1; int iUserCount = this->m_DevilSquareRankList.size(); int iExp = 0; for ( std::vector<OBJECTSTRUCT *>::iterator Itor = this->m_DevilSquareRankList.begin() ; Itor != this->m_DevilSquareRankList.end() ; Itor++ ) { memcpy(this->m_DevilSquareScoreInfoTOP10.Score[count].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN); this->m_DevilSquareScoreInfoTOP10.Score[count].TotalScore = (*(Itor))->m_nEventScore; if ( iUserCount <= 6 ) { if ( count < 4 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[count-1][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[count-1][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1]; } } else { int lc5 = count*100/iUserCount; if ( count == 1 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[0][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[0][1]; } else if ( lc5 <= 30 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[1][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[1][1]; } else if ( lc5 <= 50 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[2][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[2][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1]; } } count++; if ( count >= 10 ) { break; } } this->m_DevilSquareScoreInfoTOP10.Count = count; int iSize = count * 24 + 5; PHeadSetB((LPBYTE)&this->m_DevilSquareScoreInfoTOP10, 0x93, iSize); count = 1; std::vector<OBJECTSTRUCT *>::iterator Itor = this->m_DevilSquareRankList.begin(); LogAddTD("[DevilSquare] Rank [%d]", this->m_iIndex); for ( ; Itor != this->m_DevilSquareRankList.end(); Itor++ ) { if ( iUserCount <= 6 ) { if ( count < 4 ) //webzen fixed on season 3.0 { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[count-1][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[count-1][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1]; } } else { int lc7 = count*100/iUserCount; if ( count ==1 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[0][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[0][1]; } else if ( lc7 <= 30 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[1][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[1][1]; } else if ( lc7 <= 50 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[2][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[2][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1]; } } if ( g_CrywolfSync.GetOccupationState() == 1 && Configs.CrywolfApplyMvpPenalty != FALSE) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = (this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100; } __int64 exp = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp; gObjSealUserSetExp((*(Itor)), exp, TRUE); //Seal Exp (Season3 add-on) (*(Itor))->Experience += (int)exp; bool ret = gObjLevelUp((*(Itor)), exp, 0, EVENT_TYPE_DEVILSQUARE); (*(Itor))->m_nEventMoney = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen; if ( gObjCheckMaxZen((*(Itor))->m_Index, (*(Itor))->m_nEventMoney) == FALSE ) { int Zen = MAX_ZEN - (*(Itor))->Money; (*(Itor))->Money += Zen; } else { (*(Itor))->Money += (*(Itor))->m_nEventMoney; } GCMoneySend((*(Itor))->m_Index, (*(Itor))->Money); if ( ret == true ) { GCKillPlayerExpSend((*(Itor))->m_Index, (WORD)-1, exp, 0, 0);//Season 4.5 changed } this->SendRankingInfo((*(Itor))); LogAddTD("Rank :[%d] : [%s][%s][%d][%d][%d]", count, (*(Itor))->AccountID, (*(Itor))->Name, (*(Itor))->m_nEventMoney, (*(Itor))->m_nEventExp, (*(Itor))->m_nEventScore); memcpy(this->m_DevilSquareScoreInfoTOP10.Score[0].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN); this->m_DevilSquareScoreInfoTOP10.Score[0].TotalScore = (*(Itor))->m_nEventScore; this->m_DevilSquareScoreInfoTOP10.MyRank = count; count++; DataSend((*(Itor))->m_Index, (LPBYTE)&this->m_DevilSquareScoreInfoTOP10 , iSize); (*(Itor))->m_nEventScore = 0; (*(Itor))->m_nEventMoney = 0; (*(Itor))->m_nEventExp = 0; } }
// ----------------------------------------------------------------------------------------------------------------------------------------------------- void CPersonalShop::BuyItemPersonalShop(PMSG_REQ_BUYITEM_FROM_PSHOP * lpMsg, int aSourceIndex) { LPOBJ SrcObj = &gObj[aSourceIndex]; // ------ if( gDoPShopOpen == FALSE ) return; // ------ if( gObjIsConnected( MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)) == FALSE ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller is Offline (%d).", SrcObj->AccountID, SrcObj->Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)); // ------ SendPShopBuyItemResult(aSourceIndex, -1, 0, 2); return; } // ------ LPOBJ lpObj = &gObj[MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)]; // ------ if( lpObj->Type != OBJ_USER ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller isn't an Object User (%d).", SrcObj->AccountID, SrcObj->Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)); // ------ SendPShopBuyItemResult(aSourceIndex, -1, 0, 2); return; } // ------ if( lpObj->CloseCount >= 0 ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Seller is Closing (%d).", SrcObj->AccountID, SrcObj->Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)); // ------ SendPShopBuyItemResult(aSourceIndex, -1, 0,2); return; } // ------ if( SrcObj->CloseCount >= 0 ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Buyer is Closing (%d).", SrcObj->AccountID, SrcObj->Name, MAKE_NUMBERW(lpMsg->NumberH, lpMsg->NumberL)); // ------ SendPShopBuyItemResult(aSourceIndex, -1, 0, 2); return; } // ------ if( lpObj->m_bPShopOpen == false ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Didn't Open Shop.", SrcObj->AccountID, SrcObj->Name, lpObj->AccountID, lpObj->Name); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 3); return; } // ------ char szName[MAX_ACCOUNT_LEN+1] = {0}; // ------ memcpy(szName, lpMsg->btName, sizeof(lpMsg->btName)); szName[MAX_ACCOUNT_LEN] = 0; // ------ int iITEM_LOG_TYPE; int iITEM_LOG_LEVEL; int iITEM_LOG_DUR; int iITEM_LOG_SERIAL; // ------ if( strcmp(szName, lpObj->Name) ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: Name Mismatch [%s]-[%s]", SrcObj->AccountID, SrcObj->Name, szName, lpObj->Name); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 6); return; } // ------ if( (lpObj->Penalty &4) == 4 || (lpObj->Penalty &8) == 8 ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] is in Item Block", SrcObj->AccountID, SrcObj->Name, lpObj->AccountID, lpObj->Name); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0,9); return; } // ------ if( (SrcObj->Penalty &4) == 4 || (SrcObj->Penalty &8) == 8 ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] is in Item Block", SrcObj->AccountID, SrcObj->Name, lpObj->AccountID, lpObj->Name); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0,9); return; } // ------ EnterCriticalSection(&lpObj->m_critPShopTrade); // ------ if( lpObj->m_bPShopTransaction == true ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Already In Trade.", SrcObj->AccountID, SrcObj->Name, lpObj->AccountID, lpObj->Name); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0,4); // ------ LeaveCriticalSection(&lpObj->m_critPShopTrade); } else { lpObj->m_bPShopTransaction = true; // ------ LeaveCriticalSection(&lpObj->m_critPShopTrade); // ------ if( gObjInventorySearchSerialNumber(&gObj[aSourceIndex], lpObj->Inventory1[lpMsg->btItemPos].GetNumber()) == FALSE ) { GCReFillSend(aSourceIndex, SrcObj->Life, -3, 1, SrcObj->iShield); // ------ CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] CopyItem :: [%s](%d)", SrcObj->AccountID, SrcObj->Name, __FILE__, __LINE__); return; } // ------ if( gObjInventorySearchSerialNumber(lpObj, lpObj->Inventory1[lpMsg->btItemPos].GetNumber()) == FALSE ) { GCReFillSend(lpObj->m_Index, lpObj->Life, -3, 1, lpObj->iShield); // ------ CLog.LogAddC(TColor.Red(), PShopModule, "(Error): [%s][%s] CopyItem :: [%s](%d)", lpObj->AccountID, lpObj->Name, __FILE__, __LINE__); return; } // ------ if(gObjFixInventoryPointer(aSourceIndex) == false ) { CLog.LogAddC(TColor.Red(), PShopModule, "[Fix Inv.Ptr] False Location - [%s](%d)", __FILE__, __LINE__); } // ------ if( SrcObj->pTransaction == 1 ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Item Buy Request Failed: Requester Transaction == 1, IF_STAT_TYPE : %d", SrcObj->AccountID, SrcObj->Name, SrcObj->m_IfState.type); return; } // ------ iITEM_LOG_TYPE = 0; iITEM_LOG_LEVEL = 0; iITEM_LOG_DUR = 0; iITEM_LOG_SERIAL = 0; // ------ __try { if( PSHOP_RANGE(lpMsg->btItemPos) == FALSE ) { SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 5); return; } // ------ if( lpObj->m_bMapSvrMoveQuit == true ) { SendPShopBuyItemResult(aSourceIndex, -1, 0, 2); return; } // ------ if( lpObj->Inventory1[lpMsg->btItemPos].IsItem() == TRUE ) { if( lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue <= 0 ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Didn't Choose Item Price.", SrcObj->AccountID, SrcObj->Name, lpObj->AccountID, lpObj->Name); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 6); return; } // ------ if( SrcObj->Money < lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Lack of Zen.", SrcObj->AccountID, SrcObj->Name, lpObj->AccountID, lpObj->Name); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 7); return; } // ------ DWORD dwCost = lpObj->Inventory1[lpMsg->btItemPos].m_iPShopValue; // ------ if( gObjCheckMaxZen(lpObj->m_Index, dwCost) == FALSE ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] Exceeding Zen of the Host", SrcObj->AccountID, SrcObj->Name, lpObj->AccountID, lpObj->Name); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 8); return; } // ------ BYTE btNewItemPos = 0; btNewItemPos = gObjOnlyInventoryInsertItem(aSourceIndex, lpObj->Inventory1[lpMsg->btItemPos]); // ------ if( btNewItemPos == 0xFF ) { CLog.LogAddC(TColor.Red(), PShopModule, "[%s][%s] Shop Item Buy Request Failed: [%s][%s] No Room to Buy Item.", SrcObj->AccountID, SrcObj->Name, lpObj->AccountID, lpObj->Name); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, 0, 8); return; } // ------ iITEM_LOG_TYPE = lpObj->Inventory1[lpMsg->btItemPos].m_Type; iITEM_LOG_LEVEL = lpObj->Inventory1[lpMsg->btItemPos].m_Level; iITEM_LOG_DUR = lpObj->Inventory1[lpMsg->btItemPos].m_Durability; iITEM_LOG_SERIAL = lpObj->Inventory1[lpMsg->btItemPos].m_Number; // ------ gObjInventoryItemSet_PShop(lpObj->m_Index, lpMsg->btItemPos, -1); // ------ lpObj->Inventory1[lpMsg->btItemPos].Clear(); GCInventoryItemDeleteSend(lpObj->m_Index, lpMsg->btItemPos, TRUE); // ------ SrcObj->Money -= dwCost; lpObj->Money += dwCost; // ------ GCMoneySend(aSourceIndex, SrcObj->Money); GCMoneySend(lpObj->m_Index, lpObj->Money); // ------ SendPShopBuyItemResult(aSourceIndex, lpObj->m_Index, btNewItemPos, 1); // ------ SendPShopSoldItemResult(lpObj->m_Index, aSourceIndex, lpMsg->btItemPos); // ------ CLog.LogAddC(TColor.Green(), PShopModule, "[%s][%s][%s] Shop Item Buy Request Succeed: [%s][%s][%s] Price = (%d), Type:(%d)[%s] Level:(%d) Dur:(%d) Serial:(%d).", SrcObj->AccountID, SrcObj->Name, SrcObj->Ip_addr, lpObj->AccountID, lpObj->Name, lpObj->Ip_addr, dwCost, iITEM_LOG_TYPE, ItemAttribute[iITEM_LOG_TYPE].Name, iITEM_LOG_LEVEL, iITEM_LOG_DUR, iITEM_LOG_SERIAL); // ------ if( PShop_CheckInventoryEmpty(lpObj->m_Index) == true ) { CLog.LogAddC(TColor.Green(), PShopModule, "[%s][%s] Sold All Items - Auto Closing Shop.", lpObj->AccountID, lpObj->Name); // ------ SendMsg.MessageOut(lpObj->m_Index, 0x01, "[PersonalShop] All items in Your Shop have been sold!"); // ------ lpObj->m_bPShopOpen = false; // ------ memset(lpObj->m_szPShopText, 0, sizeof(lpObj->m_szPShopText)); // ------ SendPShopCloseResult(lpObj->m_Index, 1); } else { lpObj->m_bPShopItemChange = true; } } } // ------ __finally { lpObj->m_bPShopTransaction = false; } } }
void CDevilSquareGround::SendScore() { if ( this->m_DevilSquareRankList.size() < 1 ) { return; } BYTE count = 1; int iUserCount = this->m_DevilSquareRankList.size(); int iExp = 0; std::vector<OBJECTSTRUCT *>::iterator Itor = this->m_DevilSquareRankList.begin(); for (Itor = this->m_DevilSquareRankList.begin() ; Itor != this->m_DevilSquareRankList.end() ; Itor++ ) { memcpy(this->m_DevilSquareScoreInfoTOP10.Score[count].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN); this->m_DevilSquareScoreInfoTOP10.Score[count].TotalScore = (*(Itor))->m_nEventScore; if ( iUserCount <= 6 ) { if ( count < 4 ) // For DS from 0 to 3 { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[count-1][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[count-1][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1]; } } else { int lc5 = count*100/iUserCount; if ( count == 1 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[0][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[0][1]; } else if ( lc5 <= 30 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[1][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[1][1]; } else if ( lc5 <= 50 ) { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[2][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[2][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[count].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[count].BonusExp = this->m_Bonus[3][1]; } } count++; if ( count >= 10 ) { break; } } this->m_DevilSquareScoreInfoTOP10.Count = count; int iSize = count * 24 + 5; PHeadSetB((LPBYTE)&this->m_DevilSquareScoreInfoTOP10, 0x93, iSize); count = 1; Itor = this->m_DevilSquareRankList.begin(); LogAdd("[DevilSquare] Rank [%d]", this->m_iIndex); for ( ; Itor != this->m_DevilSquareRankList.end(); Itor++ ) { if ( iUserCount <= 6 ) { if ( count < 3 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[count-1][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[count-1][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1]; } } else { int lc7 = count*100/iUserCount; if ( count ==1 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[0][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[0][1]; } else if ( lc7 <= 30 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[1][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[1][1]; } else if ( lc7 <= 50 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[2][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[2][1]; } else { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen = this->m_Bonus[3][0]; this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = this->m_Bonus[3][1]; } } if ( g_CrywolfSync.GetOccupationState() == 1 && g_iCrywolfApplyMvpPenalty != FALSE) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = (this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp * g_CrywolfSync.GetGettingExpPenaltyRate()) / 100; } /*if ( iExp > 0 ) { if ( lpObj->Type == OBJ_USER ) { if ( lpObj->m_wExprienceRate > 0 ) { lpObj->Experience += iExp; lpObj->m_nEventExp += iExp; } } }*/ if ( (*(Itor))->m_wExprienceRate == 0 ) iExp = 0; else { iExp = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp; (*(Itor))->Experience += iExp; } //(*(Itor))->Experience += this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp; bool ret = false; if ( (*(Itor))->m_wExprienceRate > 0 ) { ret = gObjLevelUp((*(Itor)), iExp, 0, EVENT_TYPE_DEVILSQUARE); } (*(Itor))->m_nEventMoney = this->m_DevilSquareScoreInfoTOP10.Score[0].BonusZen; if ( gObjCheckMaxZen((*(Itor))->m_Index, (*(Itor))->m_nEventMoney) == FALSE ) { int Zen = MAX_ZEN - (*(Itor))->Money; (*(Itor))->Money += Zen; } else { (*(Itor))->Money += (*(Itor))->m_nEventMoney; } GCMoneySend((*(Itor))->m_Index, (*(Itor))->Money); if ( ret == true ) { if ( (*(Itor))->m_wExprienceRate > 0 ) { GCKillPlayerExpSend((*(Itor))->m_Index, (WORD)-1, iExp, 0, 0); } } this->SendRankingInfo((*(Itor))); LogAdd("Rank :[%d] : [%s][%s][%d][%d][%d]", count, (*(Itor))->AccountID, (*(Itor))->Name, (*(Itor))->m_nEventMoney, (*(Itor))->m_nEventExp, (*(Itor))->m_nEventScore); memcpy(this->m_DevilSquareScoreInfoTOP10.Score[0].Name , (*(Itor))->Name, MAX_ACCOUNT_LEN); this->m_DevilSquareScoreInfoTOP10.Score[0].TotalScore = (*(Itor))->m_nEventScore; if ( (*(Itor))->m_wExprienceRate == 0 ) { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = 0; } else { this->m_DevilSquareScoreInfoTOP10.Score[0].BonusExp = iExp; } this->m_DevilSquareScoreInfoTOP10.MyRank = count; count++; DataSend((*(Itor))->m_Index, (BYTE *)&this->m_DevilSquareScoreInfoTOP10 , iSize); (*(Itor))->m_nEventScore = 0; (*(Itor))->m_nEventMoney = 0; (*(Itor))->m_nEventExp = 0; } }