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

cShield.cpp 11KB

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