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

cAltar.cpp 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 cAltar.cpp
  19. * Handles the altar object functions.
  20. *
  21. * This class is referenced whenever an altar is created, used, or assessed.
  22. * Inherits from the cObject class.
  23. */
  24. //Cubem0j0: Need to review, this may be a better fit under World objects.
  25. #include "Client.h"
  26. #include "MasterServer.h"
  27. #include "Object.h"
  28. #include "WorldManager.h"
  29. /***************
  30. * constructors
  31. **************/
  32. /**
  33. * Handles the creation of altars.
  34. *
  35. * Called whenever an altar object should be initialized.
  36. */
  37. cAltar::cAltar( DWORD dwType, DWORD dwGUID, cLocation *pcLoc, char* strName, char* strDesc)
  38. {
  39. SetLocation( pcLoc );
  40. m_dwGUID = dwGUID;
  41. m_strName.assign( strName );
  42. m_strDescription.assign( strDesc );
  43. m_dwType = dwType;
  44. m_dwModel = (dwType ? 0x0359 : 0x034E);
  45. m_wAnimConfig = (dwType ? 0x002E : 0x002D);
  46. m_wSoundSet = (dwType ? 0x0034 : 0x0035);
  47. m_wModel = (dwType ? 0x0356 : 0x0357);
  48. m_wIcon = (dwType ? 0x134F : 0x134F);
  49. m_fStatic = TRUE;
  50. m_wNumPortals = 0x1;
  51. }
  52. /**********
  53. * methods
  54. *********/
  55. /**
  56. * Handles the message sent for the creation of altars.
  57. *
  58. * This function is called whenever an altar should be created for a client.
  59. *
  60. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  61. */
  62. cMessage cAltar::CreatePacket()
  63. {
  64. cMessage cmCreate;
  65. unsigned char bUnknown[] = {
  66. 0x00, 0x00, // Animation type 0 - 1
  67. 0x3D, 0x00, // Starting Stance 2 - 3
  68. 0x00, 0xF0, 0x7A, 0x01, // Unknown - Flag 0x00000002 in it 4 - 7
  69. };
  70. cmCreate << 0xF745L
  71. << m_dwGUID
  72. << BYTE( 0x11 )
  73. << BYTE( 0 )
  74. << BYTE( 0 )
  75. << BYTE( 0 );
  76. DWORD dwFlags = 0x00018803L;
  77. cmCreate << dwFlags;
  78. cmCreate << WORD( 0x0410 );
  79. cmCreate << WORD( 0x0000 );
  80. // MASK 0x00010000 unknown Bytes - Starting Animation
  81. cmCreate << 0x08L;
  82. cmCreate.pasteData(bUnknown,sizeof(bUnknown));
  83. cmCreate << 0x0L;
  84. // MASK 0x00008000 - Location
  85. if ( !m_fIsOwned )
  86. cmCreate.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) );
  87. // MASK 0x00000002 Animation Set
  88. DWORD dwAnimC = 0x09000000L + m_wAnimConfig;
  89. cmCreate << dwAnimC;
  90. // MASK 0x00000800 Sound Set
  91. DWORD dwSoundSet = 0x20000000L + m_wSoundSet;
  92. cmCreate << dwSoundSet;
  93. // MASK 0x00000001 ModelNumber
  94. DWORD dwModel = 0x02000000L + m_dwModel;
  95. cmCreate << dwModel;
  96. // SeaGreens
  97. WORD wNuminteracts = 0x0;
  98. WORD wNumbubbles = 0x0;
  99. WORD wNumJumps = 0x0;
  100. WORD wNumOverrides = 0x0;
  101. WORD wUnkFlag8 = 0x0;
  102. WORD wUnkFlag10 = 0x0;
  103. cmCreate << m_wPositionSequence
  104. << m_wNumAnims
  105. << wNumbubbles
  106. << wNumJumps
  107. << m_wNumPortals
  108. << m_wNumAnims
  109. << wNumOverrides
  110. << wUnkFlag8
  111. << m_wNumLogins
  112. << wUnkFlag10;
  113. DWORD dwFlags2 = 0x00000030;
  114. cmCreate << dwFlags2 << m_strName.c_str( ) << WORD(m_wModel) << WORD(m_wIcon);
  115. DWORD dwObjectFlags1 = 0x80L;
  116. cmCreate << dwObjectFlags1;
  117. DWORD dwObjectFlags2 = (m_dwType ? 0x0414 : 0x0814);
  118. cmCreate << dwObjectFlags2 ;
  119. // Masked against dwFlags2
  120. // Mask 0x0010 dwUnknown_v2
  121. cmCreate << DWORD(0x20);
  122. // Mask 0x0020 - unknown_v3
  123. cmCreate << float(2.0);
  124. return cmCreate;
  125. }
  126. /**
  127. * Handles the actions of altar objects.
  128. *
  129. * This function is called whenever an altar is used or should perform an action.
  130. */
  131. void cAltar::Action(cClient* who)
  132. {
  133. who->m_pcAvatar->m_fIsPK = m_dwType;
  134. who->m_pcAvatar->SetIsPK_DB();
  135. DWORD dwFlagToSet;
  136. switch(m_dwType)
  137. {
  138. case 0:
  139. {
  140. dwFlagToSet = 0x2L;
  141. break;
  142. }
  143. case 1:
  144. {
  145. dwFlagToSet = 0x4L;
  146. break;
  147. }
  148. }
  149. cMessage cmSetFlag;
  150. cmSetFlag << 0x022CL << BYTE(0) << who->m_pcAvatar->GetGUID() << 0x4L << m_dwType; // byte(0) pkFlag 0x4L
  151. cWorldManager::SendToAllInFocus( who->m_pcAvatar->m_Location, cmSetFlag, 4 );
  152. cMasterServer::ServerMessage(ColorGreen,who,(m_dwType ? "You hear distant laughter of delight and welcome, as you join the ranks of those freed from Asheron's protective shackles by Bael'Zharon. You have become one of his Chosen, a Player Killer." : " You are enveloped in a feeling of warmth as you are brought back protection of Light."));
  153. cMessage cmActionComplete;
  154. // Particle Effect
  155. DWORD dwParticle = (m_dwType ? 71 : 141 );
  156. cMessage cPart = who->m_pcAvatar->Particle( dwParticle );
  157. cWorldManager::SendToAllInFocus( who->m_pcAvatar->m_Location, cPart, 3 );
  158. dwParticle = (m_dwType ? 142 : 147 );
  159. cMessage cPart2 = who->m_pcAvatar->Particle( dwParticle );
  160. cWorldManager::SendToAllInFocus( who->m_pcAvatar->m_Location, cPart2, 3 );
  161. // End Particle Effect
  162. cMessage cmCoverME;
  163. cmCoverME << 0x0229L << who->m_pcAvatar->m_bFlagCount++ << who->m_pcAvatar->GetGUID() << DWORD(134) << dwFlagToSet;
  164. cWorldManager::SendToAllInFocus( who->m_pcAvatar->m_Location, cmCoverME, 4 );
  165. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  166. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  167. }
  168. //TODO: Fix this assess message
  169. /**
  170. * Handles the assessment of altar objects.
  171. *
  172. * This function is called whenever an altar is assessed by a client.
  173. *
  174. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  175. */
  176. void cAltar::Assess(cClient *pcAssesser)
  177. {
  178. cMessage cmAssess;
  179. cmAssess << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID() << ++pcAssesser->m_dwF7B0Sequence << 0xC9L;
  180. cmAssess << m_dwGUID << 0x0008L << 1L << 0x0010L << (dwType ? "Use this altar to become PK" : "Use this altar to become an NPK");
  181. pcAssesser->AddPacket(WORLD_SERVER,cmAssess,4);
  182. cMessage cmActionComplete;
  183. cmActionComplete << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID( ) << ++pcAssesser->m_dwF7B0Sequence << 0x01C7L << 0L << 0L;
  184. pcAssesser->AddPacket(WORLD_SERVER,cmActionComplete,4);
  185. }