Handler_Item.cpp
上传用户:szopptop
上传日期:2013-04-23
资源大小:1047k
文件大小:11k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. int CItem::GetUpgrade(int nCount, int nRandom)
  3. {
  4. int nResult = 0;
  5. for (int i = 0; i < nCount; i++)
  6. {
  7. if ((rand() % nRandom) == 0)
  8. nResult++;
  9. else
  10. break;
  11. }
  12. return nResult;
  13. }
  14. void CStdItem::GetStandardItem(_LPTCLIENTITEMRCD lpClientItemRcd)
  15. {
  16. strcpy(lpClientItemRcd->tStdItem.szName, szName);
  17. lpClientItemRcd->tStdItem.btStdMode = (BYTE)wStdMode;
  18. lpClientItemRcd->tStdItem.btShape = (BYTE)wShape;
  19. lpClientItemRcd->tStdItem.btWeight = (BYTE)wWeight;
  20. lpClientItemRcd->tStdItem.btAniCount = 0;
  21. lpClientItemRcd->tStdItem.btSource = 0;
  22. lpClientItemRcd->tStdItem.wLooks = (WORD)dwLooks;
  23. lpClientItemRcd->tStdItem.wDuraMax = (WORD)wDuraMax;
  24. lpClientItemRcd->tStdItem.btNeed = 0;
  25. lpClientItemRcd->tStdItem.btNeedLevel = 0;
  26. lpClientItemRcd->tStdItem.nPrice = (UINT)dwPrice;
  27. }
  28. CStdItemSpecial::CStdItemSpecial()
  29. {
  30. }
  31. void CStdItemSpecial::GetStandardItem(_LPTCLIENTITEMRCD lpClientItemRcd)
  32. {
  33. memcpy(lpClientItemRcd->tStdItem.szName, szName, memlen(szName));
  34. lpClientItemRcd->tStdItem.btStdMode = (BYTE)wStdMode;
  35. lpClientItemRcd->tStdItem.btShape = (BYTE)wShape;
  36. lpClientItemRcd->tStdItem.btWeight = (BYTE)wWeight;
  37. lpClientItemRcd->tStdItem.btAniCount = (BYTE)wAniCount;
  38. lpClientItemRcd->tStdItem.btSource = (BYTE)wSource;
  39. // lpClientItemRcd->tStdItem.btNeedIdentify = (BYTE)g_pStdItemWeapon[nIdx].wNeedIdentify;
  40. lpClientItemRcd->tStdItem.wLooks = (WORD)dwLooks;
  41. lpClientItemRcd->tStdItem.wDuraMax = (WORD)wDuraMax;
  42. lpClientItemRcd->tStdItem.btNeed = (BYTE)wNeed;
  43. lpClientItemRcd->tStdItem.btNeedLevel = (BYTE)wNeedLevel;
  44. lpClientItemRcd->tStdItem.nPrice = (UINT)dwPrice;
  45. }
  46. void CStdItemSpecial::GetUpgradeStdItem(_LPTCLIENTITEMRCD lpClientItemRcd, _LPTUSERITEMRCD lpUserItemRcd)
  47. {
  48. /* switch (lpUserItemRcd->szMakeIndex[0])
  49. {
  50. case 'A': // Weapon
  51. {
  52. lpClientItemRcd->tStdItem.wDC = MAKEWORD(g_pStdItemWeapon[nIdx].wDC, g_pStdItemWeapon[nIdx].wDC2 + lpUserItemRcd->btValue[0]);
  53. lpClientItemRcd->tStdItem.wMC = MAKEWORD(g_pStdItemWeapon[nIdx].wMC, g_pStdItemWeapon[nIdx].wMC2 + lpUserItemRcd->btValue[1]);
  54. lpClientItemRcd->tStdItem.wSC = MAKEWORD(g_pStdItemWeapon[nIdx].wSC, g_pStdItemWeapon[nIdx].wSC2 + lpUserItemRcd->btValue[2]); //3:青款, 4:历林
  55. lpClientItemRcd->tStdItem.wAC = MAKEWORD(g_pStdItemWeapon[nIdx].wAC + lpUserItemRcd->btValue[3], g_pStdItemWeapon[nIdx].wAC2 + lpUserItemRcd->btValue[5]); //沥犬
  56. lpClientItemRcd->tStdItem.wMAC = MAKEWORD(g_pStdItemWeapon[nIdx].wMAC + lpUserItemRcd->btValue[4], g_pStdItemWeapon[nIdx].wMAC2 + lpUserItemRcd->btValue[6]); //傍拜加档(-/+)
  57. lpClientItemRcd->tStdItem.btSource = (BYTE)lpUserItemRcd->btValue[7];
  58. if (lpUserItemRcd->btValue[10]) lpClientItemRcd->tStdItem.btNeedIdentify = 0x01;
  59. break;
  60. }
  61. case 'B': // Armor
  62. {
  63. lpClientItemRcd->tStdItem.wAC = MAKEWORD(g_pStdItemArmor[nIdx].wAC, g_pStdItemArmor[nIdx].wAC2 + lpUserItemRcd->btValue[0]);
  64. lpClientItemRcd->tStdItem.wDC = MAKEWORD(g_pStdItemArmor[nIdx].wDC, g_pStdItemArmor[nIdx].wDC2 + lpUserItemRcd->btValue[2]);
  65. lpClientItemRcd->tStdItem.wMAC = MAKEWORD(g_pStdItemArmor[nIdx].wMAC, g_pStdItemArmor[nIdx].wMAC2 + lpUserItemRcd->btValue[1]);
  66. lpClientItemRcd->tStdItem.wMC = MAKEWORD(g_pStdItemArmor[nIdx].wMC, g_pStdItemArmor[nIdx].wMC2 + lpUserItemRcd->btValue[3]);
  67. lpClientItemRcd->tStdItem.wSC = MAKEWORD(g_pStdItemArmor[nIdx].wSC, g_pStdItemArmor[nIdx].wSC2 + lpUserItemRcd->btValue[4]);
  68. break;
  69. }
  70. case 'C': // Accessory
  71. {
  72. lpClientItemRcd->tStdItem.wAC  = MAKEWORD(g_pStdItemAccessory[nIdx].wAC, g_pStdItemAccessory[nIdx].wAC2 + lpUserItemRcd->btValue[0]);
  73. lpClientItemRcd->tStdItem.wMAC = MAKEWORD(g_pStdItemAccessory[nIdx].wMAC,g_pStdItemAccessory[nIdx].wMAC2+ lpUserItemRcd->btValue[1]);
  74. lpClientItemRcd->tStdItem.wDC  = MAKEWORD(g_pStdItemAccessory[nIdx].wDC, g_pStdItemAccessory[nIdx].wDC2 + lpUserItemRcd->btValue[2]);
  75. lpClientItemRcd->tStdItem.wMC  = MAKEWORD(g_pStdItemAccessory[nIdx].wMC, g_pStdItemAccessory[nIdx].wMC2 + lpUserItemRcd->btValue[3]);
  76. lpClientItemRcd->tStdItem.wSC  = MAKEWORD(g_pStdItemAccessory[nIdx].wSC, g_pStdItemAccessory[nIdx].wSC2 + lpUserItemRcd->btValue[4]);
  77. break;
  78. }
  79. }
  80. */
  81. switch (btType)
  82. {
  83. case 0:
  84. {
  85. lpClientItemRcd->tStdItem.wDC = MAKEWORD(wDC, wDC2 + lpUserItemRcd->btValue[0]);
  86. lpClientItemRcd->tStdItem.wMC = MAKEWORD(wMC, wMC2 + lpUserItemRcd->btValue[1]);
  87. lpClientItemRcd->tStdItem.wSC = MAKEWORD(wSC, wSC2 + lpUserItemRcd->btValue[2]); //3:青款, 4:历林
  88. lpClientItemRcd->tStdItem.wAC = MAKEWORD(wAC + lpUserItemRcd->btValue[3], wAC2 + lpUserItemRcd->btValue[5]);  //沥犬
  89. lpClientItemRcd->tStdItem.wMAC = MAKEWORD(wMAC + lpUserItemRcd->btValue[4], wMAC2 + lpUserItemRcd->btValue[6]);  //傍拜加档(-/+)
  90. lpClientItemRcd->tStdItem.btSource = lpUserItemRcd->btValue[7];
  91. // if (lpMakeItemRcd->btValue[10])
  92. // lptWeaponItem->NeedIdentify := 0x01;
  93. break;
  94. }
  95. case 1:
  96. {
  97. lpClientItemRcd->tStdItem.wAC = MAKEWORD(wAC, wAC2 + lpUserItemRcd->btValue[0]);
  98. lpClientItemRcd->tStdItem.wMAC = MAKEWORD(wMAC, wMAC2 + lpUserItemRcd->btValue[1]);
  99. lpClientItemRcd->tStdItem.wDC = MAKEWORD(wDC, wDC2 + lpUserItemRcd->btValue[2]);
  100. lpClientItemRcd->tStdItem.wMC = MAKEWORD(wMC, wMC2 + lpUserItemRcd->btValue[3]);
  101. lpClientItemRcd->tStdItem.wSC = MAKEWORD(wSC, wSC2 + lpUserItemRcd->btValue[4]);
  102. break;
  103. }
  104. case 2:
  105. {
  106. lpClientItemRcd->tStdItem.wAC  = MAKEWORD(wAC, wAC2 + lpUserItemRcd->btValue[0]);
  107. lpClientItemRcd->tStdItem.wMAC = MAKEWORD(wMAC,wMAC2+ lpUserItemRcd->btValue[1]);
  108. lpClientItemRcd->tStdItem.wDC  = MAKEWORD(wDC, wDC2 + lpUserItemRcd->btValue[2]);
  109. lpClientItemRcd->tStdItem.wMC  = MAKEWORD(wMC, wMC2 + lpUserItemRcd->btValue[3]);
  110. lpClientItemRcd->tStdItem.wSC  = MAKEWORD(wSC, wSC2 + lpUserItemRcd->btValue[4]);
  111. break;
  112. }
  113. default:
  114. {
  115. lpClientItemRcd->tStdItem.wAC = 0;
  116. lpClientItemRcd->tStdItem.wMAC = 0;
  117. lpClientItemRcd->tStdItem.wDC = 0;
  118. lpClientItemRcd->tStdItem.wMC = 0;
  119. lpClientItemRcd->tStdItem.wSC = 0;
  120. lpClientItemRcd->tStdItem.btSource = 0;
  121. break;
  122. }
  123. }
  124. }
  125. void CStdItemSpecial::UpgradeRandomItem(BYTE* btValue, WORD &nDura, WORD &nDuraMax)//_LPTMAKEITEMRCD lpMakeItemRcd)
  126. {
  127. int nUpgrade, nIncp, nVal;
  128. switch (btType)
  129. {
  130. case 0: // 公扁
  131. {
  132. // 颇鲍 可记
  133. nUpgrade = GetUpgrade(12, 15);
  134. if (rand() % 15 == 0) 
  135. btValue[0] = 1 + nUpgrade; // DC
  136. // 傍拜 加档
  137. nUpgrade = GetUpgrade(12, 15);
  138. if (rand() % 20 == 0)
  139. {
  140. nIncp = (int)((1 + nUpgrade) / 3);
  141. if (nIncp > 0)
  142. {
  143. if (rand() % 3 != 0) btValue[6] = nIncp; // 傍拜 加档 (-)
  144. else
  145. btValue[6] = 10 + nIncp; // 傍拜 加档 (+)
  146. }
  147. }
  148. // 付仿
  149. nUpgrade = GetUpgrade(12, 15);
  150. if (rand() % 15 == 0) 
  151. btValue[1] = 1 + nUpgrade; // MC
  152. // 档仿
  153. nUpgrade = GetUpgrade(12, 15);
  154. if (rand() % 15 == 0) 
  155. btValue[2] = 1 + nUpgrade; // SC
  156. // 沥犬
  157. nUpgrade = GetUpgrade(12, 15);
  158. if (rand() % 24 == 0) 
  159. btValue[5] = 1 + ((int)nUpgrade / 2); // 沥犬 (+)
  160. // 郴备
  161. nUpgrade = GetUpgrade(12, 12);
  162. if (rand() % 3 < 2)
  163. {
  164. nVal = (1 + nUpgrade) * 2000;
  165. nDuraMax = _MIN(65000, nDuraMax + nVal);
  166. nDura = _MIN(65000, nDura + nVal);
  167. }
  168. // 碍档
  169. nUpgrade = GetUpgrade(12, 15);
  170. if (rand() % 10 == 0) 
  171. btValue[7] = 1 + ((int)nUpgrade / 2);
  172. break;
  173. }
  174. case 1: // 规绢备幅
  175. {
  176. //规绢
  177. nUpgrade = GetUpgrade(6, 15);
  178. if (rand() % 40 == 0) 
  179. btValue[0] = 1 + nUpgrade; // AC
  180. //付亲
  181. nUpgrade = GetUpgrade(6, 15);
  182. if (rand() % 40 == 0) 
  183. btValue[1] = 1 + nUpgrade; // MAC
  184. //颇鲍
  185. nUpgrade = GetUpgrade(6, 20);
  186. if (rand() % 40 == 0) 
  187. btValue[2] = 1 + nUpgrade; // DC
  188. //付过
  189. nUpgrade = GetUpgrade(6, 20);
  190. if (rand() % 40 == 0) 
  191. btValue[3] = 1 + nUpgrade; // MC
  192. //档仿
  193. nUpgrade = GetUpgrade(6, 20);
  194. if (rand() % 40 == 0) 
  195. btValue[4] = 1 + nUpgrade; // SC
  196. //郴备
  197. nUpgrade = GetUpgrade(6, 10);
  198. if (rand() % 8 < 6)
  199. {
  200. nVal = (1 + nUpgrade) * 2000;
  201. nDuraMax = _MIN(65000, nDuraMax + nVal);
  202. nDura = _MIN(65000, nDura + nVal);
  203. }
  204. break;
  205. }
  206. case 2: // 馆瘤, 迫瘤, 格吧捞
  207. {
  208. // 沥犬
  209. nUpgrade = GetUpgrade(6, 30);
  210. if (rand() % 60 == 0) 
  211. btValue[0] = 1 + nUpgrade; // AC(HIT)
  212. //刮酶
  213. nUpgrade = GetUpgrade(6, 30);
  214. if (rand() % 60 == 0) 
  215. btValue[1] = 1 + nUpgrade; // MAC(SPEED)
  216. //颇鲍
  217. nUpgrade = GetUpgrade(6, 20);
  218. if (rand() % 30 == 0) 
  219. btValue[2] = 1 + nUpgrade; // DC
  220. //付过
  221. nUpgrade = GetUpgrade(6, 20);
  222. if (rand() % 30 == 0) 
  223. btValue[3] = 1 + nUpgrade; // MC
  224. //档仿
  225. nUpgrade = GetUpgrade(6, 20);
  226. if (rand() % 30 == 0) 
  227. btValue[4] = 1 + nUpgrade; // SC
  228. //郴备
  229. nUpgrade = GetUpgrade(6, 12);
  230. if (rand() % 20 < 15)
  231. {
  232. nVal = (1 + nUpgrade) * 1000;
  233. nDuraMax = _MIN(65000, nDuraMax + nVal);
  234. nDura = _MIN(65000, nDura + nVal);
  235. }
  236. break;
  237. }
  238. }
  239. }
  240. void CStdItemSpecial::ApplyItemParameters(CObjectAddAbility *m_pAddAbility)
  241. {
  242. switch (btType)
  243. {
  244. case 0:
  245. {
  246.             m_pAddAbility->HIT = m_pAddAbility->HIT + wAC2;
  247.             if (wMAC2 > 10)
  248.                m_pAddAbility->HitSpeed = m_pAddAbility->HitSpeed + wMAC2 - 10; //傍拜加档 (+)
  249.             else
  250.                m_pAddAbility->HitSpeed = m_pAddAbility->HitSpeed - wMAC2; //傍拜加档 (-)
  251.             m_pAddAbility->Luck = m_pAddAbility->Luck + wAC;   //霸烙惑狼 捞亥飘甫 烹秦 嘿澜
  252.             m_pAddAbility->UnLuck = m_pAddAbility->UnLuck + wMAC;  //霸烙惑狼 捞亥飘甫 烹秦 嘿澜(乔纳捞)
  253. break;
  254. }
  255. case 1:
  256. {    
  257. m_pAddAbility->AC = MAKEWORD(LOBYTE(m_pAddAbility->AC) + wAC, HIBYTE(m_pAddAbility->AC) + wAC2);
  258. m_pAddAbility->MAC = MAKEWORD(LOBYTE(m_pAddAbility->MAC) + wMAC, HIBYTE(m_pAddAbility->MAC) + wMAC2);
  259. break;
  260. }
  261. case 2:
  262. {
  263. switch (wStdMode)
  264. {
  265. case 21: //格吧捞
  266. m_pAddAbility->AntiMagic += wAC2;
  267. m_pAddAbility->UnLuck += wMAC;
  268. m_pAddAbility->Luck += wMAC2;
  269. break;
  270. case 22: //格吧捞
  271. case 41: //迫骂
  272. m_pAddAbility->HIT += wAC2;
  273. m_pAddAbility->SPEED += wMAC2;
  274. break;
  275. case 23: //格吧捞
  276. m_pAddAbility->HealthRecover += wAC2;
  277. m_pAddAbility->SpellRecover += wMAC2;
  278. m_pAddAbility->HitSpeed += wAC;
  279. m_pAddAbility->HitSpeed -= wMAC;
  280. break;
  281. case 32: //馆瘤
  282. m_pAddAbility->AntiPoison += wAC2;
  283. m_pAddAbility->PoisonRecover += wMAC2;
  284. m_pAddAbility->HitSpeed += wAC;
  285. m_pAddAbility->HitSpeed -= wMAC;
  286. break;
  287. default:
  288. m_pAddAbility->AC = MAKEWORD(LOBYTE(m_pAddAbility->AC) + wAC, HIBYTE(m_pAddAbility->AC) + wAC2);
  289. m_pAddAbility->MAC = MAKEWORD(LOBYTE(m_pAddAbility->MAC) + wMAC, HIBYTE(m_pAddAbility->MAC) + wMAC2);
  290. break;
  291. }
  292. break;
  293. }
  294. }
  295. m_pAddAbility->DC = MAKEWORD(LOBYTE(m_pAddAbility->DC) + wDC, HIBYTE(m_pAddAbility->DC) + wDC2);
  296. m_pAddAbility->MC = MAKEWORD(LOBYTE(m_pAddAbility->MC) + wMC, HIBYTE(m_pAddAbility->MC) + wMC2);
  297. m_pAddAbility->SC = MAKEWORD(LOBYTE(m_pAddAbility->SC) + wSC, HIBYTE(m_pAddAbility->SC) + wSC2);
  298. }