Advertisement
Guest User

Untitled

a guest
Apr 12th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.75 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "../../common/stl.h"
  3.  
  4. #include "constants.h"
  5. #include "skill.h"
  6. #include "char.h"
  7.  
  8. void CSkillProto::SetPointVar(const std::string& strName, double dVar)
  9. {
  10. kPointPoly.SetVar(strName, dVar);
  11. kPointPoly2.SetVar(strName, dVar);
  12. kPointPoly3.SetVar(strName, dVar);
  13. kMasterBonusPoly.SetVar(strName, dVar);
  14. }
  15.  
  16. void CSkillProto::SetDurationVar(const std::string& strName, double dVar)
  17. {
  18. kDurationPoly.SetVar(strName, dVar);
  19. kDurationPoly2.SetVar(strName, dVar);
  20. kDurationPoly3.SetVar(strName, dVar);
  21. }
  22.  
  23. void CSkillProto::SetSPCostVar(const std::string& strName, double dVar)
  24. {
  25. kSPCostPoly.SetVar(strName, dVar);
  26. kGrandMasterAddSPCostPoly.SetVar(strName, dVar);
  27. }
  28.  
  29. CSkillManager::CSkillManager()
  30. {
  31. }
  32.  
  33. CSkillManager::~CSkillManager()
  34. {
  35. itertype(m_map_pkSkillProto) it = m_map_pkSkillProto.begin();
  36. for ( ; it != m_map_pkSkillProto.end(); ++it) {
  37. M2_DELETE(it->second);
  38. }
  39. }
  40.  
  41. struct SPointOnType
  42. {
  43. const char * c_pszName;
  44. int iPointOn;
  45. } kPointOnTypes[] = {
  46. { "NONE", POINT_NONE },
  47. { "MAX_HP", POINT_MAX_HP },
  48. { "MAX_SP", POINT_MAX_SP },
  49. { "HP_REGEN", POINT_HP_REGEN },
  50. { "SP_REGEN", POINT_SP_REGEN },
  51. { "BLOCK", POINT_BLOCK },
  52. { "HP", POINT_HP },
  53. { "SP", POINT_SP },
  54. { "ATT_GRADE", POINT_ATT_GRADE_BONUS },
  55. { "DEF_GRADE", POINT_DEF_GRADE_BONUS },
  56. { "MAGIC_ATT_GRADE",POINT_MAGIC_ATT_GRADE_BONUS },
  57. { "MAGIC_DEF_GRADE",POINT_MAGIC_DEF_GRADE_BONUS },
  58. { "BOW_DISTANCE", POINT_BOW_DISTANCE },
  59. { "MOV_SPEED", POINT_MOV_SPEED },
  60. { "ATT_SPEED", POINT_ATT_SPEED },
  61. { "POISON_PCT", POINT_POISON_PCT },
  62. { "RESIST_RANGE", POINT_RESIST_BOW },
  63. //{ "RESIST_MELEE", POINT_RESIST_MELEE },
  64. { "CASTING_SPEED", POINT_CASTING_SPEED },
  65. { "REFLECT_MELEE", POINT_REFLECT_MELEE },
  66. { "ATT_BONUS", POINT_ATT_BONUS },
  67. { "DEF_BONUS", POINT_DEF_BONUS },
  68. { "RESIST_NORMAL", POINT_RESIST_NORMAL_DAMAGE },
  69. { "DODGE", POINT_DODGE },
  70. { "KILL_HP_RECOVER",POINT_KILL_HP_RECOVERY },
  71. { "KILL_SP_RECOVER",POINT_KILL_SP_RECOVER },
  72. { "HIT_HP_RECOVER", POINT_HIT_HP_RECOVERY },
  73. { "HIT_SP_RECOVER", POINT_HIT_SP_RECOVERY },
  74. { "CRITICAL", POINT_CRITICAL_PCT },
  75. { "MANASHIELD", POINT_MANASHIELD },
  76. { "SKILL_DAMAGE_BONUS", POINT_SKILL_DAMAGE_BONUS },
  77. { "NORMAL_HIT_DAMAGE_BONUS", POINT_NORMAL_HIT_DAMAGE_BONUS },
  78. { "BLEED_PCT",POINT_BLEEDING_PCT },
  79. { "BLEED_REDUCE",POINT_BLEEDING_REDUCE },
  80. { "\n", POINT_NONE },
  81. };
  82.  
  83. int FindPointType(const char * c_sz)
  84. {
  85. for (int i = 0; *kPointOnTypes[i].c_pszName != '\n'; ++i)
  86. {
  87. if (!strcasecmp(c_sz, kPointOnTypes[i].c_pszName))
  88. return kPointOnTypes[i].iPointOn;
  89. }
  90. return -1;
  91. }
  92.  
  93. bool CSkillManager::Initialize(TSkillTable * pTab, int iSize)
  94. {
  95. char buf[1024];
  96. std::map<DWORD, CSkillProto *> map_pkSkillProto;
  97.  
  98. TSkillTable * t = pTab;
  99. bool bError = false;
  100.  
  101. for (int i = 0; i < iSize; ++i, ++t)
  102. {
  103. CSkillProto * pkProto = M2_NEW CSkillProto;
  104.  
  105. pkProto->dwVnum = t->dwVnum;
  106. strlcpy(pkProto->szName, t->szName, sizeof(pkProto->szName));
  107. pkProto->dwType = t->bType;
  108. pkProto->bMaxLevel = t->bMaxLevel;
  109. pkProto->dwFlag = t->dwFlag;
  110. pkProto->dwAffectFlag = t->dwAffectFlag;
  111. pkProto->dwAffectFlag2 = t->dwAffectFlag2;
  112.  
  113. pkProto->bLevelStep = t->bLevelStep;
  114. pkProto->bLevelLimit = t->bLevelLimit;
  115. pkProto->iSplashRange = t->dwSplashRange;
  116. pkProto->dwTargetRange = t->dwTargetRange;
  117. pkProto->preSkillVnum = t->preSkillVnum;
  118. pkProto->preSkillLevel = t->preSkillLevel;
  119.  
  120. pkProto->lMaxHit = t->lMaxHit;
  121.  
  122. pkProto->bSkillAttrType = t->bSkillAttrType;
  123.  
  124. int iIdx = FindPointType(t->szPointOn);
  125.  
  126. if (iIdx < 0)
  127. {
  128. snprintf(buf, sizeof(buf), "SkillManager::Initialize : cannot find point type on skill: %s szPointOn: %s", t->szName, t->szPointOn);
  129. sys_err("%s", buf);
  130. SendLog(buf);
  131. bError = true;
  132. M2_DELETE(pkProto);
  133. continue;
  134. }
  135.  
  136. pkProto->bPointOn = iIdx;
  137.  
  138. int iIdx2 = FindPointType(t->szPointOn2);
  139.  
  140. if (iIdx2 < 0)
  141. {
  142. snprintf(buf, sizeof(buf), "SkillManager::Initialize : cannot find point type on skill: %s szPointOn2: %s", t->szName, t->szPointOn2);
  143. sys_err("%s", buf);
  144. SendLog(buf);
  145. bError = true;
  146. M2_DELETE(pkProto);
  147. continue;
  148. }
  149.  
  150. pkProto->bPointOn2 = iIdx2;
  151.  
  152. int iIdx3 = FindPointType(t->szPointOn3);
  153.  
  154. if (iIdx3 < 0)
  155. {
  156. if (t->szPointOn3[0] == 0)
  157. {
  158. iIdx3 = POINT_NONE;
  159. }
  160. else
  161. {
  162. snprintf(buf, sizeof(buf), "SkillManager::Initialize : cannot find point type on skill: %s szPointOn3: %s", t->szName, t->szPointOn3);
  163. sys_err("%s", buf);
  164. SendLog(buf);
  165. bError = true;
  166. M2_DELETE(pkProto);
  167. continue;
  168. }
  169. }
  170.  
  171. pkProto->bPointOn3 = iIdx3;
  172.  
  173. if (!pkProto->kSplashAroundDamageAdjustPoly.Analyze(t->szSplashAroundDamageAdjustPoly))
  174. {
  175. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szSplashAroundDamageAdjustPoly: %s", t->szName, t->szSplashAroundDamageAdjustPoly);
  176. sys_err("%s", buf);
  177. SendLog(buf);
  178. bError = true;
  179. M2_DELETE(pkProto);
  180. continue;
  181. }
  182.  
  183. if (!pkProto->kPointPoly.Analyze(t->szPointPoly))
  184. {
  185. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szPointPoly: %s", t->szName, t->szPointPoly);
  186. sys_err("%s", buf);
  187. SendLog(buf);
  188. bError = true;
  189. M2_DELETE(pkProto);
  190. continue;
  191. }
  192.  
  193. if (!pkProto->kPointPoly2.Analyze(t->szPointPoly2))
  194. {
  195. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szPointPoly2: %s", t->szName, t->szPointPoly2);
  196. sys_err("%s", buf);
  197. SendLog(buf);
  198. bError = true;
  199. M2_DELETE(pkProto);
  200. continue;
  201. }
  202.  
  203. if (!pkProto->kPointPoly3.Analyze(t->szPointPoly3))
  204. {
  205. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szPointPoly3: %s", t->szName, t->szPointPoly3);
  206. sys_err("%s", buf);
  207. SendLog(buf);
  208. bError = true;
  209. M2_DELETE(pkProto);
  210. continue;
  211. }
  212.  
  213. if (!pkProto->kSPCostPoly.Analyze(t->szSPCostPoly))
  214. {
  215. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szSPCostPoly: %s", t->szName, t->szSPCostPoly);
  216. sys_err("%s", buf);
  217. SendLog(buf);
  218. bError = true;
  219. M2_DELETE(pkProto);
  220. continue;
  221. }
  222.  
  223. if (!pkProto->kGrandMasterAddSPCostPoly.Analyze(t->szGrandMasterAddSPCostPoly))
  224. {
  225. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szGrandMasterAddSPCostPoly: %s", t->szName, t->szGrandMasterAddSPCostPoly);
  226. sys_err("%s", buf);
  227. SendLog(buf);
  228. bError = true;
  229. M2_DELETE(pkProto);
  230. continue;
  231. }
  232.  
  233. if (!pkProto->kDurationPoly.Analyze(t->szDurationPoly))
  234. {
  235. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szDurationPoly: %s", t->szName, t->szDurationPoly);
  236. sys_err("%s", buf);
  237. SendLog(buf);
  238. bError = true;
  239. M2_DELETE(pkProto);
  240. continue;
  241. }
  242.  
  243. if (!pkProto->kDurationPoly2.Analyze(t->szDurationPoly2))
  244. {
  245. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szDurationPoly2: %s", t->szName, t->szDurationPoly2);
  246. sys_err("%s", buf);
  247. SendLog(buf);
  248. bError = true;
  249. M2_DELETE(pkProto);
  250. continue;
  251. }
  252.  
  253. if (!pkProto->kDurationPoly3.Analyze(t->szDurationPoly3))
  254. {
  255. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szDurationPoly3: %s", t->szName, t->szDurationPoly3);
  256. sys_err("%s", buf);
  257. SendLog(buf);
  258. bError = true;
  259. M2_DELETE(pkProto);
  260. continue;
  261. }
  262.  
  263. if (!pkProto->kDurationSPCostPoly.Analyze(t->szDurationSPCostPoly))
  264. {
  265. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szDurationSPCostPoly: %s", t->szName, t->szDurationSPCostPoly);
  266. sys_err("%s", buf);
  267. SendLog(buf);
  268. bError = true;
  269. M2_DELETE(pkProto);
  270. continue;
  271. }
  272.  
  273. if (!pkProto->kCooldownPoly.Analyze(t->szCooldownPoly))
  274. {
  275. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szCooldownPoly: %s", t->szName, t->szCooldownPoly);
  276. sys_err("%s", buf);
  277. SendLog(buf);
  278. bError = true;
  279. M2_DELETE(pkProto);
  280. continue;
  281. }
  282.  
  283. sys_log(0, "Master %s", t->szMasterBonusPoly);
  284. if (!pkProto->kMasterBonusPoly.Analyze(t->szMasterBonusPoly))
  285. {
  286. snprintf(buf, sizeof(buf), "SkillManager::Initialize : syntax error skill: %s szMasterBonusPoly: %s", t->szName, t->szMasterBonusPoly);
  287. sys_err("%s", buf);
  288. SendLog(buf);
  289. bError = true;
  290. M2_DELETE(pkProto);
  291. continue;
  292. }
  293.  
  294. sys_log(0, "#%-3d %-24s type %u flag %u affect %u point_poly: %s",
  295. pkProto->dwVnum, pkProto->szName, pkProto->dwType, pkProto->dwFlag, pkProto->dwAffectFlag, t->szPointPoly);
  296.  
  297. map_pkSkillProto.insert(std::map<DWORD, CSkillProto *>::value_type(pkProto->dwVnum, pkProto));
  298. }
  299.  
  300. if (!bError)
  301. {
  302. // ±âÁ¸ Å×À̺íÀÇ ³»¿ëÀ» Áö¿î´Ù.
  303. itertype(m_map_pkSkillProto) it = m_map_pkSkillProto.begin();
  304.  
  305. while (it != m_map_pkSkillProto.end()) {
  306. M2_DELETE(it->second);
  307. ++it;
  308. }
  309.  
  310. m_map_pkSkillProto.clear();
  311.  
  312. // »õ·Î¿î ³»¿ëÀ» »ğÀÔ
  313. it = map_pkSkillProto.begin();
  314.  
  315. while (it != map_pkSkillProto.end())
  316. {
  317. m_map_pkSkillProto.insert(std::map<DWORD, CSkillProto *>::value_type(it->first, it->second));
  318. ++it;
  319. }
  320.  
  321. SendLog("Skill Prototype reloaded!");
  322. }
  323. else
  324. SendLog("There were erros when loading skill table");
  325.  
  326. return !bError;
  327. }
  328.  
  329. CSkillProto * CSkillManager::Get(DWORD dwVnum)
  330. {
  331. std::map<DWORD, CSkillProto *>::iterator it = m_map_pkSkillProto.find(dwVnum);
  332.  
  333. if (it == m_map_pkSkillProto.end())
  334. return NULL;
  335.  
  336. return it->second;
  337. }
  338.  
  339. CSkillProto * CSkillManager::Get(const char * c_pszSkillName)
  340. {
  341. std::map<DWORD, CSkillProto *>::iterator it = m_map_pkSkillProto.begin();
  342.  
  343. while (it != m_map_pkSkillProto.end())
  344. {
  345. if (!strcasecmp(it->second->szName, c_pszSkillName))
  346. return it->second;
  347.  
  348. it++;
  349. }
  350.  
  351. return NULL;
  352. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement