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

cMerchantSign.cpp 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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 cMerchantSign.cpp
  19. *
  20. * This class is referenced whenever a lifestone is created, used, or assessed.
  21. * Inherits from the cObject class.
  22. *
  23. * Author: Cubem0j0
  24. */
  25. #include "avatar.h"
  26. #include "object.h"
  27. #include "cWObjectModels.h"
  28. #include "client.h"
  29. #include "WorldManager.h"
  30. #include "MasterServer.h"
  31. /**
  32. * Handles the creation of merchant signs.
  33. *
  34. * Called whenever a merchant sign object should be initialized.
  35. *
  36. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  37. */
  38. cMessage cMerchantSign::CreatePacket()
  39. {
  40. cMessage cmReturn;
  41. cWObjectModels *pcModel = cWObjectModels::FindModel( m_dwWOModelID );
  42. cObject *pcObject = cWorldManager::FindObject( m_dwGUID );
  43. if( pcModel )
  44. {
  45. cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant
  46. cmReturn << pcModel->m_bPaletteChange
  47. << pcModel->m_bTextureChange
  48. << pcModel->m_bModelChange;
  49. // The Model Vectors
  50. if ( pcModel->m_bPaletteChange != 0)
  51. {
  52. for (int i = 0; i < pcModel->m_bPaletteChange; i++)
  53. {
  54. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorPal[i],sizeof(pcModel->m_vectorPal[i]));
  55. }
  56. }
  57. if (pcModel->m_bPaletteChange != 0)
  58. {
  59. cmReturn << WORD( pcModel->m_wUnknown1 );
  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. if(iObjectType == 0)
  78. //Cube: Everything else.
  79. {
  80. cmReturn << pcModel->m_dwFlags1 << WORD(0x0418) << WORD(0x0001);
  81. }
  82. //Cube: Readable signs
  83. if(iObjectType == 1)
  84. {
  85. cmReturn << pcModel->m_dwFlags1 << 0x0418L << 0x0065L;
  86. }
  87. //Cube: Nullified Statues
  88. if(iObjectType == 2)
  89. {
  90. cmReturn << pcModel->m_dwFlags1 << 0x0418L; //<< 0x0008L;
  91. }
  92. //Cubem0j0: This was added for Gharundhim signs, if this was not added they would fall to the ground.
  93. if(iObjectType == 3)
  94. {
  95. cmReturn << pcModel->m_dwFlags1 << WORD(0x0018) << WORD(0x0000);
  96. }
  97. if (pcModel->m_dwFlags1 & 0x00010000)
  98. {
  99. cmReturn << pcModel->m_dwUnknownCount;// pcModel->m_dwUnknownCount;
  100. // Vector of UnknownCount
  101. for ( int i = 0;i < pcModel->m_dwUnknownCount; i++)
  102. {
  103. cmReturn << pcModel->m_bInitialAnimation[i]; //pcModel->m_bInitialAnimation[i];
  104. }
  105. cmReturn << pcModel->m_dwUnknownDword;
  106. }
  107. // Flags1 & 0x00020000
  108. if (pcModel->m_dwFlags1 & 0x00020000)
  109. {
  110. cmReturn << pcModel->m_dwUnknown;
  111. }
  112. // Flags1 & 0x00008000 - Location Data
  113. if (pcModel->m_dwFlags1 & 0x00008000)
  114. {
  115. cmReturn.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) );
  116. }
  117. // Flags1 & 0x00000002 - Animation Config
  118. if (pcModel->m_dwFlags1 & 0x00000002)
  119. {
  120. //Format = 0x09000000
  121. cmReturn << 0x09000000 + pcModel->m_wAnimConfig;
  122. }
  123. // Flags1 & 0x00000800 - sound Set
  124. if (pcModel->m_dwFlags1 & 0x00000800)
  125. {
  126. //Format = 0x20000001;
  127. cmReturn << 0x20000000 + pcModel->m_wSoundSet;
  128. }
  129. // Flags1 & 0x00001000 - Particle Effects ?
  130. if (pcModel->m_dwFlags1 & 0x00001000)
  131. {
  132. //Format = 0x34000004;
  133. cmReturn << 0x34000000 + pcModel->m_dwUnknown_Blue;
  134. }
  135. // Flags1 & 0x00000001 - Object's Model Number
  136. if (pcModel->m_dwFlags1 & 0x00000001)
  137. {
  138. //Format = 0x02000001;
  139. cmReturn << 0x02000000 + pcModel->m_dwModelNumber;
  140. }
  141. // Flags1 & 0x00000080 - Unknown_Green This represents Model Scale
  142. if (pcModel->m_dwFlags1 & 0x00000080)
  143. {
  144. if(pcModel->m_flScale == 0)
  145. {
  146. cmReturn << 1.0f;
  147. }
  148. else
  149. {
  150. cmReturn << pcModel->m_flScale; // Scale?
  151. }
  152. }
  153. // MASK 0x00008000 - Location
  154. // if ( !m_fIsOwned )
  155. // cmReturn.CannedData( (BYTE *)&m_Location, sizeof( cLocation ) );
  156. // MASK 0x00000001 ModelNumber
  157. // DWORD dwModel = 0x02000000L + pcModel->m_dwModelNumber;
  158. // cmReturn << dwModel;
  159. // SeaGreens
  160. WORD wNuminteracts = 0x0;
  161. WORD wNumbubbles = 0x0;
  162. WORD wNumJumps = 0x0;
  163. WORD wNumOverrides = 0x0;
  164. WORD wUnkFlag8 = 0x0;
  165. WORD wUnkFlag10 = 0x0;
  166. cmReturn << m_wPositionSequence
  167. << m_wNumAnims //wNuminteracts
  168. << wNumbubbles
  169. << wNumJumps
  170. << m_wNumPortals
  171. << m_wNumAnims
  172. << wNumOverrides
  173. << wUnkFlag8
  174. << m_wNumLogins
  175. << wUnkFlag10;
  176. switch (iObjectType)
  177. {
  178. default:
  179. {
  180. DWORD dwFlags2 = 0x00200018;
  181. cmReturn << dwFlags2 << m_strName.c_str( ) << WORD(pcModel->m_wModel) << WORD(pcModel->m_wIcon);
  182. DWORD dwObjectFlags1 = 0x80L;
  183. cmReturn << dwObjectFlags1;
  184. DWORD dwObjectFlags2 = 0x14L;
  185. cmReturn << dwObjectFlags2;
  186. // Masked against dwFlags2
  187. //Mask 0x0008 - Value
  188. cmReturn << DWORD(0x00);
  189. // Mask 0x0010 dwUnknown_v2
  190. cmReturn << DWORD(0x01);
  191. // Mask 0x00200000 - Burden
  192. cmReturn << WORD(0x0040);
  193. break;
  194. }
  195. case 1:
  196. {
  197. DWORD dwFlags2 = 0x00200038;
  198. cmReturn << dwFlags2 << pcModel->m_strName.c_str( ) << WORD(pcModel->m_wModel) << WORD(pcModel->m_wIcon);
  199. DWORD dwObjectFlags1 = 0x2000L;
  200. cmReturn << dwObjectFlags1;
  201. DWORD dwObjectFlags2 = 0x0114L;
  202. cmReturn << dwObjectFlags2;
  203. // Masked against dwFlags2
  204. //Mask 0x0008 - Value
  205. cmReturn << DWORD(0x00);
  206. // Mask 0x0010 dwUnknown_v2
  207. cmReturn << DWORD(0x20);
  208. // Mask 0x0020 Approach distance
  209. cmReturn << float(3.0);
  210. // Mask 0x00200000 - Burden
  211. cmReturn << WORD(0x0040);
  212. break;
  213. }
  214. case 2:
  215. {
  216. DWORD dwFlags2 = 0x00200010;
  217. cmReturn << dwFlags2 << pcModel->m_strName.c_str( ) << WORD(pcModel->m_wModel) << WORD(pcModel->m_wIcon);
  218. DWORD dwObjectFlags1 = 0x2000L;
  219. cmReturn << dwObjectFlags1;
  220. DWORD dwObjectFlags2 = 0x14L;
  221. cmReturn << dwObjectFlags2;
  222. // Masked against dwFlags2
  223. // Mask 0x0010 dwUnknown_v2
  224. cmReturn << DWORD(0x01);
  225. // Mask 0x00200000 - Burden
  226. cmReturn << WORD(0x0708);
  227. break;
  228. }
  229. }
  230. return cmReturn;
  231. }
  232. /**
  233. * Handles the actions of merchant sign objects.
  234. *
  235. * This function is called whenever a merchant sign is used or should perform an action.
  236. */
  237. void cMerchantSign::Action(cClient *who)
  238. {
  239. switch(iObjectType)
  240. {
  241. case 1:
  242. {
  243. cMessage cmRead;
  244. cmRead << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x00B8L
  245. << m_dwGUID << 0x01L << 0x01L << 0x03E8L << 0x01L << 0xFFFFFFFF << "Welcome to Asheron's Call" << "beer good" << 0xFFFF0002
  246. << 0L << 0L << 0L << 0L << 0L;
  247. // << 0x00L << 0x00L << m_strDescription.c_str();
  248. /*
  249. cMessage cmNotWorking;
  250. cmNotWorking << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x02EB
  251. << "Reading this sign, not yet implemented! :p";
  252. */
  253. who->AddPacket(WORLD_SERVER,cmRead,4);
  254. //Action Complete
  255. cMessage cmActionComplete;
  256. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  257. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  258. break;
  259. }
  260. default:
  261. {
  262. //Action Complete
  263. cMessage cmActionComplete;
  264. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  265. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  266. break;
  267. }
  268. }
  269. }
  270. /**
  271. * Handles the assessment of merchant sign objects.
  272. *
  273. * This function is called whenever a merchant sign is assessed by a client.
  274. *
  275. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  276. */
  277. void cMerchantSign::Assess(cClient *pcAssesser)
  278. {
  279. //Action Complete
  280. cMessage cmActionComplete;
  281. cmActionComplete << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID( ) << ++pcAssesser->m_dwF7B0Sequence << 0x01C7L << 0L;
  282. pcAssesser->AddPacket(WORLD_SERVER,cmActionComplete,4);
  283. }