SHARE
TWEET

Untitled

a guest Aug 25th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "WarbandAutoblock.h"
  2. #include "DebugMenu.h"
  3. #include "GameTimer.h"
  4. #include "Settings.h"
  5.  
  6. WarbandAutoblock::WarbandAutoblock() {
  7. }
  8.  
  9.  
  10. WarbandAutoblock::~WarbandAutoblock() {
  11. }
  12.  
  13. wb::attackPhase lastEnemyPhase = wb::attackPhase::ap_none;
  14.  
  15. void WarbandAutoblock::autoBlock(wb::agent* localPlayer) {
  16.     auto enemy = EntityList::getClosestAgentWithinZone(localPlayer, 10);
  17.  
  18.     if (enemy != nullptr) {
  19.         wb::attackPhase enemyPhase;
  20.         wb::attackType enemyAction;
  21.  
  22.         enemy->getMeleeAttackData(enemyPhase, enemyAction);
  23.  
  24.         //autoblock
  25.         //if (isKeyHeld(0xDD8718, 7)) {
  26.             if (enemyPhase == wb::attackPhase::ap_ready || enemyPhase == wb::attackPhase::ap_release) {
  27.                 switch (enemyAction) {
  28.                 case wb::attackType::at_overswing:
  29.                     localPlayer->control.actions_2 = 0x8000;
  30.                     break;
  31.                 case wb::attackType::at_swing_left:
  32.                     localPlayer->control.actions_2 = 0x2000;
  33.                     break;
  34.                 case wb::attackType::at_swing_right:
  35.                     localPlayer->control.actions_2 = 0x4000;
  36.                     break;
  37.                 case wb::attackType::at_thrust:
  38.                     localPlayer->control.actions_2 = 0x10000;
  39.                     break;
  40.                 }
  41.  
  42.                 localPlayer->control.actions_2 |= movementFlag(localPlayer);
  43.                 lastEnemyPhase = enemyPhase;
  44.             }
  45.             else {
  46.                 localPlayer->control.actions_2 = movementFlag(localPlayer);
  47.             }
  48.         /*}*/
  49.     }
  50. }
  51.  
  52. int WarbandAutoblock::movementFlag(wb::agent* localPlayer) {
  53.     int result = 0;
  54.     int game_key = 0xDD8718;
  55.     if (localPlayer->isMounted()) {
  56.         if (isKeyHeld(game_key, 0) && !isKeyHeld(game_key, 1))
  57.             result |= 0x10u;
  58.         if (isKeyHeld(game_key, 1) && !isKeyHeld(game_key, 0))
  59.             result |= 0x20;
  60.         if (isKeyHeld(game_key, 3) && !isKeyHeld(game_key, 2))
  61.             result |= 0x40;
  62.         if (isKeyHeld(game_key, 2) && !isKeyHeld(game_key, 3))
  63.             result |= 0x80;
  64.     }
  65.     else {
  66.         if (isKeyHeld(game_key, 0) && !isKeyHeld(game_key, 1))
  67.             result |= 0x1;
  68.         if (isKeyHeld(game_key, 1) && !isKeyHeld(game_key, 0))
  69.             result |= 0x2;
  70.         if (isKeyHeld(game_key, 3) && !isKeyHeld(game_key, 2))
  71.             result |= 0x4;
  72.         if (isKeyHeld(game_key, 2) && !isKeyHeld(game_key, 3))
  73.             result |= 0x8;
  74.     }
  75.  
  76.     return result;
  77. }
  78. const float KICK_DISTANCE = 0.95f;
  79.  
  80. void WarbandAutoblock::autoKick(wb::agent* localPlayer, float* camera_horizontal_rotation, rgl::vector4 enemyVelocity, rgl::vector4 enemyPosition) {
  81.     //rgl::vector4 movement_dir;
  82.     //movement_dir.x = localPlayer->movement_dir.y;
  83.     //movement_dir.y = -localPlayer->movement_dir.x;
  84.     //movement_dir.x = localPlayer->movement_dir.z;
  85.  
  86.     //rgl::vector4 movement_dir_turn = localPlayer->movement_dir * 0.6000000238418579;
  87.     //float unknown_x = movement_dir.x * 0.1000000014901161;
  88.     //float unknown_y = movement_dir.y * 0.1000000014901161;
  89.     //float unknown_z = movement_dir.z * 0.1000000014901161;
  90.  
  91.     //rgl::vector4 kickSpot;
  92.     //kickSpot.x = unknown_x + localPlayer->position.x + movement_dir_turn.x;
  93.     //kickSpot.y = unknown_y + localPlayer->position.y + movement_dir_turn.y;
  94.     //kickSpot.z = unknown_z + localPlayer->position.z + movement_dir_turn.z;
  95.     //auto predictedPosition = rgl::math::predictTime(enemyPosition, enemyVelocity, 25 * TICK_TIMER);
  96.     //auto cross = RglEngine::worldToScreenDirectx9(kickSpot);
  97.     //auto distance = predictedPosition - kickSpot;
  98.     //float kickDistance = distance.x * distance.x + distance.y * distance.y;
  99.     //float d = localPlayer->position.distTo(predictedPosition);
  100.     //if (cross.z <= 1.0f) {
  101.     //  DebugMenu::drawCross(cross);
  102.     //}
  103.  
  104.     //if (d < KICK_DISTANCE) {
  105.     //  rgl::vector4 distanceBetween = localPlayer->position - enemyPosition;
  106.     //  D3DXVECTOR4 lookDirection = XMath::vectorToAngles(distanceBetween);
  107.     //  *camera_horizontal_rotation = D3DXToRadian(lookDirection.x);
  108.  
  109.     //  int viewAngleY = rgl::math::clamp(D3DXToDegree(*camera_horizontal_rotation), 0);
  110.     //  int angle = rgl::math::clamp(D3DXToDegree(atan2(-localPlayer->movement_dir.x, localPlayer->movement_dir.y)), 0);
  111.  
  112.     //  if (viewAngleY == angle)
  113.     //      localPlayer->control.actions_1 |= 0x10000000;
  114.     //}
  115. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top