Guest User

Untitled

a guest
May 22nd, 2020
436
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. // char.h
  2.  
  3.     public:
  4.         int GetHorseActionTime();
  5.         void SetHorseActionTime(const int iTimeSec)
  6.         {
  7.             m_iHorseActionTime = iTimeSec;
  8.             m_iHorseActionLastTime = thecore_pulse();
  9.         }
  10.     private:
  11.         int m_iHorseActionTime;
  12.         int m_iHorseActionLastTime;
  13.  
  14. // char.cpp
  15.     int CHARACTER::GetHorseActionTime()
  16.     {
  17.         const int iCurrentTime = thecore_pulse() - m_iHorseActionLastTime;
  18.         const int iWaitTimeSec = PASSES_PER_SEC(m_iHorseActionTime);
  19.         if (iWaitTimeSec >= iCurrentTime)
  20.         {
  21.             ChatPacket(CHAT_TYPE_INFO, "Wait %d sec(s)!", m_iHorseActionTime);
  22.             return iWaitTimeSec != 0;
  23.         }
  24.         return 0;
  25.     }
  26.  
  27. // char_horse.cpp
  28.  
  29.     bool CHARACTER::StartRiding()
  30.     {
  31.         if (GetHorseActionTime() != 0)
  32.         {
  33.             return false;
  34.         }
  35.        
  36.         /*
  37.             [...]
  38.         */
  39.  
  40.         if (GetHorseActionTime() == 0)
  41.         {
  42.             SetHorseActionTime(10 /*sec(s)*/);
  43.         }
  44.         return true;
  45.     }
Add Comment
Please, Sign In to add comment