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

cGems.cpp 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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 cGems.cpp
  19. * Implements functionality for gems.
  20. *
  21. * This class is referenced whenever a gem 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 gems in the world.
  32. *
  33. * This function is called whenever a gem should be created in the world for a client.
  34. *
  35. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  36. */
  37. cMessage cGems::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. //Cubem0j0: Test code for armor only.
  59. cmReturn << WORD( 0x0C50 );
  60. }
  61. if ( pcModel->m_bTextureChange != 0)
  62. {
  63. for (int i = 0; i < pcModel->m_bTextureChange; i++)
  64. {
  65. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i]));
  66. }
  67. }
  68. if ( pcModel->m_bModelChange != 0)
  69. {
  70. for (int i = 0; i < pcModel->m_bModelChange; i++)
  71. {
  72. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i]));
  73. }
  74. }
  75. }
  76. cmReturn.pasteAlign(4);
  77. cmReturn << pcModel->m_dwFlags1 << 0x414L << 0x65L;
  78. // MASK 0x00008000 -- Location
  79. if ( !m_fIsOwned )
  80. cmReturn.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) );
  81. // MASK 0x00000800 -- Sound Set
  82. DWORD dwSoundSet = 0x20000000L + pcModel->m_wSoundSet;
  83. cmReturn << dwSoundSet;
  84. // MASK 0x00001000 -- Particle Effects (unknown_blue)
  85. cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue;
  86. // MASK 0x00000001 -- ModelNumber
  87. DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber;
  88. cmReturn << dwModel;
  89. // SeaGreens
  90. WORD wNuminteracts = 0x0;
  91. WORD wNumbubbles = 0x0;
  92. WORD wNumJumps = 0x0;
  93. WORD wNumOverrides = 0x0;
  94. WORD wUnkFlag8 = 0x0;
  95. WORD wUnkFlag10 = 0x0;
  96. cmReturn << m_wPositionSequence
  97. << m_wNumAnims //wNuminteracts
  98. << wNumbubbles
  99. << wNumJumps
  100. << m_wNumPortals
  101. << m_wNumAnims
  102. << wNumOverrides
  103. << wUnkFlag8
  104. << m_wNumLogins
  105. << wUnkFlag10;
  106. // if(pcModel->m_dwContainerID != 0)
  107. // {
  108. // DWORD owned = pcModel->m_dwFlags2 & 0x00004000;
  109. // cmReturn << owned;
  110. // }
  111. // else
  112. // {
  113. cmReturn << pcModel->m_dwFlags2; // Object Flags
  114. // }
  115. cmReturn << Name( ); // Object's Name
  116. cmReturn << pcModel->m_wModel; // Object's Model
  117. cmReturn << pcModel->m_wIcon; // Object's Icon
  118. cmReturn << pcModel->m_dwObjectFlags1; // Object Flags
  119. cmReturn << pcModel->m_dwObjectFlags2; // Object Flags
  120. //Gems flag2 - 81607098
  121. // Mask 0x0008 - Value
  122. if(pcModel->m_dwFlags2 & 0x00000008)
  123. {
  124. cmReturn << pcModel->m_dwValue;
  125. }
  126. // Mask 0x0010 dwUnknown_v2
  127. cmReturn << DWORD(0x00000008);
  128. // Mask 0x0080 Icon Highlight
  129. if(pcModel->m_dwFlags2 & 0x00000080)
  130. {
  131. cmReturn << pcModel->m_dwIconHighlight;
  132. }
  133. // Mask 0x1000 Stack
  134. if(pcModel->m_dwFlags2 & 0x00001000)
  135. {
  136. cmReturn << pcModel->m_wStack;
  137. }
  138. // Mask 0x2000 Stack Limit
  139. if(pcModel->m_dwFlags2 & 0x00002000)
  140. {
  141. cmReturn << pcModel->m_wStackLimit;
  142. }
  143. // Mask 0x4000 Container ID
  144. if(pcModel->m_dwFlags2 & 0x00004000)
  145. {
  146. cmReturn << pcModel->m_dwContainerID;
  147. }
  148. // Mask 0x00200000 - Burden
  149. if(pcModel->m_dwFlags2 & 0x00200000)
  150. {
  151. cmReturn << pcModel->m_wBurden;
  152. }
  153. // Mask 0x00400000 - Spell ID
  154. if(pcModel->m_dwFlags2 & 0x00400000)
  155. {
  156. cmReturn << 0x00BF;
  157. }
  158. // Mask 0x01000000 - Workmanship
  159. if(pcModel->m_dwFlags2 & 0x01000000)
  160. {
  161. cmReturn << pcModel->m_fWorkmanship;
  162. }
  163. // Mask 0x80000000 - Material
  164. if(pcModel->m_dwFlags2 & 0x80000000)
  165. {
  166. cmReturn << 0x1DL; //Lavender Jade
  167. }
  168. pcObject->SetType(7);
  169. return cmReturn;
  170. }
  171. /**
  172. * Handles the message sent for the creation of gems in a container.
  173. *
  174. * This function is called whenever a gem should be created in the inventory of another object.
  175. *
  176. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  177. */
  178. cMessage cGems::CreatePacketContainer(DWORD Container, DWORD ItemModelID)
  179. {
  180. cMessage cmReturn;
  181. cItemModels *pcModel = cItemModels::FindModel( ItemModelID );
  182. cObject *pcObject = cWorldManager::FindObject( m_dwGUID );
  183. if( pcModel )
  184. {
  185. cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant
  186. cmReturn << pcModel->m_bPaletteChange
  187. << pcModel->m_bTextureChange
  188. << pcModel->m_bModelChange;
  189. // The Model Vectors
  190. if ( pcModel->m_bPaletteChange != 0)
  191. {
  192. for (int i = 0; i < pcModel->m_bPaletteChange; i++)
  193. {
  194. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorPal[i],sizeof(pcModel->m_vectorPal[i]));
  195. }
  196. }
  197. if (pcModel->m_bPaletteChange != 0)
  198. {
  199. //Cubem0j0: Test code for armor only.
  200. cmReturn << WORD( 0x0C50 );
  201. }
  202. if ( pcModel->m_bTextureChange != 0)
  203. {
  204. for (int i = 0; i < pcModel->m_bTextureChange; i++)
  205. {
  206. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i]));
  207. }
  208. }
  209. if ( pcModel->m_bModelChange != 0)
  210. {
  211. for (int i = 0; i < pcModel->m_bModelChange; i++)
  212. {
  213. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i]));
  214. }
  215. }
  216. }
  217. cmReturn.pasteAlign(4);
  218. cmReturn << pcModel->m_dwFlags1 << 0x414L << 0x65L;
  219. // MASK 0x00000800 -- Sound Set
  220. DWORD dwSoundSet = 0x20000000L + pcModel->m_wSoundSet;
  221. cmReturn << dwSoundSet;
  222. // MASK 0x00001000 -- Particle Effects (unknown_blue)
  223. cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue;
  224. // MASK 0x00000001 -- ModelNumber
  225. DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber;
  226. cmReturn << dwModel;
  227. // SeaGreens
  228. WORD wNuminteracts = 0x0;
  229. WORD wNumbubbles = 0x0;
  230. WORD wNumJumps = 0x0;
  231. WORD wNumOverrides = 0x0;
  232. WORD wUnkFlag8 = 0x0;
  233. WORD wUnkFlag10 = 0x0;
  234. cmReturn << m_wPositionSequence
  235. << m_wNumAnims //wNuminteracts
  236. << wNumbubbles
  237. << wNumJumps
  238. << m_wNumPortals
  239. << m_wNumAnims
  240. << wNumOverrides
  241. << wUnkFlag8
  242. << m_wNumLogins
  243. << wUnkFlag10;
  244. cmReturn << pcModel->m_dwFlags2; // Object Flags
  245. cmReturn << Name( ); // Objects Name
  246. cmReturn << pcModel->m_wModel; // Objects Model
  247. cmReturn << pcModel->m_wIcon; // Objects Icon
  248. cmReturn << pcModel->m_dwObjectFlags1; // Object Flags
  249. cmReturn << pcModel->m_dwObjectFlags2; // Object Flags
  250. //Gems flag2 - 81607098
  251. // Mask 0x0008 - Value
  252. if(pcModel->m_dwFlags2 & 0x00000008)
  253. {
  254. cmReturn << pcModel->m_dwValue;
  255. }
  256. if(pcModel->m_dwFlags2 & 0x00000010)
  257. cmReturn << pcModel->m_dwUnknown_v2;
  258. // Mase 0x0080 Icon Highlight
  259. if(pcModel->m_dwFlags2 & 0x00000080)
  260. {
  261. cmReturn << pcModel->m_dwIconHighlight;
  262. }
  263. // Mase 0x1000 Stack
  264. if(pcModel->m_dwFlags2 & 0x00001000)
  265. {
  266. cmReturn << pcModel->m_wStack;
  267. }
  268. // Mase 0x2000 Stack Limit
  269. if(pcModel->m_dwFlags2 & 0x00002000)
  270. {
  271. cmReturn << pcModel->m_wStackLimit;
  272. }
  273. // Mask 0x4000 Container ID
  274. if(pcModel->m_dwFlags2 & 0x00004000)
  275. {
  276. cmReturn << Container;
  277. }
  278. // Mask 0x00200000 - Burden
  279. if(pcModel->m_dwFlags2 & 0x00200000)
  280. {
  281. cmReturn << pcModel->m_wBurden;
  282. }
  283. // Mask 0x00400000 - Spell ID
  284. if(pcModel->m_dwFlags2 & 0x00400000)
  285. {
  286. cmReturn << 0x00BF;
  287. }
  288. // Mask 0x01000000 - Workmanship
  289. if(pcModel->m_dwFlags2 & 0x01000000)
  290. cmReturn << pcModel->m_fWorkmanship;
  291. // Mask 0x80000000 - Material
  292. if(pcModel->m_dwFlags2 & 0x80000000)
  293. {
  294. cmReturn << 0x1DL; //Lavender Jade
  295. }
  296. cmReturn << WORD(0x0000);
  297. return cmReturn;
  298. }
  299. /**
  300. * Handles the actions of gem objects.
  301. *
  302. * This function is called whenever a gem is used or should perform an action.
  303. */
  304. void cGems::Action(cClient *who)
  305. {
  306. cItemModels *pcModel = cItemModels::FindModel( m_dwItemModelID );
  307. cObject *pcObject = cWorldManager::FindObject( m_dwGUID );
  308. //Cast the spell
  309. cMessage cmGemCast;
  310. cmGemCast << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x004EL << pcModel->m_dwSpellID
  311. << 0x0001 << 0x005F << 0x0001 << 0x0096; // << 0L << 0L << 0L << WORD(0x0000) << 0x409C2000 << who->m_pcAvatar->GetGUID( );
  312. //<< 0L << 0xC4268000 << 0x85FA45A7 << 0xC1AD5408 << 0x00005008 << 0x04L <<0x0L;
  313. who->AddPacket(WORLD_SERVER,cmGemCast,4);
  314. //Remove the item
  315. who->m_pcAvatar->DeleteFromInventory(pcObject);
  316. cMessage cmRemoveItem;
  317. cmRemoveItem << 0x0024L << m_dwGUID;
  318. who->AddPacket(WORLD_SERVER,cmRemoveItem,4);
  319. cMessage cmActionComplete;
  320. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  321. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  322. }
  323. /**
  324. * Handles the assessment of gem objects.
  325. *
  326. * This function is called whenever a gem is assessed by a client.
  327. *
  328. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  329. */
  330. void cGems::Assess( cClient *pcAssesser )
  331. {
  332. cItemModels *pcModel = cItemModels::FindModel( m_dwItemModelID );
  333. cMessage cmAssess;
  334. DWORD flags = 0x00000009;
  335. cmAssess << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID() << ++pcAssesser->m_dwF7B0Sequence << 0xC9L << m_dwGUID
  336. << flags
  337. << 0x01L
  338. << WORD(0x02)
  339. << WORD(0x10)
  340. << 0x13L
  341. << pcModel->m_dwValue
  342. << 0x05L
  343. << DWORD(pcModel->m_wBurden)
  344. << WORD(0x01)
  345. << WORD(0x08)
  346. << 0x10L
  347. << pcModel->m_strDescription.c_str();
  348. pcAssesser->AddPacket(WORLD_SERVER, cmAssess,4);
  349. cMessage cmActionComplete;
  350. cmActionComplete << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID( ) << ++pcAssesser->m_dwF7B0Sequence << 0x01C7L << 0L;
  351. pcAssesser->AddPacket(WORLD_SERVER,cmActionComplete,4);
  352. }