Advertisement
LukasCCB

[TUTORIAL] Inspecting Gun In FirstPerson

Jul 10th, 2016
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.24 KB | None | 0 0
  1. /*
  2. So seen this a couple of times, everyone wants this inspect weapon from cs:go.
  3.  
  4. Follow the tutorial below and you will be successful, however this tutorials only offer the outline for code only, I cannot supply the animation. I'm sure you can do some digging and find one. Make sure you place it inside Animation5 folder.
  5.  
  6. How it works.. Hold "B" and it will play the inspect animation that you chose on a loo
  7.  
  8. GIF: https://i.gyazo.com/d551e9eee6b65f292b960d72a8c9337d.gif
  9.  
  10. >>> DOWNLOAD ANIMATION FILES NEEDED TO GET THIS WORKING HERE <<<
  11. https://mega.nz/#!S9xDhJoA!trpt3wdLQQ4fN_eEXgSXXEaKovSjGnxfk8pdnXQai-A
  12. */
  13.  
  14. EclipseStudio/Sources/ObjectsCode/AI/AI_Player.CPP
  15. Find:
  16. Code:
  17. if(wpn && hudAttm && hudAttm->isActive() && wpn->getCategory()>=storecat_ASR && wpn->getCategory()<=storecat_SMG)
  18.          isInAttmMenu = true;
  19. Add Below:
  20. Code:
  21. bool isWantingToInspect = (InputMappingMngr->isPressed(r3dInputMappingMngr::KS_INSPECT_GUN) && wpn && wpn->getCategory()>=storecat_ASR && wpn->getCategory()<=storecat_SMG && hudMain && !hudPause->isActive() && !hudAttm->isActive() && !hudVault->isActive() && !hudRepair->isActive() && !hudCraft->isActive() && !hudSafelock->isActive() && !hudTrade->isActive() && !hudStore->isActive() && !hudMain->isChatInputActive() && !Mouse->GetMouseVisibility() && !InputMappingMngr->isPressed(r3dInputMappingMngr::KS_PRIMARY_FIRE) && !InputMappingMngr->isPressed(r3dInputMappingMngr::KS_AIM));
  22. Find:
  23. Code:
  24. uberAnim_->SyncAnimation(PlayerState, PlayerMoveDir, force, wpn, isInAttmMenu);
  25. Replace:
  26.  
  27. Code:
  28. uberAnim_->SyncAnimation(PlayerState, PlayerMoveDir, force, wpn, isInAttmMenu, isWantingToInspect);
  29. ----------------
  30.  
  31. EclipseStudio/Sources/ObjectsCode/AI/AI_PlayerAnim.cpp
  32. Find:
  33. Code:
  34. aid_.attmMenuIdleWeapon[5] = AddAnimation("FPS_Attch_Idle_SMG");
  35. Add Below:
  36. Code:
  37. aid_.InspectWeapon[0] = AddAnimation("XXXXYOURANIMATIONNAMEHEREXXXX"); //ASR
  38. aid_.InspectWeapon[1] = AddAnimation("XXXXYOURANIMATIONNAMEHEREXXXX"); //SNP
  39. aid_.InspectWeapon[2] = AddAnimation("XXXXYOURANIMATIONNAMEHEREXXXX"); //SHG
  40. aid_.InspectWeapon[3] = AddAnimation("XXXXYOURANIMATIONNAMEHEREXXXX"); //MG
  41. aid_.InspectWeapon[4] = AddAnimation("XXXXYOURANIMATIONNAMEHEREXXXX"); //HG
  42. aid_.InspectWeapon[5] = AddAnimation("XXXXYOURANIMATIONNAMEHEREXXXX"); //SMG
  43. Find:
  44. Code:
  45. void CUberAnim::SyncAnimation(int PlayerState, int MoveDir, bool force, const Weapon* weap, bool isInAttmMenu)
  46. Replace
  47. Code:
  48. void CUberAnim::SyncAnimation(int PlayerState, int MoveDir, bool force, const Weapon* weap, bool isInAttmMenu, bool isWantingToInspect)
  49. Find:
  50. Code:
  51. if(isInAttmMenu && CurrentWeapon && IsFPSMode()
  52. Replace:
  53. Code:
  54. if(!isWantingToInspect && isInAttmMenu && CurrentWeapon && IsFPSMode()
  55. Find:
  56. Code:
  57. // switch anim state
  58. Add Above:
  59. Code:
  60. ///Inspect
  61.  
  62.  
  63.     if(isWantingToInspect && CurrentWeapon && IsFPSMode()
  64.         && !IsSwimming && PlayerState != PLAYER_SWIM_IDLE && PlayerState != PLAYER_SWIM_SLOW && PlayerState != PLAYER_SWIM && PlayerState != PLAYER_SWIM_FAST
  65.         )
  66.     {
  67.         bool AlreadyPlayingInspect = false;
  68.  
  69.  
  70.         int animIdx = 0;
  71.         switch(CurrentWeapon->getCategory())
  72.         {
  73.         case storecat_ASR:
  74.             animIdx = 0;
  75.             break;
  76.         case storecat_SNP:
  77.             animIdx = 1;
  78.             break;
  79.         case storecat_SHTG:
  80.             animIdx = 2;
  81.             break;
  82.         case storecat_MG:
  83.             animIdx = 3;
  84.             break;
  85.         case storecat_HG:
  86.             animIdx = 4;
  87.             break;
  88.         case storecat_SMG:
  89.             animIdx = 5;
  90.             break;
  91.         default:
  92.             r3d_assert(false);
  93.             break;
  94.         }
  95.  
  96.  
  97.         r3dgameVector(r3dAnimation::r3dAnimInfo)::iterator it;
  98.         for(it=anim.AnimTracks.begin(); it!=anim.AnimTracks.end(); ++it)
  99.         {
  100.             const r3dAnimation::r3dAnimInfo& ai = *it;
  101.             if(ai.pAnim->iAnimId == data_->aid_.InspectWeapon[animIdx])
  102.             {
  103.                 AlreadyPlayingInspect = true;
  104.                 break;
  105.             }
  106.         }
  107.        
  108.         if(!AlreadyPlayingInspect)
  109.             anim.StartAnimation(data_->aid_.InspectWeapon[animIdx], ANIMFLAG_RemoveOtherNow | ANIMFLAG_Looped, 0.0f, 1.0f, 0.1f);
  110.         else // playing idle anim
  111.         {
  112.             // do nothing :)
  113.         }
  114.  
  115.  
  116.         AnimPlayerState = -1; // reset, so that after attm menu we will return back to proper animation
  117.         return;
  118.     }
  119.  
  120.  
  121.     ///END of Inspect
  122. -----------------
  123.  
  124. EclipseStudio/Sources/ObjectsCode/AI/AI_PlayerAnim.h
  125. Find:
  126. Code:
  127. int        attmMenuIdleWeapon[6];
  128. Add Below:
  129. Code:
  130. int        InspectWeapon[6];
  131. Find:
  132. Code:
  133. void        SyncAnimation(int PlayerState, int MoveDir, bool force, const Weapon* weap, bool isInAttmMenu);
  134. Replace:
  135. Code:
  136. void        SyncAnimation(int PlayerState, int MoveDir, bool force, const Weapon* weap, bool isInAttmMenu, bool isWantingToInspect = false);
  137. -------------------
  138.  
  139. Eternity/Include/r3dInput.h
  140. Find:
  141. Code:
  142. KS_NUM,
  143. Add Above:
  144. Code:
  145. KS_INSPECT_GUN,
  146. ------------------
  147.  
  148. Eternity/Source/r3dInput.cpp
  149. Inside: r3dInputMappingMngr::r3dInputMappingMngr() at the very bottom of the container
  150. Add:
  151. Code:
  152. m_Mapping[KS_INSPECT_GUN] =                KeyboardMapping(INPUTMAP_KEYBOARD, kbsB, "INSPECT GUN", false);
  153.  
  154. /*
  155. By GetRektBambi
  156. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement