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

cDoor.cpp 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 cDoor.cpp
  19. * Handles the door object functions.
  20. *
  21. * This class is referenced whenever a door is created, used, or assessed.
  22. * Inherits from the cObject class.
  23. */
  24. #include "Client.h"
  25. #include "MasterServer.h"
  26. #include "Object.h"
  27. #include "WorldManager.h"
  28. /***************
  29. * constructors
  30. **************/
  31. /**
  32. * Handles the creation of doors.
  33. *
  34. * Called whenever a door object should be initialized.
  35. */
  36. cDoor::cDoor( WORD type, DWORD dwGUID, cLocation *pcLoc, char *szName, char *szDesc)
  37. {
  38. SetLocation( pcLoc );
  39. m_dwGUID = dwGUID;//cWorldManager::NewGUID_Object( );
  40. m_strName.assign( szName );
  41. m_strDescription.assign( szDesc );
  42. m_dwModel = type;
  43. m_dwType = 0;
  44. m_fStatic = TRUE;
  45. m_dwDoorState = 0x0CL;
  46. }
  47. /**********
  48. * methods
  49. *********/
  50. /**
  51. * Handles the message sent for the creation of doors in the world.
  52. *
  53. * This function is called whenever a door should be created in the world for a given client.
  54. *
  55. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  56. */
  57. cMessage cDoor::CreatePacket()
  58. {
  59. cMessage cmCreate;
  60. unsigned char bUnknown[] = {
  61. 0x00, 0x00, // Animation type 0 - 1
  62. 0x3D, 0x00, // Starting Stance 2 - 3
  63. 0x02, 0xF0, 0xB4, 0x02, // Unknown - Flag 0x00000002 in it 4 - 7
  64. 0x0B, 0x00, 0x00, 0x00, // Status 9 - 11
  65. };
  66. cmCreate << 0xF745L
  67. << m_dwGUID
  68. << BYTE( 0x11 )
  69. << BYTE( 0 )
  70. << BYTE( 0 )
  71. << BYTE( 0 );
  72. DWORD dwFlags = 0x00019803L;
  73. cmCreate << dwFlags;
  74. cmCreate << WORD( 0x0008 );
  75. cmCreate << WORD( 0x0001 );
  76. // MASK 0x00010000 unknown Bytes - Starting Animation
  77. cmCreate << 0x0CL;
  78. CopyMemory(&bUnknown[9],&m_dwDoorState,4);
  79. cmCreate.pasteData(bUnknown,sizeof(bUnknown));
  80. //cmCreate << 0x003D0000 << 0x02B4F002 << m_dwDoorState; //0x0000000C; // unknownByte
  81. cmCreate << 0x0L;
  82. // MASK 0x00008000 -- Location
  83. if ( !m_fIsOwned )
  84. cmCreate.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) );
  85. // MASK 0x00000002 -- Animation Set
  86. DWORD dwAnimC = 0x09000000L + m_wAnimConfig;
  87. cmCreate << dwAnimC;
  88. // MASK 0x00000800 -- Sound Set
  89. DWORD dwSoundSet = 0x20000000L + m_wSoundSet;
  90. cmCreate << dwSoundSet;
  91. // MASK 0x00001000 -- Particle Effects (unknown_blue)
  92. cmCreate << 0x3400002BL;//0x00000000L;
  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 //wNuminteracts
  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);//WORD( 0x019C ) << WORD( 0x1317 );;//WORD( 0x0116 ) << WORD( 0x1317 );
  115. DWORD dwObjectFlags1 = 0x80L;
  116. cmCreate << dwObjectFlags1;
  117. DWORD dwObjectFlags2 = 0x1014L;
  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 door objects.
  128. *
  129. * This function is called whenever a door is used or should perform an action.
  130. */
  131. void cDoor::Action(cClient* who)
  132. {
  133. cMessage cmUseDoor,cmRet;
  134. WORD m_wStance;
  135. if(m_wState == 0)
  136. {
  137. m_dwDoorState = 0x0CL;
  138. m_wStance = 0x3D; // Starting Stance
  139. m_wState = 1;
  140. }
  141. else
  142. {
  143. m_dwDoorState = 0x0BL;
  144. m_wStance = 0x3D;
  145. m_wState = 0;
  146. }
  147. cmUseDoor << 0xF74CL // Packet type
  148. << m_dwGUID // Door's GUID
  149. << m_wNumLogins // number of logins
  150. << ++m_wPositionSequence // sequence number
  151. << ++m_wNumAnims // Number Animations this login session
  152. << WORD(0x00) // Activity
  153. << WORD(0x00)
  154. << WORD(0x3D) // Starting Stance
  155. << DWORD(0x02B4F002) // Supposed to be Animation Mask
  156. << m_dwDoorState; // Door state Closed = 0x0C Open = 0x0B
  157. cWorldManager::SendToAllInFocus( who->m_pcAvatar->m_Location, cmUseDoor, 3 );
  158. cMessage cmActionComplete;
  159. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  160. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  161. }
  162. /**
  163. * Handles the assessment of door objects.
  164. *
  165. * This function is called whenever a door is assessed by a client.
  166. *
  167. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  168. */
  169. void cDoor::Assess(cClient *pcAssesser)
  170. {
  171. cMessage cmAssess;
  172. cmAssess << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID() << ++pcAssesser->m_dwF7B0Sequence << 0xC9L;
  173. cmAssess << m_dwGUID << 0x00400000L << 1L << (m_dwType ? "Use this Door to Close" : "Use this Door to Open");
  174. pcAssesser->AddPacket(WORLD_SERVER,cmAssess,4);
  175. }