Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. void Player::addManaSpent(unsigned long long int spent)
  2. {
  3. if(spent == 0 || this->afkCheckFailed == true || this->getIP() == 0) {
  4. return;
  5. }
  6.  
  7. uint64_t spentMultiplier = (uint64_t)g_game.getMagicLevelStage(this).multiplier;
  8. spent *= spentMultiplier;
  9.  
  10. if (this->access < g_serverconfig.getInt("access->staffcharacter"))
  11. {
  12. bool downgraded = FALSE;
  13.  
  14. //Setting Max Magic Levels for Vocations
  15. int mlvl;
  16. int prevmlvl;
  17.  
  18. switch(this->vocation)
  19. {
  20.  
  21. case 1:
  22.  
  23. mlvl = 1600; // max magic level for mage
  24.  
  25. if (this->maglevel < mlvl)
  26. this->manaspent += spent;
  27.  
  28. else
  29. {
  30. if (this->manaspent != 0)
  31. this->manaspent = 0;
  32.  
  33. if (this->maglevel > mlvl)
  34. {
  35. prevmlvl = this->maglevel;
  36.  
  37. this->maglevel = mlvl;
  38.  
  39. downgraded = TRUE;
  40. }
  41. }
  42.  
  43. break;
  44.  
  45. case 3:
  46.  
  47. mlvl = 450; // max magic level for paladin
  48.  
  49. if (this->maglevel < mlvl)
  50. this->manaspent += spent;
  51.  
  52. else
  53. {
  54. if (this->manaspent != 0)
  55. this->manaspent = 0;
  56.  
  57. if (this->maglevel > mlvl)
  58. {
  59. prevmlvl = this->maglevel;
  60.  
  61. this->maglevel = mlvl;
  62.  
  63. downgraded = TRUE;
  64. }
  65. }
  66.  
  67. break;
  68.  
  69. case 4:
  70.  
  71. mlvl = 100; // max magic level for knight
  72.  
  73. if (this->maglevel < mlvl)
  74. this->manaspent += spent;
  75.  
  76. else
  77. {
  78. if (this->manaspent != 0)
  79. this->manaspent = 0;
  80.  
  81. if (this->maglevel > mlvl)
  82. {
  83. prevmlvl = this->maglevel;
  84.  
  85. this->maglevel = mlvl;
  86.  
  87. downgraded = TRUE;
  88. }
  89. }
  90.  
  91. break;
  92. }
  93.  
  94. //Downgraded Magic Level Message
  95. if (downgraded == TRUE)
  96. {
  97. std::stringstream MaglvMsg;
  98.  
  99. MaglvMsg << "You were downgraded from magic level " << prevmlvl << " to magic level " << mlvl << ".";
  100.  
  101. this->sendTextMessage(MSG_ADVANCE, MaglvMsg.str().c_str());
  102. }
  103. }
  104.  
  105. //Magic Level Advance
  106. unsigned long long int reqMana = this->getReqMana(this->maglevel+1, this->vocation);
  107.  
  108. if (this->access < g_serverconfig.getInt("access->staffcharacter") && this->manaspent >= reqMana)
  109. {
  110. this->manaspent -= reqMana;
  111. this->maglevel++;
  112.  
  113. std::stringstream MaglvMsg;
  114.  
  115. //this->manaspent = 0;
  116. MaglvMsg << "You advanced from magic level " << (this->maglevel - 1) << " to magic level " << this->maglevel << ".";
  117.  
  118. this->sendTextMessage(MSG_ADVANCE, MaglvMsg.str().c_str());
  119. this->sendStats();
  120. }
  121. //End Magic Level Advance*/
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement