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

cPack.cpp 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  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 cPack.cpp
  19. * Implements functionality for packs (sacks, packs, etc.).
  20. *
  21. * This class is referenced whenever a pack 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 packs in the world.
  32. *
  33. * This function is called whenever a pack should be created in the world for a client.
  34. *
  35. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  36. */
  37. cMessage cPack::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( pcModel->m_wUnknown_1 );
  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. /*
  116. // Flags2
  117. DWORD dwFlags2 = 0x00203018;
  118. if ( m_fIsOwned )
  119. dwFlags2 |= 0x4000;
  120. // DWORD dwObjectFlags1 = 0x00000020;
  121. // DWORD dwObjectFlags2 = 0x00008010;
  122. cmReturn << dwFlags2;
  123. */
  124. cmReturn << Name( ); // Object's Name
  125. cmReturn << pcModel->m_wModel; // Object's Model
  126. cmReturn << this->m_wIcon; // Object's Icon
  127. cmReturn << pcModel->m_dwObjectFlags1; // Object Flags
  128. cmReturn << pcModel->m_dwObjectFlags2; // Object Flags
  129. // Masked against dwFlags2
  130. // Mask 0x0008 - Value
  131. //cmReturn << DWORD(0x00000007);
  132. if(pcModel->m_dwFlags2 & 0x00000008)
  133. {
  134. cmReturn << pcModel->m_dwValue;
  135. }
  136. // Mask 0x0010 dwUnknown_v2
  137. cmReturn << DWORD(0x00000001);
  138. // Mask 0x10000 Equip Possible
  139. cmReturn << DWORD(0x0010);
  140. // Mask 0x40000 Coverage Mask
  141. cmReturn << DWORD(0x0040);
  142. if(pcModel->m_dwFlags2 & 0x00004000)
  143. {
  144. cmReturn << pcModel->m_dwContainerID;
  145. }
  146. // Mask 0x00200000 - Burden
  147. cmReturn << WORD(0x0040);
  148. // Mask 0x10000000 - Hookable
  149. cmReturn << WORD(0x0001);
  150. // pcObject->SetType(3);
  151. return cmReturn;
  152. }
  153. /**
  154. * Handles the message sent for the creation of pack in a container.
  155. *
  156. * This function is called whenever a pack should be created in the inventory of another object.
  157. *
  158. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  159. */
  160. cMessage cPack::CreatePacketContainer(DWORD Container, DWORD ItemModelID)
  161. {
  162. cMessage cmReturn;
  163. cItemModels *pcModel = cItemModels::FindModel( ItemModelID );
  164. cObject *pcObject = cWorldManager::FindObject( m_dwGUID );
  165. if( pcModel )
  166. {
  167. cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant
  168. cmReturn << pcModel->m_bPaletteChange
  169. << pcModel->m_bTextureChange
  170. << pcModel->m_bModelChange;
  171. // The Model Vectors
  172. if ( pcModel->m_bPaletteChange != 0)
  173. {
  174. for (int i = 0; i < pcModel->m_bPaletteChange; i++)
  175. {
  176. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorPal[i],sizeof(pcModel->m_vectorPal[i]));
  177. }
  178. }
  179. if (pcModel->m_bPaletteChange != 0)
  180. {
  181. //Cubem0j0: Test code for armor only.
  182. cmReturn << WORD( pcModel->m_wUnknown_1 );
  183. }
  184. if ( pcModel->m_bTextureChange != 0)
  185. {
  186. for (int i = 0; i < pcModel->m_bTextureChange; i++)
  187. {
  188. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i]));
  189. }
  190. }
  191. if ( pcModel->m_bModelChange != 0)
  192. {
  193. for (int i = 0; i < pcModel->m_bModelChange; i++)
  194. {
  195. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i]));
  196. }
  197. }
  198. }
  199. cmReturn.pasteAlign(4);
  200. cmReturn << 0x00021881 << 0x414L << 0x65L;
  201. // MASK 0x00000800 -- Sound Set
  202. DWORD dwSoundSet = 0x20000000L + pcModel->m_wSoundSet;
  203. cmReturn << dwSoundSet;
  204. // MASK 0x00001000 -- Particle Effects (unknown_blue)
  205. cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue;
  206. // MASK 0x00000001 -- ModelNumber
  207. DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber;
  208. cmReturn << dwModel;
  209. // MASK 0x00000080 -- Scale
  210. cmReturn << float(1.0);
  211. // SeaGreens
  212. WORD wNuminteracts = 0x0;
  213. WORD wNumbubbles = 0x0;
  214. WORD wNumJumps = 0x0;
  215. WORD wNumOverrides = 0x0;
  216. WORD wUnkFlag8 = 0x0;
  217. WORD wUnkFlag10 = 0x0;
  218. cmReturn << m_wPositionSequence
  219. << m_wNumAnims //wNuminteracts
  220. << wNumbubbles
  221. << wNumJumps
  222. << m_wNumPortals
  223. << m_wNumAnims
  224. << wNumOverrides
  225. << wUnkFlag8
  226. << m_wNumLogins
  227. << wUnkFlag10;
  228. // Flags2 - 0020403A
  229. cmReturn << pcModel->m_dwFlags2;
  230. cmReturn << Name( ); // Object's Name
  231. cmReturn << pcModel->m_wModel; // Object's Model
  232. cmReturn << this->m_wIcon; // Object's Icon
  233. cmReturn << pcModel->m_dwObjectFlags1; // Object Flags
  234. cmReturn << pcModel->m_dwObjectFlags2; // Object Flags
  235. // Masked against dwFlags2
  236. // Mask 0x0002 - Item Slots in Pack TODO: Add Item slots to Item_Model_data table in DB
  237. cmReturn << BYTE(0x18);
  238. // Mask 0x0008 - Value
  239. cmReturn << pcModel->m_dwValue;
  240. // Mask 0x0010 dwUnknown_v2
  241. cmReturn << pcModel->m_dwUnknown_v2;
  242. // Mask 0x0020 Approach Distance - This seems wierd...
  243. cmReturn << float(3.0);
  244. // Mask 0x4000 - Container ID
  245. cmReturn << Container;
  246. // Mask 0x00200000 - Burden
  247. cmReturn << pcModel->m_wBurden;
  248. //Cube: Even though no mask for Icon Overlay appears to exist for this item, the entry does appear in the message.
  249. // Mask 0x40000000 - Icon Overlay
  250. cmReturn << 0xE2468500; //Decode this later...
  251. // pcObject->SetType(3);
  252. return cmReturn;
  253. }
  254. /**
  255. * Handles the actions of pack objects.
  256. *
  257. * This function is called whenever a pack is used or should perform an action.
  258. */
  259. void cPack::Action(cClient *who)
  260. {
  261. }
  262. /**
  263. * Handles the assessment of pack objects.
  264. *
  265. * This function is called whenever a pack is assessed by a client.
  266. *
  267. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  268. */
  269. void cPack::Assess( cClient *pcAssesser )
  270. {
  271. cItemModels *pcModel = cItemModels::FindModel( m_dwItemModelID );
  272. cMessage cmAssess;
  273. DWORD flags = 0x00000089;
  274. cmAssess << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID() << ++pcAssesser->m_dwF7B0Sequence << 0xC9L << m_dwGUID
  275. << flags
  276. << 0x01L //Success = 0x01, Failure = 0x00
  277. << WORD(0x0007)
  278. << WORD(0x0010)
  279. << 0xB0L //Activation Req
  280. << 0x06L //Skill ID
  281. << 0x73L //Activation req
  282. << 0xD1L //Skill Level
  283. << 0x13L //Value
  284. << pcModel->m_dwValue //Amount
  285. << 0x83L //Material
  286. << 0x3FL //Silver
  287. << 0x05L //Burden
  288. << 0xCCL //blah
  289. << 0x69L //Workmanship
  290. << 0x07L //This value is the level of work 1 = poor, 2 = well, etc.
  291. << 0x1CL //Armor Level
  292. << 0x64L //AL 100
  293. << WORD(0x0001) //Count (as above) total number of DWORDS
  294. << WORD(0x0008) //Unknown
  295. << 0x10L
  296. << this->m_strName.c_str()
  297. << float(1.2) //Slashing
  298. << float(1.1) //Piercing
  299. << float(1.0) //Bludgeon
  300. << float(0.4) //Fire
  301. << float(0.7) //Cold
  302. << float(0.3) //Acid
  303. << float(0.4); //Electric
  304. /*
  305. DWORD flags = 0x0000009F;
  306. << WORD(0x000C) //Total number of DWORDS
  307. << WORD(0x0010) //Unknown
  308. << 0xB0L //Activation Req
  309. << 0x06L //Skill ID
  310. << 0x13L //Value
  311. << pcModel->m_dwValue //Amount
  312. << 0x73L //Activation req
  313. << 0xD1L //Skill Level
  314. << 0x83L //Material
  315. << 0x3FL //Silver
  316. << 0x05L //Burden
  317. << 0xCCL //blah
  318. << 0x69L //Workmanship
  319. << 0x07L //This value is the level of work 1 = poor, 2 = well, etc.
  320. << 0x6AL //Spellcraft
  321. << 0xBDL //Amount
  322. << 0x6BL //Current mana
  323. << 0x01FAL //-mana amount
  324. << 0x1CL //Armor Level
  325. << 0x64L //AL 100
  326. << 0x6CL //Max mana
  327. << 0x01FAL //-mana amount
  328. << 0xACL //Description format
  329. << 0x01L // ?
  330. << 0x6DL //Arcane req
  331. << 0x54L //Amount
  332. << WORD(0x0001) //Count (as above) total number of DWORDS
  333. << WORD(0x0008) //Unknown
  334. << 0x64L
  335. << 0x01L
  336. << WORD(0x0001) //Count (as above) total number of DWORDS
  337. << WORD(0x0008) //Unknown
  338. << 0x05L
  339. << 0x55
  340. << 0x55
  341. << 0x55
  342. << 0x55
  343. << 0x55
  344. << 0x55
  345. << 0xA5
  346. << 0xBF;
  347. << WORD(0x0001) //Count (as above) total number of DWORDS
  348. << WORD(0x0008) //Unknown
  349. << 0x10L
  350. << this->m_strName.c_str()
  351. << 0x03L
  352. << 0x05CDL
  353. << 0x05D9L
  354. << 0x0625L
  355. << float(1.2)
  356. << float(1.1)
  357. << float(1.0)
  358. << float(0.4)
  359. << float(0.7)
  360. << float(0.3)
  361. << float(0.4);
  362. */
  363. pcAssesser->AddPacket(WORLD_SERVER, cmAssess,4);
  364. cMessage cmActionComplete;
  365. cmActionComplete << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID( ) << ++pcAssesser->m_dwF7B0Sequence << 0x01C7L << 0L;
  366. pcAssesser->AddPacket(WORLD_SERVER,cmActionComplete,4);
  367. }