Guest User

Untitled

a guest
Apr 22nd, 2020
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. void Creature::onGainExperience(uint64_t gainExp, Creature* target)
  2. {
  3. TextMessage message(MESSAGE_EXPERIENCE_OTHERS, ucfirst(getNameDescription()) + " gained " + std::to_string(gainExp) + (gainExp != 1 ? " experience points." : " experience point."));
  4. static constexpr std::array<TextColor_t, 12> colors = {
  5. TEXTCOLOR_BLUE,
  6. TEXTCOLOR_LIGHTGREEN,
  7. TEXTCOLOR_LIGHTBLUE,
  8. TEXTCOLOR_MAYABLUE,
  9. TEXTCOLOR_DARKRED,
  10. TEXTCOLOR_LIGHTGREY,
  11. TEXTCOLOR_SKYBLUE,
  12. TEXTCOLOR_PURPLE,
  13. TEXTCOLOR_RED,
  14. TEXTCOLOR_ORANGE,
  15. TEXTCOLOR_YELLOW,
  16. TEXTCOLOR_WHITE_EXP,
  17. };
  18. message.position = position;
  19. message.primary.color = colors[uniform_random(0, colors.size() - 1)];
  20. message.primary.value = gainExp;
  21.  
  22. }
  23.  
  24. {
  25. if (gainExp == 0 || !master) {
  26. return;
  27. }
  28.  
  29. gainExp /= 2;
  30. master->onGainExperience(gainExp, target);
  31.  
  32. std::ostringstream strExp;
  33. strExp << gainExp;
  34. g_game.addAnimatedText(strExp.str(), _position, TEXTCOLOR_WHITE_EXP);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment