KMagicDesc.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:7k
源码类别:

模拟服务器

开发平台:

C/C++

  1. #include "KCore.h"
  2. #include "KEngine.h"
  3. #include "KMagicAttrib.h"
  4. #include "KMagicDesc.h"
  5. #include "GameDataDef.h"
  6. #include "KFaction.h"
  7. #define MAGICDESC_FILE "\settings\MagicDesc.Ini"
  8. extern const char * g_MagicID2String(int nAttrib);
  9. const char MAGIC_ATTRIB_STRING[][100] = 
  10. {
  11. //改变技能的属性
  12. "skill_begin",
  13. "skill_cost_v", // 消耗MANA
  14. "skill_costtype_v", //
  15. "skill_mintimepercast_v", // 每次发魔法的间隔时间
  16. "skill_misslenum_v", // 
  17. "skill_misslesform_v",
  18. "skill_param1_v",
  19. "skill_param2_v",
  20. "skill_reserve1",
  21. "skill_reserve2",
  22. "skill_reserve3",
  23. "skill_reserve4",
  24. "skill_eventskilllevel",
  25. "skill_end",
  26. //改变发出子弹的属性
  27. "missle_begin",
  28. "missle_movekind_v",
  29. "missle_speed_v",
  30. "missle_lifetime_v",
  31. "missle_height_v",
  32. "missle_damagerange_v",
  33. "missle_radius_v",
  34. "missle_reserve1",
  35. "missle_reserve2",
  36. "missle_reserve3",
  37. "missle_reserve4",
  38. "missle_reserve5",
  39. "missle_end",
  40. //装备属性
  41. "item_begin",
  42. "weapondamagemin_v",
  43. "weapondamagemax_v",
  44. "armordefense_v",
  45. "durability_v",
  46. "requirestr",
  47. "requiredex",
  48. "requirevit",
  49. "requireeng",
  50. "requirelevel",
  51. "requireseries",
  52. "requiresex",
  53. "requiremenpai",
  54. "weapondamageenhance_p",
  55. "armordefenseenhance_p",
  56. "requirementreduce_p",
  57. "indestructible_b",
  58. "item_reserve1",
  59. "item_reserve2",
  60. "item_reserve3",
  61. "item_reserve4",
  62. "item_reserve5",
  63. "item_reserve6",
  64. "item_reserve7",
  65. "item_reserve8",
  66. "item_reserve9",
  67. "item_reserve10",
  68. "item_end",
  69. "damage_begin",
  70. "attackrating_v",
  71. "attackrating_p",
  72. "ignoredefense_p",
  73. "physicsdamage_v",
  74. "colddamage_v",
  75. "firedamage_v",
  76. "lightingdamage_v",
  77. "poisondamage_v",
  78. "magicdamage_v",
  79. "physicsenhance_p",
  80. "steallife_p",
  81. "stealmana_p",
  82. "stealstamina_p",
  83. "knockback_p",
  84. "deadlystrike_p",
  85. "fatallystrike_p",
  86. "stun_p",
  87. "damage_reserve1",
  88. "damage_reserve2",
  89. "damage_reserve3",
  90. "damage_reserve4",
  91. "damage_reserve5",
  92. "damage_reserve6",
  93. "damage_reserve7",
  94. "damage_reserve8",
  95. "damage_reserve9",
  96. "damage_reserve10",
  97. "damage_end",
  98. "normal_begin",
  99. "lifemax_v",
  100. "lifemax_p",
  101. "life_v",
  102. "lifereplenish_v",
  103. "manamax_v",
  104. "manamax_p",
  105. "mana_v",
  106. "manareplenish_v",
  107. "staminamax_v",
  108. "staminamax_p",
  109. "stamina_v",
  110. "staminareplenish_v",
  111. "strength_v",
  112. "dexterity_v",
  113. "vitality_v",
  114. "energy_v",
  115. "poisonres_p",
  116. "fireres_p",
  117. "lightingres_p",
  118. "physicsres_p",
  119. "coldres_p",
  120. "freezetimereduce_p",
  121. "burntimereduce_p",
  122. "poisontimereduce_p",
  123. "poisondamagereduce_v",
  124. "stuntimereduce_p",
  125. "fastwalkrun_p",
  126. "visionradius_p",
  127. "fasthitrecover_v",
  128. "allres_p",
  129. "attackspeed_v",
  130. "castspeed_v",
  131. "meleedamagereturn_v",
  132. "meleedamagereturn_p",
  133. "rangedamagereturn_v",
  134. "rangedamagereturn_p",
  135. "addphysicsdamage_v",
  136. "addfiredamage_v",
  137. "addcolddamage_v",
  138. "addlightingdamage_v",
  139. "addpoisondamage_v",
  140. "addphysicsdamage_p",
  141. "slowmissle_b",
  142. "changecamp_b",
  143. "physicsarmor_v",
  144. "coldarmor_v",
  145. "firearmor_v",
  146. "poisonarmor_v",
  147. "lightingarmor_v",
  148. "damagetomana_p",
  149. "lucky_v",
  150. "steallifeenhance_p",
  151. "stealmanaenhance_p",
  152. "stealstaminaenhance_p",
  153. "allskill_v",
  154. "metalskill_v",
  155. "woodskill_v",
  156. "waterskill_v",
  157. "fireskill_v",
  158. "earthskill_v",
  159. "knockbackenhance_p",
  160. "deadlystrikeenhance_p",
  161. "stunenhance_p",
  162. "badstatustimereduce_v",
  163. "manashield_p",
  164. "adddefense_v",
  165. "adddefense_p",
  166. "fatallystrikeenhance_p",
  167. "lifepotion_v",
  168. "manapotion_v",
  169. "physicsresmax_p",
  170. "coldresmax_p",
  171. "fireresmax_p",
  172. "lightingresmax_p",
  173. "poisonresmax_p",
  174. "allresmax_p",
  175. "coldenhance_p",
  176. "fireenhance_p",
  177. "lightingenhance_p",
  178. "poisonenhance_p",
  179. "magicenhance_p",
  180. "attackratingenhance_v",
  181. "attackratingenhance_p",
  182. "normal_end",
  183. };
  184. KMagicDesc g_MagicDesc;
  185. KMagicDesc::KMagicDesc()
  186. {
  187. m_szDesc[0] = 0;
  188. }
  189. KMagicDesc::~KMagicDesc()
  190. {
  191. }
  192. BOOL KMagicDesc::Init()
  193. {
  194. // g_SetFilePath("\");
  195. return (m_IniFile.Load(MAGICDESC_FILE));
  196. }
  197. const char* KMagicDesc::GetDesc(void *pData)
  198. {
  199. char szTempDesc[128];
  200. char* pTempDesc = szTempDesc;
  201. int i = 0;
  202. ZeroMemory(m_szDesc, 128);
  203. if (!pData)
  204. return NULL;
  205. KMagicAttrib* pAttrib = (KMagicAttrib *)pData;
  206. const char *pszKeyName = g_MagicID2String(pAttrib->nAttribType);
  207. m_IniFile.GetString("Descript", pszKeyName, "", szTempDesc, 128);
  208. while(*pTempDesc)
  209. {
  210. if (*pTempDesc == '#')
  211. {
  212. int nDescAddType = 0;
  213. switch(*pTempDesc + 3)
  214. {
  215. case '+':
  216. nDescAddType = 1;
  217. break;
  218. default:
  219. nDescAddType = 0;
  220. break;
  221. }
  222. int nValue = 0;
  223. switch(*(pTempDesc + 2))
  224. {
  225. case '1':
  226. nValue = pAttrib->nValue[0];
  227. break;
  228. case '2':
  229. nValue = pAttrib->nValue[1];
  230. break;
  231. case '3':
  232. nValue = pAttrib->nValue[2];
  233. break;
  234. default:
  235. nValue = pAttrib->nValue[0];
  236. break;
  237. }
  238. switch(*(pTempDesc+1))
  239. {
  240. case 'm': // 门派
  241. strcat(m_szDesc, g_Faction.m_sAttribute[nValue].m_szName);
  242. i += strlen(g_Faction.m_sAttribute[nValue].m_szName);
  243. break;
  244. case 's': // 五行
  245. switch(nValue)
  246. {
  247. case series_metal:
  248. strcat(m_szDesc, "金系");
  249. break;
  250. case series_wood:
  251. strcat(m_szDesc, "木系");
  252. break;
  253. case series_water:
  254. strcat(m_szDesc, "水系");
  255. break;
  256. case series_fire:
  257. strcat(m_szDesc, "火系");
  258. break;
  259. case series_earth:
  260. strcat(m_szDesc, "土系");
  261. break;
  262. default:
  263. strcat(m_szDesc, "无系");
  264. break;
  265. }
  266. i += 4;
  267. break;
  268. case 'k': // 消耗类型
  269. switch(nValue)
  270. {
  271. case 0:
  272. strcat(m_szDesc, "内力");
  273. break;
  274. case 1:
  275. strcat(m_szDesc, "生命");
  276. break;
  277. case 2:
  278. strcat(m_szDesc, "体力");
  279. break;
  280. case 3:
  281. strcat(m_szDesc, "金钱");
  282. break;
  283. default:
  284. strcat(m_szDesc, "内力");
  285. break;
  286. }
  287. i += 4;
  288. break;
  289. case 'd': // 数字
  290. {
  291. //if (nValue == 0) // 数值为零的话,不显示
  292. {
  293. // return NULL;
  294. }
  295. switch(nDescAddType)
  296. {
  297. case 1:
  298. if (nValue > 0)
  299. {
  300. strcat(m_szDesc, "增加");
  301. }
  302. else
  303. {
  304. nValue = -nValue;
  305. strcat(m_szDesc, "减少");
  306. }
  307. break;
  308. default:
  309. break;
  310. }
  311. char szMsg[16];
  312. sprintf(szMsg, "%d", nValue);
  313. strcat(m_szDesc, szMsg);
  314. i += strlen(szMsg);
  315. }
  316. break;
  317. case 'x': // 性别
  318. if (nValue)
  319. strcat(m_szDesc, "女性");
  320. else
  321. strcat(m_szDesc, "男性");
  322. i += 4;
  323. break;
  324. default:
  325. break;
  326. }
  327. pTempDesc += 4;
  328. }
  329. else
  330. {
  331. m_szDesc[i] = *pTempDesc;
  332. pTempDesc++;
  333. i++;
  334. }
  335. }
  336. return m_szDesc;
  337. }
  338. const char * g_MagicID2String(int nAttrib)
  339. {
  340. if ((nAttrib < 0) || nAttrib >= magic_normal_end) return MAGIC_ATTRIB_STRING[magic_normal_end];
  341. return  MAGIC_ATTRIB_STRING[nAttrib];
  342. }
  343. int g_String2MagicID(char * szMagicAttribName)
  344. {
  345. if ((!szMagicAttribName) || (!szMagicAttribName[0])) return -1;
  346. //nValue2 当值为-1时为永久性状态,0为非状态,其它值为有时效性状态魔法效果
  347. //需要将状态数据与非状态数据分离出来,放入相应的数组内,并记录总数量
  348. for (int i  = 0 ; i <= magic_normal_end; i ++)
  349. {
  350. if (!strcmp(szMagicAttribName, g_MagicID2String(i)))
  351. return i;
  352. }
  353. return -1;
  354. }