Advertisement
Pr0nogo

Untitled

Jul 21st, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. // 5
  2. CUNIT *__stdcall MedicHeal_TargetAcquire(CUNIT *unitMem)
  3. {
  4. CUNIT *result; // eax
  5. CUNIT *v2; // ebx
  6. CUNIT *v3; // edi
  7. CUNIT *v4; // esi
  8. CSPRITE *v5; // eax
  9. unsigned int v6; // eax
  10. CUNIT *j; // edx
  11. char v8; // bl
  12. CORDER *v9; // eax
  13. int v10; // ecx
  14. CUNIT *v11; // eax
  15. CORDER *v12; // eax
  16. int v13; // esi
  17. int v14; // eax
  18. unsigned int v15; // edi
  19. CUNIT *v16; // ebx
  20. unsigned int v17; // eax
  21. int v18[1700]; // [esp+8h] [ebp-1AA0h]
  22. int v19; // [esp+1A98h] [ebp-10h]
  23. CUNIT *v20; // [esp+1A9Ch] [ebp-Ch]
  24. unsigned int v21; // [esp+1AA0h] [ebp-8h]
  25. unsigned int i; // [esp+1AA4h] [ebp-4h]
  26.  
  27. v2 = unitMem;
  28. result = (CUNIT *)TechUseAllowed(unitMem, TECH_Healing, (unsigned __int8)unitMem->owner);
  29. if ( result )
  30. {
  31. if ( unitMem->CAIControl )
  32. {
  33. v4 = playerUnitPointers[(unsigned __int8)unitMem->owner];
  34. v3 = 0;
  35. for ( i = 0; v4; v4 = v4->playerNext )
  36. {
  37. v5 = v4->sprite;
  38. if ( v5 )
  39. {
  40. if ( v4->mainOrderType )
  41. {
  42. if ( !(v5->flags & 0x20) )
  43. {
  44. v20 = (CUNIT *)v4->statusFlags;
  45. if ( (unsigned __int8)v20 & 1 )
  46. {
  47. if ( !v4->isBeingHealed )
  48. {
  49. if ( AI_OrderHeal(v2, v4) )
  50. {
  51. if ( !((unsigned int)v20 & USFlag_IsHallucination) )
  52. {
  53. if ( !v3 && v4->type == UNI_T_MEDIC )
  54. v3 = v4;
  55. if ( unitsdat_SpecialAbilityFlags[(unsigned __int16)v4->type] & USAFlag_Organic )
  56. {
  57. v6 = i;
  58. v18[i] = (int)v4;
  59. i = v6 + 1;
  60. }
  61. }
  62. }
  63. v2 = unitMem;
  64. }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. for ( j = v3; j; j = j->playerNext )
  71. {
  72. v8 = j->mainOrderType;
  73. if ( v8 == -80 || (v9 = j->orderQueueHead) != 0 && v9->orderType == -80 )
  74. {
  75. v10 = 0;
  76. if ( i )
  77. {
  78. while ( 1 )
  79. {
  80. if ( v8 == -80 )
  81. {
  82. v11 = j->mainOrderTargetUnit;
  83. }
  84. else
  85. {
  86. v12 = j->orderQueueHead;
  87. v13 = (int)v12->position;
  88. v11 = (CUNIT *)v12->target;
  89. v19 = v13;
  90. }
  91. if ( v11 == (CUNIT *)v18[v10] )
  92. break;
  93. if ( ++v10 >= i )
  94. goto LABEL_31;
  95. }
  96. v18[v10] = 0;
  97. }
  98. }
  99. LABEL_31:
  100. ;
  101. }
  102. v14 = 0;
  103. v15 = 99999999;
  104. v20 = 0;
  105. v21 = 0;
  106. if ( i )
  107. {
  108. do
  109. {
  110. v16 = (CUNIT *)v18[v14];
  111. if ( v16 )
  112. {
  113. v17 = getDistanceFast(
  114. unitMem->sprite->position.x,
  115. v16->sprite->position.x,
  116. unitMem->sprite->position.y,
  117. v16->sprite->position.y);
  118. if ( v17 < v15 )
  119. {
  120. v15 = v17;
  121. v20 = v16;
  122. }
  123. }
  124. v14 = v21++ + 1;
  125. }
  126. while ( v21 < i );
  127. }
  128. result = v20;
  129. }
  130. else
  131. {
  132. result = AI_BestUnit_InBox(160, unitMem, (int (__fastcall *)(_DWORD, _DWORD))Medic_HealTargetProc, unitMem);
  133. }
  134. }
  135. return result;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement