Advertisement
Guest User

CNWSCreature__ResolveAttackRoll

a guest
Oct 19th, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.17 KB | None | 0 0
  1. void __thiscall CNWSCreature__ResolveAttackRoll(int this, int a2)
  2. {
  3.   int v2; // ebp@1
  4.   int v3; // ebx@2
  5.   int v4; // edi@2
  6.   int v5; // esi@2
  7.   void *v6; // eax@3
  8.   _UNKNOWN *v7; // eax@3
  9.   int v8; // edi@5
  10.   int v9; // eax@5
  11.   int v10; // eax@5
  12.   int v11; // eax@9
  13.   int v12; // ecx@12
  14.   int v13; // edx@12
  15.   int v14; // eax@18
  16.   int v15; // eax@22
  17.   int v16; // edi@23
  18.   int v17; // edi@23
  19.   int v18; // eax@23
  20.   int v19; // edi@23
  21.   int v20; // eax@32
  22.   void *v21; // eax@42
  23.   int v22; // ebx@43
  24.   int v23; // eax@45
  25.   int v24; // ST0C_4@45
  26.   int v25; // eax@47
  27.   int v26; // eax@49
  28.   void *v27; // edi@49
  29.   void *v28; // eax@49
  30.   int v29; // ecx@49
  31.   int v30; // [sp+10h] [bp-3Ch]@1
  32.   int v31; // [sp+14h] [bp-38h]@5
  33.   int v32; // [sp+18h] [bp-34h]@2
  34.   int v33; // [sp+20h] [bp-2Ch]@2
  35.   int v34; // [sp+24h] [bp-28h]@2
  36.   int v35; // [sp+28h] [bp-24h]@9
  37.   char v36; // [sp+30h] [bp-1Ch]@9
  38.   char v37; // [sp+38h] [bp-14h]@9
  39.   int v38; // [sp+48h] [bp-4h]@3
  40.  
  41.   v2 = this;
  42.   v30 = 0;
  43.   if ( !a2 )
  44.     return;
  45.   v4 = *(_DWORD *)(this + 2760);
  46.   LOBYTE(v32) = *(_BYTE *)(v4 + 8468);
  47.   v5 = CNWSCombatRound__GetAttack((void *)v4, (unsigned __int8)v32);
  48.   v33 = *(_DWORD *)(v5 + 52);
  49.   v34 = CNWSCombatRound__GetOffHandAttack(v4);
  50.   v3 = (unsigned __int16)CNWRules__RollDice(1u, 20);
  51.   if ( g_bEnableCombatDebugging )
  52.   {
  53.     v6 = CNWSCreatureStats__GetFullName(*(void **)(v2 + 3172), &v32);
  54.     v38 = 0;
  55.     v7 = CExoString__CStr(v6);
  56.     CExoString__Format(v5 + 104, "%s Attack Roll: %d", v7, v3);
  57.     v38 = -1;
  58.     CExoString___CExoString((int)&v32);
  59.   }
  60.   if ( (*(int (__thiscall **)(int))(*(_DWORD *)a2 + 48))(a2) )
  61.   {
  62.     v9 = (*(int (__thiscall **)(int))(*(_DWORD *)a2 + 48))(a2);
  63.     v32 = *(_DWORD *)(v2 + 3172);
  64.     v8 = v9;
  65.     v30 = v9;
  66.     v10 = (*(int (**)(void))(*(_DWORD *)a2 + 48))();
  67.     v31 = CNWSCreatureStats__GetAttackModifierVersus(v32, v10);
  68.     if ( v8 )
  69.     {
  70.       v32 = (signed __int16)CNWSCreatureStats__GetArmorClassVersus(*(_DWORD *)(v8 + 3172), v2, 0);
  71.       CNWSCreature__ResolveSneakAttack(v2, v8);
  72.       CNWSCreature__ResolveDeathAttack(v2, v8);
  73.       goto LABEL_10;
  74.     }
  75.   }
  76.   else
  77.   {
  78.     v8 = 0;
  79.     v31 = CNWSCreatureStats__GetAttackModifierVersus(*(_DWORD *)(v2 + 3172), 0);
  80.   }
  81.   v32 = 0;
  82.   if ( g_bEnableCombatDebugging )
  83.   {
  84.     CExoString__CExoString(&v36, (const char **)(v5 + 104));
  85.     v38 = 1;
  86.     CNWSpellArray__CNWSpellArray(&v35);
  87.     LOBYTE(v38) = 2;
  88.     CExoString__Format((int)&v35, " Versus AC %d", 0);
  89.     v11 = CExoString__operator_(&v36, (int)&v37, (const char **)&v35);
  90.     LOBYTE(v38) = 3;
  91.     CExoString__operator_(v5 + 104, (const char **)v11);
  92.     LOBYTE(v38) = 2;
  93.     CExoString___CExoString((int)&v37);
  94.     LOBYTE(v38) = 1;
  95.     CExoString___CExoString((int)&v35);
  96.     v38 = -1;
  97.     CExoString___CExoString((int)&v36);
  98.     v8 = v30;
  99.   }
  100. LABEL_10:
  101.   if ( *(_DWORD *)(v5 + 68) == 1 )
  102.   {
  103.     *(_BYTE *)(v5 + 14) = 20;
  104.     *(_DWORD *)(v5 + 16) = v31;
  105.     *(_BYTE *)(v5 + 80) = 7;
  106.     return;
  107.   }
  108.   v13 = v32;
  109.   *(_DWORD *)(v5 + 16) = v31;
  110.   v12 = 0;
  111.   *(_BYTE *)(v5 + 14) = v3;
  112.   if ( v3 + v31 >= v13 )
  113.     v12 = 1;
  114.   if ( CNWSCreature__ResolveDefensiveEffects(v2, a2, v12) != 1 )
  115.   {
  116.     if ( (*(int (**)(void))(*(_DWORD *)a2 + 48))() )
  117.     {
  118.       if ( v3 != 20 )
  119.       {
  120.         if ( *(_BYTE *)(v8 + 1195) == 1 )
  121.         {
  122.           v14 = *(_DWORD *)(v8 + 2760);
  123.           if ( *(_BYTE *)(v14 + 8528) )
  124.           {
  125.             if ( !*(_DWORD *)(v14 + 8452) )
  126.             {
  127.               if ( *(_BYTE *)(v8 + 2525) != 6 )
  128.               {
  129.                 if ( !v33 )
  130.                 {
  131.                   LOBYTE(v15) = CNWSCreature__GetRangeWeaponEquipped(v8);
  132.                   if ( !v15 )
  133.                   {
  134.                     v17 = *(_DWORD *)(v8 + 3172);
  135.                     v18 = (*(int (__thiscall **)(int))(*(_DWORD *)v2 + 16))(v2);
  136.                     v19 = CNWSCreatureStats__GetSkillRank(v17, 0xAu, v18, 0);
  137.                     v16 = (unsigned __int16)CNWRules__RollDice(1u, 20) + v19;
  138.                     if ( v16 >= v3 + v31 )
  139.                     {
  140.                       if ( v16 - 10 >= v3 + v31 )
  141.                         CNWSCombatRound__AddParryAttack(*(_DWORD *)(v30 + 2760), *(_DWORD *)(v2 + 4));
  142.                       *(_BYTE *)(v5 + 80) = 2;
  143.                       --*(_BYTE *)(*(_DWORD *)(v30 + 2760) + 8528);
  144.                       return;
  145.                     }
  146.                     CNWSCombatRound__AddParryIndex(*(_DWORD *)(v30 + 2760));
  147.                     --*(_BYTE *)(*(_DWORD *)(v30 + 2760) + 8528);
  148.                     v8 = v30;
  149.                   }
  150.                 }
  151.               }
  152.             }
  153.           }
  154.         }
  155.       }
  156.     }
  157.     if ( v3 != 1 && (v31 + v3 >= v32 || v3 == 20) )
  158.     {
  159.       if ( v3 >= CNWSCreatureStats__GetCriticalHitRoll(*(void **)(v2 + 3172), v34) )
  160.       {
  161.         LOWORD(v20) = CNWRules__RollDice(1u, 20);
  162.         *(_DWORD *)(v5 + 72) = 1;
  163.         v20 = (unsigned __int16)v20;
  164.         *(_BYTE *)(v5 + 15) = v20;
  165.         if ( v31 + v20 >= v32 )
  166.         {
  167.           if ( !v8 )
  168.             goto LABEL_61;
  169.           if ( CServerExoApp__GetDifficultyOption(*(_DWORD *)(g_pAppManager + 4), 0) == 1
  170.             && (*(_DWORD *)(v8 + 2776) || CNWSCreature__GetIsPossessedFamiliar(v8))
  171.             && !*(_DWORD *)(v2 + 2776)
  172.             && !CNWSCreature__GetIsPossessedFamiliar(v2) )
  173.           {
  174.             *(_BYTE *)(v5 + 80) = 1;
  175.             return;
  176.           }
  177.           if ( !CNWSCreatureStats__GetEffectImmunity(
  178.                   *(_DWORD *)(v8 + 3172),
  179.                   CNWSEffectListHandler__IMMUNITY_TYPE_CRITICAL_HITS,
  180.                   v2)
  181.             && CNWSCreatureStats__HasFeat(*(_DWORD *)(v8 + 3172), 896) != 1 )
  182.           {
  183. LABEL_61:
  184.             *(_BYTE *)(v5 + 80) = 3;
  185.             return;
  186.           }
  187.           v21 = operator new(0x34u);
  188.           v38 = 4;
  189.           if ( v21 )
  190.             v22 = CNWCCMessageData__CNWCCMessageData(v21);
  191.           else
  192.             v22 = 0;
  193.           v24 = *(_DWORD *)(v8 + 4);
  194.           v38 = -1;
  195.           CNWCCMessageData__SetObjectID(v22, 0, v24);
  196.           CScriptEvent__SetInteger(v22, 0, 126);
  197.           v23 = *(_DWORD *)(v5 + 164);
  198.           if ( *(_DWORD *)(v5 + 160) == v23 )
  199.           {
  200.             if ( v23 )
  201.               v25 = 2 * v23;
  202.             else
  203.               v25 = 16;
  204.             v27 = *(void **)(v5 + 156);
  205.             *(_DWORD *)(v5 + 164) = v25;
  206.             v28 = operator new(4 * v25);
  207.             v29 = *(_DWORD *)(v5 + 160);
  208.             *(_DWORD *)(v5 + 156) = v28;
  209.             v26 = 0;
  210.             if ( v29 > 0 )
  211.             {
  212.               do
  213.               {
  214.                 *(_DWORD *)(*(_DWORD *)(v5 + 156) + 4 * v26) = *((_DWORD *)v27 + v26);
  215.                 ++v26;
  216.               }
  217.               while ( v26 < *(_DWORD *)(v5 + 160) );
  218.             }
  219.             if ( v27 )
  220.               operator delete(v27);
  221.           }
  222.           *(_DWORD *)(*(_DWORD *)(v5 + 156) + 4 * *(_DWORD *)(v5 + 160)++) = v22;
  223.         }
  224.       }
  225.       *(_BYTE *)(v5 + 80) = 1;
  226.       return;
  227.     }
  228.     *(_BYTE *)(v5 + 80) = 4;
  229.     if ( v3 == 1 )
  230.       *(_BYTE *)(v5 + 20) = 1;
  231.     else
  232.       *(_BYTE *)(v5 + 20) = abs(v3 + v31 - v32);
  233.   }
  234. }
  235.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement