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

cJewelry.cpp 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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 cJewelry.cpp
  19. * Implements functionality for jewelry.
  20. *
  21. * This class is referenced whenever jewelry is created, used, or assessed.
  22. * Inherits from the cObject class.
  23. */
  24. #include "avatar.h"
  25. #include "object.h"
  26. #include "cItemModels.h"
  27. #include "client.h"
  28. #include "WorldManager.h"
  29. #include "MasterServer.h"
  30. /**
  31. * Handles the message sent for the creation of jewelry in the world.
  32. *
  33. * This function is called whenever jewelry should be created in the world for a client.
  34. *
  35. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  36. */
  37. cMessage cJewelry::CreatePacket( )
  38. {
  39. cMessage cmReturn;
  40. cItemModels *pcModel = cItemModels::FindModel( m_dwItemModelID );
  41. cObject *pcObject = cWorldManager::FindObject( m_dwGUID );
  42. if( pcModel )
  43. {
  44. cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant
  45. cmReturn << pcModel->m_bPaletteChange
  46. << pcModel->m_bTextureChange
  47. << pcModel->m_bModelChange;
  48. // The Model Vectors
  49. if ( pcModel->m_bPaletteChange != 0)
  50. {
  51. for (int i = 0; i < pcModel->m_bPaletteChange; i++)
  52. {
  53. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorPal[i],sizeof(pcModel->m_vectorPal[i]));
  54. }
  55. }
  56. if (pcModel->m_bPaletteChange != 0)
  57. {
  58. cmReturn << WORD( pcModel->m_wUnknown1 );
  59. }
  60. if ( pcModel->m_bTextureChange != 0)
  61. {
  62. for (int i = 0; i < pcModel->m_bTextureChange; i++)
  63. {
  64. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i]));
  65. }
  66. }
  67. if ( pcModel->m_bModelChange != 0)
  68. {
  69. for (int i = 0; i < pcModel->m_bModelChange; i++)
  70. {
  71. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i]));
  72. }
  73. }
  74. }
  75. cmReturn.pasteAlign(4);
  76. cmReturn << pcModel->m_dwFlags1 << 0x414L << 0x65L;
  77. // MASK 0x00008000 -- Location
  78. if ( !m_fIsOwned )
  79. cmReturn.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) );
  80. // MASK 0x00000800 -- Sound Set
  81. DWORD dwSoundSet = 0x20000000L + pcModel->m_wSoundSet;
  82. cmReturn << dwSoundSet;
  83. // MASK 0x00001000 -- Particle Effects (unknown_blue)
  84. cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue;
  85. // MASK 0x00000001 -- ModelNumber
  86. DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber;
  87. cmReturn << dwModel;
  88. // MASK 0x00000080 -- Scale
  89. cmReturn << float(1.0);
  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. cmReturn << 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. // Flags2
  108. //DWORD dwFlags2 = 0x81210018;
  109. cmReturn << pcModel->m_dwFlags2;
  110. cmReturn << Name( ); // Object's Name
  111. cmReturn << pcModel->m_wModel; // Object's Model
  112. cmReturn << this->m_wIcon; // Object's Icon
  113. cmReturn << pcModel->m_dwObjectFlags1; // Object Flags
  114. cmReturn << pcModel->m_dwObjectFlags2; // Object Flags
  115. // Masked against dwFlags2
  116. // Mask 0x0008 - Value
  117. cmReturn << pcModel->m_dwValue;
  118. // Mask 0x0010 dwUnknown_v2
  119. cmReturn << pcModel->m_dwUnknown_v2;
  120. // Mask 0x0080 - If Enchanted
  121. // Mask 0x10000 Equip Possible
  122. cmReturn << pcModel->m_dwEquipPossible;
  123. // Mask 0x00200000 - Burden
  124. cmReturn << pcModel->m_wBurden;
  125. //Mask 0x01000000 - Workmanship
  126. cmReturn << float(3.0);
  127. //Mask 0x80000000 - Material
  128. cmReturn << 0x05L;
  129. return cmReturn;
  130. }
  131. /**
  132. * Handles the message sent for the creation of jewelry in a container.
  133. *
  134. * This function is called whenever jewelry should be created in the inventory of another object.
  135. *
  136. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  137. */
  138. cMessage cJewelry::CreatePacketContainer(DWORD Container, DWORD ItemModelID)
  139. {
  140. cMessage cmReturn;
  141. cItemModels *pcModel = cItemModels::FindModel( ItemModelID );
  142. cObject *pcObject = cWorldManager::FindObject( m_dwGUID );
  143. if( pcModel )
  144. {
  145. cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant
  146. cmReturn << pcModel->m_bPaletteChange
  147. << pcModel->m_bTextureChange
  148. << pcModel->m_bModelChange;
  149. // The Model Vectors
  150. if ( pcModel->m_bPaletteChange != 0)
  151. {
  152. for (int i = 0; i < pcModel->m_bPaletteChange; i++)
  153. {
  154. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorPal[i],sizeof(pcModel->m_vectorPal[i]));
  155. }
  156. }
  157. if (pcModel->m_bPaletteChange != 0)
  158. {
  159. //Cubem0j0: Test code for armor only.
  160. cmReturn << WORD( pcModel->m_wUnknown_1 );
  161. }
  162. if ( pcModel->m_bTextureChange != 0)
  163. {
  164. for (int i = 0; i < pcModel->m_bTextureChange; i++)
  165. {
  166. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i]));
  167. }
  168. }
  169. if ( pcModel->m_bModelChange != 0)
  170. {
  171. for (int i = 0; i < pcModel->m_bModelChange; i++)
  172. {
  173. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i]));
  174. }
  175. }
  176. }
  177. cmReturn.pasteAlign(4);
  178. cmReturn << pcModel->m_dwFlags1 << 0x414L << 0x65L;
  179. // MASK 0x00000800 -- Sound Set
  180. DWORD dwSoundSet = 0x20000000L + pcModel->m_wSoundSet;
  181. cmReturn << dwSoundSet;
  182. // MASK 0x00001000 -- Particle Effects (unknown_blue)
  183. cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue;
  184. // MASK 0x00000001 -- ModelNumber
  185. DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber;
  186. cmReturn << dwModel;
  187. // MASK 0x00000080 -- Scale
  188. cmReturn << float(1.0);
  189. // SeaGreens
  190. WORD wNuminteracts = 0x0;
  191. WORD wNumbubbles = 0x0;
  192. WORD wNumJumps = 0x0;
  193. WORD wNumOverrides = 0x0;
  194. WORD wUnkFlag8 = 0x0;
  195. WORD wUnkFlag10 = 0x0;
  196. cmReturn << m_wPositionSequence
  197. << m_wNumAnims //wNuminteracts
  198. << wNumbubbles
  199. << wNumJumps
  200. << m_wNumPortals
  201. << m_wNumAnims
  202. << wNumOverrides
  203. << wUnkFlag8
  204. << m_wNumLogins
  205. << wUnkFlag10;
  206. // Flags2
  207. //DWORD dwFlags2 = 0x81214018;
  208. cmReturn << pcModel->m_dwFlags2;
  209. cmReturn << Name( ); // Object's Name
  210. cmReturn << pcModel->m_wModel; // Object's Model
  211. cmReturn << this->m_wIcon; // Object's Icon
  212. cmReturn << pcModel->m_dwObjectFlags1; // Object Flags
  213. cmReturn << pcModel->m_dwObjectFlags2; // Object Flags
  214. if(pcModel->m_dwFlags2 & 0x00000008)
  215. cmReturn << pcModel->m_dwValue;
  216. if(pcModel->m_dwFlags2 & 0x00000010)
  217. cmReturn << pcModel->m_dwUnknown_v2;
  218. if(pcModel->m_dwFlags2 & 0x00000080)
  219. cmReturn << pcModel->m_dwIconHighlight;
  220. if(pcModel->m_dwFlags2 & 0x00004000)
  221. cmReturn << Container;
  222. if(pcModel->m_dwFlags2 & 0x00010000)
  223. cmReturn << pcModel->m_dwEquipPossible;
  224. if(pcModel->m_dwFlags2 & 0x00200000)
  225. cmReturn << pcModel->m_wBurden;
  226. if(pcModel->m_dwFlags2 & 0x01000000)
  227. cmReturn << pcModel->m_wHooks;
  228. if(pcModel->m_dwFlags2 & 0x01000000)
  229. cmReturn << pcModel->m_fWorkmanship;
  230. if(pcModel->m_dwFlags2 & 0x80000000)
  231. cmReturn << pcModel->m_dwMaterialType;
  232. //cmReturn << WORD(0x0000);
  233. return cmReturn;
  234. }
  235. /**
  236. * Handles the actions of jewelry objects.
  237. *
  238. * This function is called whenever jewelry is used or should perform an action.
  239. */
  240. void cJewelry::Action(cClient *who)
  241. {
  242. //Action Complete
  243. cMessage cmActionComplete;
  244. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  245. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  246. }
  247. /**
  248. * Handles the assessment of jewelry objects.
  249. *
  250. * This function is called whenever jewelry is assessed by a client.
  251. *
  252. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  253. */
  254. void cJewelry::Assess( cClient *pcAssesser )
  255. {
  256. //Cubem0j0: See comments below.
  257. cItemModels *pcModel = cItemModels::FindModel( m_dwItemModelID );
  258. cMessage cmAssess;
  259. DWORD flags = 0x00000089;
  260. cmAssess << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID() << ++pcAssesser->m_dwF7B0Sequence << 0xC9L << m_dwGUID
  261. << flags;
  262. pcAssesser->AddPacket(WORLD_SERVER, cmAssess,4);
  263. cMessage cmActionComplete;
  264. cmActionComplete << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID( ) << ++pcAssesser->m_dwF7B0Sequence << 0x01C7L << 0L;
  265. pcAssesser->AddPacket(WORLD_SERVER,cmActionComplete,4);
  266. }