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

cClothes.cpp 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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 cClothes.cpp
  19. * Implements functionality for clothing.
  20. *
  21. * This class is referenced whenever a piece of clothing 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 clothing in the world.
  32. *
  33. * This function is called whenever a piece of clothing should be created in the world for a client.
  34. *
  35. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  36. */
  37. cMessage cClothes::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 << m_bPaletteChange
  46. << pcModel->m_bTextureChange
  47. << pcModel->m_bModelChange;
  48. // the human palette
  49. if (m_bPaletteChange != 0)
  50. {
  51. cmReturn << WORD( pcModel->m_wUnknown_1 );
  52. }
  53. // the palette vectors
  54. if ( m_bPaletteChange != 0)
  55. {
  56. for (int i = 0; i < m_bPaletteChange; i++)
  57. {
  58. cmReturn.pasteData((UCHAR*)&m_vectorPal[i],sizeof(m_vectorPal[i]));
  59. }
  60. }
  61. // the texture vectors
  62. if ( pcModel->m_bTextureChange != 0)
  63. {
  64. for (int i = 0; i < pcModel->m_bTextureChange; i++)
  65. {
  66. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i]));
  67. }
  68. }
  69. // the model vectors
  70. if ( pcModel->m_bModelChange != 0)
  71. {
  72. for (int i = 0; i < pcModel->m_bModelChange; i++)
  73. {
  74. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i]));
  75. }
  76. }
  77. }
  78. cmReturn.pasteAlign(4);
  79. cmReturn << pcModel->m_dwFlags1 << 0x414L << 0x65L;
  80. // MASK 0x00008000 -- Location
  81. if ( !m_fIsOwned )
  82. cmReturn.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) );
  83. // MASK 0x00000800 -- Sound Set
  84. DWORD dwSoundSet = 0x20000000L + pcModel->m_wSoundSet;
  85. cmReturn << dwSoundSet;
  86. // MASK 0x00001000 -- Particle Effects (unknown_blue)
  87. cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue;
  88. // MASK 0x00000001 -- ModelNumber
  89. DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber;
  90. cmReturn << dwModel;
  91. // SeaGreens
  92. WORD wNuminteracts = 0x0;
  93. WORD wNumbubbles = 0x0;
  94. WORD wNumJumps = 0x0;
  95. WORD wNumOverrides = 0x0;
  96. WORD wUnkFlag8 = 0x0;
  97. WORD wUnkFlag10 = 0x0;
  98. cmReturn << m_wPositionSequence
  99. << m_wNumAnims //wNuminteracts
  100. << wNumbubbles
  101. << wNumJumps
  102. << m_wNumPortals
  103. << m_wNumAnims
  104. << wNumOverrides
  105. << wUnkFlag8
  106. << m_wNumLogins
  107. << wUnkFlag10;
  108. /*
  109. Flags2
  110. DWORD dwFlags2 = 0x81250018;
  111. */
  112. DWORD flags2 = pcModel->m_dwFlags2;
  113. if (pcObject && pcObject->m_fEquipped == 2)
  114. {
  115. flags2 = (flags2 ^ 0x00004000);
  116. flags2 = (flags2 | 0x00020000 | 0x00008000);
  117. }
  118. cmReturn << flags2;
  119. cmReturn << Name( ); // Object's Name
  120. cmReturn << pcModel->m_wModel; // Object's Model
  121. cmReturn << m_wIcon; // Object's Icon
  122. cmReturn << pcModel->m_dwObjectFlags1; // Object Flags
  123. cmReturn << pcModel->m_dwObjectFlags2; // Object Flags
  124. if(flags2 & 0x00000008)
  125. cmReturn << pcModel->m_dwValue;
  126. if(flags2 & 0x00000010)
  127. cmReturn << pcModel->m_dwUnknown_v2;
  128. if(flags2 & 0x00000080)
  129. cmReturn << pcModel->m_dwIconHighlight;
  130. if(flags2 & 0x00008000)
  131. cmReturn << pcObject->m_dwOwnerID;
  132. if(flags2 & 0x00010000)
  133. cmReturn << pcModel->m_dwEquipPossible;
  134. if(flags2 & 0x00020000)
  135. cmReturn << pcModel->m_dwEquipPossible;
  136. if(flags2 & 0x00040000)
  137. cmReturn << pcModel->m_dwCoverage;
  138. if(flags2 & 0x01000000)
  139. cmReturn << pcModel->m_fWorkmanship;
  140. if(flags2 & 0x00200000)
  141. cmReturn << pcModel->m_wBurden;
  142. if(flags2 & 0x01000000)
  143. cmReturn << pcModel->m_fWorkmanship;
  144. if(flags2 & 0x10000000)
  145. cmReturn << pcModel->m_wHooks;
  146. if(flags2 & 0x80000000)
  147. cmReturn << pcModel->m_dwMaterialType;
  148. return cmReturn;
  149. }
  150. /**
  151. * Handles the message sent for the creation of clothing in a container.
  152. *
  153. * This function is called whenever a piece of clothing should be created in the inventory of another object.
  154. *
  155. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  156. */
  157. cMessage cClothes::CreatePacketContainer(DWORD Container, DWORD ItemModelID)
  158. {
  159. cMessage cmReturn;
  160. cItemModels *pcModel = cItemModels::FindModel( ItemModelID );
  161. cObject *pcObject = cWorldManager::FindObject( m_dwGUID );
  162. if( pcModel )
  163. {
  164. cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant
  165. cmReturn << m_bPaletteChange
  166. << pcModel->m_bTextureChange
  167. << pcModel->m_bModelChange;
  168. // the human palette
  169. if (m_bPaletteChange != 0)
  170. {
  171. cmReturn << WORD( pcModel->m_wUnknown_1 );
  172. }
  173. // the palette vectors
  174. if ( m_bPaletteChange != 0)
  175. {
  176. for (int i = 0; i < m_bPaletteChange; i++)
  177. {
  178. cmReturn.pasteData((UCHAR*)&m_vectorPal[i],sizeof(m_vectorPal[i]));
  179. }
  180. }
  181. // the texture vectors
  182. if ( pcModel->m_bTextureChange != 0)
  183. {
  184. for (int i = 0; i < pcModel->m_bTextureChange; i++)
  185. {
  186. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i]));
  187. }
  188. }
  189. // the model vectors
  190. if ( pcModel->m_bModelChange != 0)
  191. {
  192. for (int i = 0; i < pcModel->m_bModelChange; i++)
  193. {
  194. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i]));
  195. }
  196. }
  197. }
  198. cmReturn.pasteAlign(4);
  199. cmReturn << pcModel->m_dwFlags1 << 0x414L << 0x65L;
  200. // MASK 0x00000800 -- Sound Set
  201. DWORD dwSoundSet = 0x20000000L + pcModel->m_wSoundSet;
  202. cmReturn << dwSoundSet;
  203. // MASK 0x00001000 -- Particle Effects (unknown_blue)
  204. cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue;
  205. // MASK 0x00000001 -- ModelNumber
  206. DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber;
  207. cmReturn << dwModel;
  208. // SeaGreens
  209. WORD wNuminteracts = 0x0;
  210. WORD wNumbubbles = 0x0;
  211. WORD wNumJumps = 0x0;
  212. WORD wNumOverrides = 0x0;
  213. WORD wUnkFlag8 = 0x0;
  214. WORD wUnkFlag10 = 0x0;
  215. cmReturn << m_wPositionSequence
  216. << m_wNumAnims //wNuminteracts
  217. << wNumbubbles
  218. << wNumJumps
  219. << m_wNumPortals
  220. << m_wNumAnims
  221. << wNumOverrides
  222. << wUnkFlag8
  223. << m_wNumLogins
  224. << wUnkFlag10;
  225. DWORD flags2 = pcModel->m_dwFlags2;
  226. if (m_fEquipped == 2)
  227. {
  228. flags2 = (flags2 ^ 0x00004000);
  229. flags2 = (flags2 | 0x00020000 | 0x00008000);
  230. }
  231. //can be 0x81254018, 0x81278098
  232. // Flags2
  233. cmReturn << flags2;
  234. cmReturn << Name( ); // Object's Name
  235. cmReturn << pcModel->m_wModel; // Object's Model
  236. cmReturn << m_wIcon; // Object's Icon
  237. cmReturn << pcModel->m_dwObjectFlags1; // Object Flags
  238. cmReturn << pcModel->m_dwObjectFlags2; // Object Flags
  239. if(flags2 & 0x00000008)
  240. cmReturn << pcModel->m_dwValue;
  241. if(flags2 & 0x00000010)
  242. cmReturn << pcModel->m_dwUnknown_v2;
  243. if(flags2 & 0x00000080)
  244. cmReturn << pcModel->m_dwIconHighlight;
  245. if(flags2 & 0x00004000)
  246. cmReturn << Container;
  247. if(flags2 & 0x00008000)
  248. cmReturn << Container;
  249. if(flags2 & 0x00010000)
  250. cmReturn << pcModel->m_dwEquipPossible;
  251. if(flags2 & 0x00020000)
  252. cmReturn << pcModel->m_dwEquipPossible;
  253. if(flags2 & 0x00040000)
  254. cmReturn << pcModel->m_dwCoverage;
  255. if(flags2 & 0x01000000)
  256. cmReturn << pcModel->m_fWorkmanship;
  257. if(flags2 & 0x00200000)
  258. cmReturn << pcModel->m_wBurden;
  259. if(flags2 & 0x01000000)
  260. cmReturn << pcModel->m_fWorkmanship;
  261. if(flags2 & 0x10000000)
  262. cmReturn << pcModel->m_wHooks;
  263. if(flags2 & 0x80000000)
  264. cmReturn << pcModel->m_dwMaterialType;
  265. return cmReturn;
  266. }
  267. /**
  268. * Handles the actions of clothing objects.
  269. *
  270. * This function is called whenever a piece of clothing is used or should perform an action.
  271. */
  272. void cClothes::Action(cClient *who)
  273. {
  274. }
  275. /**
  276. * Handles the assessment of clothing objects.
  277. *
  278. * This function is called whenever a piece of clothing is assessed by a client.
  279. *
  280. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  281. */
  282. void cClothes::Assess( cClient *pcAssesser )
  283. {
  284. cItemModels *pcModel = cItemModels::FindModel( m_dwItemModelID );
  285. cMessage cmAssess;
  286. DWORD flags = 0x00000089;
  287. cmAssess << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID() << ++pcAssesser->m_dwF7B0Sequence << 0xC9L << m_dwGUID
  288. << flags
  289. << 0x01L; //Success = 0x01L, Failure = 0x00L
  290. if (flags & 0x00000001 == 0x00000001)
  291. {
  292. cmAssess << WORD(0x0003) //Value count
  293. << WORD(0x0010)
  294. << 0x13L //Value key
  295. << pcModel->m_dwValue //Value
  296. << 0x05L //Burden key
  297. << DWORD(pcModel->m_wBurden) //Burden
  298. << 0x1CL //Armor Level key
  299. << pcModel->m_dwArmor_Level; //Armor Level
  300. }
  301. if (flags & 0x00000002 == 0x00000002)
  302. {
  303. cmAssess << WORD(0x0001) //Value count
  304. << WORD(0x0008)
  305. << 0x64L //Dyeable
  306. << 0x01L; //True = 0x01L, False = 0x00L
  307. }
  308. if (flags & 0x00000008 == 0x00000008)
  309. {
  310. cmAssess << WORD(0x0001) //Count (as above) total number of DWORDS
  311. << WORD(0x0008) //Unknown
  312. << 0x10L //Full Description key
  313. << this->m_strName.c_str(); //Description
  314. }
  315. if (flags & 0x00000080 == 0x00000080)
  316. {
  317. cmAssess << pcModel->m_fProt_Slashing //Slashing
  318. << pcModel->m_fProt_Piercing //Piercing
  319. << pcModel->m_fProt_Bludgeon //Bludgeon
  320. << pcModel->m_fProt_Fire //Fire
  321. << pcModel->m_fProt_Cold //Cold
  322. << pcModel->m_fProt_Acid //Acid
  323. << pcModel->m_fProt_Electric; //Electric
  324. }
  325. pcAssesser->AddPacket(WORLD_SERVER, cmAssess,4);
  326. cMessage cmActionComplete;
  327. cmActionComplete << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID( ) << ++pcAssesser->m_dwF7B0Sequence << 0x01C7L << 0L;
  328. pcAssesser->AddPacket(WORLD_SERVER,cmActionComplete,4);
  329. }