Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.94 KB | None | 0 0
  1. #pragma once
  2.  
  3. namespace sdk
  4. {
  5. class CUserCmd;
  6. class CBaseEntity;
  7. class CBaseWeapon;
  8. }
  9.  
  10. struct Info
  11. {
  12. Info() {}
  13.  
  14. SDK::CAnimationLayer backup_layer, prev_layer;
  15. Vector last_lby, inverse, inverse_right, inverse_left, lby, back, left, right, backtrack;
  16. float stored_simtime, last_move_time, pre_anim_lby;
  17. int last_ammo;
  18. bool breaking_lby, reset_state, could_be_faking;
  19. std::vector<float> unresolved_yaw, lby_deltas;
  20.  
  21. bool lby_changed;
  22. bool could_be_slowmo;
  23. bool is_moving;
  24. bool is_dormant;
  25. bool is_last_moving_lby_valid;
  26. bool is_standing;
  27. bool is_fakewalking;
  28. bool is_jumping;
  29. bool is_crouching;
  30. bool lby_updated;
  31. bool using_fake_angles;
  32. float last_moving_lby;
  33. float stored_lby;
  34. float next_lby_update_time;
  35. float can_predict;
  36. int stored_missed;
  37. };
  38.  
  39.  
  40. class CResolver
  41. {
  42. public:
  43. Info player_info[65];
  44. void DoFSN();
  45. void record(SDK::CBaseEntity * entity, float new_yaw);
  46. // void NoSpreade(SDK::CBaseEntity * player, int entID);
  47. // void override(SDK::CBaseEntity * entity);
  48. void Nospread1(SDK::CBaseEntity* player, int entID);
  49. // void resolve1(SDK::CBaseEntity * entity);
  50. void Byeter(SDK::CBaseEntity * entity);
  51. void Spread4(SDK::CBaseEntity * entity);
  52. void AKHook(SDK::CBaseEntity * entity);
  53. void Spread5(SDK::CBaseEntity * entity);
  54. void LBYPrediction(SDK::CBaseEntity * entity);
  55. void resolve(SDK::CBaseEntity* entity);
  56. struct ResolverData
  57. {
  58. //ints
  59. int right_damage = 0, left_damage = 0;
  60. int stored_missed;
  61. int missed;
  62. int shotaimangles;
  63. //ints
  64.  
  65. //floats
  66. float lastlbystand;
  67. float right_fraction = 0.f, left_fraction = 0.f;
  68. float last_moving_lby;
  69. float stored_lby;
  70. float next_lby_update;
  71. float lby1, nextlbyup;
  72. float lastmovinglby;
  73. float flick;
  74. //floats
  75.  
  76. //bools
  77. bool is_moving;
  78. bool is_jumping;
  79. bool is_crouching;
  80. bool using_fake_angles;
  81. bool bfakeangle, bfakewalk, playerhurtcalled, weaponfirecalled;
  82. bool lbywasupdated;
  83. //bools
  84.  
  85. //vectors
  86. SDK::CAnimationLayer anim_layers[15];
  87. //vectors
  88.  
  89.  
  90. } pResolverData[64];
  91.  
  92.  
  93. bool AntiFreestanding(SDK::CBaseEntity* entity, float & yaw);
  94.  
  95. void DoCM();
  96.  
  97. bool IsYawSideways(SDK::CBaseEntity * entity, float yaw);
  98.  
  99. void DoResolver();
  100. void ProcessSnapShots();
  101.  
  102. public:
  103. /// resolve types, they're "flags" so to speak since a player can have more than 1 resolve type at once
  104. /// if angles overlap
  105. static const unsigned int RESOLVE_TYPE_NUM = 8;
  106. static const unsigned short RESOLVE_TYPE_OVERRIDE = 0b00000001,
  107. RESOLVE_TYPE_NO_FAKE = 0b00000010,
  108. RESOLVE_TYPE_LBY = 0b00000100,
  109. RESOLVE_TYPE_LBY_UPDATE = 0b00001000,
  110. RESOLVE_TYPE_PREDICTED_LBY_UPDATE = 0b00010000,
  111. RESOLVE_TYPE_LAST_MOVING_LBY = 0b00100000,
  112. RESOLVE_TYPE_NOT_BREAKING_LBY = 0b01000000,
  113. RESOLVE_TYPE_BRUTEFORCE = 0b10000000,
  114. RESOLVE_TYPE_LAST_MOVING_LBY_DELTA = 0b100000000,
  115. RESOLVE_TYPE_ANTI_FREESTANDING = 0b1000000000;
  116.  
  117. public:
  118. /// a struct holding info the resolver needs, updated every frame for every player
  119. class PlayerResolveRecord
  120. {
  121. public:
  122. PlayerResolveRecord()
  123. {
  124. resolve_type = 0;
  125. shots_missed_moving_lby = 0;
  126. shots_missed_moving_lby_delta = 0;
  127.  
  128. last_balance_adjust_trigger_time = 0.f;
  129. last_moving_lby_delta = 0.f;
  130. last_time_moving = 0.f;
  131. last_time_down_pitch = 0.f;
  132. next_predicted_lby_update = 0.f;
  133.  
  134. SDK::CAnimationLayer anim_layers[15];
  135. has_fake = false;
  136. is_dormant = false, is_last_moving_lby_delta_valid = false;
  137. is_last_moving_lby_valid = false, is_fakewalking = false;
  138. is_balance_adjust_triggered = false, is_balance_adjust_playing = false;
  139. did_lby_flick = false, did_predicted_lby_flick = false;
  140.  
  141. for (int i = 0; i < RESOLVE_TYPE_NUM; i++)
  142. {
  143. shots_hit[i] = 0;
  144. shots_fired[i] = 0;
  145. }
  146. }
  147.  
  148. public:
  149. struct AntiFreestandingRecord
  150. {
  151. int right_damage = 0, left_damage = 0;
  152. float right_fraction = 0.f, left_fraction = 0.f;
  153. };
  154.  
  155. public:
  156. // SDK::CAnimationLayer anim_layers[15];
  157. AntiFreestandingRecord anti_freestanding_record;
  158.  
  159. Vector resolved_angles, networked_angles;
  160. Vector velocity, origin;
  161.  
  162. int shots_hit[RESOLVE_TYPE_NUM], shots_fired[RESOLVE_TYPE_NUM];
  163. int shots_missed_moving_lby, shots_missed_moving_lby_delta;
  164. unsigned short resolve_type;
  165.  
  166. float lower_body_yaw;
  167. float last_moving_lby;
  168. float last_moving_lby_delta;
  169. float last_balance_adjust_trigger_time;
  170. float last_time_moving;
  171. float last_time_down_pitch;
  172. float next_predicted_lby_update;
  173.  
  174. bool is_dormant;
  175. bool is_last_moving_lby_valid;
  176. bool is_fakewalking;
  177. bool is_last_moving_lby_delta_valid;
  178. bool is_balance_adjust_triggered, is_balance_adjust_playing;
  179. bool did_lby_flick, did_predicted_lby_flick;
  180. bool has_fake;
  181. };
  182.  
  183. /// a snapshot holding info about the moment you shot, used to count shots missed / hit
  184. struct ShotSnapshot
  185. {
  186. SDK::CBaseEntity* entity; /// person we shot at
  187. PlayerResolveRecord resolve_record; /// their resolve record when we shot
  188.  
  189. float time; /// time when snapshot was created
  190. float first_processed_time; /// time when the shot was first processed
  191. bool was_shot_processed;
  192. int hitgroup_hit;
  193. };
  194.  
  195. private:
  196. PlayerResolveRecord player_resolve_records[64];
  197. std::vector<ShotSnapshot> shot_snapshots;
  198. std::vector<Vector> last_eye_positions;
  199.  
  200. public:
  201. PlayerResolveRecord & GetPlayerResolveInfo(SDK::CBaseEntity* entity)
  202. {
  203. return player_resolve_records[entity->GetIndex()];
  204. }
  205.  
  206. // std::string TranslateResolveRecord(unsigned short resolve_type);
  207. // CColor GetResolveColor(unsigned short resolve_type);
  208. int GetResolveTypeIndex(unsigned short resolve_type);
  209. std::string TranslateResolveRecord(unsigned short resolve_type);
  210. CColor GetResolveColor(unsigned short resolve_type);
  211. //int GetShotsMissed(SDK::CBaseEntity* entity, unsigned short resolve_type);
  212.  
  213. bool IsResolved(const unsigned short& resolve_type)
  214. {
  215. if (resolve_type & RESOLVE_TYPE_NO_FAKE ||
  216. resolve_type & RESOLVE_TYPE_LBY_UPDATE ||
  217. resolve_type & RESOLVE_TYPE_PREDICTED_LBY_UPDATE)
  218. return true;
  219.  
  220. return false;
  221. }
  222.  
  223. bool IsFakewalking(SDK::CBaseEntity* entity)
  224. {
  225. return player_resolve_records[entity->GetIndex()].is_fakewalking;
  226. }
  227.  
  228. bool IsMovingOnGround(SDK::CBaseEntity* entity)
  229. {
  230. return player_resolve_records[entity->GetIndex()].velocity.Length2D() > 0.5f && entity->GetFlags() & FL_ONGROUND;
  231. }
  232.  
  233. bool IsFakingYaw(SDK::CBaseEntity* entity);
  234.  
  235. /// pushback a record onto the shot snapshot queue
  236. void AddShotSnapshot(SDK::CBaseEntity* entity, PlayerResolveRecord resolve_record);
  237.  
  238. //void EventCallback(SDK::IGameEventManager game_event);
  239.  
  240. private:
  241. // void ProcessSnapShots();
  242.  
  243. void UpdateResolveRecord(SDK::CBaseEntity* entity);
  244.  
  245. void ResolveYaw(SDK::CBaseEntity* entity);
  246. void bruteforce();
  247. void ResolvePitch(SDK::CBaseEntity* entity);
  248. void Royal(SDK::CBaseEntity* entity);
  249.  
  250. void ResolveYawBruteforce(SDK::CBaseEntity* entity);
  251. float ResolveYawOverride(SDK::CBaseEntity* entity);
  252.  
  253. };
  254.  
  255. extern CResolver* resolver;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement