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

cSalvage.cpp 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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 cSalvage.cpp
  19. * Implements functionality for salvage
  20. *
  21. * This class is referenced whenever salvage 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 salvage in the world.
  32. *
  33. * This function is called whenever salvage should be created in the world for a client.
  34. *
  35. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  36. */
  37. cMessage cSalvage::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. pcModel->m_dwFlags1 += 0x00008000;
  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. DWORD dwFlags2 = pcModel->m_dwFlags2 -= 0x00004000;
  107. cmReturn << dwFlags2;
  108. char Salvage[100];
  109. sprintf(Salvage,"%s (%d) ",Name(),pcModel->m_wUses);
  110. cmReturn << Salvage; // 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. if(pcModel->m_dwFlags2 & 0x00000008)
  116. cmReturn << pcModel->m_dwValue;
  117. if(pcModel->m_dwFlags2 & 0x00000010)
  118. cmReturn << 0x00080008;
  119. if(pcModel->m_dwFlags2 & 0x00080000)
  120. cmReturn << pcModel->m_dwUseableOn;
  121. if(pcModel->m_dwFlags2 & 0x00000400)
  122. cmReturn << pcModel->m_wUses; //For salvage, this is quantity
  123. if(pcModel->m_dwFlags2 & 0x00000800)
  124. cmReturn << WORD(0x0064); //For salvage this is max quantity (always 100)
  125. if(pcModel->m_dwFlags2 & 0x00001000)
  126. cmReturn << WORD(0x0001); //Always 1
  127. if(pcModel->m_dwFlags2 & 0x00002000)
  128. cmReturn << WORD(0x0001); //Always 1
  129. if(pcModel->m_dwFlags2 & 0x00200000)
  130. cmReturn << pcModel->m_wBurden;
  131. if(pcModel->m_dwFlags2 & 0x01000000)
  132. cmReturn << pcModel->m_fWorkmanship;
  133. if(pcModel->m_dwFlags2 & 0x10000000)
  134. cmReturn << pcModel->m_wHooks;
  135. if(pcModel->m_dwFlags2 & 0x40000000)
  136. cmReturn << 0x0L;
  137. if(pcModel->m_dwFlags2 & 0x80000000)
  138. cmReturn << pcModel->m_dwMaterialType;
  139. return cmReturn;
  140. }
  141. /**
  142. * Handles the message sent for the creation of salvage in a container.
  143. *
  144. * This function is called whenever salvage should be created in the inventory of another object.
  145. *
  146. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  147. */
  148. cMessage cSalvage::CreatePacketContainer(DWORD Container, DWORD ItemModelID)
  149. {
  150. cMessage cmReturn;
  151. cItemModels *pcModel = cItemModels::FindModel( ItemModelID );
  152. cObject *pcObject = cWorldManager::FindObject( m_dwGUID );
  153. if( pcModel )
  154. {
  155. cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant
  156. cmReturn << pcModel->m_bPaletteChange
  157. << pcModel->m_bTextureChange
  158. << pcModel->m_bModelChange;
  159. // The Model Vectors
  160. if ( pcModel->m_bPaletteChange != 0)
  161. {
  162. for (int i = 0; i < pcModel->m_bPaletteChange; i++)
  163. {
  164. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorPal[i],sizeof(pcModel->m_vectorPal[i]));
  165. }
  166. }
  167. cmReturn << WORD( 0x0000 );
  168. if ( pcModel->m_bTextureChange != 0)
  169. {
  170. for (int i = 0; i < pcModel->m_bTextureChange; i++)
  171. {
  172. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i]));
  173. }
  174. }
  175. if ( pcModel->m_bModelChange != 0)
  176. {
  177. for (int i = 0; i < pcModel->m_bModelChange; i++)
  178. {
  179. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i]));
  180. }
  181. }
  182. }
  183. cmReturn.pasteAlign(4);
  184. cmReturn << pcModel->m_dwFlags1 << 0x414L << 0x65L;
  185. // MASK 0x00008000 -- Location
  186. // if ( !m_fIsOwned )
  187. // cmReturn.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) );
  188. // MASK 0x00000800 -- Sound Set
  189. DWORD dwSoundSet = 0x20000000L + pcModel->m_wSoundSet;
  190. cmReturn << dwSoundSet;
  191. // MASK 0x00001000 -- Particle Effects (unknown_blue)
  192. cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue;
  193. // MASK 0x00000001 -- ModelNumber
  194. DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber;
  195. cmReturn << dwModel;
  196. // SeaGreens
  197. WORD wNuminteracts = 0x0;
  198. WORD wNumbubbles = 0x0;
  199. WORD wNumJumps = 0x0;
  200. WORD wNumOverrides = 0x0;
  201. WORD wUnkFlag8 = 0x0;
  202. WORD wUnkFlag10 = 0x0;
  203. cmReturn << m_wPositionSequence
  204. << m_wNumAnims //wNuminteracts
  205. << wNumbubbles
  206. << wNumJumps
  207. << m_wNumPortals
  208. << m_wNumAnims
  209. << wNumOverrides
  210. << wUnkFlag8
  211. << m_wNumLogins
  212. << wUnkFlag10;
  213. // Flags2
  214. // DWORD dwFlags2 = 0xD1287C18;
  215. cmReturn << pcModel->m_dwFlags2; // Object Flags
  216. char Salvage[100];
  217. sprintf(Salvage,"%s (%d) ",Name(),pcModel->m_wUses);
  218. cmReturn << Salvage; // Object's Name
  219. cmReturn << pcModel->m_wModel; // Object's Model
  220. cmReturn << this->m_wIcon; // Object's Icon
  221. cmReturn << pcModel->m_dwObjectFlags1; // Object Flags
  222. cmReturn << pcModel->m_dwObjectFlags2; // Object Flags
  223. if(pcModel->m_dwFlags2 & 0x00000008)
  224. cmReturn << pcModel->m_dwValue;
  225. if(pcModel->m_dwFlags2 & 0x00000010)
  226. cmReturn << 0x00080008;
  227. if(pcModel->m_dwFlags2 & 0x00080000)
  228. cmReturn << pcModel->m_dwUseableOn;
  229. if(pcModel->m_dwFlags2 & 0x00000400)
  230. cmReturn << pcModel->m_wUses; //For salvage, this is quantity
  231. if(pcModel->m_dwFlags2 & 0x00000800)
  232. cmReturn << WORD(0x0064); //For salvage this is max quantity (always 100)
  233. if(pcModel->m_dwFlags2 & 0x00001000)
  234. cmReturn << WORD(0x0001); //Always 1
  235. if(pcModel->m_dwFlags2 & 0x00002000)
  236. cmReturn << WORD(0x0001); //Always 1
  237. if(pcModel->m_dwFlags2 & 0x00004000)
  238. cmReturn << Container;
  239. if(pcModel->m_dwFlags2 & 0x00200000)
  240. cmReturn << pcModel->m_wBurden;
  241. if(pcModel->m_dwFlags2 & 0x01000000)
  242. cmReturn << pcModel->m_fWorkmanship;
  243. if(pcModel->m_dwFlags2 & 0x10000000)
  244. cmReturn << pcModel->m_wHooks;
  245. if(pcModel->m_dwFlags2 & 0x40000000)
  246. cmReturn << 0x0L;
  247. if(pcModel->m_dwFlags2 & 0x80000000)
  248. cmReturn << pcModel->m_dwMaterialType;
  249. return cmReturn;
  250. }
  251. /**
  252. * Handles the actions of salvage objects.
  253. *
  254. * This function is called whenever salvage is used or should perform an action.
  255. */
  256. void cSalvage::Action(cClient* who)
  257. {
  258. }
  259. /**
  260. * Handles the assessment of salvage objects.
  261. *
  262. * This function is called whenever salvage is assessed by a client.
  263. *
  264. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  265. */
  266. void cSalvage::Assess(cClient *pcAssesser)
  267. {
  268. cItemModels *pcModel = cItemModels::FindModel( m_dwItemModelID );
  269. cMessage cmAssess;
  270. DWORD flags = 0x00000009;
  271. cmAssess << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID() << ++pcAssesser->m_dwF7B0Sequence << 0xC9L << m_dwGUID
  272. << flags
  273. << 0x01L //Success = 0x01, Failure = 0x00
  274. << WORD(0x0006) //Total number of DWORDS
  275. << WORD(0x0010) //Unknown
  276. << 0x21L // Bonded
  277. << 0x01L
  278. << 0x83L //Material
  279. << pcModel->m_dwMaterialType
  280. << 0x13L //Value
  281. << pcModel->m_dwValue // 4 pyreals
  282. << 0x05L //Burden
  283. << DWORD (pcModel->m_wBurden) //50 bu
  284. << 0x69L //Workmanship
  285. << pcModel->m_fWorkmanship
  286. << 0xAAL //Number of Items salvaged from (TODO: Implement this :p)
  287. << 0x01L
  288. << WORD(0x0002) //Count (as above) total number of DWORDS
  289. << WORD(0x0008) //Unknown
  290. << 0x0EL //String
  291. << pcModel->m_strDescription.c_str()
  292. << 0x0FL
  293. << "Test";
  294. pcAssesser->AddPacket(WORLD_SERVER, cmAssess,4);
  295. }