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

模拟服务器

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. #define _MSG_GOOD "+GOOD/"
  3. #define _MSG_FAIL "+FAIL/"
  4. CMagicInfo* GetMagicInfo(int nMagicID);
  5. int GetBack(int nDirection);
  6. CMirMap* GetMap(char *pszMapName);
  7. CPlayerObject* GetUserHuman(char *pszCharName);
  8. void SendRDBSocket(int nCertification, char *pszData1, char *pszData2, int nData2Len);
  9. void CPlayerObject::Constructor()
  10. {
  11. m_bEmpty = true;
  12. m_wObjectType = _OBJECT_HUMAN;
  13. m_nViewRange = 12;
  14. m_dwSearchTime = GetTickCount();
  15. m_dwSearchTick = 1000;
  16. m_fIsDead = FALSE;
  17. m_btLight = 2;
  18. m_fAdminMode = FALSE;
  19. m_dwLastCryTime = 0;
  20. m_fIsCapture = FALSE;
  21. }
  22. bool CPlayerObject::IsEmpty()
  23. {
  24. return m_bEmpty;
  25. }
  26. CPlayerObject::CPlayerObject(): CCharObject(NULL)
  27. {
  28. Constructor();
  29. }
  30. CPlayerObject::CPlayerObject(CUserInfo* pUserInfo): CCharObject(pUserInfo)
  31. {
  32. Constructor();
  33. }
  34. BOOL CPlayerObject::IsProperTarget(CCharObject* pTargetObject)
  35. {
  36. BOOL fFlag = FALSE;
  37. if (!pTargetObject)
  38. return fFlag;
  39. int nMode = m_pUserInfo->GetAttackMode();
  40. switch (nMode)
  41. {
  42. case HAM_ALL:
  43. if (!(pTargetObject->m_wObjectType & _OBJECT_NPC))
  44. fFlag = TRUE;
  45. break;
  46. case HAM_PEACE:
  47. if (pTargetObject->m_wObjectType & _OBJECT_ANIMAL)
  48. fFlag = TRUE;
  49. break;
  50. case HAM_GROUP:
  51. /*                  if not ((target.RaceServer >= RC_NPC) and (target.RaceServer <= RC_PEACENPC)) then
  52.              Result := TRUE;
  53.           if target.RaceServer = RC_USERHUMAN then
  54.              if IsGroupMember (target) then
  55.                 Result := FALSE; */
  56. break;
  57. case HAM_GUILD:
  58. /*                  if not ((target.RaceServer >= RC_NPC) and (target.RaceServer <= RC_PEACENPC)) then
  59.              Result := TRUE;
  60.           if target.RaceServer = RC_USERHUMAN then
  61.              if MyGuild <> nil then begin
  62.                 if TGuild(MyGuild).IsMember(target.UserName) then
  63.                    Result := FALSE;
  64.                 if BoGuildWarArea and (target.MyGuild <> nil) then begin  //巩颇傈,傍己傈 瘤开俊 乐澜
  65.                    if TGuild(MyGuild).IsAllyGuild(TGuild(target.MyGuild)) then
  66.                       Result := FALSE;
  67.                 end;
  68.              end;
  69.        end; */
  70. break;
  71. case HAM_PKATTACK:
  72. /*
  73.           if not ((target.RaceServer >= RC_NPC) and (target.RaceServer <= RC_PEACENPC)) then
  74.              Result := TRUE;
  75.           if target.RaceServer = RC_USERHUMAN then
  76.              if self.PKLevel >= 2 then begin  //傍拜窍绰 磊啊 弧盎捞
  77.                 if target.PKLevel < 2 then Result := TRUE
  78.                 else Result := FALSE;
  79.              end else begin
  80.                 //傍拜窍绰 磊啊 闰嫡捞
  81.                 if target.PKLevel >= 2 then Result := TRUE
  82.                 else Result := FALSE;
  83.              end;
  84.        end;
  85. */ break;
  86. }
  87. /* if target.RaceServer = RC_USERHUMAN then begin
  88.         if (InSafeZone) or (target.InSafeZone) then begin
  89.            Result := FALSE;
  90.         end;
  91.         if not target.BoInFreePKArea then begin  //傍己傈 瘤开俊辑绰 力寇 等促.
  92.            if (PKLevel >= 2) and (Abil.Level > 10) then begin //绊乏 弧盎捞甸
  93.               if (target.Abil.Level <= 10) and (target.PKLevel < 2) then //历肪 馒茄 檬焊甫 傍拜 给茄促.
  94.                  Result := FALSE;
  95.            end;
  96.            if (Abil.Level <= 10) and (PKLevel < 2) then begin //历肪 馒茄 檬焊
  97.               if (target.PKLevel >= 2) and (target.Abil.Level > 10) then //绊肪 弧盎捞甸阑 傍拜给茄促.
  98.                  Result := FALSE;
  99.            end;
  100.         end;
  101.         //甘 捞悼饶 3檬 悼救篮 傍拜 给窍绊 救 寸窃
  102.         if (GetTickCount - MapMoveTime < 3000) or (GetTickCount - target.MapMoveTime < 3000) then
  103.            Result := FALSE;
  104.      end else begin
  105.         if target.Master = self then begin  //郴 何窍
  106.            if HumAttackMode <> HAM_ALL then  //葛滴 傍拜 老锭父 何窍啊 傍拜凳
  107.               Result := FALSE;
  108.         end else begin
  109.            if target.Master <> nil then
  110.               Result := IsProperTarget(target.Master);
  111.         end;
  112.      end; */
  113. return fFlag;
  114. }
  115. void CPlayerObject::GetCharName(char *pszCharName)
  116. strcpy(pszCharName, m_szName); 
  117. }
  118. BOOL CPlayerObject::ReadBook(char *pszMakeIndex)
  119. {
  120. if (!m_pUserInfo) return FALSE;
  121. int nMagicID = m_pUserInfo->GetMagicID(pszMakeIndex);
  122. if (m_pUserInfo->IsMyMagic(nMagicID)) return FALSE;
  123. CMagicInfo* pMagicInfo = GetMagicInfo(nMagicID);
  124. if (pMagicInfo)
  125. {
  126. if (((pMagicInfo->sJob == m_pUserInfo->GetJob()) || pMagicInfo->sJob == 99) && m_Ability.Level >= pMagicInfo->sNeed[0])
  127. {
  128. char szEncodeMsg[256];
  129. _TDEFAULTMESSAGE DefMsg;
  130. _LPTHUMANMAGICRCD lpHumanMagicRcd = new _THUMANMAGICRCD;
  131. if (lpHumanMagicRcd)
  132. {
  133. lpHumanMagicRcd->btMagicID = nMagicID;
  134. lpHumanMagicRcd->btLevel = 0;
  135. lpHumanMagicRcd->btUseKey = 0;
  136. lpHumanMagicRcd->nCurrTrain = 0;
  137. m_pUserInfo->m_lpTMagicRcd.AddNewNode(lpHumanMagicRcd);
  138. RecalcAbilitys();
  139. _TCLIENTMAGICRCD tClientMagicRcd;
  140. tClientMagicRcd.btMagicID = lpHumanMagicRcd->btMagicID;
  141. tClientMagicRcd.btLevel = lpHumanMagicRcd->btLevel;
  142. tClientMagicRcd.btUseKey = lpHumanMagicRcd->btUseKey;
  143. tClientMagicRcd.nCurrTrain = lpHumanMagicRcd->nCurrTrain;
  144. tClientMagicRcd.tStdMagic.btEffect = (BYTE)g_pMagicInfo[lpHumanMagicRcd->btMagicID].sEffect;
  145. tClientMagicRcd.tStdMagic.btEffectType = (BYTE)g_pMagicInfo[lpHumanMagicRcd->btMagicID].sEffectType;
  146. memcpy(&tClientMagicRcd.tStdMagic.sNeed, g_pMagicInfo[lpHumanMagicRcd->btMagicID].sNeed, sizeof(tClientMagicRcd.tStdMagic.sNeed));
  147. memcpy(&tClientMagicRcd.tStdMagic.nTrain, g_pMagicInfo[lpHumanMagicRcd->btMagicID].nTrain, sizeof(tClientMagicRcd.tStdMagic.nTrain));
  148. tClientMagicRcd.tStdMagic.btDefSpell = (BYTE)g_pMagicInfo[lpHumanMagicRcd->btMagicID].sDefSpell;
  149. tClientMagicRcd.tStdMagic.nDelayTime = g_pMagicInfo[lpHumanMagicRcd->btMagicID].sDelay;
  150. fnMakeDefMessage(&DefMsg, SM_ADDMAGIC, 0, 0, 0, 1);
  151. int nPos = fnEncode6BitBufA((unsigned char *)&tClientMagicRcd, szEncodeMsg, sizeof(_TCLIENTMAGICRCD), sizeof(szEncodeMsg));
  152. szEncodeMsg[nPos] = '';
  153. SendSocket(&DefMsg, szEncodeMsg);
  154. return TRUE;
  155. }
  156. }
  157. }
  158. return FALSE;
  159. }
  160. BOOL CPlayerObject::EatItem(char *pszMakeIndex)
  161. {
  162. int nStdIndex = m_pUserInfo->GetGenItemStdIdx(pszMakeIndex);
  163. if (g_pStdItemEtc[nStdIndex].wStdMode != 0) return FALSE;
  164. if (g_pStdItemEtc[nStdIndex].wShape == 1)
  165. IncHealthSpell(g_pStdItemEtc[nStdIndex].wDuraMax/*+hp*/, g_pStdItemEtc[nStdIndex].dwRSource/*+mp*/);
  166. else
  167. {
  168. if ((m_IncHealth + g_pStdItemEtc[nStdIndex].wDuraMax < 500) && (g_pStdItemEtc[nStdIndex].wDuraMax > 0))
  169. m_IncHealth += (WORD)g_pStdItemEtc[nStdIndex].wDuraMax;
  170. if ((m_IncSpell + g_pStdItemEtc[nStdIndex].dwRSource < 500) && (g_pStdItemEtc[nStdIndex].dwRSource > 0))
  171. m_IncSpell += (WORD)g_pStdItemEtc[nStdIndex].dwRSource;
  172. }
  173. return TRUE;
  174. }
  175. BOOL CPlayerObject::ServerGetEatItem(int nItemIndex, char *pszMakeIndex)
  176. {
  177. if (!m_pUserInfo) return FALSE;
  178. _TDEFAULTMESSAGE DefMsg;
  179. BOOL fFlag = FALSE;
  180. _LPTGENERALITEMRCD lptGenItem = m_pUserInfo->GetUseGenItem(pszMakeIndex);
  181. if (lptGenItem)
  182. {
  183. switch (g_pStdItemEtc[nItemIndex].wStdMode)
  184. {
  185. case 0:
  186. {
  187. if (EatItem(pszMakeIndex))
  188. {
  189. m_pUserInfo->RemoveGenItem(lptGenItem);
  190. fFlag = TRUE;
  191. }
  192. break;
  193. }
  194. case 3:
  195. {
  196. break;
  197. }
  198. case 4:
  199. {
  200. if (ReadBook(pszMakeIndex))
  201. {
  202. m_pUserInfo->RemoveGenItem(lptGenItem);
  203. if (m_pUserInfo->m_lpTMagicErgumSkill)
  204. {
  205. if (!m_pUserInfo->m_fLongHitSkill)
  206. {
  207. m_pUserInfo->AllowLongHitSkill(TRUE);
  208. SendSocket(NULL, "+LNG");
  209. }
  210. }
  211. if (m_pUserInfo->m_lpTMagicBanwolSkill)
  212. {
  213. if (!m_pUserInfo->m_fWideHitSkill)
  214. {
  215. m_pUserInfo->AllowWideHitSkill(TRUE);
  216. SendSocket(NULL, "+WID");
  217. }
  218. }
  219. fFlag = TRUE;
  220. }
  221. break;
  222. }
  223. }
  224. }
  225. if (fFlag)
  226. {
  227.   fnMakeDefMessage(&DefMsg, SM_EAT_OK, 0, 0, 0, 0);
  228. SendSocket(&DefMsg, NULL);
  229. }
  230. else
  231. {
  232.   fnMakeDefMessage(&DefMsg, SM_EAT_FAIL, 0, 0, 0, 0);
  233. SendSocket(&DefMsg, NULL);
  234. }
  235. return fFlag;
  236. }
  237. void CPlayerObject::SendAddItem(_LPTUSERITEMRCD lpTItemRcd)
  238. {
  239. _TDEFAULTMESSAGE SendDefMsg;
  240. _TCLIENTITEMRCD tClientItemRcd;
  241. char szEncodeMsg[256];
  242. fnMakeDefMessage(&SendDefMsg, SM_ADDITEM, (int)this, 0, 0, 1);
  243. if (lpTItemRcd->szMakeIndex[0] != 'G')
  244. {
  245. g_pStdItemSpecial[lpTItemRcd->nStdIndex].GetStandardItem(&tClientItemRcd);
  246. g_pStdItemSpecial[lpTItemRcd->nStdIndex].GetUpgradeStdItem(&tClientItemRcd, lpTItemRcd);
  247. if (strlen(lpTItemRcd->szPrefixName))
  248. strcpy(tClientItemRcd.tStdItem.szPrefixName, lpTItemRcd->szPrefixName);
  249. else
  250. ZeroMemory(tClientItemRcd.tStdItem.szPrefixName, sizeof(tClientItemRcd.tStdItem.szPrefixName));
  251. }
  252. else
  253. {
  254. g_pStdItemEtc[lpTItemRcd->nStdIndex].GetStandardItem(&tClientItemRcd);
  255. g_pStdItemEtc[lpTItemRcd->nStdIndex].GetUpgradeStdItem(&tClientItemRcd, lpTItemRcd);
  256. }
  257. memcpy(tClientItemRcd.szMakeIndex, lpTItemRcd->szMakeIndex, 12);
  258. tClientItemRcd.nDura = lpTItemRcd->nDura;
  259. tClientItemRcd.nDuraMax = lpTItemRcd->nDuraMax;
  260. int nPos =  fnEncode6BitBufA((unsigned char *)&tClientItemRcd, szEncodeMsg, sizeof(_TCLIENTITEMRCD), sizeof(szEncodeMsg));
  261. szEncodeMsg[nPos] = '';
  262. SendSocket(&SendDefMsg, szEncodeMsg);
  263. }
  264. BOOL CPlayerObject::PickUp()
  265. {
  266. CMapItem* pMapItem = m_pMap->GetItem(m_nCurrX, m_nCurrY);
  267. if (pMapItem)
  268. {
  269. if (memcmp(pMapItem->szName, g_szGoldName, memlen(g_szGoldName) - 1) == 0)
  270. {
  271. if (m_pMap->RemoveObject(m_nCurrX, m_nCurrY, OS_ITEMOBJECT, (VOID *)pMapItem))
  272. {
  273. if (m_pUserInfo->IncGold(pMapItem->nCount))
  274. {
  275. AddRefMsg(RM_ITEMHIDE, 0, (int)pMapItem, m_nCurrX, m_nCurrY, NULL);
  276. GoldChanged();
  277. delete pMapItem;
  278. pMapItem = NULL;
  279. return TRUE;
  280. }
  281. else
  282. m_pMap->AddNewObject(m_nCurrX, m_nCurrY, OS_ITEMOBJECT, (VOID *)pMapItem);
  283. }
  284. }
  285. else
  286. {
  287. if (m_pUserInfo->IsEnoughBag())
  288. {
  289. if (m_pMap->RemoveObject(m_nCurrX, m_nCurrY, OS_ITEMOBJECT, (VOID *)pMapItem))
  290. {
  291. _LPTUSERITEMRCD lptItemRcd = (_LPTUSERITEMRCD)pMapItem->pItem;
  292. if (int nUpdate = UpdateItemToDB(lptItemRcd, _ITEM_ACTION_PICKUP))
  293. {
  294. AddRefMsg(RM_ITEMHIDE, 0, (int)pMapItem, m_nCurrX, m_nCurrY, NULL);
  295. if (nUpdate == 2)
  296. {
  297. SendAddItem(lptItemRcd);
  298. m_pUserInfo->m_lpTItemRcd.AddNewNode(lptItemRcd);
  299. }
  300. delete pMapItem;
  301. pMapItem = NULL;
  302. }
  303. }
  304. }
  305. }
  306. }
  307. return FALSE;
  308. }
  309. /*function  TCreature.PickUp: Boolean;
  310. var
  311.    i: integer;
  312.    pu: PTUserItem;
  313.    pmi: PTMapItem;
  314.    ps: PTStdItem;
  315.    hum: TUserHuman;
  316. begin
  317.    Result := FALSE;
  318.    if BoDealing then exit;  //背券吝俊绰 拱扒阑 林阑 荐 绝促.
  319.    pmi := PEnvir.GetItem (CX, CY);
  320.    if pmi <> nil then begin
  321.       if CompareText (pmi.Name, '陛傈') = 0 then begin
  322.          if PEnvir.DeleteFromMap (CX, CY, OS_ITEMOBJECT, TObject(pmi)) = 1 then begin
  323.             if IncGold (pmi.Count) then begin
  324.                SendRefMsg (RM_ITEMHIDE, 0, integer(pmi), CX, CY, '');
  325.                //肺弊巢辫
  326.                AddUserLog ('凛扁_' +
  327.                            MapName + '_' +
  328.                            IntToStr(CX) + '_' +
  329.                            IntToStr(CY) + '_' +
  330.                            UserName + '_' +
  331.                            '陛傈_' +
  332.                            IntToStr(pmi.count));
  333.                GoldChanged;
  334.                Dispose (pmi);
  335.             end else
  336.                PEnvir.AddToMap (CX, CY, OS_ITEMOBJECT, TObject(pmi));
  337.          end;
  338.       end else
  339.          if IsEnoughBag then begin
  340.             if PEnvir.DeleteFromMap (CX, CY, OS_ITEMOBJECT, TObject(pmi)) = 1 then begin
  341.                new (pu);
  342.                pu^ := pmi.UserItem;
  343.                ps := UserEngine.GetStdItem (pu.Index);
  344.                if (ps <> nil) and IsAddWeightAvailable (UserEngine.GetStdItemWeight(pu.Index)) then begin
  345.                   SendMsg (self, RM_ITEMHIDE, 0, integer(pmi), CX, CY, '');
  346.                   AddItem (pu);
  347.                   //肺弊巢辫
  348.                   if not IsCheapStuff (ps.StdMode) then
  349.                      AddUserLog ('凛扁_' +
  350.                                  MapName + '_' +
  351.                                  IntToStr(CX) + '_' +
  352.                                  IntToStr(CY) + '_' +
  353.                                  UserName + '_' +
  354.                                  UserEngine.GetStdItemName (pu.Index) + '_' +
  355.                                  IntToStr(pu.MakeIndex));
  356.                   Dispose (pmi);
  357.                   if RaceServer = RC_USERHUMAN then begin
  358.                      if self is TUserHuman then begin
  359.                         hum := TUserHuman(self);
  360.                         TUserHuman(hum).SendAddItem (pu^);
  361.                      end;
  362.                   end;
  363.                   Result := TRUE;
  364.                end else begin
  365.                   Dispose (pu);
  366.                   PEnvir.AddToMap (CX, CY, OS_ITEMOBJECT, TObject(pmi));
  367.                end;
  368.             end;
  369.          end;
  370.    end;
  371. end;
  372. */
  373. int CPlayerObject::UpdateItemToDB(_LPTUSERITEMRCD lpMakeItemRcd, int nAction)
  374. {
  375. char szQuery[1024];
  376. char szMakeDay[7];
  377. char szMakeIndex[6];
  378. ZeroMemory(szMakeDay, sizeof(szMakeDay));
  379. ZeroMemory(szMakeIndex, sizeof(szMakeIndex));
  380. memcpy(szMakeDay, &lpMakeItemRcd->szMakeIndex[1], 6);
  381. memcpy(szMakeIndex, &lpMakeItemRcd->szMakeIndex[7], 5);
  382. if (atoi(szMakeDay) == 0 && atoi(szMakeIndex) == 0)
  383. {
  384. _TMAKEITEMRCD tMakeItemRcd;
  385. tMakeItemRcd.szStdType = lpMakeItemRcd->szMakeIndex[0];
  386. tMakeItemRcd.nDura = lpMakeItemRcd->nDura;
  387. tMakeItemRcd.nDuraMax = lpMakeItemRcd->nDuraMax;
  388. tMakeItemRcd.nStdIndex = lpMakeItemRcd->nStdIndex;
  389. memcpy(tMakeItemRcd.btValue, lpMakeItemRcd->btValue, sizeof(lpMakeItemRcd->btValue));
  390. _TDEFAULTMESSAGE Def;
  391. char szEncodeMsg1[24];
  392. char szEncodeMsg2[128];
  393. fnMakeDefMessage(&Def, DB_MAKEITEMRCD2, (int)this, 0, 0, 0);
  394. int nPos = fnEncodeMessageA(&Def, szEncodeMsg1, sizeof(szEncodeMsg1));
  395. szEncodeMsg1[nPos] = '';
  396. nPos = fnEncode6BitBufA((unsigned char *)lpMakeItemRcd, szEncodeMsg2, sizeof(_LPTMAKEITEMRCD), sizeof(szEncodeMsg2));
  397. strcpy(&szEncodeMsg2[nPos], m_pUserInfo->m_szUserID);
  398. strcat(szEncodeMsg2, "/");
  399. strcat(szEncodeMsg2, m_pUserInfo->m_szCharName);
  400. SendRDBSocket(2, szEncodeMsg1, szEncodeMsg2, strlen(szEncodeMsg2));
  401. return 1;
  402. }
  403. switch (nAction)
  404. {
  405. case _ITEM_ACTION_CREATE:
  406. {
  407. /* sprintf(szQuery, "INSERT TBL_CHARACTER_ITEM (FLD_LOGINID, FLD_CHARNAME, FLD_STDTYPE, FLD_MAKEDATE, FLD_MAKEINDEX, "
  408. "FLD_STDINDEX, FLD_DURA, FLD_DURAMAX, FLD_VALUE1, FLD_VALUE2, FLD_VALUE3, FLD_VALUE4, FLD_VALUE5, "
  409. "FLD_VALUE6, FLD_VALUE7, FLD_VALUE8, FLD_VALUE9, FLD_VALUE10, FLD_VALUE11, FLD_VALUE12, FLD_VALUE13, "
  410. "FLD_VALUE14, FLD_LASTOWNER, FLD_LASTACTION) "
  411. "VALUES( '%s', '%s', '%c', '%s', '%05d', %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %s, %d )", 
  412. pszUserID, pszCharName, lpMakeItemRcd->szMakeIndex[0], g_szYesterDay, g_nItemIndexCnt,
  413. lpMakeItemRcd->nStdIndex, lpMakeItemRcd->nDura, lpMakeItemRcd->nDuraMax, 
  414. lpMakeItemRcd->btValue[0], lpMakeItemRcd->btValue[1], lpMakeItemRcd->btValue[2], lpMakeItemRcd->btValue[3], 
  415. lpMakeItemRcd->btValue[5], lpMakeItemRcd->btValue[5], lpMakeItemRcd->btValue[6], lpMakeItemRcd->btValue[7], 
  416. lpMakeItemRcd->btValue[8], lpMakeItemRcd->btValue[9], lpMakeItemRcd->btValue[10], lpMakeItemRcd->btValue[11], 
  417. lpMakeItemRcd->btValue[12], lpMakeItemRcd->btValue[13], pszCharName, _ITEM_ACTION_CREATE);
  418. */ break;
  419. }
  420. case _ITEM_ACTION_THROW:
  421. {
  422. sprintf(szQuery, "UPDATE TBL_CHARACTER_ITEM SET FLD_LOGINID='%s', FLD_CHARNAME='%s', "
  423. "FLD_DURA=%d, FLD_DURAMAX=%d, FLD_VALUE1=%d, FLD_VALUE2=%d, FLD_VALUE3=%d, FLD_VALUE4=%d, FLD_VALUE5=%d, "
  424. "FLD_VALUE6=%d, FLD_VALUE7=%d, FLD_VALUE8=%d, FLD_VALUE9=%d, FLD_VALUE10=%d, FLD_VALUE11=%d, FLD_VALUE12=%d, FLD_VALUE13=%d, "
  425. "FLD_VALUE14=%d, FLD_LASTOWNER='%s', FLD_LASTACTION=%d "
  426. "WHERE FLD_STDTYPE='%c' AND FLD_MAKEDATE='%s' AND FLD_MAKEINDEX='%s' AND FLD_STDINDEX=%d",
  427. "0", "WEMADE", lpMakeItemRcd->nDura, lpMakeItemRcd->nDuraMax, 
  428. lpMakeItemRcd->btValue[0], lpMakeItemRcd->btValue[1], lpMakeItemRcd->btValue[2], lpMakeItemRcd->btValue[3], 
  429. lpMakeItemRcd->btValue[5], lpMakeItemRcd->btValue[5], lpMakeItemRcd->btValue[6], lpMakeItemRcd->btValue[7], 
  430. lpMakeItemRcd->btValue[8], lpMakeItemRcd->btValue[9], lpMakeItemRcd->btValue[10], lpMakeItemRcd->btValue[11], 
  431. lpMakeItemRcd->btValue[12], lpMakeItemRcd->btValue[13], m_pUserInfo->m_szCharName, _ITEM_ACTION_THROW,
  432. lpMakeItemRcd->szMakeIndex[0], szMakeDay, szMakeIndex, lpMakeItemRcd->nStdIndex);
  433. break;
  434. }
  435. case _ITEM_ACTION_PICKUP:
  436. {
  437. sprintf(szQuery, "UPDATE TBL_CHARACTER_ITEM SET FLD_LOGINID='%s', FLD_CHARNAME='%s', "
  438. "FLD_DURA=%d, FLD_DURAMAX=%d, FLD_VALUE1=%d, FLD_VALUE2=%d, FLD_VALUE3=%d, FLD_VALUE4=%d, FLD_VALUE5=%d, "
  439. "FLD_VALUE6=%d, FLD_VALUE7=%d, FLD_VALUE8=%d, FLD_VALUE9=%d, FLD_VALUE10=%d, FLD_VALUE11=%d, FLD_VALUE12=%d, FLD_VALUE13=%d, "
  440. "FLD_VALUE14=%d, FLD_LASTOWNER='%s', FLD_LASTACTION=%d "
  441. "WHERE FLD_STDTYPE='%c' AND FLD_MAKEDATE='%s' AND FLD_MAKEINDEX='%s' AND FLD_STDINDEX=%d",
  442. m_pUserInfo->m_szUserID, m_pUserInfo->m_szCharName, lpMakeItemRcd->nDura, lpMakeItemRcd->nDuraMax, 
  443. lpMakeItemRcd->btValue[0], lpMakeItemRcd->btValue[1], lpMakeItemRcd->btValue[2], lpMakeItemRcd->btValue[3], 
  444. lpMakeItemRcd->btValue[5], lpMakeItemRcd->btValue[5], lpMakeItemRcd->btValue[6], lpMakeItemRcd->btValue[7], 
  445. lpMakeItemRcd->btValue[8], lpMakeItemRcd->btValue[9], lpMakeItemRcd->btValue[10], lpMakeItemRcd->btValue[11], 
  446. lpMakeItemRcd->btValue[12], lpMakeItemRcd->btValue[13], "WEMADE", _ITEM_ACTION_PICKUP,
  447. lpMakeItemRcd->szMakeIndex[0], szMakeDay, szMakeIndex, lpMakeItemRcd->nStdIndex);
  448. break;
  449. }
  450. case _ITEM_ACTION_UPDATE:
  451. {
  452. sprintf(szQuery, "UPDATE TBL_CHARACTER_ITEM SET "
  453. "FLD_DURA=%d, FLD_DURAMAX=%d, FLD_VALUE1=%d, FLD_VALUE2=%d, FLD_VALUE3=%d, FLD_VALUE4=%d, FLD_VALUE5=%d, "
  454. "FLD_VALUE6=%d, FLD_VALUE7=%d, FLD_VALUE8=%d, FLD_VALUE9=%d, FLD_VALUE10=%d, FLD_VALUE11=%d, FLD_VALUE12=%d, FLD_VALUE13=%d, "
  455. "FLD_VALUE14=%d, FLD_LASTOWNER='%s', FLD_LASTACTION=%d, FLD_PREFIXNAME='%s' "
  456. "WHERE FLD_STDTYPE='%c' AND FLD_MAKEDATE='%s' AND FLD_MAKEINDEX='%s' AND FLD_STDINDEX=%d",
  457. lpMakeItemRcd->nDura, lpMakeItemRcd->nDuraMax, 
  458. lpMakeItemRcd->btValue[0], lpMakeItemRcd->btValue[1], lpMakeItemRcd->btValue[2], lpMakeItemRcd->btValue[3], 
  459. lpMakeItemRcd->btValue[5], lpMakeItemRcd->btValue[5], lpMakeItemRcd->btValue[6], lpMakeItemRcd->btValue[7], 
  460. lpMakeItemRcd->btValue[8], lpMakeItemRcd->btValue[9], lpMakeItemRcd->btValue[10], lpMakeItemRcd->btValue[11], 
  461. lpMakeItemRcd->btValue[12], lpMakeItemRcd->btValue[13], m_pUserInfo->m_szCharName, _ITEM_ACTION_UPDATE, lpMakeItemRcd->szPrefixName,
  462. lpMakeItemRcd->szMakeIndex[0], szMakeDay, szMakeIndex, lpMakeItemRcd->nStdIndex);
  463. break;
  464. }
  465. default:
  466. return 0;
  467. }
  468. CRecordset *pRec = g_pConnGame->CreateRecordset();
  469. if ( !pRec->Execute( szQuery ) || pRec->GetRowCount() <= 0 )
  470. {
  471. InsertLogMsg(_T("UpdateItemToDB : 盎脚 坷幅"));
  472. g_pConnGame->DestroyRecordset( pRec );
  473. return 0;
  474. }
  475. g_pConnGame->DestroyRecordset( pRec );
  476. return 2;
  477. }
  478. void CPlayerObject::WeightChanged()
  479. {
  480. if (m_pUserInfo)
  481. {
  482. m_WAbility.Weight = m_pUserInfo->CalcBagWeight();
  483. UpdateProcess(this, RM_WEIGHTCHANGED, 0, 0, 0, 0, NULL); 
  484. }
  485. }
  486. void CPlayerObject::Whisper(char *pszChar, char *pszMsg)
  487. {
  488. char szChatMsg[512];
  489. int nLen;
  490. CPlayerObject* pPlayerObject = GetUserHuman(pszChar);
  491. if (pPlayerObject)
  492. {
  493. nLen = memlen(m_pUserInfo->m_szCharName);
  494. memmove(szChatMsg, m_pUserInfo->m_szCharName, (nLen - 1));
  495. memmove(&szChatMsg[nLen - 1], "=> ", 3);
  496. memmove(&szChatMsg[nLen + 2], pszMsg, memlen(pszMsg));
  497. pPlayerObject->AddProcess(this, RM_WHISPER, 0, 0, 0, 0, szChatMsg);
  498. }
  499. else
  500. {
  501. TCHAR wszMsg[64];
  502. nLen = memlen(pszChar);
  503. LoadString(g_hInst, IDS_CANTFIND_HUMAN, wszMsg, sizeof(wszMsg)/sizeof(TCHAR));
  504. memmove(szChatMsg, pszChar, (nLen - 1));
  505. WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, &szChatMsg[nLen - 1], sizeof(szChatMsg) - nLen, NULL, NULL);
  506. SysMsg(szChatMsg, 0);
  507. }
  508. }
  509. /*procedure TUserHuman.Whisper (whostr, saystr: string);
  510. var
  511.    hum: TUserHuman;
  512.    svidx: integer;
  513. begin
  514.    hum := TUserHuman (UserEngine.GetUserHuman (whostr));
  515.    if hum <> nil then begin
  516.       if not hum.ReadyRun then begin
  517.          SysMsg (whostr + '丛俊霸 皋技瘤甫 傈崔 且 荐 绝嚼聪促.', 0);
  518.          exit;
  519.       end;
  520.       if not hum.BoHearWhisper or hum.IsBlockWhisper (UserName) then begin
  521.          SysMsg (whostr + '丛篮 庇加富 芭何吝 涝聪促.', 0);
  522.          exit;
  523.       end;
  524.       hum.SendMsg (self, RM_WHISPER, 0, 0, 0, 0, UserName + '=> ' + saystr);
  525.    end else begin
  526.       if UserEngine.FindOtherServerUser (whostr, svidx) then begin
  527.          UserEngine.SendInterMsg (ISM_WHISPER, svidx, whostr + '/' + UserName + '=> ' + saystr);
  528.       end else
  529.          SysMsg (whostr + '丛阑 茫阑 荐 绝嚼聪促.', 0);
  530.    end;
  531. end;
  532. }
  533. */
  534. int CPlayerObject::CalcGetExp(int nTagLevel, int nTagHP)
  535. {
  536. int nExp;
  537. if (m_Ability.Level < nTagLevel + 10) nExp = nTagHP;
  538. else
  539. nExp = nTagHP - ROUND((nTagHP / 15) * (m_Ability.Level - (nTagLevel + 10)));
  540. if (nExp <= 0)
  541. nExp = 1;
  542. return nExp;
  543. }
  544. void CPlayerObject::AddBodyLuck(double fLuck)
  545. {
  546. /* if (fLuck > 0) && (
  547.    if (r > 0) and (BodyLuck < 5 * BODYLUCKUNIT) then
  548.       BodyLuck := BodyLuck + r;
  549.    if (r < 0) and (BodyLuck > -(5 * BODYLUCKUNIT)) then
  550.       BodyLuck := BodyLuck + r;
  551.    n := Trunc (BodyLuck / BODYLUCKUNIT);
  552.    if n > 5 then n := 5;
  553.    if n < -10 then n := -10;
  554.    BodyLuckLevel := n;
  555. end;
  556. */
  557. }
  558. void CPlayerObject::WinExp(int nExp)
  559. {
  560. m_Ability.Exp += nExp;
  561. AddBodyLuck (nExp * 0.002);
  562. AddProcess(this, RM_WINEXP, 0, nExp, 0, 0);
  563. if (m_Ability.Exp >= m_Ability.MaxExp)
  564. {
  565. m_Ability.Exp -= m_Ability.MaxExp;
  566. m_Ability.Level++;
  567. HasLevelUp(m_Ability.Level - 1);
  568. AddBodyLuck (100);
  569. /*      AddUserLog ('肪诀_' +
  570.                   UserName + '_' +
  571.                   IntToStr(Abil.Level) + '_' +
  572.                   IntToStr(Abil.Exp)); */
  573. }
  574. }
  575. void CPlayerObject::GainExp(int nExp)
  576. {
  577. WinExp(nExp);
  578. }
  579. /*
  580. procedure TCreature.GainExp (exp: longword);
  581. var
  582.    i, n, sumlv, dexp: integer;
  583.    cret: TCreature;
  584. const
  585.    bonus: array[0..GROUPMAX] of Real = (1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 2.1, 2.2);
  586. begin
  587.    try
  588.       if GroupOwner <> nil then begin
  589.          sumlv := 0;
  590.          n := 0;
  591.          for i:=0 to GroupOwner.GroupMembers.Count-1 do begin
  592.             cret := TCreature(GroupOwner.GroupMembers.Objects[i]);
  593.             if not cret.Death and (PEnvir = cret.PEnvir) and (abs(CX-cret.CX) <= 12) and (abs(CY-cret.CY) <= 12) then begin
  594.                sumlv := sumlv + cret.Abil.Level;
  595.                Inc (n);
  596.             end;
  597.          end;
  598.          if (sumlv > 0) and (n > 1) then begin
  599.             if n in [0..GROUPMAX] then
  600.                exp := Round (exp * bonus[n]);
  601.             for i:=0 to GroupOwner.GroupMembers.Count-1 do begin
  602.                cret := TCreature(GroupOwner.GroupMembers.Objects[i]);
  603.                if not cret.Death and (PEnvir = cret.PEnvir) and (abs(CX-cret.CX) <= 12) and (abs(CY-cret.CY) <= 12) then
  604.                   cret.WinExp (Round (exp / sumlv * cret.Abil.Level));
  605.             end;
  606.          end else
  607.             WinExp (exp);
  608.       end else
  609.          WinExp (exp);
  610.    except
  611.       MainOutMessage ('[Exception] TCreature.GainExp');
  612.    end;
  613. end;
  614. */
  615. void CPlayerObject::HasLevelUp(int nPrevLevel)
  616. {
  617.    m_Ability.MaxExp = NEEDEXPS[m_Ability.Level];
  618.    RecalcLevelAbilitys();
  619. /*
  620. {$IFDEF FOR_ABIL_POINT}
  621. //4/16老 何磐 利侩
  622.    if prevlevel + 1 = Abil.Level then begin
  623.       BonusPoint := BonusPoint + GetBonusPoint (Job, Abil.Level);  //肪诀俊 蝶弗 焊呈胶
  624.       SendMsg (self, RM_ADJUST_BONUS, 0, 0, 0, 0, '');
  625.    end else begin
  626.       if prevlevel <> Abil.Level then begin
  627.          //焊呈胶 器牢飘甫 贸澜何磐 促矫 拌魂茄促.
  628.          BonusPoint := GetLevelBonusSum (Job, Abil.Level);
  629.          FillChar (BonusAbil, sizeof(TNakedAbility), #0);
  630.          FillChar (CurBonusAbil, sizeof(TNakedAbility), #0);
  631.          //if prevlevel <> 0 then begin
  632.          RecalcLevelAbilitys;  //饭骇俊 蝶弗 瓷仿摹甫 拌魂茄促.
  633.          //end else begin
  634.          //   RecalcLevelAbilitys_old;
  635.          //   BonusPoint := 0;
  636.          //end;
  637.          SendMsg (self, RM_ADJUST_BONUS, 0, 0, 0, 0, '');
  638.       end;
  639.    end;
  640. {$ENDIF}
  641. */
  642. RecalcAbilitys();
  643. AddProcess(this, RM_LEVELUP, 0, m_Ability.Exp, 0, 0, NULL);
  644. }
  645. void CPlayerObject::RecalcHitSpeed()
  646. {
  647. m_nHitDouble = 0;
  648. /*HitPoint := DEFHIT + BonusAbil.Hit;*/
  649. m_btHitPoint = 5;
  650.    /*case Job of
  651.       2: SpeedPoint := DEFSPEED + BonusAbil.Speed + 3;  //档荤绰 扁夯 刮酶捞 臭促.
  652.       else SpeedPoint := DEFSPEED + BonusAbil.Speed;
  653.    end;*/
  654. if (m_pUserInfo->GetJob() == 2)
  655. m_btSpeedPoint = DEFSPEED + 3;
  656. else
  657. m_btSpeedPoint = DEFSPEED;
  658. m_pUserInfo->m_lpTMagicErgumSkill = NULL;
  659. m_pUserInfo->m_lpTMagicBanwolSkill = NULL;
  660. m_pUserInfo->m_lpTMagicFireSwordSkill = NULL;
  661. m_pUserInfo->m_lpTMagicOneSwordSkill = NULL;
  662. m_pUserInfo->m_lpTMagicIlkwangSkill = NULL;
  663. m_pUserInfo->m_lpTMagicPowerHitSkill = NULL;
  664. PLISTNODE pListNode = m_pUserInfo->m_lpTMagicRcd.GetHead();
  665. while (pListNode)
  666. {
  667. _LPTHUMANMAGICRCD lptUserMagicRcd = m_pUserInfo->m_lpTMagicRcd.GetData(pListNode);
  668. switch (lptUserMagicRcd->btMagicID)
  669. {
  670. case _SKILL_ILKWANG:
  671. {
  672. m_pUserInfo->m_lpTMagicIlkwangSkill = lptUserMagicRcd;
  673. if (lptUserMagicRcd->btLevel > 0)
  674. m_btHitPoint += ROUND(8 / 3 * lptUserMagicRcd->btLevel);
  675. break;
  676. }
  677. case _SKILL_ERGUM:
  678. m_pUserInfo->m_lpTMagicErgumSkill = lptUserMagicRcd;
  679. break;
  680. case _SKILL_BANWOL:
  681. m_pUserInfo->m_lpTMagicBanwolSkill = lptUserMagicRcd;
  682. break;
  683. case _SKILL_FIRESWORD:
  684. {
  685. m_pUserInfo->m_lpTMagicFireSwordSkill = lptUserMagicRcd;
  686. m_nHitDouble = 4 + lptUserMagicRcd->btLevel * 4;  //+40% ~ +160%
  687. break;
  688. }
  689. case _SKILL_ONESWORD:
  690. {
  691. m_pUserInfo->m_lpTMagicOneSwordSkill = lptUserMagicRcd;
  692. if (lptUserMagicRcd->btLevel > 0)
  693. m_btHitPoint += ROUND(9 / 3 * lptUserMagicRcd->btLevel);
  694. break;
  695. }
  696. case _SKILL_YEDO:
  697. {
  698. m_pUserInfo->m_lpTMagicPowerHitSkill = lptUserMagicRcd;
  699. if (lptUserMagicRcd->btLevel > 0)
  700. m_btHitPoint += ROUND(3 / 3 * lptUserMagicRcd->btLevel);
  701. m_btHitPlus = 5 + lptUserMagicRcd->btLevel;
  702. m_pUserInfo->m_btAttackSkillCount = 7 - lptUserMagicRcd->btLevel;
  703. m_pUserInfo->m_btAttackSkillPointCount = rand() % m_pUserInfo->m_btAttackSkillCount;
  704. break;
  705. }
  706. }
  707. pListNode = m_pUserInfo->m_lpTMagicRcd.GetNext(pListNode);
  708. }
  709. }
  710. void CPlayerObject::RecalcAbilitys()
  711. {
  712. BOOL fCGHI[4];
  713. m_btAntiPoison = 0;
  714. m_btPoisonRecover = 0;
  715. m_btHealthRecover = 0;
  716. m_btSpellRecover = 0;
  717. m_btAntiMagic = 1;   //扁夯 10%
  718. m_sHitSpeed = 0;
  719. fCGHI[0] = FALSE;
  720. fCGHI[1] = FALSE;
  721. fCGHI[2] = FALSE;
  722. fCGHI[3] = FALSE;
  723. BOOL fOldHumHideMode = m_fHumHideMode;
  724. ZeroMemory(&m_AddAbility, sizeof(m_AddAbility));
  725. m_WAbility = m_Ability;
  726. m_WAbility.Weight = 0;
  727. m_WAbility.HandWeight = 0;
  728. m_WAbility.WearWeight = 0;
  729. _LPTUSERITEMRCD lpUserItemRcd = NULL;
  730. for (int i = U_DRESS; i <= U_RINGR; i++)
  731. {
  732. if (lpUserItemRcd = m_pUserInfo->GetAccessory(i))
  733. {
  734. g_pStdItemSpecial[lpUserItemRcd->nStdIndex].ApplyItemParameters(&m_AddAbility);
  735. if ( i == U_RIGHTHAND || i == U_WEAPON )
  736. m_WAbility.HandWeight += g_pStdItemSpecial[lpUserItemRcd->nStdIndex].wWeight;
  737. else
  738. m_WAbility.WearWeight += g_pStdItemSpecial[lpUserItemRcd->nStdIndex].wWeight; 
  739. if ( i == U_WEAPON )
  740. m_AddAbility.WeaponStrong = (BYTE)g_pStdItemSpecial[lpUserItemRcd->nStdIndex].dwRSource; // 公扁狼 碍档. 碍档啊 臭栏搁 肋 救 磺俺咙
  741. }
  742. }
  743. m_WAbility.Weight = m_pUserInfo->CalcBagWeight();
  744. // BEGIN:篮脚贱
  745. if ((m_fFixedHideMode) && (m_wStatusArr[STATE_TRANSPARENT] > 0))
  746. m_fHumHideMode = TRUE;
  747. if (m_fHumHideMode)
  748. {
  749. if (!fOldHumHideMode)
  750. {
  751. m_nCharStatus = GetCharStatus();
  752. AddRefMsg(RM_CHARSTATUSCHANGED, m_sHitSpeed/*wparam*/, m_nCharStatus, 0, 0, NULL);
  753. }
  754. }
  755. else
  756. {
  757. if (fOldHumHideMode)
  758. {
  759. m_wStatusArr[STATE_TRANSPARENT] = 0;
  760. m_nCharStatus = GetCharStatus();
  761. AddRefMsg(RM_CHARSTATUSCHANGED, m_sHitSpeed/*wparam*/, m_nCharStatus, 0, 0, NULL);
  762. }
  763. }
  764. // END:篮脚贱
  765. RecalcHitSpeed();
  766. // BEGIN:Light (Candle)
  767. BYTE btOldLight = m_btLight;
  768. _LPTGENERALITEMRCD lpTItemRcd = m_pUserInfo->GetRightHand();
  769. if (lpTItemRcd)
  770. {
  771. if (lpTItemRcd->nDura > 0)
  772. m_btLight = 8;
  773. else
  774. m_btLight = 2;
  775. }
  776. else
  777. m_btLight = 2;
  778. if (btOldLight != m_btLight)
  779. AddRefMsg(RM_CHANGELIGHT, 0, 0, 0, 0, NULL);
  780. // END
  781. m_btAntiMagic += m_AddAbility.AntiMagic;
  782. m_btHitPoint += m_AddAbility.HIT;
  783. m_btSpeedPoint += m_AddAbility.SPEED;
  784. m_btAntiPoison += m_AddAbility.AntiPoison;
  785. m_btPoisonRecover += m_AddAbility.PoisonRecover;
  786. m_btHealthRecover += m_AddAbility.HealthRecover;
  787. m_btSpellRecover += m_AddAbility.SpellRecover;
  788. m_sHitSpeed += m_AddAbility.HitSpeed;
  789. //   Luck := Luck + AddAbil.Luck;
  790. //   Luck := Luck - AddAbil.UnLuck;
  791. m_WAbility.MaxHP = m_Ability.MaxHP + m_AddAbility.HP;
  792. m_WAbility.MaxMP = m_Ability.MaxMP + m_AddAbility.MP;
  793. m_WAbility.AC = MAKEWORD(LOBYTE(m_AddAbility.AC)  + LOBYTE(m_Ability.AC),  HIBYTE(m_AddAbility.AC)  + HIBYTE(m_Ability.AC));
  794. m_WAbility.MAC = MAKEWORD(LOBYTE(m_AddAbility.MAC) + LOBYTE(m_Ability.MAC), HIBYTE(m_AddAbility.MAC) + HIBYTE(m_Ability.MAC));
  795. m_WAbility.DC = MAKEWORD(LOBYTE(m_AddAbility.DC)  + LOBYTE(m_Ability.DC),  HIBYTE(m_AddAbility.DC)  + HIBYTE(m_Ability.DC));
  796. m_WAbility.MC = MAKEWORD(LOBYTE(m_AddAbility.MC)  + LOBYTE(m_Ability.MC),  HIBYTE(m_AddAbility.MC)  + HIBYTE(m_Ability.MC));
  797. m_WAbility.SC = MAKEWORD(LOBYTE(m_AddAbility.SC)  + LOBYTE(m_Ability.SC),  HIBYTE(m_AddAbility.SC)  + HIBYTE(m_Ability.SC));
  798. if (m_wStatusArr[STATE_DEFENCEUP] > 0) // 规绢仿 惑铰
  799. m_WAbility.AC = MAKEWORD(LOBYTE(m_WAbility.AC), HIBYTE(m_WAbility.AC) + 2 + (m_Ability.Level / 7));
  800. if (m_wStatusArr[STATE_MAGDEFENCEUP] > 0) // 付亲仿 惑铰
  801. m_WAbility.MAC = MAKEWORD(LOBYTE(m_WAbility.MAC), HIBYTE(m_WAbility.MAC) + 2 + (m_Ability.Level / 7));
  802. UpdateProcess(this, RM_CHARSTATUSCHANGED, m_sHitSpeed/*wparam*/, m_nCharStatus, 0, 0, NULL);
  803. }
  804. void CPlayerObject::ServerGetMagicKeyChange(int nMagicID, int nUseKey)
  805. {
  806. PLISTNODE pListNode = m_pUserInfo->m_lpTMagicRcd.GetHead();
  807. while (pListNode)
  808. {
  809. _LPTHUMANMAGICRCD lptUserMagicRcd = m_pUserInfo->m_lpTMagicRcd.GetData(pListNode);
  810. if (lptUserMagicRcd)
  811. {
  812. if (lptUserMagicRcd->btMagicID == nMagicID)
  813. {
  814. lptUserMagicRcd->btUseKey = nUseKey;
  815. break;
  816. }
  817. }
  818. pListNode = m_pUserInfo->m_lpTMagicRcd.GetNext(pListNode);
  819. }
  820. }
  821. void CPlayerObject::SendMyMagics()
  822. {
  823. char szEncodeMsg[4096];
  824. int nPos = 0;
  825. _TDEFAULTMESSAGE DefMsg;
  826. int nCnt = m_pUserInfo->EncodeMyMagic(szEncodeMsg, sizeof(szEncodeMsg), nPos);
  827. szEncodeMsg[nPos] = '';
  828. fnMakeDefMessage(&DefMsg, SM_SENDMYMAGIC, 0, 0, 0, nCnt);
  829. SendSocket(&DefMsg, szEncodeMsg);
  830. }
  831. void CPlayerObject::SendBagItems()
  832. {
  833. char szEncodeMsg[8096];
  834. int nCnt = m_pUserInfo->m_lpTItemRcd.GetCount();
  835. int nGenCnt = m_pUserInfo->m_lpTGenItemRcd.GetCount();
  836. int nPos = 0;
  837. _TCLIENTITEMRCD tClientItemRcd;
  838. _TDEFAULTMESSAGE DefMsg;
  839. if (nCnt)
  840. {
  841. PLISTNODE pListNode = m_pUserInfo->m_lpTItemRcd.GetHead();
  842. while (pListNode)
  843. {
  844. _LPTUSERITEMRCD lptUserItemRcd = m_pUserInfo->m_lpTItemRcd.GetData(pListNode);
  845. if (lptUserItemRcd)
  846. {
  847. g_pStdItemSpecial[lptUserItemRcd->nStdIndex].GetStandardItem(&tClientItemRcd);
  848. g_pStdItemSpecial[lptUserItemRcd->nStdIndex].GetUpgradeStdItem(&tClientItemRcd, lptUserItemRcd);
  849. memcpy(tClientItemRcd.szMakeIndex, lptUserItemRcd->szMakeIndex, 12);
  850. tClientItemRcd.nDura = lptUserItemRcd->nDura;
  851. tClientItemRcd.nDuraMax = lptUserItemRcd->nDuraMax;
  852. if (strlen(lptUserItemRcd->szPrefixName))
  853. strcpy(tClientItemRcd.tStdItem.szPrefixName, lptUserItemRcd->szPrefixName);
  854. else
  855. ZeroMemory(tClientItemRcd.tStdItem.szPrefixName, sizeof(tClientItemRcd.tStdItem.szPrefixName));
  856. nPos += fnEncode6BitBufA((unsigned char *)&tClientItemRcd, &szEncodeMsg[nPos], sizeof(_TCLIENTITEMRCD), sizeof(szEncodeMsg) - nPos);
  857. szEncodeMsg[nPos++] = '/';
  858. }
  859. pListNode = m_pUserInfo->m_lpTItemRcd.GetNext(pListNode);
  860. }
  861. }
  862. if (nGenCnt)
  863. {
  864. char szVal[5];
  865. ZeroMemory(szVal, sizeof(szVal));
  866. PLISTNODE pListNode = m_pUserInfo->m_lpTGenItemRcd.GetHead();
  867. while (pListNode)
  868. {
  869. _LPTGENERALITEMRCD lptGenItemRcd = m_pUserInfo->m_lpTGenItemRcd.GetData(pListNode);
  870. if (lptGenItemRcd)
  871. {
  872. memcpy(tClientItemRcd.szMakeIndex, lptGenItemRcd->szMakeIndex, 12);
  873. tClientItemRcd.nDura = lptGenItemRcd->nDura;
  874. tClientItemRcd.nDuraMax = lptGenItemRcd->nDuraMax;
  875. g_pStdItemEtc[lptGenItemRcd->nStdIndex].GetStandardItem(&tClientItemRcd);
  876. nPos += fnEncode6BitBufA((unsigned char *)&tClientItemRcd, &szEncodeMsg[nPos], sizeof(_TCLIENTITEMRCD), sizeof(szEncodeMsg) - nPos);
  877. szEncodeMsg[nPos++] = '/';
  878. }
  879. pListNode = m_pUserInfo->m_lpTGenItemRcd.GetNext(pListNode);
  880. }
  881. }
  882. szEncodeMsg[nPos] = '';
  883. fnMakeDefMessage(&DefMsg, SM_BAGITEMS, (int)this, 0, 0, nCnt + nGenCnt);
  884. SendSocket(&DefMsg, szEncodeMsg);
  885. }
  886. void CPlayerObject::RecalcLevelAbilitys()
  887. {
  888. int n;
  889. float nLevel = m_Ability.Level;
  890. switch (m_pUserInfo->m_THumanRcd.btJob)
  891. {
  892. case 2: // 档荤
  893. {
  894.             m_Ability.MaxHP = 14 + ROUND((nLevel / 6 + 2.5) * nLevel);
  895.             m_Ability.MaxMP = 13 + ROUND((nLevel / 8)* 2.2 * nLevel);
  896.             m_Ability.MaxWeight = 50 + ROUND((nLevel / 4) * nLevel);
  897.             m_Ability.MaxWearWeight = 15 + ROUND((nLevel / 50) * nLevel);
  898.             m_Ability.MaxHandWeight = 12 + ROUND((nLevel / 42) * nLevel);
  899.             n = (int)nLevel / 7;
  900.             
  901. m_Ability.DC = MAKEWORD(_MAX(n-1, 0), _MAX(1, n));
  902.             m_Ability.MC = 0;
  903.             m_Ability.SC = MAKEWORD(_MAX(n-1, 0), _MAX(1, n));
  904.             m_Ability.AC = 0;
  905.             
  906. n = ROUND(nLevel / 6);
  907.             m_Ability.MAC = MAKEWORD(n / 2, n + 1);
  908. break;
  909. }
  910. case 1: // 贱荤
  911. {
  912.             m_Ability.MaxHP = 14 + ROUND((nLevel / 15 + 1.8) * nLevel);
  913.             m_Ability.MaxMP = 13 + ROUND((nLevel / 5 + 2) * 2.2 * nLevel);
  914.             m_Ability.MaxWeight = 50 + ROUND((nLevel / 5) * nLevel);
  915.             m_Ability.MaxWearWeight = 15 + ROUND((nLevel / 100) * nLevel);
  916.             m_Ability.MaxHandWeight = 12 + ROUND((nLevel / 90) * nLevel);
  917.             n = (int)nLevel / 7;
  918. m_Ability.DC = MAKEWORD(_MAX(n-1, 0), _MAX(1, n));
  919.             m_Ability.MC = MAKEWORD(_MAX(n-1, 0), _MAX(1, n));
  920.             m_Ability.SC = 0;
  921.             m_Ability.AC = 0;
  922.             m_Ability.MAC = 0;
  923. break;
  924. }
  925. case 0: // 傈荤
  926. {
  927.             m_Ability.MaxHP = 14 + ROUND((nLevel / 4 + 4) * nLevel);
  928.             m_Ability.MaxMP = 11 + (int)(nLevel * 2);
  929.             m_Ability.MaxWeight = 50 + ROUND((nLevel / 3) * nLevel);
  930.             m_Ability.MaxWearWeight = 15 + ROUND((nLevel / 20) * nLevel);
  931.             m_Ability.MaxHandWeight = 12 + ROUND((nLevel / 13) * nLevel);
  932.             m_Ability.DC = MAKEWORD(_MAX((int)(nLevel / 7) - 1, 1), _MAX(1, int(nLevel / 5)));
  933.             m_Ability.SC = 0;
  934.             m_Ability.MC = 0;
  935.             m_Ability.AC = MAKEWORD(0, int(nLevel / 7));
  936.             m_Ability.MAC = 0;
  937. break;
  938. }
  939. }
  940. if (m_Ability.HP > m_Ability.MaxHP) m_Ability.HP = m_Ability.MaxHP;
  941. if (m_Ability.MP > m_Ability.MaxMP) m_Ability.MP = m_Ability.MaxMP;
  942. }
  943. void CPlayerObject::Initialize()
  944. {
  945. if (!m_pUserInfo) return;
  946. m_dwLatestHitTime = 0;
  947. m_nHitTimeOverCount = 0;
  948. m_nCurrX = m_pUserInfo->m_THumanRcd.nCX;
  949. m_nCurrY = m_pUserInfo->m_THumanRcd.nCY;
  950. m_nDirection = m_pUserInfo->m_THumanRcd.nDirection;
  951. m_pMap = GetMap(m_pUserInfo->m_THumanRcd.szMapName);
  952. memcpy(m_szName, m_pUserInfo->m_szCharName, memlen(m_pUserInfo->m_szCharName));
  953. if (m_pMap)
  954. {
  955. AddProcess(this, RM_LOGON, 0, 0, 0, 0, NULL); 
  956. m_pMap->AddNewObject(m_nCurrX, m_nCurrY, OS_MOVINGOBJECT, this);
  957. AddRefMsg(RM_TURN, m_nDirection, m_nCurrX, m_nCurrY, 0, NULL);
  958. m_Ability.Level = m_pUserInfo->m_THumanRcd.szLevel;
  959. m_Ability.Exp = m_pUserInfo->m_THumanRcd.nExp;
  960. m_Ability.MaxExp = NEEDEXPS[m_Ability.Level];
  961. RecalcLevelAbilitys();
  962. RecalcAbilitys();
  963. m_btBright = g_nMirDayTime;
  964. AddProcess(this, RM_ABILITY, 0, 0, 0, 0, NULL);
  965. AddProcess(this, RM_SUBABILITY, 0, 0, 0, 0, NULL);
  966. AddProcess(this, RM_DAYCHANGING, 0, 0, 0, 0, NULL);
  967. AddProcess(this, RM_SENDUSEITEMS, 0, 0, 0, 0, NULL);
  968. AddProcess(this, RM_SENDMYMAGIC, 0, 0, 0, 0, NULL);
  969. // BEGIN : Send Attack Mode Msg
  970. TCHAR wszMsg[128];
  971. char szMsg[128];
  972. LoadString(g_hInst, m_pUserInfo->GetAttackMode() + IDS_ATTACKMODE_ALL, wszMsg, sizeof(wszMsg)/sizeof(TCHAR));
  973. WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szMsg, sizeof(szMsg), NULL, NULL);
  974. SysMsg(szMsg, 1);
  975. LoadString(g_hInst, IDS_ATTACKMODE_CHGMODE, wszMsg, sizeof(wszMsg)/sizeof(TCHAR));
  976. WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szMsg, sizeof(szMsg), NULL, NULL);
  977. SysMsg(szMsg, 1);
  978. // END : Send Attack Mode Msg
  979. }
  980. }
  981. /*
  982. void CPlayerObject::SendSocket(_LPTDEFAULTMESSAGE lpDefMsg, char *pszPacket)
  983. {
  984. DWORD dwBytesSends = 0;
  985. _TMSGHEADER MsgHdr;
  986. MsgHdr.nCode = 0xAA55AA55;
  987. MsgHdr.wIdent = GM_DATA;
  988. MsgHdr.wUserGateIndex = m_pUserInfo->m_nUserGateIndex;
  989. MsgHdr.wUserListIndex = m_pUserInfo->m_nUserServerIndex;
  990. MsgHdr.nSocket = m_pUserInfo->m_sock;
  991. if (lpDefMsg)
  992. {
  993. if (pszPacket)
  994. {
  995. int nLength = memlen(pszPacket);
  996. if (nLength >= 256) return; // If pszPacket is too long.
  997. MsgHdr.nLength = sizeof(_TDEFAULTMESSAGE) + nLength;
  998. m_pUserInfo->m_pGateInfo->OverlappedEx[1].DataBuf.len = sizeof(_TMSGHEADER) + MsgHdr.nLength;
  999. memmove(m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer, (char *)&MsgHdr, sizeof(_TMSGHEADER));
  1000. memmove(&m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer[sizeof(_TMSGHEADER)], lpDefMsg, sizeof(_TDEFAULTMESSAGE));
  1001. memmove(&m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer[sizeof(_TMSGHEADER) + sizeof(_TDEFAULTMESSAGE)], pszPacket, MsgHdr.nLength - sizeof(_TDEFAULTMESSAGE));
  1002. m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer[m_pUserInfo->m_pGateInfo->OverlappedEx[1].DataBuf.len] = '';
  1003. }
  1004. else
  1005. {
  1006. MsgHdr.nLength = sizeof(_TDEFAULTMESSAGE);
  1007. m_pUserInfo->m_pGateInfo->OverlappedEx[1].DataBuf.len = sizeof(_TMSGHEADER) + MsgHdr.nLength;
  1008. memmove(m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer, (char *)&MsgHdr, sizeof(_TMSGHEADER));
  1009. memmove(&m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer[sizeof(_TMSGHEADER)], lpDefMsg, sizeof(_TDEFAULTMESSAGE));
  1010. m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer[m_pUserInfo->m_pGateInfo->OverlappedEx[1].DataBuf.len] = '';
  1011. }
  1012. }
  1013. else
  1014. {
  1015. int nLen = (memlen(pszPacket) - 1);
  1016. MsgHdr.nLength = -(nLen);
  1017. m_pUserInfo->m_pGateInfo->OverlappedEx[1].DataBuf.len = sizeof(_TMSGHEADER) + nLen;
  1018. memmove(m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer, (char *)&MsgHdr, sizeof(_TMSGHEADER));
  1019. memmove(&m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer[sizeof(_TMSGHEADER)], pszPacket, nLen);
  1020. m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer[m_pUserInfo->m_pGateInfo->OverlappedEx[1].DataBuf.len] = '';
  1021. }
  1022. m_pUserInfo->m_pGateInfo->OverlappedEx[1].nOvFlag = OVERLAPPED_SEND;
  1023. m_pUserInfo->m_pGateInfo->OverlappedEx[1].DataBuf.buf = m_pUserInfo->m_pGateInfo->OverlappedEx[1].Buffer;
  1024. WSASend(m_pUserInfo->m_pGateInfo->m_sock, &m_pUserInfo->m_pGateInfo->OverlappedEx[1].DataBuf, 1, &dwBytesSends, 0, (OVERLAPPED *)&m_pUserInfo->m_pGateInfo->OverlappedEx[1], NULL);
  1025. }
  1026. */
  1027. BOOL CPlayerObject::DoRideHorse(int nDir, int fRideFlag)
  1028. {
  1029. // if (fRideFlag == m_xAbility.m_fRideHorse)
  1030. // {
  1031. /* if (m_xAbility.m_fRideHorse)
  1032. AddRefMsg(RM_RIDE, 0, 0, 0, 0, NULL);
  1033. else
  1034. AddRefMsg(RM_RIDE, 1, 0, 0, 0, NULL);
  1035. */
  1036. // return TRUE;
  1037. // }
  1038. return FALSE;
  1039. }
  1040. void CPlayerObject::MakeFeature()
  1041. {
  1042. m_tFeature.btGender = m_pUserInfo->GetGenderFeature();
  1043. m_tFeature.btWear = m_pUserInfo->GetDressFeature();
  1044. m_tFeature.btHair = m_pUserInfo->GetHairFeature();
  1045. m_tFeature.btWeapon = m_pUserInfo->GetWeaponFeature();
  1046. m_tFeatureEx.btHorse = m_pUserInfo->GetHorseFeatureEx();
  1047. m_tFeatureEx.dwHairColor = 0xFFFF;
  1048. m_tFeatureEx.dwWearColor = 0xFFFF;
  1049. }
  1050. BOOL CPlayerObject::CheckTakeOnItem(WORD wWhere, _LPTUSERITEMRCD lpTItemRcd)
  1051. {
  1052. TCHAR wszMsg[64];
  1053. char szMsg[64];
  1054. int nNeed = g_pStdItemSpecial[lpTItemRcd->nStdIndex].wNeed;
  1055. int nNeedLevel = g_pStdItemSpecial[lpTItemRcd->nStdIndex].wNeedLevel;;
  1056. int nWeight = g_pStdItemSpecial[lpTItemRcd->nStdIndex].wWeight;
  1057. if (wWhere == U_DRESS)
  1058. {
  1059. if (lpTItemRcd->szMakeIndex[0] != 'B') return FALSE;
  1060. if (g_pStdItemSpecial[lpTItemRcd->nStdIndex].wStdMode == 10) // 巢磊渴
  1061. {
  1062. if (m_tFeature.btGender != 0)
  1063. {
  1064. LoadString(g_hInst, IDS_MALE_WEAR, wszMsg, sizeof(wszMsg)/sizeof(TCHAR));
  1065. WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szMsg, sizeof(szMsg), NULL, NULL);
  1066. SysMsg(szMsg, 0);
  1067. return FALSE;
  1068. }
  1069. }
  1070. else if (g_pStdItemSpecial[lpTItemRcd->nStdIndex].wStdMode == 11) // 咯磊渴
  1071. {
  1072. if (m_tFeature.btGender != 1)
  1073. {
  1074. LoadString(g_hInst, IDS_FEMALE_WEAR, wszMsg, sizeof(wszMsg)/sizeof(TCHAR));
  1075. WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szMsg, sizeof(szMsg), NULL, NULL);
  1076. SysMsg(szMsg, 0);
  1077. return FALSE;
  1078. }
  1079. }
  1080. }
  1081.    
  1082. if ((wWhere == U_WEAPON) || (wWhere == U_RIGHTHAND))
  1083. {
  1084. if (m_WAbility.MaxHandWeight < nWeight)
  1085. {
  1086. LoadString(g_hInst, IDS_NOTENOUGH_VALUE, wszMsg, sizeof(wszMsg)/sizeof(TCHAR));
  1087. WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szMsg, sizeof(szMsg), NULL, NULL);
  1088. SysMsg(szMsg, 0);
  1089. return FALSE;
  1090. }
  1091. }
  1092. else
  1093. {
  1094. if (m_WAbility.MaxWearWeight < nWeight + m_pUserInfo->CalcWearWeightEx(wWhere))
  1095. {
  1096. LoadString(g_hInst, IDS_NOTENOUGH_WEIGHT, wszMsg, sizeof(wszMsg)/sizeof(TCHAR));
  1097. WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szMsg, sizeof(szMsg), NULL, NULL);
  1098. SysMsg(szMsg, 0);
  1099. return FALSE;
  1100. }
  1101. }
  1102. switch (nNeed)
  1103. {
  1104. case 0:
  1105. if (m_WAbility.Level < nNeedLevel) goto _NOTENOUGH_VALUE;
  1106. break;
  1107. case 1:
  1108. if (HIBYTE(m_WAbility.DC) < nNeedLevel) goto _NOTENOUGH_VALUE;
  1109. break;
  1110. case 2:
  1111. if (HIBYTE(m_WAbility.MC) < nNeedLevel) goto _NOTENOUGH_VALUE;
  1112. break;
  1113. case 3:
  1114. if (HIBYTE(m_WAbility.SC) < nNeedLevel) goto _NOTENOUGH_VALUE;
  1115. break;
  1116. }
  1117. return TRUE;
  1118. _NOTENOUGH_VALUE:
  1119. LoadString(g_hInst, IDS_NOTENOUGH_VALUE, wszMsg, sizeof(wszMsg)/sizeof(TCHAR));
  1120. WideCharToMultiByte(CP_ACP, 0, wszMsg, -1, szMsg, sizeof(szMsg), NULL, NULL);
  1121. SysMsg(szMsg, 0);
  1122. return FALSE;
  1123. }
  1124. void CPlayerObject::ServerGetTakeOnGenItem(WORD wWhere, char *pszItemIndex)
  1125. {
  1126. _LPTGENERALITEMRCD lpTGenItemRcd = NULL;
  1127. _TDEFAULTMESSAGE DefMsg;
  1128. if (m_pUserInfo->m_lpTGenItemRcd.GetCount())
  1129. {
  1130. PLISTNODE pListNode = m_pUserInfo->m_lpTGenItemRcd.GetHead();
  1131. while (pListNode)
  1132. {
  1133. lpTGenItemRcd = m_pUserInfo->m_lpTGenItemRcd.GetData(pListNode);
  1134. if (memcmp(pszItemIndex, lpTGenItemRcd->szMakeIndex, _MAKEITEMINDEX) == 0)
  1135. {
  1136. memcpy(m_pUserInfo->m_THumanRcd.szTakeItem[wWhere], lpTGenItemRcd->szMakeIndex, _MAKEITEMINDEX);
  1137. RecalcAbilitys();
  1138. LONG lFeature = GetFeatureToLong();
  1139. AddProcess(this, RM_ABILITY, 0, 0, 0, 0, NULL);
  1140. AddProcess(this, RM_SUBABILITY, 0, 0, 0, 0, NULL);
  1141. fnMakeDefMessage(&DefMsg, SM_TAKEON_OK, lFeature, 0, 0, 0);
  1142. SendSocket(&DefMsg, NULL);
  1143. AddRefMsg(RM_FEATURECHANGED, 0, lFeature, 0, 0, NULL);
  1144. return;
  1145. }
  1146. pListNode = m_pUserInfo->m_lpTGenItemRcd.GetNext(pListNode);
  1147. }
  1148. }
  1149. fnMakeDefMessage(&DefMsg, SM_TAKEON_FAIL, 2, 0, 0, 0);
  1150. SendSocket(&DefMsg, NULL);
  1151. }
  1152. void CPlayerObject::ServerGetTakeOnItem(WORD wWhere, char *pszItemIndex)
  1153. {
  1154. _TDEFAULTMESSAGE DefMsg;
  1155. _LPTUSERITEMRCD lpTItemRcd = m_pUserInfo->GetItem(pszItemIndex);
  1156. if (lpTItemRcd)
  1157. {
  1158. if (CheckTakeOnItem(wWhere, lpTItemRcd))
  1159. {
  1160. memcpy(m_pUserInfo->m_THumanRcd.szTakeItem[wWhere], lpTItemRcd->szMakeIndex, _MAKEITEMINDEX);
  1161. switch (wWhere)
  1162. {
  1163. case U_DRESS:
  1164. m_tFeature.btWear = m_pUserInfo->GetDressFeature();
  1165. break;
  1166. case U_WEAPON:
  1167. m_tFeature.btWeapon = m_pUserInfo->GetWeaponFeature();
  1168. break;
  1169. }
  1170. RecalcAbilitys();
  1171. LONG lFeature = GetFeatureToLong();
  1172. AddProcess(this, RM_ABILITY, 0, 0, 0, 0, NULL);
  1173. AddProcess(this, RM_SUBABILITY, 0, 0, 0, 0, NULL);
  1174. fnMakeDefMessage(&DefMsg, SM_TAKEON_OK, lFeature, 0, 0, 0);
  1175. SendSocket(&DefMsg, NULL);
  1176. AddRefMsg(RM_FEATURECHANGED, 0, lFeature, 0, 0, NULL);
  1177. return;
  1178. }
  1179. else
  1180. {
  1181. fnMakeDefMessage(&DefMsg, SM_TAKEON_FAIL, 1, 0, 0, 0);
  1182. SendSocket(&DefMsg, NULL);
  1183. return;
  1184. }
  1185. }
  1186. fnMakeDefMessage(&DefMsg, SM_TAKEON_FAIL, 2, 0, 0, 0);
  1187. SendSocket(&DefMsg, NULL);
  1188. }
  1189. void CPlayerObject::ServerGetTakeOffItem(WORD wWhere, char *pszItemIndex)
  1190. {
  1191. _LPTUSERITEMRCD lpTItemRcd = NULL;
  1192. _TDEFAULTMESSAGE DefMsg;
  1193. // PLISTNODE pListNode = m_pUserInfo->m_lpTItemRcd.GetHead();
  1194. // while (pListNode)
  1195. // {
  1196. // lpTItemRcd = m_pUserInfo->m_lpTItemRcd.GetData(pListNode);
  1197. if (memcmp(m_pUserInfo->m_THumanRcd.szTakeItem[wWhere], pszItemIndex, _MAKEITEMINDEX) == 0)
  1198. {
  1199. ZeroMemory(m_pUserInfo->m_THumanRcd.szTakeItem[wWhere], _MAKEITEMINDEX);
  1200. memcpy(m_pUserInfo->m_THumanRcd.szTakeItem[wWhere], "0", 2);
  1201. switch (wWhere)
  1202. {
  1203. case U_DRESS:
  1204. m_tFeature.btWear = m_pUserInfo->GetDressFeature();
  1205. break;
  1206. case U_WEAPON:
  1207. m_tFeature.btWeapon = m_pUserInfo->GetWeaponFeature();
  1208. break;
  1209. }
  1210. RecalcAbilitys();
  1211. LONG lFeature = GetFeatureToLong();
  1212. AddProcess(this, RM_ABILITY, 0, 0, 0, 0, NULL);
  1213. AddProcess(this, RM_SUBABILITY, 0, 0, 0, 0, NULL);
  1214. fnMakeDefMessage(&DefMsg, SM_TAKEOFF_OK, lFeature, 0, 0, 0);
  1215. SendSocket(&DefMsg, NULL);
  1216. AddRefMsg(RM_FEATURECHANGED, 0, lFeature, 0, 0, NULL);
  1217. }
  1218. else
  1219. {
  1220. fnMakeDefMessage(&DefMsg, SM_TAKEOFF_FAIL, 1, 0, 0, 0);
  1221. SendSocket(&DefMsg, NULL);
  1222. }
  1223. }
  1224. void CPlayerObject::SendMapName()
  1225. {
  1226. if (m_pMap)
  1227. {
  1228. _TDEFAULTMESSAGE DefMsg;
  1229. char szEncodeMsg[256];
  1230. fnMakeDefMessage(&DefMsg, SM_MAPDESCRIPTION, 0, 0, 0, 0);
  1231. int nPos = fnEncode6BitBufA((unsigned char *)m_pMap->m_szMapTextName, szEncodeMsg, memlen(m_pMap->m_szMapTextName) - 1, sizeof(szEncodeMsg));
  1232. szEncodeMsg[nPos] = '';
  1233. SendSocket(&DefMsg, szEncodeMsg);
  1234. }
  1235. }
  1236. void CPlayerObject::SendNewMap()
  1237. {
  1238. if (m_pMap)
  1239. {
  1240. _TDEFAULTMESSAGE DefMsg;
  1241. char szEncodeMsg[256];
  1242. fnMakeDefMessage(&DefMsg, SM_NEWMAP, (int)this, m_nCurrX, m_nCurrY, MAKEWORD(DayBright(), m_pMap->m_btSeries));
  1243. int nPos = fnEncode6BitBufA((unsigned char *)m_pMap->m_szMapName, szEncodeMsg, memlen(m_pMap->m_szMapName) - 1, sizeof(szEncodeMsg));
  1244. szEncodeMsg[nPos] = '';
  1245. SendSocket(&DefMsg, szEncodeMsg);
  1246. }
  1247. }
  1248. BYTE CPlayerObject::DayBright()
  1249. {
  1250. int n;
  1251. //               begin
  1252. //                  if PEnvir.Darkness then n := 1
  1253. //                  else
  1254. if (m_btBright == 1)
  1255. n = 0;
  1256. else if (m_btBright == 3)
  1257. n = 1;
  1258. else
  1259. n = 2;
  1260. /*                  if PEnvir.DayLight then n := 0; */
  1261. return n;
  1262. }
  1263. void CPlayerObject::Run()
  1264. {
  1265. if (RestoreHealSpell())
  1266. Die();
  1267. // 家券 坷宏璃飘 八荤
  1268. if (m_xSlaveObjList.GetCount())
  1269. {
  1270. PLISTNODE pListNode = m_xSlaveObjList.GetHead();
  1271. while (pListNode)
  1272. {
  1273. CCharObject* pCharObject = m_xSlaveObjList.GetData(pListNode);
  1274. if (pCharObject)
  1275. {
  1276. if (pCharObject->m_fIsDead || pCharObject->m_fIsGhost || pCharObject->m_pMasterObject != this)
  1277. pListNode = m_xSlaveObjList.RemoveNode(pListNode);
  1278. else
  1279. pListNode = m_xSlaveObjList.GetNext(pListNode);
  1280. }
  1281. }
  1282. }
  1283. CCharObject::Run();
  1284. }
  1285. WORD CPlayerObject::GetThisCharColor()
  1286. {
  1287. return _CHAT_COLOR3;
  1288. }
  1289. void CPlayerObject::ServerGetButch(CCharObject* pCharObject, int nX, int nY, int nDir)
  1290. {
  1291. if ((abs(nX - m_nCurrX) <= 2) && (abs(nY - m_nCurrY) <= 2))
  1292. {
  1293. if (m_pMap->IsValidObject(nX, nY, 2, pCharObject))
  1294. {
  1295. CAnimalObject* pAnimalObject = dynamic_cast<CAnimalObject*>(pCharObject);
  1296. if (pAnimalObject)
  1297. {
  1298. if (pAnimalObject->m_fIsDead && !pAnimalObject->m_fSkeleton)
  1299. {
  1300. int n = 5 + rand() % 16;
  1301. int m = 100 + rand() % 201;
  1302. pAnimalObject->m_nMeatQuality -= n;
  1303. pAnimalObject->m_nBodyLeathery -= m;
  1304. if (pAnimalObject->m_nMeatQuality < 0) 
  1305. pAnimalObject->m_nMeatQuality = 0;
  1306. if (pAnimalObject->m_nBodyLeathery <= 0)
  1307. {
  1308. //               if (animal.RaceServer >= RC_ANIMAL) and (animal.RaceServer < RC_MONSTER) then begin  //荤娇鞍捞 绊扁甫林绰 巴父, 秦榜肺 函窃
  1309. //                  animal.BoSkeleton := TRUE;
  1310. //                  animal.ApplyMeatQuality;
  1311. //                  animal.SendRefMsg (RM_SKELETON, animal.Dir, animal.CX, animal.CY, 0, '')
  1312. //               end;
  1313. pAnimalObject->m_fSkeleton = TRUE;
  1314. pAnimalObject->AddRefMsg(RM_SKELETON, pAnimalObject->m_nDirection, pAnimalObject->m_nCurrX, pAnimalObject->m_nCurrY, 0, NULL);
  1315. // if (!pAnimalObject->TakeCretBagItems())
  1316. // SysMag("酒公巴档 掘瘤 给沁嚼聪促.", 0);
  1317. pAnimalObject->m_nBodyLeathery = 50;
  1318. }
  1319. m_dwDeathTime = GetTickCount();
  1320. }
  1321. }
  1322. }
  1323. m_nDirection = nDir;
  1324. }
  1325. AddRefMsg(RM_BUTCH, nDir, m_nCurrX, m_nCurrY, 0, NULL);
  1326. }
  1327. BOOL CPlayerObject::SpellXY(int nKey, int nTargetX, int nTargetY, int nTargetObj)
  1328. {
  1329. if (!m_pUserInfo) return FALSE;
  1330. _LPTHUMANMAGICRCD lptMagicRcd = m_pUserInfo->GetMagicRcdByKey(nKey);
  1331. if (lptMagicRcd)
  1332. {
  1333. CMagicInfo* pMagicInfo = GetMagicInfo(lptMagicRcd->btMagicID);
  1334. if (pMagicInfo)
  1335. {
  1336. int nSpellPoint = pMagicInfo->GetSpellPoint(lptMagicRcd->btLevel);
  1337. switch (lptMagicRcd->btMagicID)
  1338. {
  1339. case _SKILL_ERGUM:
  1340. {
  1341. if (!m_pUserInfo->m_fLongHitSkill)
  1342. {
  1343. m_pUserInfo->AllowLongHitSkill(TRUE);
  1344. SendSocket(NULL, "+LNG");
  1345. }
  1346. else
  1347. {
  1348. m_pUserInfo->AllowLongHitSkill(FALSE);
  1349. SendSocket(NULL, "+ULNG");
  1350. }
  1351. return TRUE;
  1352. }
  1353. case _SKILL_BANWOL:
  1354. {
  1355. if (!m_pUserInfo->m_fWideHitSkill)
  1356. {
  1357. m_pUserInfo->AllowWideHitSkill(TRUE);
  1358. SendSocket(NULL, "+WID");
  1359. }
  1360. else
  1361. {
  1362. m_pUserInfo->AllowWideHitSkill(FALSE);
  1363. SendSocket(NULL, "+UWID");
  1364. }
  1365. return TRUE;
  1366. }
  1367. case _SKILL_FIRESWORD:
  1368. {
  1369. if (m_pUserInfo->AllowFireHitSkill())
  1370. {
  1371. DamageSpell(nSpellPoint);
  1372. HealthSpellChanged();
  1373. SendSocket(NULL, "+FIR");
  1374. }
  1375. return TRUE;
  1376. }
  1377. }
  1378. if (m_WAbility.MP >= nSpellPoint)
  1379. {
  1380. DamageSpell(nSpellPoint);
  1381. HealthSpellChanged();
  1382. GetNextDirection(nTargetX, nTargetY);
  1383. switch (lptMagicRcd->btMagicID)
  1384. {
  1385. case _SKILL_HANGMAJINBUB:
  1386. case _SKILL_DEJIWONHO:
  1387. case _SKILL_FIRECHARM:
  1388. case _SKILL_FIRE:
  1389. case _SKILL_FIREBALL2:
  1390. case _SKILL_FIREBALL:
  1391. case _SKILL_BIGCLOAK:
  1392. case _SKILL_CLOAK:
  1393. AddRefMsg(RM_SPELL2, pMagicInfo->sEffect, nTargetX, nTargetY, pMagicInfo->nIndex, NULL);
  1394. break;
  1395. case _SKILL_MOOTEBO:
  1396. DoMotaebo();
  1397. return TRUE;
  1398. default:
  1399. AddRefMsg(RM_SPELL, pMagicInfo->sEffect, nTargetX, nTargetY, pMagicInfo->nIndex, NULL);
  1400. break;
  1401. }
  1402. return DoSpell(lptMagicRcd, nTargetX, nTargetY, (CCharObject*)nTargetObj);
  1403. }
  1404. } // if (pMagicInfo)
  1405. }
  1406. return FALSE;
  1407. }
  1408. BOOL CPlayerObject::DoSpell(_LPTHUMANMAGICRCD lptMagicRcd, int TargetX, int TargetY, CCharObject* pTargetObject)
  1409. {
  1410. BOOL fTrain = FALSE;
  1411. CMagicInfo* pMagicInfo = GetMagicInfo(lptMagicRcd->btMagicID);
  1412. if (!pMagicInfo) return FALSE;
  1413. switch (lptMagicRcd->btMagicID)
  1414. {
  1415. case _SKILL_SHOWHP: // 沤扁颇楷
  1416. {
  1417. if (!DoShowHP(pTargetObject, pMagicInfo, lptMagicRcd->btLevel))
  1418. return FALSE;
  1419. break;
  1420. }
  1421. case _SKILL_HEALLING: // 雀汗贱
  1422. {
  1423. if (!pTargetObject)
  1424. {
  1425. pTargetObject = (CCharObject*)this;
  1426. TargetX = m_nCurrX;
  1427. TargetY = m_nCurrY;
  1428. }
  1429. int nPwr = GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow() + LOBYTE(m_WAbility.SC) * 2, lptMagicRcd->btLevel), 
  1430. (HIBYTE(m_WAbility.SC) - LOBYTE(m_WAbility.SC)) * 2 + 1);
  1431. if (pTargetObject->m_WAbility.HP < pTargetObject->m_WAbility.MaxHP)
  1432. {
  1433. pTargetObject->AddDelayProcess(this, RM_MAGHEALING, 0, nPwr, 0, 0, NULL, 800);
  1434. #ifdef _DEBUG
  1435. char szMsg[64];
  1436. sprintf(szMsg, "%s 雀汗矫糯 - PW:%d HP:%d", pTargetObject->m_szName, nPwr, pTargetObject->m_WAbility.HP);
  1437. SysMsg(szMsg, 0);
  1438. #endif
  1439. }
  1440. break;
  1441. }
  1442. case _SKILL_BIGHEALLING: // 措雀汗贱
  1443. {
  1444. int nPwr = GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow() + LOBYTE(m_WAbility.SC) * 2, lptMagicRcd->btLevel), 
  1445. (HIBYTE(m_WAbility.SC) - LOBYTE(m_WAbility.SC)) * 2 + 1);
  1446. if (MagBigHealing(nPwr, TargetX, TargetY))
  1447. fTrain = TRUE;
  1448. break;
  1449. }
  1450. case _SKILL_LIGHTENING: // 碍拜
  1451. {
  1452. if (IsProperTarget(pTargetObject))
  1453. {
  1454. if (pTargetObject->m_btAntiMagic <= (rand() % 10))
  1455. {
  1456. int nPwr = GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow(), lptMagicRcd->btLevel) + LOBYTE(m_WAbility.MC), 
  1457. HIBYTE(m_WAbility.MC) - LOBYTE(m_WAbility.MC) + 1);
  1458. if (pTargetObject->m_wObjectType & _OBJECT_ANIMAL)
  1459. {
  1460. fTrain = TRUE;
  1461. if (((CMonsterObject*)pTargetObject)->m_btLifeAttrib == LA_UNDEAD)
  1462. nPwr = ROUND(nPwr * 1.5);
  1463. }
  1464. AddDelayProcess(this, RM_DELAYMAGIC, nPwr, MAKELONG(TargetX, TargetY), 2, (int)pTargetObject, NULL, 1400);
  1465. }
  1466. else
  1467. pTargetObject = NULL;
  1468. }
  1469. break;
  1470. }
  1471. case _SKILL_FIREBALL: // 拳堪厘
  1472. case _SKILL_FIREBALL2: // 陛碍拳堪厘 
  1473. {
  1474. int nPwr = GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow(), lptMagicRcd->btLevel) + LOBYTE(m_WAbility.MC), 
  1475. HIBYTE(m_WAbility.MC) - LOBYTE(m_WAbility.MC) + 1);
  1476. AddDelayProcess(this, RM_DELAYMAGIC, nPwr, MAKELONG(TargetX, TargetY), 2, (int)pTargetObject, NULL, 900);
  1477. /*         if user.MagCanHitTarget (user.CX, user.CY, target) then begin
  1478.     if user.IsProperTarget (target) then begin
  1479.        if (target.AntiMagic <= Random(10)) and (abs(target.CX-xx) <= 1) and (abs(target.CY-yy) <= 1) then begin
  1480.           with user do begin
  1481.              pwr := GetAttackPower (
  1482.                          GetPower (MPow(pum)) + Lobyte(WAbil.MC),
  1483.                          ShortInt(Hibyte(WAbil.MC)-Lobyte(WAbil.MC)) + 1
  1484.                       );
  1485.              //pwr := GetPower (MPow(pum)) + (Lobyte(WAbil.MC) + Random(Hibyte(WAbil.MC)-Lobyte(WAbil.MC) + 1));
  1486.              //鸥百 嘎澜, 饶俊 瓤苞唱鸥巢
  1487.              //target.SendDelayMsg (user, RM_MAGSTRUCK, 0, pwr, 0, 0, '', 1200 + _MAX(Abs(CX-xx),Abs(CY-yy)) * 50 );
  1488.           end;
  1489.           //rm-delaymagic俊辑 selecttarget阑 贸府茄促.
  1490.           user.SendDelayMsg (user, RM_DELAYMAGIC, pwr, MakeLong(xx, yy), 2, integer(target), '', 600);
  1491.           if (target.RaceServer >= RC_ANIMAL) then train := TRUE;
  1492.        end else
  1493.           target := nil;
  1494.     end else
  1495.        target := nil;
  1496.  end else
  1497.     target := nil; */
  1498. break;
  1499. }
  1500. case _SKILL_FIREWIND: // 拳堪浅
  1501. {
  1502. if (MagPushArround(3) > 0) fTrain = TRUE;
  1503. break;
  1504. }
  1505. case _SKILL_FIRE: // 堪荤厘
  1506. {
  1507. int nX = 0, nY = 0;
  1508. int nDir = GetNextDirection(TargetX, TargetY);
  1509. if (GetNextPosition(nDir, 1, nX, nY))
  1510. {
  1511. GetNextPosition(nDir, 5, TargetX, TargetY);
  1512. int nPwr = GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow(), lptMagicRcd->btLevel) + LOBYTE(m_WAbility.MC), 
  1513. HIBYTE(m_WAbility.MC) - LOBYTE(m_WAbility.MC) + 1);
  1514. if (MagPassThroughMagic(nX, nY, TargetX, TargetY, nDir, nPwr, FALSE) > 0)
  1515. fTrain = TRUE;
  1516. }
  1517. break;
  1518. }
  1519. case _SKILL_SHOOTLIGHTEN: // 汾牢厘
  1520. {
  1521. int nX = 0, nY = 0;
  1522. int nDir = GetNextDirection(TargetX, TargetY);
  1523. if (GetNextPosition(nDir, 1, nX, nY))
  1524. {
  1525. GetNextPosition(nDir, 8, TargetX, TargetY);
  1526. int nPwr = GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow(), lptMagicRcd->btLevel) + LOBYTE(m_WAbility.MC), 
  1527. HIBYTE(m_WAbility.MC) - LOBYTE(m_WAbility.MC) + 1);
  1528. if (MagPassThroughMagic(nX, nY, TargetX, TargetY, nDir, nPwr, TRUE) > 0)
  1529. fTrain = TRUE;
  1530. }
  1531. break;
  1532. }
  1533. case _SKILL_SHIELD: // 林贱狼阜
  1534. {
  1535. if (MagBubbleDefenceUp(lptMagicRcd->btLevel, pMagicInfo->GetPower(15 + GetRPow(m_WAbility.MC), lptMagicRcd->btLevel)))
  1536. fTrain = TRUE;
  1537. break;
  1538. }
  1539. case _SKILL_EATTHFIRE: // 瘤堪贱
  1540. {
  1541. int nPwr = GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow(), lptMagicRcd->btLevel) + LOBYTE(m_WAbility.MC), 
  1542. HIBYTE(m_WAbility.MC) - LOBYTE(m_WAbility.MC) + 1);
  1543. if (MagMakeFireCross(nPwr, pMagicInfo->GetPower(10, lptMagicRcd->btLevel) + GetRPow(m_WAbility.MC) / 2, TargetX, TargetY))
  1544. fTrain = TRUE;
  1545. break;
  1546. }
  1547. case _SKILL_FIREBOOM: // 气凯颇
  1548. case _SKILL_SNOWWIND: // 葫汲浅
  1549. {
  1550. if (MagBigExplosion(GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow(), lptMagicRcd->btLevel) + LOBYTE(m_WAbility.MC), 
  1551. HIBYTE(m_WAbility.MC) - LOBYTE(m_WAbility.MC) + 1), 
  1552. TargetX, TargetY, 1))
  1553. fTrain = TRUE;
  1554. break;
  1555. }
  1556. case _SKILL_AMYOUNSUL:
  1557. case _SKILL_HANGMAJINBUB:
  1558. case _SKILL_DEJIWONHO:
  1559. case _SKILL_CLOAK:
  1560. case _SKILL_FIRECHARM:
  1561. case _SKILL_HOLYSHIELD:
  1562. case _SKILL_BIGCLOAK:
  1563. case _SKILL_SKELLETON:
  1564. {
  1565. if (_LPTGENERALITEMRCD lptItem = m_pUserInfo->CanUseBujuk())
  1566. {
  1567. if (lptItem->nDura >= 1)
  1568. {
  1569. lptItem->nDura--;
  1570. AddProcess(this, RM_DURACHANGE, U_ARMRINGL, lptItem->nDura, lptItem->nDuraMax, 0);
  1571. switch (lptMagicRcd->btMagicID)
  1572. {
  1573. case _SKILL_HANGMAJINBUB: // 亲付柳过
  1574. {
  1575. int nPwr = GetAttackPower(pMagicInfo->GetPower13(60, lptMagicRcd->btLevel) + 5 * LOBYTE(m_WAbility.SC),
  1576. 5 * (HIBYTE(m_WAbility.SC) - LOBYTE(m_WAbility.SC)) + 1);
  1577. if (MagMakeDefenceArea(TargetX, TargetY, 3, nPwr, STATE_MAGDEFENCEUP))
  1578. fTrain = TRUE;
  1579. break;
  1580. }
  1581. case _SKILL_DEJIWONHO: // 措瘤盔龋
  1582. {
  1583. int nPwr = GetAttackPower(pMagicInfo->GetPower13(60, lptMagicRcd->btLevel) + 5 * LOBYTE(m_WAbility.SC),
  1584. 5 * (HIBYTE(m_WAbility.SC) - LOBYTE(m_WAbility.SC)) + 1);
  1585. if (MagMakeDefenceArea(TargetX, TargetY, 3, nPwr, STATE_DEFENCEUP))
  1586. fTrain = TRUE;
  1587. break;
  1588. }
  1589. case _SKILL_CLOAK: // 篮脚贱
  1590. {
  1591. if (MagMakePrivateTransparent(pMagicInfo->GetPower13(30, lptMagicRcd->btLevel) + 3 * GetRPow(m_WAbility.SC)))
  1592. fTrain = TRUE;
  1593. break;
  1594. }
  1595. case _SKILL_BIGCLOAK: // 措篮脚贱
  1596. {
  1597. if (MagMakeGroupTransparent(TargetX, TargetY, pMagicInfo->GetPower13(30, lptMagicRcd->btLevel) + 3 * GetRPow(m_WAbility.SC)))
  1598. fTrain = TRUE;
  1599. break;
  1600. }
  1601. case _SKILL_FIRECHARM: // 气混拌
  1602. {
  1603. int nPwr = GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow(), lptMagicRcd->btLevel) + LOBYTE(m_WAbility.SC), 
  1604. HIBYTE(m_WAbility.SC) - LOBYTE(m_WAbility.SC) + 1);
  1605. AddDelayProcess(this, RM_DELAYMAGIC, nPwr, MAKELONG(TargetX, TargetY), 2, (int)pTargetObject, NULL, 900);
  1606. break;
  1607. }
  1608. case _SKILL_HOLYSHIELD: // 搬拌
  1609. {
  1610. if (MagMakeHolyCurtain(pMagicInfo->GetPower13(40, lptMagicRcd->btLevel) + 3 * GetRPow(m_WAbility.SC), TargetX, TargetY) > 0)
  1611. fTrain = TRUE;
  1612. break;
  1613. }
  1614. case _SKILL_SKELLETON: // 归榜家券贱
  1615. {
  1616. int nX, nY;
  1617. GetFrontPosition(nX, nY);
  1618. if (MakeSlave(94, nX, nY, lptMagicRcd->btLevel, 1, 48 * 60 * 60))
  1619. fTrain = TRUE;
  1620. break;
  1621. }
  1622. }
  1623. }
  1624. else
  1625. return FALSE;
  1626. }
  1627. else
  1628. return FALSE;
  1629. break;
  1630. }
  1631. case _SKILL_SINSU: // 脚荐家券
  1632. {
  1633. if (_LPTGENERALITEMRCD lptItem = m_pUserInfo->CanUseBujuk())
  1634. {
  1635. if (lptItem->nDura >= 5)
  1636. {
  1637. lptItem->nDura -= 5;
  1638. AddProcess(this, RM_DURACHANGE, U_ARMRINGL, lptItem->nDura, lptItem->nDuraMax, 0);
  1639. if (GetAvailablePosition(m_pMap, TargetX, TargetY, 3))
  1640. {
  1641. AddDelayProcess(this, RM_MAKESLAVE, 161, TargetX, TargetY, lptMagicRcd->btLevel, NULL, 1200);
  1642. fTrain = TRUE;
  1643. }
  1644. else
  1645. return FALSE;
  1646. }
  1647. else
  1648. return FALSE;
  1649. }
  1650. else
  1651. return FALSE;
  1652. break;
  1653. }
  1654. case _SKILL_KILLUNDEAD:
  1655. {
  1656. if (pTargetObject)
  1657. {
  1658. if (IsProperTarget(pTargetObject))
  1659. {
  1660. // if (MagTurnUnDead(pTargetObject, TargetX, TargetY, lptMagicRcd->btLevel))
  1661. MagTurnUndead(pTargetObject, TargetX, TargetY, lptMagicRcd->btLevel);
  1662. fTrain = TRUE;
  1663. }
  1664. }
  1665. break;
  1666. }
  1667. case _SKILL_TAMMING:
  1668. break;
  1669. case _SKILL_LIGHTFLOWER:
  1670. {
  1671. if (MagElecBlizzard(GetAttackPower(pMagicInfo->GetPower(pMagicInfo->MPow(), lptMagicRcd->btLevel) + LOBYTE(m_WAbility.MC),
  1672. (HIBYTE(m_WAbility.MC) - LOBYTE(m_WAbility.MC)) + 1)))
  1673. fTrain = TRUE;
  1674. break;
  1675. }
  1676. }
  1677. /*   if not nofire then begin
  1678.       with user do begin
  1679.          if needfire then
  1680.             SendRefMsg (RM_MAGICFIRE, 0, MakeWord(pum.pDef.EffectType, pum.pDef.Effect), MakeLong(xx, yy), integer(target), '');
  1681.          //嘎篮 惑措
  1682.          if (pum.Level < 3) and train then
  1683.             if Abil.Level >= pum.pDef.NeedLevel[pum.Level] then begin
  1684.                //荐访饭骇俊 档崔茄 版快
  1685.                user.TrainSkill (pum, 1 + Random(3));
  1686.                if not CheckMagicLevelup (pum) then
  1687.                   SendDelayMsg (user, RM_MAGIC_LVEXP, 0, pum.pDef.MagicId, pum.Level, pum.CurTrain, '', 1000);
  1688.             end;
  1689.       end;
  1690.       Result := TRUE;
  1691.    end; */
  1692. AddRefMsg(RM_MAGICFIRE, 0, lptMagicRcd->btMagicID, MAKELONG(TargetX, TargetY), (LONG)pTargetObject, NULL);
  1693. if (lptMagicRcd->btLevel < 3)
  1694. {
  1695. if (m_Ability.Level >= pMagicInfo->sNeed[lptMagicRcd->btLevel])
  1696. TrainSkill(lptMagicRcd, 1 + (rand() % 3));
  1697. }
  1698. return TRUE;
  1699. }
  1700. void CPlayerObject::TrainSkill(_LPTHUMANMAGICRCD lptMagicRcd, int nTrain)
  1701. {
  1702. if (m_fFastTrain)
  1703. lptMagicRcd->nCurrTrain += (nTrain * 3);
  1704. else
  1705. lptMagicRcd->nCurrTrain += nTrain;
  1706. }
  1707. BOOL CPlayerObject::MakeSlave(int nMonRace, int nX, int nY, int nLevel, int nMax, DWORD dwRoyaltySec)
  1708. {
  1709. CMonRaceInfo* pMonRaceInfo = &g_pMonRaceInfo[nMonRace];
  1710. if (pMonRaceInfo)
  1711. {
  1712. CMonsterObject* pMonsterObject = (CMonsterObject*)AddCreatureSysop(nX, nY, pMonRaceInfo, FALSE);
  1713. if (pMonsterObject)
  1714. {
  1715. pMonsterObject->m_pMasterObject = this;
  1716. m_xSlaveObjList.AddNewNode(pMonsterObject);
  1717. /*         mon.MasterRoyaltyTime := GetTickCount + longword(royaltysec) * 1000;
  1718.          mon.SlaveMakeLevel := slevel;
  1719.          mon.SlaveExpLevel := slevel;
  1720.          mon.RecalcAbilitys; //ApplySlaveLevelAbilitys;
  1721.          if mon.WAbil.HP < mon.WAbil.MaxHP then begin
  1722.             mon.WAbil.HP := mon.WAbil.HP + (mon.WAbil.MaxHP - mon.WAbil.HP) div 2;
  1723.          end;
  1724.          mon.ChangeNameColor;
  1725.          SlaveList.Add (mon);
  1726.          Result := mon;
  1727.  */
  1728. return TRUE;
  1729. }
  1730. }
  1731. return FALSE;
  1732. }
  1733. void CPlayerObject::Operate()
  1734. {
  1735. if (!m_pUserInfo) return;
  1736. if (m_pUserInfo->m_fFireHitSkill)
  1737. {
  1738. if (GetTickCount() - m_pUserInfo->m_dwLatestFireHitTime > 20 * 1000)
  1739. {
  1740. TCHAR szText[64];
  1741. char szMsg[64];
  1742. m_pUserInfo->m_fFireHitSkill = FALSE;
  1743. LoadString(g_hInst, IDS_TIMEOUT_FIREHIT, szText, sizeof(szText)/sizeof(TCHAR));
  1744. WideCharToMultiByte(CP_ACP, 0, szText, -1, szMsg, sizeof(szMsg), NULL, NULL);
  1745. SysMsg(szMsg, 0);
  1746. SendSocket(NULL, "+UFIR");
  1747. }
  1748. }
  1749. if (m_nEvent >= 0)
  1750. {
  1751. if ((m_nEvent >= 0) && (m_nEvent < g_nNumOfMoveMapEventInfo))
  1752. {
  1753. CMirMap* pMirMap = GetMap(g_pMoveMapEventInfo[m_nEvent].szDMapFileName);
  1754. if (pMirMap)
  1755. SpaceMove(g_pMoveMapEventInfo[m_nEvent].nDX, g_pMoveMapEventInfo[m_nEvent].nDY, pMirMap);
  1756. m_nEvent = -1;
  1757. }
  1758. }
  1759. Run();
  1760. int nCount = m_DelayProcessQ.GetCount();
  1761. int nPos;
  1762. _TDEFAULTMESSAGE DefMsg;
  1763. _LPTPROCESSMSG lpProcessMsg;
  1764. if (nCount)
  1765. {
  1766. for (int i = 0; i < nCount; i++)
  1767. {
  1768. lpProcessMsg = (_LPTPROCESSMSG)m_DelayProcessQ.PopQ();
  1769. if (lpProcessMsg)
  1770. {
  1771. if (GetTickCount() < lpProcessMsg->dwDeliveryTime)
  1772. {
  1773. m_DelayProcessQ.PushQ((BYTE *)lpProcessMsg);
  1774. continue;
  1775. }
  1776. switch (lpProcessMsg->wIdent)
  1777. {
  1778. case RM_MAGIC_LVEXP:
  1779. {
  1780. fnMakeDefMessage(&DefMsg, SM_MAGIC_LVEXP, lpProcessMsg->lParam3, 
  1781. (WORD)lpProcessMsg->lParam2, (WORD)lpProcessMsg->lParam1, 0);
  1782. SendSocket(&DefMsg, NULL);
  1783. break;
  1784. }
  1785. case RM_STRUCK:
  1786. {
  1787. lpProcessMsg->pCharObject->AddRefMsg(RM_STRUCK, lpProcessMsg->wParam, lpProcessMsg->lParam1, 
  1788. lpProcessMsg->lParam2, lpProcessMsg->lParam3, NULL);
  1789. break;
  1790. }
  1791. case RM_DOOPENHEALTH:
  1792. {
  1793. MakeOpenHealth();
  1794. break;
  1795. }
  1796. case RM_MAGHEALING:
  1797. {
  1798. if (m_IncHealing + lpProcessMsg->lParam1 < 300)
  1799. {
  1800. m_IncHealing += (BYTE)lpProcessMsg->lParam1;
  1801. m_btPerHealing = 5;
  1802. }
  1803. else
  1804. {
  1805. m_IncHealing = 300;
  1806. }
  1807. break;
  1808. }
  1809. case RM_DELAYMAGIC:
  1810. {
  1811. CCharObject* pTargetObject = (CCharObject*)lpProcessMsg->lParam3;
  1812. int nMagPower = lpProcessMsg->wParam;
  1813. if (pTargetObject)
  1814. {
  1815. int n = pTargetObject->GetMagStruckDamage(nMagPower);
  1816. if (n > 0)
  1817. {
  1818. SelectTarget(pTargetObject);
  1819. if (pTargetObject->m_wObjectType & _OBJECT_ANIMAL)
  1820. nMagPower = ROUND(nMagPower * 1.2);
  1821. // Debug Code
  1822. char szMsg[64];
  1823. sprintf(szMsg, "%s 付过 嘎澜 - PW:%d", pTargetObject->m_szName, nMagPower);
  1824. SysMsg(szMsg, 0);
  1825. // Debug Code
  1826. if ((abs(LOWORD(lpProcessMsg->lParam1) - pTargetObject->m_nCurrX) <= (int)lpProcessMsg->lParam2) &&
  1827. (abs(HIWORD(lpProcessMsg->lParam1) - pTargetObject->m_nCurrY) <= (int)lpProcessMsg->lParam2))
  1828. pTargetObject->AddProcess(this, RM_MAGSTRUCK, 0, nMagPower, 0, 0, NULL);
  1829. }
  1830. }
  1831. break;
  1832. }
  1833. case RM_MAGSTRUCK:
  1834. {
  1835. AddProcess(lpProcessMsg->pCharObject, lpProcessMsg->wIdent, lpProcessMsg->wParam, lpProcessMsg->lParam1, 
  1836. lpProcessMsg->lParam2, lpProcessMsg->lParam3, NULL);
  1837. break;
  1838. }
  1839. case RM_TRANSPARENT:
  1840. {
  1841. lpProcessMsg->pCharObject->MagMakePrivateTransparent(lpProcessMsg->lParam1);
  1842. break;
  1843. }
  1844. case RM_MAKESLAVE:
  1845. {
  1846. MakeSlave(lpProcessMsg->wParam, lpProcessMsg->lParam1, lpProcessMsg->lParam2, lpProcessMsg->lParam3, 1, 48 * 60 * 60);
  1847. break;
  1848. }
  1849. } // switch
  1850. delete lpProcessMsg;
  1851. lpProcessMsg = NULL;
  1852. }
  1853. }
  1854. }
  1855. nCount = m_ProcessQ.GetCount();
  1856. if (nCount)
  1857. {
  1858. char szEncodeMsg[256];
  1859. _TMESSAGEBODYWL MsgBodyWL;
  1860. _TSHORTMSSEAGE tsMsg;
  1861. _TCHARDESC CharDesc;
  1862. for (int i = 0; i < nCount; i++)
  1863. {
  1864. // EnterCriticalSection(&m_cs);
  1865. lpProcessMsg = (_LPTPROCESSMSG)m_ProcessQ.PopQ();
  1866. // LeaveCriticalSection(&m_cs);
  1867. //#ifdef _DEBUG
  1868. // _RPT4(_CRT_WARN, "CPlayerObject::Operate - %d, %d, %d, %d", lpProcessMsg->wIdent, lpProcessMsg->wParam, lpProcessMsg->lParam1, lpProcessMsg->lParam2);
  1869. // _RPT1(_CRT_WARN, " %d n", lpProcessMsg->lParam3);
  1870. //#endif
  1871. if (lpProcessMsg)
  1872. {
  1873. switch (lpProcessMsg->wIdent)
  1874. {
  1875. case CM_TURN:
  1876. {
  1877. if (!m_fIsDead)
  1878. {
  1879. if (TurnXY(lpProcessMsg->lParam1, lpProcessMsg->lParam2, lpProcessMsg->wParam)) // x, y, dir
  1880. memmove(szEncodeMsg, _MSG_GOOD, sizeof(_MSG_GOOD));
  1881. else
  1882. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1883. }
  1884. else
  1885. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1886. ValToAnsiStr(GetTickCount(), &szEncodeMsg[sizeof(_MSG_GOOD) - 1]);
  1887. SendSocket(NULL, szEncodeMsg);
  1888. break;
  1889. }
  1890. case CM_WALK:
  1891. {
  1892. if (!m_fIsDead)
  1893. {
  1894. // if (WalkXY(lpProcessMsg->lParam1, lpProcessMsg->lParam2, lpProcessMsg->wParam))
  1895. if (WalkTo(lpProcessMsg->wParam)) // dir
  1896. memmove(szEncodeMsg, _MSG_GOOD, sizeof(_MSG_GOOD));
  1897. else
  1898. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1899. }
  1900. else
  1901. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1902. ValToAnsiStr(GetTickCount(), &szEncodeMsg[sizeof(_MSG_GOOD) - 1]);
  1903. SendSocket(NULL, szEncodeMsg);
  1904. break;
  1905. }
  1906. case CM_RUN:
  1907. {
  1908. if (!m_fIsDead)
  1909. {
  1910. // if (RunXY(lpProcessMsg->lParam1, lpProcessMsg->lParam2, lpProcessMsg->wParam))
  1911. if (RunTo(lpProcessMsg->wParam)) // dir
  1912. memmove(szEncodeMsg, _MSG_GOOD, sizeof(_MSG_GOOD));
  1913. else
  1914. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1915. }
  1916. else
  1917. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1918. ValToAnsiStr(GetTickCount(), &szEncodeMsg[sizeof(_MSG_GOOD) - 1]);
  1919. SendSocket(NULL, szEncodeMsg);
  1920. break;
  1921. }
  1922. case CM_HIT:
  1923. case CM_LONGHIT:
  1924. case CM_WIDEHIT:
  1925. case CM_FIREHIT:
  1926. case CM_POWERHIT:
  1927. {
  1928. if (!m_fIsDead)
  1929. {
  1930. if (HitXY(lpProcessMsg->wIdent, lpProcessMsg->lParam1, lpProcessMsg->lParam2, lpProcessMsg->wParam, lpProcessMsg->lParam3))
  1931. memmove(szEncodeMsg, _MSG_GOOD, sizeof(_MSG_GOOD));
  1932. else
  1933. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1934. }
  1935. else
  1936. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1937. ValToAnsiStr(GetTickCount(), &szEncodeMsg[sizeof(_MSG_GOOD) - 1]);
  1938. SendSocket(NULL, szEncodeMsg);
  1939. break;
  1940. }
  1941. case CM_RIDE:
  1942. {
  1943. if (!m_fIsDead)
  1944. {
  1945. if (DoRideHorse(lpProcessMsg->wParam, lpProcessMsg->lParam1))
  1946. memmove(szEncodeMsg, _MSG_GOOD, sizeof(_MSG_GOOD));
  1947. else
  1948. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1949. }
  1950. else
  1951. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1952. ValToAnsiStr(GetTickCount(), &szEncodeMsg[sizeof(_MSG_GOOD) - 1]);
  1953. SendSocket(NULL, szEncodeMsg);
  1954. break;
  1955. }
  1956. case CM_SAY:
  1957. {
  1958. if (lpProcessMsg->pszData)
  1959. ProcessForUserSaid(lpProcessMsg->pszData);
  1960. break;
  1961. }
  1962. case CM_SPELL:
  1963. {
  1964. if (!m_fIsDead)
  1965. {
  1966. if (SpellXY(lpProcessMsg->wParam, lpProcessMsg->lParam1, lpProcessMsg->lParam2, lpProcessMsg->lParam3))
  1967. memmove(szEncodeMsg, _MSG_GOOD, sizeof(_MSG_GOOD));
  1968. else
  1969. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1970. }
  1971. else
  1972. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1973. ValToAnsiStr(GetTickCount(), &szEncodeMsg[sizeof(_MSG_GOOD) - 1]);
  1974. SendSocket(NULL, szEncodeMsg);
  1975. break;
  1976. }
  1977. case CM_SITDOWN:
  1978. {
  1979. if (!m_fIsDead)
  1980. memmove(szEncodeMsg, _MSG_GOOD, sizeof(_MSG_GOOD));
  1981. else
  1982. memmove(szEncodeMsg, _MSG_FAIL, sizeof(_MSG_FAIL));
  1983. ValToAnsiStr(GetTickCount(), &szEncodeMsg[sizeof(_MSG_GOOD) - 1]);
  1984. SendSocket(NULL, szEncodeMsg);
  1985. break;
  1986. }
  1987. case CM_TAKEONITEM:
  1988. {
  1989. if (lpProcessMsg->pszData)
  1990. {
  1991. char szDecodeData[16];
  1992. nPos = fnDecode6BitBufA(lpProcessMsg->pszData, szDecodeData, 12);
  1993. szDecodeData[nPos] = '';
  1994. if (szDecodeData[0] == 'G')
  1995. ServerGetTakeOnGenItem((WORD)lpProcessMsg->lParam2, szDecodeData);
  1996. else
  1997. ServerGetTakeOnItem((WORD)lpProcessMsg->lParam2, szDecodeData);
  1998. }
  1999. break;
  2000. }
  2001. case CM_TAKEOFFITEM:
  2002. {
  2003. if (lpProcessMsg->pszData)
  2004. {
  2005. char szDecodeData[16];
  2006. nPos = fnDecode6BitBufA(lpProcessMsg->pszData, szDecodeData, 12);
  2007. szDecodeData[nPos] = '';
  2008. ServerGetTakeOffItem((WORD)lpProcessMsg->lParam2, szDecodeData);
  2009. }
  2010. break;
  2011. }
  2012. case CM_QUERYUSERNAME:
  2013. {
  2014. GetQueryUserName((CCharObject*)lpProcessMsg->lParam1, lpProcessMsg->lParam2/*x*/, lpProcessMsg->lParam3/*y*/);
  2015. break;
  2016. }
  2017. case CM_QUERYBAGITEMS:
  2018. {
  2019. SendBagItems();
  2020. break;
  2021. }
  2022. case CM_EAT:
  2023. {
  2024. if (lpProcessMsg->pszData)
  2025. {
  2026. char szDecodeData[16];
  2027. nPos = fnDecode6BitBufA(lpProcessMsg->pszData, szDecodeData, 12);
  2028. szDecodeData[nPos] = '';
  2029. ServerGetEatItem(lpProcessMsg->wParam, szDecodeData);
  2030. }
  2031. break;
  2032. }
  2033. case CM_MAGICKEYCHANGE:
  2034. {
  2035. ServerGetMagicKeyChange(lpProcessMsg->wParam, lpProcessMsg->lParam1);
  2036. break;
  2037. }
  2038. case CM_DROPITEM:
  2039. {
  2040. char szDecodeData[16];
  2041. BOOL fFlag = FALSE;
  2042. if (lpProcessMsg->pszData)
  2043. {
  2044. nPos = fnDecode6BitBufA(lpProcessMsg->pszData, szDecodeData, 12);
  2045. szDecodeData[nPos] = '';
  2046. if (szDecodeData[0] == 'G')
  2047. {
  2048. if (m_pUserInfo->UserDropGenItem(lpProcessMsg->wParam, szDecodeData))
  2049. fFlag = TRUE;
  2050. }
  2051. else
  2052. {
  2053. if (m_pUserInfo->UserDropItem(lpProcessMsg->wParam, szDecodeData))
  2054. fFlag = TRUE;
  2055. }
  2056. if (fFlag)
  2057. fnMakeDefMessage(&DefMsg, SM_DROPITEM_SUCCESS, 0, lpProcessMsg->wParam, 0, 0);
  2058. else
  2059. fnMakeDefMessage(&DefMsg, SM_DROPITEM_FAIL, 0, lpProcessMsg->wParam, 0, 0);
  2060. }
  2061. else
  2062. fnMakeDefMessage(&DefMsg, SM_DROPITEM_FAIL, 0, lpProcessMsg->wParam, 0, 0);
  2063. nPos = fnEncode6BitBufA((unsigned char *)szDecodeData, szEncodeMsg, 12, sizeof(szEncodeMsg));
  2064. szEncodeMsg[nPos] = '';
  2065. SendSocket(&DefMsg, szEncodeMsg);
  2066. break;
  2067. }
  2068. case CM_PICKUP:
  2069. {
  2070. if ((m_nCurrX == (int)lpProcessMsg->lParam3) && (m_nCurrY == (int)lpProcessMsg->lParam2))
  2071. PickUp();
  2072. break;
  2073. }
  2074. case CM_BUTCH:
  2075. {
  2076. ServerGetButch((CCharObject*)lpProcessMsg->lParam1, lpProcessMsg->lParam2/*x*/, lpProcessMsg->lParam3/*y*/, lpProcessMsg->wParam); 
  2077. break;
  2078. }
  2079. case RM_LOGON:
  2080. {
  2081. SendNewMap();
  2082. fnMakeDefMessage(&DefMsg, SM_LOGON, (int)this, 
  2083. (unsigned short)m_nCurrX, (unsigned short)m_nCurrY, MAKEWORD(m_nDirection, lpProcessMsg->pCharObject->m_btLight));
  2084. nPos =  fnEncode6BitBufA((unsigned char *)&lpProcessMsg->pCharObject->m_tFeature, szEncodeMsg, sizeof(_TOBJECTFEATURE), sizeof(szEncodeMsg));
  2085. nPos += fnEncode6BitBufA((unsigned char *)&((CPlayerObject *)lpProcessMsg->pCharObject)->m_tFeatureEx, &szEncodeMsg[nPos], sizeof(_TOBJECTFEATUREEX), sizeof(szEncodeMsg) - nPos);
  2086. szEncodeMsg[nPos] = '';
  2087. SendSocket(&DefMsg, szEncodeMsg);
  2088. GetQueryUserName(this, m_nCurrX, m_nCurrY);
  2089. SendMapName();
  2090. break;
  2091. }
  2092. case RM_HEAR:
  2093. case RM_CRY:
  2094. case RM_WHISPER:
  2095. case RM_SYSMESSAGE:
  2096. case RM_SYSMESSAGE2:
  2097. case RM_GROUPMESSAGE:
  2098. case RM_GUILDMESSAGE:
  2099. case RM_MERCHANTSAY:
  2100. case RM_MONSTERSAY:
  2101. {
  2102. if (lpProcessMsg->pszData)
  2103. {
  2104. switch (lpProcessMsg->wIdent)
  2105. {
  2106. case RM_HEAR:
  2107. fnMakeDefMessage(&DefMsg, SM_HEAR, (int)lpProcessMsg->pCharObject, _CHAT_COLOR3, _CHAT_COLOR1, 0);
  2108. break;
  2109. case RM_CRY:
  2110. fnMakeDefMessage(&DefMsg, SM_HEAR, (int)lpProcessMsg->pCharObject, _CHAT_COLOR1, _CHAT_COLOR7, 0);
  2111. break;
  2112. case RM_WHISPER:
  2113. fnMakeDefMessage(&DefMsg, SM_WHISPER, (int)lpProcessMsg->pCharObject, 7, _CHAT_COLOR1, 0);
  2114. break;
  2115. case RM_SYSMESSAGE:
  2116. fnMakeDefMessage(&DefMsg, SM_SYSMESSAGE, (int)lpProcessMsg->pCharObject, _CHAT_COLOR3, _CHAT_COLOR8, 0);
  2117. break;
  2118. case RM_SYSMESSAGE2:
  2119. fnMakeDefMessage(&DefMsg, SM_SYSMESSAGE, (int)lpProcessMsg->pCharObject, _CHAT_COLOR3, _CHAT_COLOR4, 0);
  2120. break;
  2121. case RM_GROUPMESSAGE:
  2122. fnMakeDefMessage(&DefMsg, SM_SYSMESSAGE, (int)lpProcessMsg->pCharObject, _CHAT_COLOR3, _CHAT_COLOR1, 0);
  2123. break;
  2124. case RM_GUILDMESSAGE:
  2125. fnMakeDefMessage(&DefMsg, SM_GUILDMESSAGE, (int)lpProcessMsg->pCharObject, _CHAT_COLOR3, _CHAT_COLOR1, 0);
  2126. break;
  2127. case RM_MERCHANTSAY:
  2128. fnMakeDefMessage(&DefMsg, SM_MERCHANTSAY, (int)lpProcessMsg->pCharObject, 0, 0, 1);
  2129. break;
  2130. case RM_MONSTERSAY:
  2131. fnMakeDefMessage(&DefMsg, SM_MONSTERSAY, (int)lpProcessMsg->pCharObject, _CHAT_COLOR3, _CHAT_COLOR1, 0);
  2132. break;
  2133. }
  2134. nPos = fnEncode6BitBufA((unsigned char *)lpProcessMsg->pszData, szEncodeMsg, memlen(lpProcessMsg->pszData), sizeof(szEncodeMsg));
  2135. szEncodeMsg[nPos] = '';
  2136. SendSocket(&DefMsg, szEncodeMsg);
  2137. }
  2138. break;
  2139. }
  2140. case RM_RIDE:
  2141. {
  2142. break;
  2143. }
  2144. case RM_TURN:
  2145. {
  2146. if (lpProcessMsg->pCharObject != this)
  2147. {
  2148. fnMakeDefMessage(&DefMsg, SM_TURN, (int)lpProcessMsg->pCharObject, 
  2149. (unsigned short)lpProcessMsg->lParam1, (unsigned short)lpProcessMsg->lParam2, MAKEWORD(lpProcessMsg->wParam, lpProcessMsg->pCharObject->m_btLight));
  2150. CharDesc.Feature = lpProcessMsg->pCharObject->GetFeatureToLong();
  2151. CharDesc.Status = lpProcessMsg->pCharObject->m_nCharStatus;
  2152. nPos =  fnEncode6BitBufA((unsigned char *)&CharDesc, szEncodeMsg, sizeof(_TCHARDESC), sizeof(szEncodeMsg));
  2153. if (lpProcessMsg->pCharObject->m_wObjectType & _OBJECT_HUMAN)
  2154. nPos += fnEncode6BitBufA((unsigned char *)&((CPlayerObject *)lpProcessMsg->pCharObject)->m_tFeatureEx, &szEncodeMsg[nPos], sizeof(_TOBJECTFEATUREEX), sizeof(szEncodeMsg) - nPos);
  2155. if (lpProcessMsg->pszData)
  2156. nPos += fnEncode6BitBufA((unsigned char *)lpProcessMsg->pszData, &szEncodeMsg[nPos], memlen(lpProcessMsg->pszData) - 1, sizeof(szEncodeMsg) - nPos);
  2157. szEncodeMsg[nPos] = '';
  2158. SendSocket(&DefMsg, szEncodeMsg);
  2159. }
  2160. break;
  2161. }
  2162. case RM_WALK:
  2163. {
  2164. if (lpProcessMsg->pCharObject != this)
  2165. {
  2166. fnMakeDefMessage(&DefMsg, SM_WALK, (int)lpProcessMsg->pCharObject, 
  2167. (unsigned short)lpProcessMsg->lParam1, (unsigned short)lpProcessMsg->lParam2, MAKEWORD(lpProcessMsg->wParam, lpProcessMsg->pCharObject->m_btLight));
  2168. CharDesc.Feature = lpProcessMsg->pCharObject->GetFeatureToLong();
  2169. CharDesc.Status = lpProcessMsg->pCharObject->m_nCharStatus;
  2170. nPos =  fnEncode6BitBufA((unsigned char *)&CharDesc, szEncodeMsg, sizeof(_TCHARDESC), sizeof(szEncodeMsg));
  2171. if (lpProcessMsg->pCharObject->m_wObjectType & _OBJECT_HUMAN)
  2172. nPos += fnEncode6BitBufA((unsigned char *)&((CPlayerObject *)lpProcessMsg->pCharObject)->m_tFeatureEx, &szEncodeMsg[nPos], sizeof(_TOBJECTFEATUREEX), sizeof(szEncodeMsg) - nPos);
  2173. szEncodeMsg[nPos] = '';
  2174. SendSocket(&DefMsg, szEncodeMsg);
  2175. //  cdesc.Feature := TCreature(msg.sender).Feature;
  2176. //  cdesc.Status := TCreature(msg.sender).CharStatus;
  2177. //  SendSocket (@Def, EncodeBuffer (@cdesc, sizeof(TCharDesc)));
  2178. //#ifdef _DEBUG
  2179. // _RPT4(_CRT_WARN, "SM_WALK[%x]:%x, %d-%dn", ,(int)this, (int)lpProcessMsg->pCharObject, lpProcessMsg->lParam1, lpProcessMsg->lParam2);
  2180. //#endif
  2181. }
  2182. break;
  2183. }
  2184. case RM_RUN:
  2185. {
  2186. if (lpProcessMsg->pCharObject != this)
  2187. {
  2188. fnMakeDefMessage(&DefMsg, SM_RUN, (int)lpProcessMsg->pCharObject, 
  2189. (unsigned short)lpProcessMsg->lParam1, (unsigned short)lpProcessMsg->lParam2, MAKEWORD(lpProcessMsg->wParam, lpProcessMsg->pCharObject->m_btLight));
  2190. CharDesc.Feature = lpProcessMsg->pCharObject->GetFeatureToLong();
  2191. CharDesc.Status = lpProcessMsg->pCharObject->m_nCharStatus;
  2192. nPos =  fnEncode6BitBufA((unsigned char *)&CharDesc, szEncodeMsg, sizeof(_TCHARDESC), sizeof(szEncodeMsg));
  2193. if (lpProcessMsg->pCharObject->m_wObjectType & _OBJECT_HUMAN)
  2194. nPos += fnEncode6BitBufA((unsigned char *)&((CPlayerObject *)lpProcessMsg->pCharObject)->m_tFeatureEx, &szEncodeMsg[nPos], sizeof(_TOBJECTFEATUREEX), sizeof(szEncodeMsg) - nPos);
  2195. szEncodeMsg[nPos] = '';
  2196. SendSocket(&DefMsg, szEncodeMsg);
  2197. }
  2198. break;
  2199. }
  2200. case RM_BUTCH:
  2201. {
  2202. if (lpProcessMsg->pCharObject != this)
  2203. {
  2204. fnMakeDefMessage(&DefMsg, SM_BUTCH, (int)lpProcessMsg->pCharObject, 
  2205. (unsigned short)lpProcessMsg->lParam1/*x*/, (unsigned short)lpProcessMsg->lParam2/*y*/, lpProcessMsg->wParam/*Dir*/);
  2206. SendSocket(&DefMsg, NULL);
  2207. }
  2208. break;
  2209. }
  2210. case RM_HIT:
  2211. {
  2212. if (lpProcessMsg->pCharObject != this)
  2213. {
  2214. fnMakeDefMessage(&DefMsg, SM_HIT, (int)lpProcessMsg->pCharObject, 
  2215. (unsigned short)lpProcessMsg->lParam1, (unsigned short)lpProcessMsg->lParam2, MAKEWORD(LOBYTE(lpProcessMsg->wParam), lpProcessMsg->lParam3));//lpProcessMsg->pCharObject->m_nLight);
  2216. SendSocket(&DefMsg, NULL);
  2217. }
  2218. break;
  2219. }
  2220. case RM_LONGHIT:
  2221. {
  2222. if (lpProcessMsg->pCharObject != this)
  2223. {
  2224. fnMakeDefMessage(&DefMsg, SM_LONGHIT, (int)lpProcessMsg->pCharObject, 
  2225. (unsigned short)lpProcessMsg->lParam1, (unsigned short)lpProcessMsg->lParam2, lpProcessMsg->wParam);//lpProcessMsg->pCharObject->m_nLight);
  2226. SendSocket(&DefMsg, NULL);
  2227. }
  2228. break;
  2229. }
  2230. case RM_WIDEHIT:
  2231. {
  2232. if (lpProcessMsg->pCharObject != this)
  2233. {
  2234. fnMakeDefMessage(&DefMsg, SM_WIDEHIT, (int)lpProcessMsg->pCharObject, 
  2235. (unsigned short)lpProcessMsg->lParam1, (unsigned short)lpProcessMsg->lParam2, lpProcessMsg->wParam);//lpProcessMsg->pCharObject->m_nLight);
  2236. SendSocket(&DefMsg, NULL);
  2237. }
  2238. break;
  2239. }
  2240. case RM_FIREHIT:
  2241. {
  2242. if (lpProcessMsg->pCharObject != this)
  2243. {
  2244. fnMakeDefMessage(&DefMsg, SM_FIREHIT, (int)lpProcessMsg->pCharObject, 
  2245. (unsigned short)lpProcessMsg->lParam1, (unsigned short)lpProcessMsg->lParam2, lpProcessMsg->wParam);//lpProcessMsg->pCharObject->m_nLight);
  2246. SendSocket(&DefMsg, NULL);
  2247. }
  2248. break;
  2249. }
  2250. case RM_POWERHIT:
  2251. {
  2252. if (lpProcessMsg->pCharObject != this)
  2253. {
  2254. fnMakeDefMessage(&DefMsg, SM_POWERHIT, (int)lpProcessMsg->pCharObject, 
  2255. (unsigned short)lpProcessMsg->lParam1, (unsigned short)lpProcessMsg->lParam2, lpProcessMsg->wParam);//lpProcessMsg->pCharObject->m_nLight);
  2256. SendSocket(&DefMsg, NULL);
  2257. }
  2258. break;
  2259. }
  2260. case RM_SPELL:
  2261. case RM_SPELL2:
  2262. {
  2263. if (lpProcessMsg->pCharObject != this)
  2264. {
  2265. WORD wIdent;
  2266. char szMagicID[8];
  2267. if (lpProcessMsg->wIdent == RM_SPELL)
  2268. wIdent = SM_SPELL;
  2269. else
  2270. wIdent = SM_SPELL2;
  2271. fnMakeDefMessage(&DefMsg, wIdent, (int)lpProcessMsg->pCharObject, 
  2272. (unsigned short)lpProcessMsg->lParam1/*x*/, (unsigned short)lpProcessMsg->lParam2/*y*/, lpProcessMsg->wParam/*effect*/);
  2273. ValToAnsiStr(lpProcessMsg->lParam3, szMagicID); // MagicID
  2274. nPos = fnEncode6BitBufA((unsigned char *)szMagicID, szEncodeMsg, memlen(szMagicID) - 1, sizeof(szEncodeMsg));
  2275. szEncodeMsg[nPos] = '';
  2276. SendSocket(&DefMsg, szEncodeMsg);
  2277. }
  2278. break;
  2279. }
  2280. case RM_MAGICFIRE:
  2281. {
  2282. // char szMagicID[8];
  2283. fnMakeDefMessage(&DefMsg, SM_MAGICFIRE, (int)lpProcessMsg->pCharObject, 
  2284. LOWORD(lpProcessMsg->lParam2)/*x*/, HIWORD(lpProcessMsg->lParam2)/*y*/, (WORD)lpProcessMsg->lParam1);
  2285. nPos = fnEncode6BitBufA((unsigned char *)&lpProcessMsg->lParam3, szEncodeMsg, sizeof(DWORD), sizeof(szEncodeMsg));
  2286. szEncodeMsg[nPos] = '';
  2287. // ValToAnsiStr(lpProcessMsg->lParam3, szMagicID); // MagicID
  2288. SendSocket(&DefMsg, szEncodeMsg);
  2289. break;
  2290. }
  2291. case RM_STRUCK:
  2292. case RM_STRUCK_MAG:
  2293. {
  2294. if (lpProcessMsg->wParam > 0)
  2295. {
  2296. if (lpProcessMsg->pCharObject)
  2297. {
  2298. if (lpProcessMsg->pCharObject == this)
  2299. {
  2300. m_dwHealthTick = 0;
  2301. m_dwSpellTick = 0;
  2302. m_btPerHealth--;
  2303. m_btPerSpell--;
  2304. }
  2305. fnMakeDefMessage(&DefMsg, SM_STRUCK, (int)lpProcessMsg->pCharObject, 
  2306. lpProcessMsg->pCharObject->m_WAbility.HP/*HP*/, lpProcessMsg->pCharObject->m_WAbility.MaxHP/*MaxHP*/, lpProcessMsg->wParam);
  2307. MsgBodyWL.lParam1 = lpProcessMsg->pCharObject->GetFeatureToLong();
  2308. MsgBodyWL.lParam2 = lpProcessMsg->pCharObject->m_nCharStatus;
  2309. MsgBodyWL.nTag1 = lpProcessMsg->lParam3;
  2310. nPos = fnEncode6BitBufA((unsigned char *)&MsgBodyWL, szEncodeMsg, sizeof(MsgBodyWL), sizeof(szEncodeMsg));
  2311. szEncodeMsg[nPos] = '';
  2312. m_dwHealthTick = 0;
  2313. m_dwSpellTick = 0;
  2314. SendSocket(&DefMsg, szEncodeMsg);
  2315. }
  2316. }
  2317. break;
  2318. }
  2319. case RM_RUSH:
  2320. case RM_PUSH:
  2321. {
  2322. // if (lpProcessMsg->pCharObject != this)
  2323. // {
  2324. if (lpProcessMsg->wIdent == RM_PUSH)
  2325. fnMakeDefMessage(&DefMsg, SM_BACKSTEP, (int)lpProcessMsg->pCharObject, (unsigned short)lpProcessMsg->lParam1/*x*/, 
  2326. (unsigned short)lpProcessMsg->lParam2/*y*/, lpProcessMsg->wParam);
  2327. else if (lpProcessMsg->wIdent == RM_RUSH)
  2328. fnMakeDefMessage(&DefMsg, SM_RUSH, (int)lpProcessMsg->pCharObject, (unsigned short)lpProcessMsg->lParam1/*x*/, 
  2329. (unsigned short)lpProcessMsg->lParam2/*y*/, lpProcessMsg->wParam);
  2330. // }
  2331. SendSocket(&DefMsg, NULL);
  2332. break;
  2333. }
  2334. case RM_DISAPPEAR:
  2335. {
  2336. fnMakeDefMessage(&DefMsg, SM_DISAPPEAR, (int)lpProcessMsg->pCharObject, 0, 0, 0);
  2337. SendSocket(&DefMsg, NULL);
  2338. break;
  2339. }
  2340. case RM_CLEAROBJECTS:
  2341. {
  2342. fnMakeDefMessage(&DefMsg, SM_CLEAROBJECTS, 0, 0, 0, 0);
  2343. SendSocket(&DefMsg, NULL);
  2344. break;
  2345. }
  2346. case RM_CHANGEMAP:
  2347. {
  2348.   fnMakeDefMessage(&DefMsg, SM_CHANGEMAP, (int)this, m_nCurrX, m_nCurrY, MAKEWORD(DayBright(), m_pMap->m_btSeries));
  2349. nPos = fnEncode6BitBufA((unsigned char *)m_pMap->m_szMapName, szEncodeMsg, memlen(m_pMap->m_szMapName) - 1, sizeof(szEncodeMsg));
  2350. szEncodeMsg[nPos] = '';
  2351. SendSocket(&DefMsg, szEncodeMsg);
  2352. SendMapName();
  2353. break;
  2354. }
  2355. case RM_SPACEMOVE_SHOW:
  2356. {
  2357. break;
  2358. }
  2359. case RM_DOOROPEN:
  2360. {
  2361.   fnMakeDefMessage(&DefMsg, SM_DOOROPEN, 1, (unsigned short)lpProcessMsg->lParam1, 0, 0);
  2362. SendSocket(&DefMsg, NULL);
  2363. break;
  2364. }
  2365. case RM_ABILITY:
  2366. {
  2367. fnMakeDefMessage(&DefMsg, SM_ABILITY, m_pUserInfo->m_THumanRcd.dwGold, m_pUserInfo->m_THumanRcd.btJob, 0, 0);
  2368. nPos = fnEncode6BitBufA((unsigned char *)&m_WAbility, szEncodeMsg, sizeof(m_WAbility), sizeof(szEncodeMsg));
  2369. szEncodeMsg[nPos] = '';
  2370. SendSocket(&DefMsg, szEncodeMsg);
  2371. break;
  2372. }
  2373. case RM_SUBABILITY:
  2374. {
  2375. fnMakeDefMessage(&DefMsg, SM_SUBABILITY, MAKELONG(MAKEWORD(m_btAntiMagic, 0), 0), MAKEWORD(m_btHitPoint, m_btSpeedPoint), MAKEWORD(m_btAntiPoison, m_btPoisonRecover), MAKEWORD(m_btHealthRecover, m_btSpellRecover));
  2376. SendSocket(&DefMsg, NULL);
  2377. break;
  2378. }
  2379. case RM_DEATH:
  2380. {
  2381. if (lpProcessMsg->lParam3 == 1)
  2382. fnMakeDefMessage(&DefMsg, SM_NOWDEATH, (int)lpProcessMsg->pCharObject, (WORD)lpProcessMsg->lParam1, (WORD)lpProcessMsg->lParam2, lpProcessMsg->wParam);
  2383. else
  2384. fnMakeDefMessage(&DefMsg, SM_DEATH, (int)lpProcessMsg->pCharObject, (WORD)lpProcessMsg->lParam1, (WORD)lpProcessMsg->lParam2, lpProcessMsg->wParam);
  2385. CharDesc.Feature = lpProcessMsg->pCharObject->GetFeatureToLong();
  2386. CharDesc.Status = lpProcessMsg->pCharObject->m_nCharStatus;
  2387. nPos = fnEncode6BitBufA((unsigned char *)&CharDesc, szEncodeMsg, sizeof(CharDesc), sizeof(szEncodeMsg));
  2388. szEncodeMsg[nPos] = '';
  2389. SendSocket(&DefMsg, szEncodeMsg);
  2390. break;
  2391. }
  2392. case RM_SKELETON:
  2393. {
  2394. fnMakeDefMessage(&DefMsg, SM_SKELETON, (int)lpProcessMsg->pCharObject, (WORD)lpProcessMsg->lParam1, (WORD)lpProcessMsg->lParam2, lpProcessMsg->wParam);
  2395. CharDesc.Feature = lpProcessMsg->pCharObject->GetFeatureToLong();
  2396. CharDesc.Status = lpProcessMsg->pCharObject->m_nCharStatus;
  2397. nPos = fnEncode6BitBufA((unsigned char *)&CharDesc, szEncodeMsg, sizeof(CharDesc), sizeof(szEncodeMsg));
  2398. szEncodeMsg[nPos] = '';
  2399. SendSocket(&DefMsg, szEncodeMsg);
  2400. break;
  2401. }
  2402. case RM_LEVELUP:
  2403. {
  2404. fnMakeDefMessage(&DefMsg, SM_LEVELUP, m_Ability.Exp, m_Ability.Level, 0, 0);
  2405. SendSocket(&DefMsg, NULL);
  2406. fnMakeDefMessage(&DefMsg, SM_ABILITY, m_pUserInfo->m_THumanRcd.dwGold, m_pUserInfo->m_THumanRcd.btJob, 0, 0);
  2407. nPos = fnEncode6BitBufA((unsigned char *)&m_WAbility, szEncodeMsg, sizeof(m_WAbility), sizeof(szEncodeMsg));
  2408. szEncodeMsg[nPos] = '';
  2409. SendSocket(&DefMsg, szEncodeMsg);
  2410. fnMakeDefMessage(&DefMsg, SM_SUBABILITY, MAKELONG(MAKEWORD(m_btAntiMagic, 0), 0), MAKEWORD(m_btHitPoint, m_btSpeedPoint), MAKEWORD(m_btAntiPoison, m_btPoisonRecover), MAKEWORD(m_btHealthRecover, m_btSpellRecover));
  2411. SendSocket(&DefMsg, NULL);
  2412. break;
  2413. }
  2414. case RM_HEALTHSPELLCHANGED:
  2415. {
  2416. fnMakeDefMessage(&DefMsg, SM_HEALTHSPELLCHANGED, (int)lpProcessMsg->pCharObject, m_WAbility.HP, m_WAbility.MP, m_WAbility.MaxHP);
  2417. SendSocket(&DefMsg, NULL);
  2418. break;
  2419. }
  2420. case RM_FEATURECHANGED:
  2421. {
  2422. fnMakeDefMessage(&DefMsg, SM_FEATURECHANGED, (int)lpProcessMsg->pCharObject, LOWORD(lpProcessMsg->lParam1), HIWORD(lpProcessMsg->lParam1), 0);
  2423. SendSocket(&DefMsg, NULL);
  2424. break;
  2425. }
  2426. case RM_OPENHEALTH:
  2427. {
  2428. fnMakeDefMessage(&DefMsg, SM_OPENHEALTH, (int)lpProcessMsg->pCharObject, lpProcessMsg->pCharObject->m_WAbility.HP
  2429. , lpProcessMsg->pCharObject->m_WAbility.MaxHP, 0);
  2430. SendSocket(&DefMsg, NULL);
  2431. break;
  2432. }
  2433. case RM_CLOSEHEALTH:
  2434. {
  2435. fnMakeDefMessage(&DefMsg, SM_CLOSEHEALTH, (int)lpProcessMsg->pCharObject, 0, 0, 0);
  2436. SendSocket(&DefMsg, NULL);
  2437. break;
  2438. }
  2439. case RM_SENDUSEITEMS:
  2440. {
  2441. fnMakeDefMessage(&DefMsg, SM_SENDUSEITEMS, 0, 0, 0, 0);
  2442. nPos = fnEncode6BitBufA((unsigned char *)m_pUserInfo->m_THumanRcd.szTakeItem, szEncodeMsg, sizeof(m_pUserInfo->m_THumanRcd.szTakeItem), sizeof(szEncodeMsg));
  2443. szEncodeMsg[nPos] = '';
  2444. SendSocket(&DefMsg, szEncodeMsg);
  2445. break;
  2446. }
  2447. case RM_SENDMYMAGIC:
  2448. {
  2449. SendMyMagics();
  2450. break;
  2451. }
  2452. case RM_DAYCHANGING:
  2453. {
  2454. fnMakeDefMessage(&DefMsg, SM_DAYCHANGING, 0, m_btBright, DayBright(), 0);
  2455. SendSocket(&DefMsg, NULL);
  2456. break;
  2457. }
  2458. case RM_MAGSTRUCK:
  2459. case RM_MAGSTRUCK_MINE:
  2460. {
  2461. int nVal = GetMagStruckDamage(lpProcessMsg->lParam1);
  2462. if (nVal > 0)
  2463. {
  2464. StruckDamage(nVal);
  2465. HealthSpellChanged();
  2466. AddRefMsg(RM_STRUCK_MAG, nVal, m_WAbility.HP, m_WAbility.MP, (int)lpProcessMsg->pCharObject, NULL);
  2467. }
  2468. break;
  2469. }
  2470. case RM_CHARSTATUSCHANGED:
  2471. {
  2472. fnMakeDefMessage(&DefMsg, SM_CHARSTATUSCHANGED, (int)lpProcessMsg->pCharObject, 
  2473. LOWORD(lpProcessMsg->lParam1), HIWORD(lpProcessMsg->lParam1), lpProcessMsg->wParam);
  2474. SendSocket(&DefMsg, NULL);
  2475. break;
  2476. }
  2477. case RM_CHANGELIGHT:
  2478. {
  2479. fnMakeDefMessage(&DefMsg, SM_CHANGELIGHT, (int)lpProcessMsg->pCharObject, 
  2480. lpProcessMsg->pCharObject->m_btLight, 0, 0);
  2481. SendSocket(&DefMsg, NULL);
  2482. break;
  2483. }
  2484. case RM_MAGIC_LVEXP:
  2485. {
  2486. fnMakeDefMessage(&DefMsg, SM_MAGIC_LVEXP, lpProcessMsg->lParam3, 
  2487. (WORD)lpProcessMsg->lParam2, (WORD)lpProcessMsg->lParam1, 0);
  2488. SendSocket(&DefMsg, NULL);
  2489. break;
  2490. }
  2491. case RM_DIGUP:
  2492. {
  2493. fnMakeDefMessage(&DefMsg, SM_DIGUP, (int)lpProcessMsg->pCharObject, 
  2494. (WORD)lpProcessMsg->lParam1, (WORD)lpProcessMsg->lParam2, MAKEWORD(lpProcessMsg->wParam, lpProcessMsg->pCharObject->m_btLight));
  2495. MsgBodyWL.lParam1 = lpProcessMsg->pCharObject->GetFeatureToLong();
  2496. MsgBodyWL.lParam2 = lpProcessMsg->pCharObject->m_nCharStatus;
  2497. MsgBodyWL.nTag1 = lpProcessMsg->lParam3;
  2498. nPos = fnEncode6BitBufA((unsigned char *)&MsgBodyWL, szEncodeMsg, sizeof(MsgBodyWL), sizeof(szEncodeMsg));
  2499. szEncodeMsg[nPos] = '';
  2500. SendSocket(&DefMsg, szEncodeMsg);
  2501. break;
  2502. }
  2503. case RM_DIGDOWN:
  2504. {
  2505. fnMakeDefMessage(&DefMsg, SM_DIGDOWN, (int)lpProcessMsg->pCharObject, 
  2506. (WORD)lpProcessMsg->lParam1, (WORD)lpProcessMsg->lParam2, 0);
  2507. SendSocket(&DefMsg, NULL);
  2508. break;
  2509. }
  2510. case RM_ITEMSHOW:
  2511. {
  2512. fnMakeDefMessage(&DefMsg, SM_ITEMSHOW, lpProcessMsg->lParam1, 
  2513. (WORD)lpProcessMsg->lParam2, (WORD)lpProcessMsg->lParam3, lpProcessMsg->wParam);
  2514. nPos = fnEncode6BitBufA((unsigned char *)lpProcessMsg->pszData, szEncodeMsg, memlen(lpProcessMsg->pszData) - 1, sizeof(szEncodeMsg));
  2515. szEncodeMsg[nPos] = '';
  2516. SendSocket(&DefMsg, szEncodeMsg);
  2517. break;
  2518. }
  2519. case RM_ITEMHIDE:
  2520. {
  2521. fnMakeDefMessage(&DefMsg, SM_ITEMHIDE, lpProcessMsg->lParam1, 
  2522. (WORD)lpProcessMsg->lParam2, (WORD)lpProcessMsg->lParam3, 0);
  2523. SendSocket(&DefMsg, NULL);
  2524. break;
  2525. }
  2526. case RM_DURACHANGE:
  2527. {
  2528. fnMakeDefMessage(&DefMsg, SM_DURACHANGE, lpProcessMsg->lParam1, 
  2529. (WORD)lpProcessMsg->wParam, LOWORD(lpProcessMsg->lParam2), HIWORD(lpProcessMsg->lParam2));
  2530. SendSocket(&DefMsg, NULL);
  2531. break;
  2532. }
  2533. case RM_WEIGHTCHANGED:
  2534. {
  2535. fnMakeDefMessage(&DefMsg, SM_WEIGHTCHANGED, m_WAbility.Weight, m_WAbility.WearWeight, m_WAbility.HandWeight, 0); 
  2536. SendSocket(&DefMsg, NULL);
  2537. break;
  2538. }
  2539. case RM_GOLDCHANGED:
  2540. {
  2541. fnMakeDefMessage(&DefMsg, SM_GOLDCHANGED, (int)m_pUserInfo->GetGold(), 0, 0, 0); 
  2542. SendSocket(&DefMsg, NULL);
  2543. break;
  2544. }
  2545. case RM_WINEXP:
  2546. {
  2547. fnMakeDefMessage(&DefMsg, SM_WINEXP, m_Ability.Exp, (WORD)lpProcessMsg->lParam1, 0, 0); 
  2548. SendSocket(&DefMsg, NULL);
  2549. break;
  2550. }
  2551. case RM_SHOWEVENT:
  2552. {
  2553. tsMsg.wIdent = HIWORD(lpProcessMsg->lParam2);
  2554. tsMsg.wMsg = 0;
  2555. fnMakeDefMessage(&DefMsg, SM_SHOWEVENT, (int)lpProcessMsg->lParam1, lpProcessMsg->wParam, LOWORD(lpProcessMsg->lParam2), (WORD)lpProcessMsg->lParam3); 
  2556. nPos = fnEncode6BitBufA((unsigned char *)&tsMsg, szEncodeMsg, sizeof(_TSHORTMSSEAGE), sizeof(szEncodeMsg));
  2557. szEncodeMsg[nPos] = '';
  2558. SendSocket(&DefMsg, szEncodeMsg);
  2559. break;
  2560. }
  2561. case RM_HIDEEVENT:
  2562. {
  2563. fnMakeDefMessage(&DefMsg, SM_HIDEEVENT, (int)lpProcessMsg->lParam1, lpProcessMsg->wParam, (WORD)lpProcessMsg->lParam2, (WORD)lpProcessMsg->lParam3); 
  2564. SendSocket(&DefMsg, NULL);
  2565. break;
  2566. }
  2567. case RM_CHANGENAMECOLOR:
  2568. {
  2569. fnMakeDefMessage(&DefMsg, SM_CHANGENAMECOLOR, (int)lpProcessMsg->pCharObject, lpProcessMsg->pCharObject->GetThisCharColor(), 0, 0); 
  2570. SendSocket(&DefMsg, NULL);
  2571. break;
  2572. }    
  2573. case RM_FLYAXE:
  2574. {
  2575. if (lpProcessMsg->lParam3 != 0)
  2576. {
  2577. MsgBodyWL.lParam1 = ((CCharObject*)lpProcessMsg->lParam3)->m_nCurrX;
  2578. MsgBodyWL.lParam2 = ((CCharObject*)lpProcessMsg->lParam3)->m_nCurrY;
  2579. MsgBodyWL.nTag1 = LOWORD(lpProcessMsg->lParam3);
  2580. MsgBodyWL.nTag2 = HIWORD(lpProcessMsg->lParam3);
  2581. fnMakeDefMessage(&DefMsg, SM_FLYAXE, (int)lpProcessMsg->pCharObject, (WORD)lpProcessMsg->lParam1, (WORD)lpProcessMsg->lParam2, lpProcessMsg->wParam/*Dir*/);
  2582. nPos = fnEncode6BitBufA((unsigned char *)&MsgBodyWL, szEncodeMsg, sizeof(MsgBodyWL), sizeof(szEncodeMsg));
  2583. szEncodeMsg[nPos] = '';
  2584. SendSocket(&DefMsg, szEncodeMsg);
  2585. }
  2586. break;
  2587. }
  2588. case RM_LIGHTING:
  2589. {
  2590. if (lpProcessMsg->lParam3 != 0)
  2591. {
  2592. MsgBodyWL.lParam1 = ((CCharObject*)lpProcessMsg->lParam3)->m_nCurrX;
  2593. MsgBodyWL.lParam2 = ((CCharObject*)lpProcessMsg->lParam3)->m_nCurrY;
  2594. MsgBodyWL.nTag1 = lpProcessMsg->lParam3;
  2595. MsgBodyWL.nTag2 = lpProcessMsg->wParam;
  2596. fnMakeDefMessage(&DefMsg, SM_LIGHTING, (int)lpProcessMsg->pCharObject, (WORD)lpProcessMsg->lParam1, (WORD)lpProcessMsg->lParam2, lpProcessMsg->pCharObject->m_nDirection);
  2597. nPos = fnEncode6BitBufA((unsigned char *)&MsgBodyWL, szEncodeMsg, sizeof(MsgBodyWL), sizeof(szEncodeMsg));
  2598. szEncodeMsg[nPos] = '';
  2599. SendSocket(&DefMsg, szEncodeMsg);
  2600. }
  2601. break;
  2602. }
  2603. case RM_ITEMUPDATE:
  2604. {
  2605. fnMakeDefMessage(&DefMsg, SM_ITEMUPDATE, (int)lpProcessMsg->pCharObject, (WORD)lpProcessMsg->wParam, (WORD)0, 0);
  2606. nPos = fnEncode6BitBufA((unsigned char *)lpProcessMsg->pszData, szEncodeMsg, memlen(lpProcessMsg->pszData), sizeof(szEncodeMsg));
  2607. szEncodeMsg[nPos] = '';
  2608. SendSocket(&DefMsg, szEncodeMsg);
  2609. break;
  2610. }
  2611. case RM_USERNAME:
  2612. {
  2613. fnMakeDefMessage(&DefMsg, SM_USERNAME, (int)lpProcessMsg->pCharObject, lpProcessMsg->pCharObject->GetThisCharColor(), (WORD)0, 0);
  2614. nPos = fnEncode6BitBufA((unsigned char *)lpProcessMsg->pszData, szEncodeMsg, memlen(lpProcessMsg->pszData), sizeof(szEncodeMsg));
  2615. szEncodeMsg[nPos] = '';
  2616. SendSocket(&DefMsg, szEncodeMsg);
  2617. break;
  2618. }
  2619. case RM_CHANGEFACE:
  2620. {
  2621. if (lpProcessMsg->lParam1 && lpProcessMsg->lParam2)
  2622. {
  2623. fnMakeDefMessage(&DefMsg, SM_CHANGEFACE, (int)lpProcessMsg->lParam1, LOWORD(lpProcessMsg->lParam2), HIWORD(lpProcessMsg->lParam2), 0);
  2624. CharDesc.Feature = lpProcessMsg->pCharObject->GetFeatureToLong();
  2625. CharDesc.Status = lpProcessMsg->pCharObject->m_nCharStatus;
  2626. nPos = fnEncode6BitBufA((unsigned char *)&CharDesc, szEncodeMsg, sizeof(CharDesc), sizeof(szEncodeMsg));
  2627. szEncodeMsg[nPos] = '';
  2628. SendSocket(&DefMsg, szEncodeMsg);
  2629. }
  2630. break;
  2631. }
  2632. } // switch
  2633. if (lpProcessMsg->pszData)
  2634. {
  2635. delete [] lpProcessMsg->pszData;
  2636. lpProcessMsg->pszData = NULL;
  2637. }
  2638. delete lpProcessMsg;
  2639. lpProcessMsg = NULL;
  2640. } // if
  2641. } // for loop
  2642. }
  2643. }