Clone of UAS2 @ https://github.com/drudgedance/uas2

cLifestone.cpp 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*
  2. * This file is part of UAS2.
  3. *
  4. * UAS2 is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * UAS2 is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. * You should have received a copy of the GNU General Public License
  14. * along with UASv1; if not, write to the Free Software
  15. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. /**
  18. * @file cLifestone.cpp
  19. * Implements functionality for lifestones.
  20. *
  21. * This class is referenced whenever a lifestone is created, used, or assessed.
  22. * Inherits from the cObject class.
  23. */
  24. #include "Object.h"
  25. #include "MasterServer.h"
  26. #include "WorldManager.h"
  27. #include "CommandParser.h"
  28. /***************
  29. * constructors
  30. **************/
  31. /**
  32. * Handles the creation of lifestones.
  33. *
  34. * Called whenever a lifestone object should be initialized.
  35. */
  36. cLifestone::cLifestone(WORD type, DWORD dwGUID, cLocation *pcLoc, char *szName, char *szDesc)
  37. {
  38. SetLocation(pcLoc);
  39. m_dwGUID = dwGUID;
  40. m_strName.assign( szName );
  41. m_strDescription.assign( szDesc );
  42. m_dwModel = type;
  43. m_fStatic = TRUE;
  44. }
  45. /**********
  46. * methods
  47. *********/
  48. /**
  49. * Handles the message sent for the creation of lifestones in the world.
  50. *
  51. * This function is called whenever a lifestone should be created in the world for a client.
  52. *
  53. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  54. */
  55. cMessage cLifestone::CreatePacket()
  56. {
  57. cMessage cmCreate;
  58. unsigned char bUnknown[] = {
  59. 0x00, 0x00, // Animation type 0 - 1
  60. 0x3D, 0x00, // Starting Stance 2 - 3
  61. 0x00, 0xF0, 0xAA, 0x02, // Unknown - Flag 0x00000002 in it 4 - 7
  62. };
  63. cmCreate << 0xF745L
  64. << m_dwGUID
  65. << BYTE( 0x11 )
  66. << BYTE( 0 )
  67. << BYTE( 0 )
  68. << BYTE( 0 );
  69. DWORD dwFlags = 0x00018803L;
  70. WORD wPortalMode = 0x0410;
  71. cmCreate << dwFlags;
  72. cmCreate << WORD( wPortalMode );
  73. cmCreate << WORD( 0x0000 ); // wUnknown_1
  74. // MASK 0x00010000 unknown Bytes - Starting Animation
  75. cmCreate << 0x08L;
  76. cmCreate.pasteData(bUnknown,sizeof(bUnknown));
  77. cmCreate << 0x0L;
  78. // MASK 0x00008000 - Location
  79. if ( !m_fIsOwned )
  80. cmCreate.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) );
  81. // MASK 0x00000002 Animation Set
  82. DWORD dwAnimC = 0x09000000L + m_wAnimConfig;
  83. cmCreate << dwAnimC;
  84. // MASK 0x00000800 Sound Set
  85. DWORD dwSoundSet = 0x20000000L + m_wSoundSet;
  86. cmCreate << dwSoundSet;
  87. // MASK 0x00000001 ModelNumber
  88. DWORD dwModel = 0x02000000L + m_dwModel;
  89. cmCreate << dwModel;
  90. // SeaGreens
  91. WORD wNuminteracts = 0x0;
  92. WORD wNumbubbles = 0x0;
  93. WORD wNumJumps = 0x0;
  94. WORD wNumOverrides = 0x0;
  95. WORD wUnkFlag8 = 0x0;
  96. WORD wUnkFlag10 = 0x0;
  97. cmCreate << m_wPositionSequence
  98. << m_wNumAnims //wNuminteracts
  99. << wNumbubbles
  100. << wNumJumps
  101. << m_wNumPortals
  102. << m_wNumAnims
  103. << wNumOverrides
  104. << wUnkFlag8
  105. << m_wNumLogins
  106. << wUnkFlag10;
  107. DWORD dwFlags2 = 0x00800030;
  108. cmCreate << dwFlags2 << m_strName.c_str( ) << WORD(m_wModel) << WORD(m_wIcon);
  109. //DWORD dwObjectFlags1 = 0x80L;
  110. cmCreate << m_dwObjectsFlag1;
  111. //DWORD dwObjectFlags2 = 0x1014L;
  112. cmCreate << m_dwObjectsFlag2 ;
  113. // Masked against dwFlags2
  114. // Mask 0x0010 dwUnknown_v2
  115. cmCreate << DWORD(0x20);
  116. // Mask 0x0020 - unknown_v3
  117. cmCreate << float(2.0);
  118. // Mask 0x00800000 - unknown_v6
  119. cmCreate << BYTE(0x04);
  120. return cmCreate;
  121. }
  122. /**
  123. * Handles the actions of lifestone objects.
  124. *
  125. * This function is called whenever a lifestone is used or should perform an action.
  126. */
  127. void cLifestone::Action(cClient *who)
  128. {
  129. cMessage cmActionComplete;
  130. WORD wAnimate = 0x0057;
  131. float flSpeed = 1.0f;
  132. cMessage cAnimate = who->m_pcAvatar->Animation(wAnimate, flSpeed);
  133. cWorldManager::SendToAllInFocus( who->m_pcAvatar->m_Location, cAnimate, 3 );
  134. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  135. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  136. DWORD dwSound = 0x51L;
  137. cMessage cSound = who->m_pcAvatar->SoundEffect(dwSound,1.0f);
  138. cWorldManager::SendToAllInFocus( who->m_pcAvatar->m_Location, cSound, 3 );
  139. cMasterServer::ServerMessage(7,who,"You have attuned your spirit to this Lifestone. You will resurrect here after you die.");
  140. cLocation pcLoc = who->m_pcAvatar->m_Location;
  141. DWORD dwGUID = who->m_pcAvatar->GetGUID();
  142. std::string strName = who->m_pcAvatar->Name();
  143. cCommandParser::RecordLifestone(who->m_pcAvatar->m_Location,dwGUID);
  144. }
  145. /**
  146. * Handles the assessment of lifestone objects.
  147. *
  148. * This function is called whenever a lifestone is assessed by a client.
  149. *
  150. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  151. */
  152. void cLifestone::Assess(cClient *pcAssesser)
  153. {
  154. cMessage cmAssess;
  155. //Fill out basic header
  156. cmAssess << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID() << ++pcAssesser->m_dwF7B0Sequence << 0xC9L;
  157. cmAssess << m_dwGUID << 0x8L << 1L << WORD(0x01) << WORD(0x0) << WORD(0x10) << "Use this item to set your resurrection point.";
  158. pcAssesser->AddPacket(WORLD_SERVER,cmAssess,4);
  159. }