races.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "../common/debug.h"
  17. #include "races.h"
  18. #include "../common/MiscFunctions.h"
  19. Races::Races(){
  20. race_map["BARBARIAN"] = 0;
  21. race_map["DARKELF"] = 1;
  22. race_map["DWARF"] = 2;
  23. race_map["ERUDITE"] = 3;
  24. race_map["FROGLOK"] = 4;
  25. race_map["GNOME"] = 5;
  26. race_map["HALFELF"] = 6;
  27. race_map["HALFLING"] = 7;
  28. race_map["HIGHELF"] = 8;
  29. race_map["HUMAN"] = 9;
  30. race_map["IKSAR"] = 10;
  31. race_map["KERRA"] = 11;
  32. race_map["OGRE"] = 12;
  33. race_map["RATONGA"] = 13;
  34. race_map["TROLL"] = 14;
  35. race_map["WOODELF"] = 15;
  36. race_map["FAE_LIGHT"] = 16;
  37. race_map["FAE_DARK"] = 17;
  38. race_map["SARNAK"] = 18;
  39. race_map["VAMPIRE"] = 19;
  40. race_map["AERAKYN"] = 20;
  41. race_map_friendly[0] = "Barbarian";
  42. race_map_friendly[1] = "Dark Elf";
  43. race_map_friendly[2] = "Dwarf";
  44. race_map_friendly[3] = "Erudite";
  45. race_map_friendly[4] = "Froglok";
  46. race_map_friendly[5] = "Gnome";
  47. race_map_friendly[6] = "Half Elf";
  48. race_map_friendly[7] = "Halfling";
  49. race_map_friendly[8] = "High Elf";
  50. race_map_friendly[9] = "Human";
  51. race_map_friendly[10] = "Iksar";
  52. race_map_friendly[11] = "Kerra";
  53. race_map_friendly[12] = "Ogre";
  54. race_map_friendly[13] = "Ratonga";
  55. race_map_friendly[14] = "Troll";
  56. race_map_friendly[15] = "Wood Elf";
  57. race_map_friendly[16] = "Fae";
  58. race_map_friendly[17] = "Arasai";
  59. race_map_friendly[18] = "Sarnak";
  60. race_map_friendly[19] = "Vampire";
  61. race_map_friendly[20] = "Aerakyn";
  62. // "Neutral" races are in both lists - this is for /randomize RACE
  63. race_map_good[0] = "DWARF";
  64. race_map_good[1] = "FAE_LIGHT";
  65. race_map_good[2] = "FROGLOK";
  66. race_map_good[3] = "HALFLING";
  67. race_map_good[4] = "HIGHELF";
  68. race_map_good[5] = "WOODELF";
  69. race_map_good[6] = "BARBARIAN";
  70. race_map_good[7] = "ERUDITE";
  71. race_map_good[8] = "GNOME";
  72. race_map_good[9] = "HALFELF";
  73. race_map_good[10] = "HUMAN";
  74. race_map_good[11] = "KERRA";
  75. race_map_good[12] = "VAMPIRE";
  76. race_map_good[13] = "AERAKYN";
  77. race_map_evil[0] = "FAE_DARK";
  78. race_map_evil[1] = "DARKELF";
  79. race_map_evil[2] = "IKSAR";
  80. race_map_evil[3] = "OGRE";
  81. race_map_evil[4] = "RATONGA";
  82. race_map_evil[5] = "SARNAK";
  83. race_map_evil[6] = "TROLL";
  84. race_map_evil[7] = "BARBARIAN";
  85. race_map_evil[8] = "ERUDITE";
  86. race_map_evil[9] = "GNOME";
  87. race_map_evil[10] = "HALFELF";
  88. race_map_evil[11] = "HUMAN";
  89. race_map_evil[12] = "KERRA";
  90. race_map_evil[13] = "VAMPIRE";
  91. race_map_evil[14] = "AERAKYN";
  92. }
  93. sint8 Races::GetRaceID(const char* name){
  94. string race_name = string(name);
  95. race_name = ToUpper(race_name);
  96. if(race_map.count(race_name) == 1)
  97. return race_map[race_name];
  98. else
  99. return -1;
  100. }
  101. const char* Races::GetRaceName(int8 race_id){
  102. map<string, int8>::iterator itr;
  103. for(itr = race_map.begin(); itr != race_map.end(); itr++){
  104. if(itr->second == race_id)
  105. return itr->first.c_str();
  106. }
  107. return 0;
  108. }
  109. const char* Races::GetRaceNameCase(int8 race_id) {
  110. map<int8, string>::iterator itr;
  111. for(itr = race_map_friendly.begin(); itr != race_map_friendly.end(); itr++){
  112. if(itr->first == race_id)
  113. return itr->second.c_str();
  114. }
  115. return 0;
  116. }
  117. int8 Races::GetRaceNameGood() {
  118. int8 random = MakeRandomInt(0,13); // 12 good races
  119. map<int8, string>::iterator itr;
  120. for(itr = race_map_good.begin(); itr != race_map_good.end(); itr++){
  121. if(itr->first == random)
  122. return GetRaceID(itr->second.c_str());
  123. }
  124. return 9; // default to Human race if error finding another
  125. }
  126. int8 Races::GetRaceNameEvil() {
  127. int8 random = MakeRandomInt(0,14); // 13 evil races
  128. map<int8, string>::iterator itr;
  129. for(itr = race_map_evil.begin(); itr != race_map_evil.end(); itr++){
  130. if(itr->first == random)
  131. return GetRaceID(itr->second.c_str());
  132. }
  133. return 9; // default to Human race if error finding another
  134. }