Guest
Private paste!

Untitled

By: a guest | Jun 11th, 2010 | Syntax: C | Size: 5.73 KB | Hits: 251 | Expires: Never
Copy text to clipboard
  1. void __thiscall CMob__GiveMoney(CMob *this, CUser *pUser, ATTACKINFO *attackinfo_2, int nAttackCount)
  2. {
  3.   int pickpocket_skill_level; // eax@1
  4.   Reward *v5; // edx@3
  5.   int v6; // ecx@3
  6.   ATTACKINFO *attackinfo; // esi@3
  7.   int somerand; // edi@4
  8.   unsigned int rand_num; // edx@5
  9.   double v10; // st7@5
  10.   CMobTemplate *mobinfo; // ecx@9
  11.   double v12; // st7@9
  12.   double v13; // st7@13
  13.   unsigned int final_meso_drop_amount; // eax@16
  14.   int v16; // eax@22
  15.   int v17; // edi@24
  16.   Reward *v18; // [sp+Ch] [bp-20h]@9
  17.   CDropPool *v19; // [sp+Ch] [bp-20h]@21
  18.   unsigned int v20; // [sp+10h] [bp-1Ch]@15
  19.   int v21; // [sp+10h] [bp-1Ch]@24
  20.   ZArray<Reward> array_reward; // [sp+14h] [bp-18h]@3
  21.   CMob *monster; // [sp+18h] [bp-14h]@1
  22.   SKILLENTRY *ppSkillEntry; // [sp+1Ch] [bp-10h]@1
  23.   int v25; // [sp+28h] [bp-4h]@3
  24.   int v26; // [sp+38h] [bp+Ch]@4
  25.   int v27; // [sp+38h] [bp+Ch]@24
  26.   char *damage_calculated_byserver; // [sp+3Ch] [bp+10h]@4
  27.   unsigned int v29; // [sp+3Ch] [bp+10h]@24
  28.  
  29.   monster = this;
  30.   ppSkillEntry = 0;
  31.   pickpocket_skill_level = CSkillInfo__GetSkillLevel(
  32.                              TSingleton_CSkillInfo___ms_pInstance,
  33.                              &pUser->m_character,
  34.                              (int)loc_40413B,
  35.                              &ppSkillEntry);
  36.   if ( ppSkillEntry )
  37.   {
  38.     if ( pickpocket_skill_level )               // Check if it's level over zero? Despite there's checking if it's above zero before use? silly nexon
  39.     {
  40.       v5 = 0;
  41.       array_reward.a = 0;
  42.       v6 = nAttackCount;
  43.       attackinfo = attackinfo_2;
  44.       v25 = 0;
  45.       if ( nAttackCount > 0 )
  46.       {
  47.         somerand = 156 * pickpocket_skill_level;// Probably a rand huh? pickpocket lvl * 156
  48.         damage_calculated_byserver = (char *)attackinfo_2->aDamageSvr;// Getting the damage dealt, which is calculated by server
  49.         v26 = v6;                               // This is the number of attack count, which is decrease by 1 after its done with each code
  50.         do                                      // Keep on looping through while there's more monster hit, and add it to an array
  51.         {
  52.           rand_num = CRand32__Random(&g_rand) % 0x64;// Get a random number of range 0 ~ 100
  53.           v10 = (double)pUser->m_basicStat.nLevel / (double)monster->m_pTemplate->nLevel;// User Level divide by monster level
  54.           if ( v10 >= 1.0 )                     // If User level is higher than mob level, covert it to 1
  55.             v10 = 1.0;
  56.           if ( (double)*(signed int *)((char *)ppSkillEntry->aLevelData.a + somerand - 76) * v10 >= (double)rand_num )// Check if the rand num == passes, within 100% scale
  57.           {
  58.             if ( *(_DWORD *)damage_calculated_byserver > 0 )// Check if the damage calculated by server is over zero.
  59.             {
  60.               v18 = ZArray_Reward___InsertBefore(&array_reward, -1);// Insert the object "array_reward" into the array, that'll be used later
  61.               mobinfo = monster->m_pTemplate;
  62.               v12 = (double)*(signed int *)damage_calculated_byserver / (double)mobinfo->nMaxHP;// Damage calculated by server divide by monster max HP
  63.               if ( v12 >= 1.0 )                 // If the division result is over 1.0, convert to 1,0
  64.                 v12 = 1.0;
  65.               if ( v12 <= 0.5 )                 // If the division result is below 0.5, convert to 0.5
  66.                 v12 = 0.5;
  67.               v13 = (double)(mobinfo->nLevel * *(_DWORD *)((char *)ppSkillEntry->aLevelData.a + somerand - 52))
  68.                   * v12
  69.                   * 0.006666666666666667;
  70.               if ( v13 <= 1.0 )                 // If v13 below or equal to 1.0, set 1.0
  71.                 v13 = 1.0;
  72.               v20 = (signed __int64)v13;        // Set v20 to v13's value
  73.               if ( v20 )                        // This is probably checking if v20 > 0, IDA decompiler got f*ed up here
  74.                 final_meso_drop_amount = CRand32__Random(&g_rand) % v20 + 1;// Get a random value of range (0 ~ v20) + 1 and it'll be used as the drop amount
  75.               else
  76.                 final_meso_drop_amount = CRand32__Random(&g_rand);// I'm not sure about this, CRand32__Random(&g_rand) generates an unsigned int of value 0 ~ 4 billion, are Nexon that stupid?
  77.               v18->nMoney = final_meso_drop_amount;
  78.               v18->nType = 0;
  79.             }
  80.           }
  81.           damage_calculated_byserver += 4;
  82.         }
  83.         while ( v26-- != 1 );
  84.         v5 = array_reward.a;
  85.       }
  86.       v19 = &monster->baseclass_10.m_pField->m_dropPool;
  87.       if ( v5 )
  88.         v16 = *((_DWORD *)v5 - 1);
  89.       else
  90.         v16 = 0;
  91.       v17 = attackinfo->ptHit.x - 10 * v16 + 10;
  92.       v29 = 0;
  93.       v21 = 0;
  94.       v27 = 0;
  95.       while ( v5 && v29 < *((_DWORD *)v5 - 1) ) // Loop on the array created just now and drop it, ignore this if you just wanted formula
  96.       {
  97.         CDropPool__Create(
  98.           v19,
  99.           (Reward *)((char *)v5 + v21),
  100.           pUser->m_dwCharacterID,
  101.           0,
  102.           0,
  103.           monster->baseclass_0.baseclass_0.m_dwId,
  104.           attackinfo->ptHit.x,
  105.           attackinfo->ptHit.y,
  106.           v17,
  107.           0,
  108.           v27 + attackinfo->tDelay,             // Drop the meso at the delay of the attack with an increase of 120 after each meso
  109.           0,
  110.           0,
  111.           0);
  112.         ++v29;                                  // Increasing the loop :D
  113.         v27 += 120;                             // Here's where it's increasing (delay) :D
  114.         v21 += 24;                              // This might be the x position that it's dropping, which increase by 24 after each drop
  115.         v5 = array_reward.a;
  116.         v17 += 20;
  117.       }
  118.       v25 = -1;
  119.       ZArray_Reward___RemoveAll(&array_reward); // Cleanup of array
  120.     }
  121.   }
  122. }