Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.38 KB | None | 0 0
  1. inline void ResolverSetup::Auto() {
  2. //I would like to sincerely thank everyone who has helped me, despite my (inocuous) incompetence and nievity. I would like to especially thank Vidsac for his enourmous assistance, and KappaPride69 for (perhaps rudely) informing me of my errors.
  3. /*Variables*/
  4. float LBYEyeDelta; //This is for a later resolver that is not mine.
  5. float FinalAngle[64]; //Value to set after resolving is done.
  6. float MovingLBY[64]; //Value to be used if we can't resolve entity.
  7. float StoredLBY[64]; //This will be compared to BrokenLBY.
  8. float BlackListedAngles[64][3]; //A multidimensional array for blacklisting angles, will be reset upon round end.
  9. float BrokenLBY[64]; //Value to be assigned if the entity is fakewalking.
  10. float LowerBodyTargetToSubtract[64]; //This is for a later statement.
  11. bool BrokenLBYHasValue[64]; //Failsafe to make sure we don't assign the entity's eye angles to a garbage value.
  12. bool BlackListedAnglesHasValue[64][3]; //This must be multidimensional, as [0][0] might have a value, but [0][1] might not!
  13. bool ResolvedStatus[64]; //If we log an animation based LBY update, we know for sure that we have resolved the entity (if the entity is using a static angle).
  14. bool DidWeUseAnimation[64]; //For keeping track of the stupid number of sequence related variables.
  15. //bool IsFakeWalking; //To remove some cublersome rechecks - Thanks KappaPride69 for the idea. You may incorporate this if you want, I will not.
  16. static unsigned short BlackListCounter[64]; //This is for keeping track of the second digit in the multi dimensional arrays. Due to the nature of this, only the most recent blacklisted angle will not be shot at, it will suffice though
  17. static unsigned short SequenceCounter[64]; //This is for keeping track of the subtraction of LowerBodyTargetToSubtract.
  18. IClientEntity *pEntityToResolve; //The p means pointer, not perfect!
  19.  
  20.  
  21. for (int i = 0; i < Interfaces::Engine->GetMaxClients(); ++i)
  22. {
  23. pEntityToResolve = (IClientEntity*)Interfaces::EntList->GetClientEntity(i);
  24.  
  25. if (!pEntityToResolve || pEntityToResolve == hackManager.pLocal() || pEntityToResolve->IsDormant() || !pEntityToResolve->IsAlive())
  26. continue;
  27.  
  28. /*Initialization*/
  29. static bool RunOnce = false;
  30. if (!RunOnce) {
  31. for (int i = 0; i < 64; i++) {
  32. ResolvedStatus[i] = false;
  33. MovingLBY[i] = 180; //This is a fail safe for a later switch satement, base on the amount of shots fired.
  34. BrokenLBYHasValue[i] = false;
  35. StoredLBY[i] = pEntityToResolve->GetLowerBodyYaw();
  36. DidWeUseAnimation[i] = false;
  37. SequenceCounter[i] = 0;
  38. BlackListCounter[i] = 0;
  39. LowerBodyTargetToSubtract[i] = 0;
  40.  
  41. for (int z = 0; z < 3; z++) { //Only goes up to 3, as the second set of values is that large. Nested for loops run their entirety before breaking back into the base for loop.
  42. BlackListedAnglesHasValue[i][z] = false;
  43. }
  44. }
  45.  
  46. RunOnce = true; //This loop will never run again
  47. }
  48.  
  49. /*Not Fake Walking*/
  50. if (pEntityToResolve->GetVelocity().Length() > 40 && pEntityToResolve->GetFlags() &FL_ONGROUND && StoredLBY[i] != pEntityToResolve->GetLowerBodyYaw()) { //Make sure to remember that LBY updates every 0.22 seconds while running, every 1.1 seconds while still and never updates in air!
  51. FinalAngle[i] = pEntityToResolve->GetLowerBodyYaw(); //40 is just some random value; it doesn't matter. As long as the Entity isn't at FakeWalk velocity, the StoredLBY[i] != pEntityToResolve->GetLowerBodyYaw() will not generate false positives.
  52. MovingLBY[i] = pEntityToResolve->GetLowerBodyYaw();
  53. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYaw();
  54. }
  55. else
  56. {
  57. studiohdr_t* hdr = Interfaces::ModelInfo->GetStudiomodel(pEntityToResolve->GetModel()); //Credits to Tranquility!
  58. int m_nSequence = *reinterpret_cast<int*>(DWORD(pEntityToResolve) + 0x28AC); //Credits to Tranquility!
  59. if (hdr && hdr->pSeqdesc(m_nSequence)->activity == 979) // 979 = ACT_CSGO_BALANCETURN_ADJUST. 973 has nothing to do with LBY updates. Thanks KappaPride69. I think I may have just mistyped or something.
  60. { //The conditional operator doesn't really need to be used here. If SequenceCounter is zero, multiplying it by 30 will evaluate to zero anyway. This just cleans up the intention.
  61. if(!ResolvedStatus) //We don't need to reevalute the same check if we already have them resolved, thanks Vidsac!
  62. SequenceCounter[i] > 0 ? LowerBodyTargetToSubtract[i] = SequenceCounter[i] * 30 : LowerBodyTargetToSubtract[i] = 0; //Thank you stevefan1999 for the idea of using the terany/conditional operator.
  63. FinalAngle[i] = *pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract[i]; //Thank you XxharCs and vidsac for this idea
  64. ResolvedStatus[i] = true;
  65. DidWeUseAnimation[i] = true;
  66. pEntityToResolve->GetEyeAnglesXY()->y = FinalAngle[i];
  67. }
  68. else
  69. { //The not-fake-waling check has already evaluated false. If they are moving at this point, they are fake walking
  70. if (pEntityToResolve->GetVelocity().Length() > 0.1 && pEntityToResolve->GetVelocity().Length() <= 40 && pEntityToResolve->GetFlags() &FL_ONGROUND) { //If this evalutes true, the entity is fake walking, resort to BAIM.
  71. CRageBot HitscanBAIM; //An object with the explicit purpose of accessing hitscan.
  72. BrokenLBY[i] = pEntityToResolve->GetLowerBodyYaw();
  73. BrokenLBYHasValue[i] = true;
  74. HitscanBAIM.HitScan(pEntityToResolve, true); //The second paramter ensures that only the pelvis is aimed at.
  75. }
  76. else { //Not fakewalking or moving, the entity is still.
  77. if (ResolvedStatus[i]) { //We have successfully hit an angle, we can just set the entity's eye angles to a stored angle.
  78. pEntityToResolve->GetEyeAnglesXY()->y = FinalAngle[i]; //We don't need to test for blacklisting, as the ResolvedStatus at i will be set to false if we miss
  79. }
  80. else {
  81. if (BrokenLBYHasValue[i] && (BrokenLBY[i] != StoredLBY[i]) && (BlackListedAngles[i][BlackListCounter[i]] != StoredLBY[i])) { //We have detected broken LBY from fake walk and it does not equal the previously logged angle, it must have updated, but make sure it doesn't equal a blacklisted angle
  82. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYaw();
  83. ResolvedStatus[i] = true;
  84. FinalAngle[i] = pEntityToResolve->GetLowerBodyYaw();
  85. }
  86. else { //The Entity is: Not Fake-Walking; Not Moving; No Update to Animation and Not Resolved.
  87. switch (Globals::missedshots) {
  88. case 0:
  89. pEntityToResolve->GetEyeAnglesXY()->y = FinalAngle[i];
  90. break;
  91. case 1:
  92. if (FinalAngle[i] != BlackListedAngles[i][BlackListCounter[i]])
  93. pEntityToResolve->GetEyeAnglesXY()->y = FinalAngle[i];
  94. else
  95. pEntityToResolve->GetEyeAnglesXY()->y = MovingLBY[i]; //If we have blacklisted an angle, we can speed up switching to another resolver by adding the next case here
  96. break;
  97. case 2:
  98. if (MovingLBY[i] != BlackListedAngles[i][BlackListCounter[i]])
  99. pEntityToResolve->GetEyeAnglesXY()->y = MovingLBY[i];
  100. else { //The MovingLBY we logged is the same as a backlisted angle, change up resolver, this can be reached Vidsac.
  101. //This isn't my resolver, this is from Suicide.cc
  102.  
  103. LBYEyeDelta = pEntityToResolve->GetEyeAngles().y - pEntityToResolve->GetLowerBodyYaw();
  104. if (fabsf(LBYEyeDelta) >= 35.0f)
  105. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYaw();
  106. else {
  107. if (fabsf(LBYEyeDelta) < 35.0f && fabsf(LBYEyeDelta) > 0.0f && (pEntityToResolve->GetLowerBodyYaw() + LBYEyeDelta != BlackListedAngles[i][BlackListCounter[i]])) {
  108. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYaw() + LBYEyeDelta;
  109. }
  110. else {
  111.  
  112. SequenceCounter[i] > 0 ? LowerBodyTargetToSubtract[i] = SequenceCounter[i] * 30 : LowerBodyTargetToSubtract[i] = 0;
  113.  
  114. if ((pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract != BlackListedAngles[i][BlackListCounter[i]]))
  115. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract;
  116. else {
  117. LowerBodyTargetToSubtract[i] = 0;
  118. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract;
  119. }
  120. }
  121. }
  122. }
  123. break;
  124. case 3:
  125. //This isn't my resolver, this is from Suicide.cc
  126.  
  127. LBYEyeDelta = pEntityToResolve->GetEyeAngles().y - pEntityToResolve->GetLowerBodyYaw();
  128. if (fabsf(LBYEyeDelta) >= 35.0f)
  129. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYaw();
  130. else {
  131. if (fabsf(LBYEyeDelta) < 35.0f && fabsf(LBYEyeDelta) > 0.0f && (pEntityToResolve->GetLowerBodyYaw() + LBYEyeDelta != BlackListedAngles[i][BlackListCounter[i]])) {
  132. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYaw() + LBYEyeDelta;
  133. }
  134. else {
  135. SequenceCounter[i] > 0 ? LowerBodyTargetToSubtract[i] = SequenceCounter[i] * 30 : LowerBodyTargetToSubtract[i] = 0;
  136.  
  137. if ((pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract != BlackListedAngles[i][BlackListCounter[i]]))
  138. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract;
  139. else {
  140. LowerBodyTargetToSubtract[i] = 0;
  141. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract;
  142. }
  143. }
  144. }
  145. break;
  146. default:
  147. SequenceCounter[i] > 0 ? LowerBodyTargetToSubtract[i] = SequenceCounter[i] * 30 : LowerBodyTargetToSubtract[i] = 0;
  148.  
  149. if ((pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract != BlackListedAngles[i][BlackListCounter[i]]))
  150. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract;
  151. else {
  152. LowerBodyTargetToSubtract[i] = 0;
  153. pEntityToResolve->GetEyeAnglesXY()->y = pEntityToResolve->GetLowerBodyYawTarget() - LowerBodyTargetToSubtract;
  154. }
  155. break;
  156.  
  157. }
  158. }
  159. }
  160. }
  161. }
  162. }
  163.  
  164. if (didhitHS) {
  165. FinalAngle[i] = pEntityToResolve->GetLowerBodyYaw();
  166. ResolvedStatus[i] = true;
  167. }
  168. else {
  169. IClientEntity *pLocal = hackManager.pLocal();
  170. CBaseCombatWeapon* pWeapon = (CBaseCombatWeapon*)Interfaces::EntList->GetClientEntityFromHandle(pLocal->GetActiveWeaponHandle());
  171. if (!didhit) {
  172. if (pWeapon && pLocal && pWeapon->GetInaccuracy() > 65) {
  173. if (DidWeUseAnimation[i]) {
  174. SequenceCounter[i]++;
  175. if (SequenceCounter[i] > 4)
  176. SequenceCounter[i] = 0; //Not very elegant, but our miss may be due to spread
  177. }
  178. ResolvedStatus[i] = false;
  179. BlackListedAngles[i][BlackListCounter[i]] = pEntityToResolve->GetLowerBodyYaw(); //This is confusing. The first set of square paranthesies (b1g spelling) refers to the entity. The second refers to an array of integers, specifically made to count this value.
  180. BlackListedAnglesHasValue[i][BlackListCounter[i]] = true; //Same logic as above.
  181. BlackListCounter[i]++; //Increment the second digit at this entity.
  182. }
  183. }
  184. }
  185.  
  186. DidWeUseAnimation[i] = false;
  187. StoredLBY[i] = pEntityToResolve->GetLowerBodyYaw();
  188. }
  189. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement