Advertisement
Arkanun

_MSG_CombineItemAilyn

Mar 9th, 2023
554
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.49 KB | None | 0 0
  1. /*
  2. *   Copyright (C) {2015}  {Victor Klafke, Charles TheHouse}
  3. *
  4. *   This program is free software: you can redistribute it and/or modify
  5. *   it under the terms of the GNU General Public License as published by
  6. *   the Free Software Foundation, either version 3 of the License, or
  7. *   (at your option) any later version.
  8. *
  9. *   This program is distributed in the hope that it will be useful,
  10. *   but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12. *   GNU General Public License for more details.
  13. *
  14. *   You should have received a copy of the GNU General Public License
  15. *   along with this program.  If not, see [http://www.gnu.org/licenses/].
  16. *
  17. *   Contact at: [email protected]
  18. */
  19. #include "ProcessClientMessage.h"
  20.  
  21. void Exec_MSG_CombineItemAilyn(int conn, char *pMsg)
  22. {
  23.     MSG_CombineItem *m = (MSG_CombineItem*)pMsg;
  24.  
  25.     for (int i = 0; i < MAX_COMBINE; i++)
  26.     {
  27.         if (m->Item[i].sIndex == 0)
  28.             continue;
  29.  
  30.         int invPos = m->InvenPos[i];
  31.  
  32.         if (invPos < 0 || invPos >= pMob[conn].MaxCarry)
  33.         {
  34.             RemoveTrade(conn);
  35.             return;
  36.         }
  37.  
  38.         if (memcmp(&pMob[conn].MOB.Carry[invPos], &m->Item[i], sizeof(STRUCT_ITEM)))
  39.         {
  40.             ItemLog("err,msg_CombineAilyn - item remove or changed.", pUser[conn].AccountName, pUser[conn].IP);
  41.             SendClientSignalParm(conn, ESCENE_FIELD, _MSG_CombineComplete, 0);
  42.             return;
  43.         }
  44.     }
  45.  
  46.     if (pMob[conn].MOB.Coin < 50000000)
  47.     {
  48.         sprintf(temp, g_pMessageStringTable[_DN_D_Cost], 50000000);
  49.         SendClientMessage(conn, temp);
  50.        
  51.         SendClientSignalParm(conn, ESCENE_FIELD, _MSG_CombineComplete, 0);
  52.         return;
  53.     }
  54.  
  55.     int combine = GetMatchCombineAilyn(m->Item);
  56.  
  57.     if (combine == 0)
  58.     {
  59.         SendClientMessage(conn, g_pMessageStringTable[_NN_Wrong_Combination]);
  60.        
  61.         SendClientSignalParm(conn, ESCENE_FIELD, _MSG_CombineComplete, 0);
  62.         return;
  63.     }
  64.  
  65.     for (int i = 2; i < MAX_COMBINE; i++)
  66.     {
  67.         if (m->Item[i].sIndex == 0)
  68.             continue;
  69.  
  70.         memset(&pMob[conn].MOB.Carry[m->InvenPos[i]], 0, sizeof(STRUCT_ITEM));
  71.         SendItem(conn, ITEM_PLACE_CARRY, m->InvenPos[i], &pMob[conn].MOB.Carry[m->InvenPos[i]]);
  72.     }
  73.  
  74.     pMob[conn].MOB.Coin -= 50000000;
  75.     SendEtc(conn);
  76.  
  77.     ItemLog("*** Item combine ailyn. ***", pUser[conn].AccountName, pUser[conn].IP);
  78.  
  79.     for (int i = 0; i < MAX_COMBINE; i++)
  80.     {
  81.         if (m->Item[i].sIndex)
  82.         {
  83.             char itemlog[2048];
  84.                                      
  85.             BASE_GetItemCode(&m->Item[i], itemlog);
  86.                                      
  87.             strcat(temp, itemlog);
  88.         }
  89.     }
  90.     ItemLog(temp, pUser[conn].AccountName, pUser[conn].IP);
  91.     ItemLog("*** ------------------- ***", pUser[conn].AccountName, pUser[conn].IP);
  92.  
  93.     int _rand = rand() % 115;
  94.     if (_rand >= 100)
  95.         _rand -= 15;
  96.  
  97.     int ipos1 = 0;
  98.     int ipos2 = 0;
  99.  
  100.     if (_rand <= combine || LOCALSERVER)
  101.     {
  102.         if (rand() % 1 == 0)
  103.         {
  104.             ipos1 = m->InvenPos[0];
  105.             ipos2 = m->InvenPos[1];
  106.         }
  107.         else
  108.         {
  109.             ipos1 = m->InvenPos[1];
  110.             ipos2 = m->InvenPos[0];
  111.         }                            
  112.  
  113.         pMob[conn].MOB.Carry[ipos1].stEffect[0].cEffect = pMob[conn].MOB.Carry[ipos2].stEffect[0].cEffect;
  114.         pMob[conn].MOB.Carry[ipos1].stEffect[0].cValue = pMob[conn].MOB.Carry[ipos2].stEffect[0].cValue;
  115.         pMob[conn].MOB.Carry[ipos1].stEffect[1].cEffect = pMob[conn].MOB.Carry[ipos2].stEffect[1].cEffect;
  116.         pMob[conn].MOB.Carry[ipos1].stEffect[1].cValue = pMob[conn].MOB.Carry[ipos2].stEffect[1].cValue;
  117.         pMob[conn].MOB.Carry[ipos1].stEffect[2].cEffect = pMob[conn].MOB.Carry[ipos2].stEffect[2].cEffect;
  118.         pMob[conn].MOB.Carry[ipos1].stEffect[2].cValue = pMob[conn].MOB.Carry[ipos2].stEffect[2].cValue;
  119.  
  120.         BASE_SetItemSanc(&pMob[conn].MOB.Carry[ipos1], 10, m->Item[3].sIndex - 2441);
  121.  
  122.         memset(&pMob[conn].MOB.Carry[ipos2], 0, sizeof(STRUCT_ITEM));
  123.         SendItem(conn, ITEM_PLACE_CARRY, ipos2, &pMob[conn].MOB.Carry[ipos2]);
  124.  
  125.         pMob[conn].MOB.Coin -= 50000000;
  126.         SendEtc(conn);
  127.  
  128.         SendClientMessage(conn, g_pMessageStringTable[_NN_Processing_Complete]);
  129.  
  130.         SendClientSignalParm(conn, ESCENE_FIELD, _MSG_CombineComplete, 1);
  131.  
  132.         char tt[512];
  133.  
  134.         sprintf(temp, "%s ", pUser[conn].AccountName);
  135.         BASE_GetItemCode(&pMob[conn].MOB.Carry[ipos1], tt);
  136.         strcat(temp, tt);
  137.  
  138.         ItemLog(temp, "*** Combine ailyn sucess ***", pUser[conn].IP);
  139.         SendItem(conn, ITEM_PLACE_CARRY, ipos1, &pMob[conn].MOB.Carry[ipos1]);
  140.  
  141.         return;
  142.     }
  143.     else
  144.     {
  145.         sprintf(temp, "%s", g_pMessageStringTable[_NN_CombineFailed]);
  146.         SendClientMessage(conn, temp);
  147.  
  148.         SendClientSignalParm(conn, ESCENE_FIELD, _MSG_CombineComplete, 2);
  149.         ItemLog("*** Combine ailyn fail ***", pUser[conn].AccountName, pUser[conn].IP);
  150.  
  151.         return;
  152.     }
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement