ObjectEvent.cpp
上传用户:tt_chan
上传日期:2009-12-03
资源大小:4523k
文件大小:2k
源码类别:

模拟服务器

开发平台:

Visual C++

  1. #include "stdafx.h"
  2. void CEvent::Create(CMirMap* pMap, int nX, int nY, DWORD dwETime, int nType, BOOL fVisible)
  3. {
  4. m_dwOpenStartTime = GetTickCount();
  5. m_nEventType = nType;
  6. m_nEventParam = 0;
  7. m_dwContinueTime = dwETime;
  8. m_fVisible = fVisible;
  9. m_fClosed = FALSE;
  10. m_pMap = pMap;
  11. m_nX = nX;
  12. m_nY = nY;
  13. m_fActive = TRUE;
  14. m_nDamage = 0;
  15. m_pOwnObject = NULL;
  16. m_dwRunStart = GetTickCount();
  17. m_dwRunTick = 500;
  18. if (m_pMap && m_fVisible)
  19. m_pMap->AddNewObject(m_nX, m_nY, OS_EVENTOBJECT, this);
  20. else
  21. m_fVisible = FALSE;
  22. }
  23. void CEvent::Close()
  24. {
  25. m_dwCloseTime = GetTickCount();
  26. if (m_fVisible)
  27. {
  28. m_fVisible = FALSE;
  29. if (m_pMap)
  30. m_pMap->RemoveObject(m_nX, m_nY, OS_EVENTOBJECT, this);
  31. m_pMap = NULL;
  32. }
  33. }
  34. void CEvent::Run()
  35. {
  36. if (GetTickCount() - m_dwOpenStartTime > m_dwContinueTime)
  37. {
  38. m_fClosed = TRUE;
  39. Close();
  40. }
  41. }
  42. // **************************************************************************************
  43. //
  44. // 瘤堪贱 捞亥飘
  45. //
  46. // **************************************************************************************
  47. void CFireBurnEvent::Create(int nX, int nY, DWORD dwETime, CCharObject* pCharObject, int nDamage)
  48. {
  49. CEvent::Create(pCharObject->m_pMap, nX, nY, dwETime, ET_FIRE, TRUE);
  50. m_pOwnObject = pCharObject;
  51. m_nDamage = nDamage;
  52. }
  53. void CFireBurnEvent::Run()
  54. {
  55. if (GetTickCount() - m_dwTickTime > 3000)
  56. {
  57. m_dwTickTime = GetTickCount();
  58. CWHList<CCharObject*> ObjectList;
  59. m_pMap->GetAllObject(m_nX, m_nY, &ObjectList);
  60. if (ObjectList.GetCount())
  61. {
  62. PLISTNODE pListNode = ObjectList.GetHead();
  63. CCharObject* pTargetObject;
  64. while (pListNode)
  65. {
  66. if (pTargetObject = ObjectList.GetData(pListNode))
  67. {
  68. if (m_pOwnObject->IsProperTarget(pTargetObject))
  69. {
  70. pTargetObject->AddProcess(m_pOwnObject, RM_MAGSTRUCK_MINE, 0, m_nDamage, 0, 0);
  71. #ifdef _DEBUG
  72. char szMsg[64];
  73. sprintf(szMsg, "%s 瘤堪贱 嘎澜 - PW:%d HP:%d", pTargetObject->m_szName, m_nDamage, pTargetObject->m_WAbility.HP);
  74. m_pOwnObject->SysMsg(szMsg, 0);
  75. #endif
  76. }
  77. }
  78. pListNode = ObjectList.RemoveNode(pListNode);
  79. }
  80. }
  81. }
  82. CEvent::Run();
  83. }