Advertisement
Chronos_Ouroboros

AAAAA sprinting code

Oct 9th, 2017
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.37 KB | None | 0 0
  1. Script_C void S7_SprintSystem (PlayerData_t *player) {
  2. Start:
  3. // Not needed or desired in TitleMaps.
  4. if (ServerData.gameType == GAME_TITLE_MAP || !PlayerInGame (PLN))
  5. return;
  6.  
  7. if (!player) {
  8. DebugLog ("\CgScript S7_SprintSystem: Fatal error: Invalid or NULL player struct for player %d.", PLN);
  9. return;
  10. }
  11.  
  12. int tics,
  13. forwardMove,
  14. sideMove;
  15.  
  16. while (TRUE) {
  17. if (!PlayerInGame (PLN))
  18. return;
  19.  
  20. forwardMove = GetPlayerInput (-1, MODINPUT_FORWARDMOVE);
  21. sideMove = GetPlayerInput (-1, MODINPUT_SIDEMOVE);
  22.  
  23. if (CheckWeapon (SPRINTWEAPON) && !player->SprintDef.Sprinting) {
  24. SetActorPropertyFixed (0, APROP_Speed, player->SprintDef.OldSpeed);
  25. player->SprintDef.Sprinting = FALSE;
  26. tics = 0;
  27. DisableWeapon (SPRINTWEAPON, SPRINTINGTOKEN, player);
  28. }
  29. if (KeyDownMOD (BT_USER1) &&
  30. !player->SprintDef.Sprinting &&
  31. CheckInventory (STAMINATOKEN) >= 5 && !CheckInventory (DYINGTOKEN) &&
  32. !player->scriptData.staminaEmpty && !player->SprintDef.disable && !player->scriptData.beamGrab) {
  33. player->SprintDef.Sprinting = TRUE;
  34. player->SprintDef.OldSpeed = GetActorPropertyFixed (0, APROP_Speed);
  35. DisableWeapon (SPRINTWEAPON, SPRINTINGTOKEN, player);
  36. }
  37. if (KeyUpMOD (BT_USER1) && player->SprintDef.Sprinting) {
  38. SetActorPropertyFixed (0, APROP_Speed, player->SprintDef.OldSpeed);
  39. player->SprintDef.Sprinting = FALSE;
  40. tics = 0;
  41. DisableWeapon (SPRINTWEAPON, SPRINTINGTOKEN, player);
  42. }
  43. if (CheckInventory (SPRINTINGTOKEN) && player->SprintDef.Sprinting) {
  44. if (CheckInventory (STAMINATOKEN) >= 5) {
  45. if (CheckInventory (SPRINTINGTOKEN) && tics >= 5 && (forwardMove != 0 || sideMove != 0)) {
  46. tics = 0;
  47. if (GetVelocity () > 0.0k) {
  48. TakeInventory (STAMINATOKEN, 5);
  49. player->health.stamina = CheckInventory (STAMINATOKEN);
  50. }
  51. }
  52. if (CheckInventory (STAMINATOKEN) < 5 || CheckInventory (DYINGTOKEN) || player->SprintDef.disable || player->scriptData.beamGrab) {
  53. SetActorPropertyFixed (0, APROP_Speed, player->SprintDef.OldSpeed);
  54. player->SprintDef.Sprinting = FALSE;
  55. player->scriptData.staminaEmpty = 1;
  56. DisableWeapon (SPRINTWEAPON, SPRINTINGTOKEN, player);
  57. goto Start;
  58. }
  59.  
  60. accum speedBonus = 1.0k + 0.1k * player->xpSystem.agilityLVL;
  61. if (CheckInventory (SPRINTINGTOKEN)) {
  62. if (abs (forwardMove) > 6400 || abs (sideMove) > 6144)
  63. SetActorPropertyFixed (0, APROP_Speed, 1.0k + speedBonus);
  64. else if (abs (forwardMove) <= 6400 && abs (sideMove) <= 6144)
  65. SetActorPropertyFixed (0, APROP_Speed, (1.0k + speedBonus) * 2.0k);
  66. } else if (!CheckInventory (SPRINTINGTOKEN))
  67. SetActorPropertyFixed (0, APROP_Speed, player->SprintDef.OldSpeed);
  68. }
  69. }
  70.  
  71. Delay (1);
  72.  
  73. if (player->SprintDef.Sprinting)
  74. tics++;
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement