Advertisement
Guest User

Untitled

a guest
Apr 5th, 2015
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.17 KB | None | 0 0
  1. //In bg_saber.c
  2.  
  3. int lockedAnim;
  4. int Boot_LockedDir( usercmd_t *cmd )    //Which animation to lock while holding manual block
  5. {
  6.     if (g_entities->client->pers.cmd.buttons & 16384) //If you click block... (+button14)
  7.     {
  8.         if (!lockedAnim)                                        //... but only if no animation has been locked yet...
  9.         {
  10.             if ( !abs(cmd->forwardmove) && !abs(cmd->rightmove) )        //If not moving...
  11.             {
  12.                 lockedAnim = LS_PARRY_UP;                                       //... parry up (default)
  13.             }
  14.             if ( cmd->forwardmove > 0 ||                                //If moving forward...
  15.                  cmd->forwardmove < 0 &&                                //... or backward...
  16.                  !abs(cmd->rightmove) )                                 //... and not to any sides...
  17.             {
  18.                 lockedAnim = LS_PARRY_UP;                                       //... parry up.
  19.             }
  20.             if ( cmd->rightmove > 0 &&                                  //If moving right...
  21.                 !(cmd->forwardmove < 0) )                               //... and not moving backwards...
  22.             {
  23.                 lockedAnim = LS_PARRY_UR;                                       //... parry upper right.
  24.             }
  25.             if ( cmd->rightmove < 0 &&                                  //If moving left...
  26.                 !(cmd->forwardmove < 0) )                               //... and not moving backwards...
  27.             {
  28.                 lockedAnim = LS_PARRY_UL;                                       //... parry upper left.
  29.             }
  30.             if (cmd->rightmove > 0 &&                                   //If moving right...
  31.                 cmd->forwardmove < 0)                                   //... and moving backwards...
  32.             {
  33.                 lockedAnim = LS_PARRY_LL;                                       //... parry lower right (switched lower anims because more suitable).
  34.             }
  35.             if (cmd->rightmove < 0 &&                                   //If moving left...
  36.                 cmd->forwardmove < 0)                                   //... and moving backwards...
  37.             {
  38.                 lockedAnim = LS_PARRY_LR;                                       //... parry lower left (switched lower anims).
  39.             }
  40.         }                                                   // If an animation was already locked, skip all the above and return...
  41.     }
  42.     else                                                //But if you let go of block...
  43.     {
  44.         lockedAnim = 0;                                     //... stop the animation and allow new directions to be locked
  45.     }
  46.  
  47.     return lockedAnim;                          //Send the animation to use back to the caller.
  48. }
  49.  
  50. int Boot_SetBlockDir( void )
  51. {
  52.     int blockDir = Boot_LockedDir( &g_entities->client->pers.cmd);
  53.  
  54.     if (blockDir)
  55.         PM_SetSaberMove( blockDir );
  56. }
  57.  
  58. //In g_active.c for now, until I find out the best place to call from
  59.  
  60. if (ent->client->ps.weapon == WP_SABER)
  61.     {
  62.          Boot_SetBlockDir();
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement