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

cNPC.cpp 51KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  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 cNPC.cpp
  19. * Implements general functionality for Non-Player Characters (NPCs).
  20. *
  21. * Functionality includes giving, buying, and sell items to vendors.
  22. *
  23. * Inherits from the cObject class.
  24. */
  25. #include "object.h"
  26. #include "masterserver.h"
  27. #include "worldmanager.h"
  28. #include "cNPCModels.h"
  29. #include <algorithm>
  30. /***************
  31. * constructors
  32. **************/
  33. /**
  34. * Handles the creation of NPCs.
  35. *
  36. * Called whenever an NPC object should be initialized.
  37. */
  38. cNPC::cNPC(DWORD dwGUID, DWORD dwNPCModelID, char *szName, WORD wGender, cLocation *pcLoc, DWORD dwSellCategories )
  39. : m_dwNPCModelID ( dwNPCModelID )
  40. {
  41. SetLocation( pcLoc );
  42. // m_dwGUID = cWorldManager::NewGUID_Object( );
  43. // Cubem0j0: Implement NPC IDs
  44. m_dwGUID = dwGUID;
  45. m_dwNPCModelID = dwNPCModelID;
  46. m_strName.assign( szName );
  47. m_wGender = wGender;
  48. m_fStatic = TRUE;
  49. m_NPCStats.m_dwLevel = 10;
  50. m_dwSellCategories = dwSellCategories;
  51. }
  52. /**********
  53. * methods
  54. *********/
  55. /**
  56. * Handles the message sent for the creation of NPCs.
  57. *
  58. * This function is called whenever an NPC should be created for a client.
  59. * @return cMessage - Returns a Create Object (0x0000F745) server message.
  60. */
  61. cMessage cNPC::CreatePacket()
  62. {
  63. cMessage cmReturn;
  64. cNPCModels *pcModel = cNPCModels::FindModel( m_dwNPCModelID );
  65. DWORD dwFlags1;
  66. if (pcModel)
  67. {
  68. cmReturn << 0xF745L << m_dwGUID << BYTE(0x11); //0x11 is a constant
  69. cmReturn << pcModel->m_bPaletteChange
  70. << pcModel->m_bTextureChange
  71. << pcModel->m_bModelChange;
  72. if ( pcModel->m_bPaletteChange != 0)
  73. {
  74. for (int i = 0; i < pcModel->m_bPaletteChange; i++)
  75. {
  76. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorPal[i],sizeof(pcModel->m_vectorPal[i]));
  77. }
  78. }
  79. cmReturn << pcModel->m_wPaletteCode;
  80. if ( pcModel->m_bTextureChange != 0)
  81. {
  82. for (int i = 0; i < pcModel->m_bTextureChange; i++)
  83. {
  84. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorTex[i],sizeof(pcModel->m_vectorTex[i]));
  85. }
  86. }
  87. if ( pcModel->m_bModelChange != 0)
  88. {
  89. for (int i = 0; i < pcModel->m_bModelChange; i++)
  90. {
  91. cmReturn.pasteData((UCHAR*)&pcModel->m_vectorMod[i],sizeof(pcModel->m_vectorMod[i]));
  92. }
  93. }
  94. //TODO: Add support for "Monster" NPCs (Mayor Ko Ko, etc)
  95. cmReturn.pasteAlign(4);
  96. dwFlags1 = 0x00018803;
  97. cmReturn << dwFlags1 << WORD(0x0418);
  98. //Cubem0j0: This unknown appears to deal with whether or not the NPC is a merchant, quest npc, or just a regular npc.
  99. switch(IsVendor)
  100. {
  101. default:
  102. {
  103. cmReturn << WORD(0x0040); // Unknown
  104. break;
  105. }
  106. case 1:
  107. {
  108. cmReturn << WORD(0x0020); // Merchant
  109. break;
  110. }
  111. case 2:
  112. {
  113. cmReturn << WORD(0x0060); // Quest NPC
  114. break;
  115. }
  116. }
  117. DWORD dwNumInitAnimationBytes = 8;
  118. cmReturn << dwNumInitAnimationBytes;
  119. BYTE ucInitialAnimation[] = //states which animation the model starts out in
  120. {0x00, 0x00, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00};
  121. for(int blah = 0;blah<sizeof(ucInitialAnimation);blah++)
  122. cmReturn << ucInitialAnimation[blah];
  123. cmReturn << 0x00000000L; // Unknown DWORD
  124. cmReturn.pasteData( (UCHAR*)&m_Location, sizeof(m_Location) ); //Next comes the location
  125. cmReturn << DWORD (0x09000001);
  126. cmReturn << DWORD (0x20000001);
  127. cmReturn << 0x02000000 + pcModel->m_dwModelNumber;
  128. // SeaGreens
  129. WORD wUnkFlag2 = 0x1;
  130. WORD wUnkFlag3 = 0x1;
  131. WORD wUnkFlag4 = 0;
  132. WORD wUnkFlag6 = 0;
  133. WORD wUnkFlag7 = 0;
  134. WORD wUnkFlag8 = 0;
  135. WORD wUnkFlag10 = 0;
  136. cmReturn << m_wPositionSequence //movement
  137. << wUnkFlag2 // animations
  138. << wUnkFlag3 // bubble modes
  139. << wUnkFlag4 //num jumps
  140. << m_wNumPortals
  141. << wUnkFlag6 //anim count
  142. << wUnkFlag7 // overrides
  143. << wUnkFlag8
  144. << m_wNumLogins
  145. << wUnkFlag10;
  146. DWORD dwFlags2;
  147. //vendor or not
  148. switch(IsVendor)
  149. {
  150. case 0:
  151. dwFlags2 = 0x00800016;
  152. break;
  153. case 1:
  154. dwFlags2 = 0x00800036;
  155. break;
  156. case 2:
  157. dwFlags2 = 0x00900036;
  158. break;
  159. //Town Criers...
  160. case 3:
  161. dwFlags2 = 0x00900036;
  162. break;
  163. default:
  164. dwFlags2 = 0x00800016;
  165. break;
  166. }
  167. cmReturn << dwFlags2; // Word 0080 - Flag Word 0016 Length of Name
  168. cmReturn << Name( ); // Object's Name
  169. cmReturn << pcModel->m_wModel << pcModel->m_wIcon;
  170. DWORD dwObjectFlags1;
  171. DWORD dwObjectFlags2;
  172. switch(IsVendor)
  173. {
  174. case 0:
  175. {
  176. dwObjectFlags1 = 0x00000010;
  177. dwObjectFlags2 = 0x00000004;
  178. break;
  179. }
  180. case 1:
  181. {
  182. dwObjectFlags1 = 0x00000010;
  183. dwObjectFlags2 = 0x00000204;
  184. break;
  185. }
  186. case 2:
  187. {
  188. dwObjectFlags1 = 0x00000010;
  189. dwObjectFlags2 = 0x00000004;
  190. break;
  191. }
  192. default:
  193. {
  194. dwObjectFlags1 = 0x00000010;
  195. dwObjectFlags2 = 0x00000004;
  196. break;
  197. }
  198. }
  199. cmReturn << dwObjectFlags1 << dwObjectFlags2;
  200. BYTE bNumberOfSlots = 0xFF;
  201. cmReturn << bNumberOfSlots;
  202. BYTE bNumPackSlots = 0xFF;
  203. cmReturn << bNumPackSlots;
  204. cmReturn << 0x20L;
  205. if(dwFlags2 & 0x00000020)
  206. {
  207. cmReturn << float(3.0);
  208. }
  209. //Cubem0j0: 0x00800000 - This flag seems to affect what options you have when selecting the object, and also
  210. // how it appears on radar.
  211. switch(IsVendor)
  212. {
  213. case 1:
  214. {
  215. DWORD dwUnknown4 = 0x00020004;
  216. cmReturn << dwUnknown4;
  217. break;
  218. }
  219. default:
  220. {
  221. DWORD dwUnknown4 = 0x00010408;
  222. cmReturn << dwUnknown4;
  223. break;
  224. }
  225. }
  226. }
  227. else // nothing
  228. {
  229. cmReturn << 0xF755L << DWORD(1) << DWORD(124) << 0x3F2B4E94L;
  230. }
  231. return cmReturn;
  232. }
  233. /**
  234. * Handles the actions of NPC objects.
  235. *
  236. * This function is called whenever an NPC is used or should perform an general action.
  237. *
  238. * Author: Cubem0j0
  239. */
  240. void cNPC::Action(cClient* who)
  241. {
  242. float flHeading;
  243. flHeading = GetHeadingTarget( who->m_pcAvatar->m_Location.m_dwLandBlock, who->m_pcAvatar->m_Location.m_flX, who->m_pcAvatar->m_Location.m_flY, who->m_pcAvatar->m_Location.m_flZ );
  244. cWorldManager::SendToAllWithin( 5, m_Location, TurnToTarget(flHeading, who->m_pcAvatar->GetGUID( ) ), 3 );
  245. switch(m_dwMode)
  246. {
  247. case NPCMODE_SINGLE:
  248. {
  249. cMasterServer::ServerMessage(ColorBrown,who,"%s tells you, \"%s\"",m_strName.c_str(),vsMessages[0].c_str());
  250. break;
  251. }
  252. case NPCMODE_MULTI:
  253. {
  254. for(int a = 0;a<iNumMessages;a++)
  255. {
  256. cMasterServer::ServerMessage(ColorBrown,who,"%s tells you, \"%s\"",m_strName.c_str(),vsMessages[a].c_str());
  257. }
  258. break;
  259. }
  260. case NPCMODE_RANDOM:
  261. {
  262. int rnd = (double(rand())/RAND_MAX)*iNumMessages;
  263. if(rnd==iNumMessages) //not sure if this is needed, but rand() might equal RAND_MAX
  264. rnd--;
  265. cMasterServer::ServerMessage(ColorBrown,who,"%s tells you, \"%s\"",m_strName.c_str(),vsMessages[rnd].c_str());
  266. break;
  267. }
  268. }
  269. cMessage cmActionComplete;
  270. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  271. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  272. if(GetIsVendor() == 1)
  273. {
  274. this->ApproachVendor(who);
  275. }
  276. }
  277. /**
  278. * Handles the assessment of NPC objects.
  279. *
  280. * This function is called whenever an NPC is assessed by a client.
  281. * Returns a Game Event (0x0000F7B0) server message of type Identify Object (0x000000C9).
  282. */
  283. void cNPC::Assess(cClient *pcAssesser)
  284. {
  285. m_NPCStats.m_dwLevel = 10;
  286. m_NPCStats.m_dwStr = 10;
  287. m_NPCStats.m_dwEnd = 10;
  288. m_NPCStats.m_dwQuick = 10;
  289. m_NPCStats.m_dwCoord = 10;
  290. m_NPCStats.m_dwFocus = 10;
  291. m_NPCStats.m_dwSelf = 10;
  292. m_NPCStats.m_dwSpecies = 31;
  293. cMessage cmAssess;
  294. DWORD dwCharacterFlags; // Needs Decoding
  295. dwCharacterFlags = 0x0CL; // 0x04 - Level, Health | 0x08 - Stats
  296. cmAssess << 0xF7B0L
  297. << pcAssesser->m_pcAvatar->GetGUID( )
  298. << ++pcAssesser->m_dwF7B0Sequence
  299. << 0xC9L
  300. << m_dwGUID
  301. << 0x100L // Flags 0x00000100 - Character Data
  302. << 0x1L; // Pass/Failed
  303. // Process the Flag Specified Data
  304. cmAssess << dwCharacterFlags
  305. // Mask 0x04
  306. << m_NPCStats.m_dwLevel
  307. << m_NPCStats.m_dwEnd/2
  308. << m_NPCStats.m_dwEnd/2
  309. // Mask 0x08
  310. << m_NPCStats.m_dwStr
  311. << m_NPCStats.m_dwEnd
  312. << m_NPCStats.m_dwQuick
  313. << m_NPCStats.m_dwCoord
  314. << m_NPCStats.m_dwFocus
  315. << m_NPCStats.m_dwSelf
  316. << m_NPCStats.m_dwEnd
  317. << m_NPCStats.m_dwSelf
  318. << m_NPCStats.m_dwEnd
  319. << m_NPCStats.m_dwSelf
  320. // End Mask
  321. << m_NPCStats.m_dwSpecies;
  322. pcAssesser->AddPacket(WORLD_SERVER,cmAssess,4);
  323. cMessage cmActionComplete;
  324. cmActionComplete << 0xF7B0L << pcAssesser->m_pcAvatar->GetGUID( ) << ++pcAssesser->m_dwF7B0Sequence << 0x01C7L << 0L;
  325. pcAssesser->AddPacket(WORLD_SERVER,cmActionComplete,4);
  326. }
  327. /**
  328. * Handles the purchasing of items from NPC objects.
  329. *
  330. * This function is called whenever a player buys an item from an NPC.
  331. *
  332. * @param *pcClient - A pointer to the client whose avatar is purchasing the item.
  333. * @param VenderID - A the GUID of the vendor.
  334. * @param ItemID - The GUID of the object to buy.
  335. */
  336. void cNPC::BuyItem(cClient *pcClient, DWORD VendorID, DWORD ItemID)
  337. {
  338. DWORD adwGUID = pcClient->m_pcAvatar->GetGUID( );
  339. //Cube: First, find the vendor:
  340. cNPC *vendor = reinterpret_cast<cNPC *>(cWorldManager::FindObject(VendorID));
  341. //Cube: Now find the item in that vendor's inventory
  342. cObject *ObjectBuy = vendor->FindInventory(ItemID);
  343. //Cube: Finally find the object Model ID
  344. cItemModels *pcModel = cItemModels::FindModel(ObjectBuy->GetItemModelID());
  345. switch(pcModel->m_ItemType)
  346. {
  347. case 1: //Weapons
  348. {
  349. //Create the item on the avatar
  350. cWeapon* aWeapon = new cWeapon(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),1.0,TRUE,pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_dwValue,pcModel->m_wBurden,pcModel->m_bWieldType,pcModel->m_dwIconHighlight,pcModel->m_fWorkmanship,pcModel->m_dwMaterialType,pcModel->m_dwWeaponDamage,pcModel->m_dwWeaponSpeed,pcModel->m_dwWeaponSkill,pcModel->m_dwDamageType,pcModel->m_dWeaponVariance,pcModel->m_dWeaponModifier,pcModel->m_dWeaponPower,pcModel->m_dWeaponAttack);
  351. pcClient->AddPacket( WORLD_SERVER, aWeapon->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  352. pcClient->m_pcAvatar->AddInventory(aWeapon);
  353. //Reload the Vendors inventory
  354. this->ApproachVendor(pcClient);
  355. //Add the Item to the player's inventory. (Don't even know that we really need this step...)
  356. cMessage cmInsInv;
  357. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aWeapon->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  358. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  359. //Subtract the price of the item from total pyreals
  360. DWORD npy = pcClient->m_pcAvatar->m_dwPyreals - aWeapon->GetItemValue();
  361. cMessage cmRet;
  362. cmRet << 0x237L << m_bStatSequence++ << 0x14L << npy;
  363. pcClient->AddPacket( WORLD_SERVER, cmRet, 4);
  364. #if _DEBUG
  365. cMasterServer::ServerMessage(ColorYellow,NULL,"Item value is: %d",aWeapon->GetItemValue());
  366. #endif
  367. //Play the "buy" sound
  368. cMessage Sound = pcClient->m_pcAvatar->SoundEffect(122);
  369. cMessage cmActionComplete;
  370. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  371. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  372. break;
  373. }
  374. case 2: //Food
  375. {
  376. cFood* aFood = new cFood(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_dwValue, pcModel->m_wStack, pcModel->m_wBurden, pcModel->m_dwVitalID, pcModel->m_vital_affect);
  377. pcClient->AddPacket( WORLD_SERVER, aFood->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  378. pcClient->m_pcAvatar->AddInventory(aFood);
  379. this->ApproachVendor(pcClient);
  380. cMessage cmInsInv;
  381. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aFood->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  382. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  383. cMessage cmActionComplete;
  384. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  385. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  386. break;
  387. }
  388. case 3: //Armor
  389. {
  390. cArmor* aArmor = new cArmor(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),1.0,TRUE,pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_dwValue,pcModel->m_wBurden,pcModel->m_dwArmor_Level,pcModel->m_fProt_Slashing, pcModel->m_fProt_Piercing, pcModel->m_fProt_Bludgeon, pcModel->m_fProt_Fire, pcModel->m_fProt_Cold, pcModel->m_fProt_Acid, pcModel->m_fProt_Electric);
  391. pcClient->AddPacket( WORLD_SERVER, aArmor->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  392. pcClient->m_pcAvatar->AddInventory(aArmor);
  393. this->ApproachVendor(pcClient);
  394. cMessage cmInsInv;
  395. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aArmor->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  396. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  397. cMessage cmActionComplete;
  398. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  399. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  400. break;
  401. }
  402. case 5: //Scrolls
  403. {
  404. cScrolls* aScrolls = new cScrolls(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),1.0,TRUE,pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription);
  405. pcClient->AddPacket( WORLD_SERVER, aScrolls->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  406. pcClient->m_pcAvatar->AddInventory(aScrolls);
  407. this->ApproachVendor(pcClient);
  408. cMessage cmInsInv;
  409. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aScrolls->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  410. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  411. cMessage cmActionComplete;
  412. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  413. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  414. break;
  415. }
  416. case 7: //Lockpicks
  417. {
  418. cLockpicks* aPick = new cLockpicks(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),1.0,TRUE,pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_wUses,pcModel->m_wUseLimit);
  419. pcClient->AddPacket( WORLD_SERVER, aPick->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  420. pcClient->m_pcAvatar->AddInventory(aPick);
  421. this->ApproachVendor(pcClient);
  422. cMessage cmInsInv;
  423. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aPick->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  424. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  425. cMessage cmActionComplete;
  426. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  427. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  428. break;
  429. }
  430. case 8: //Wands
  431. {
  432. cWands* aWand = new cWands(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),1.0,TRUE,pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_dwValue,pcModel->m_wBurden);
  433. pcClient->AddPacket( WORLD_SERVER, aWand->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  434. pcClient->m_pcAvatar->AddInventory(aWand);
  435. this->ApproachVendor(pcClient);
  436. cMessage cmInsInv;
  437. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aWand->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  438. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  439. cMessage cmActionComplete;
  440. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  441. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  442. break;
  443. }
  444. case 12:
  445. {
  446. cShield* aShield = new cShield(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_dwValue,pcModel->m_wBurden,pcModel->m_dwArmor_Level);
  447. pcClient->AddPacket( WORLD_SERVER, aShield->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  448. pcClient->m_pcAvatar->AddInventory(aShield);
  449. this->ApproachVendor(pcClient);
  450. cMessage cmInsInv;
  451. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aShield->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  452. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  453. //Done
  454. cMessage cmActionComplete;
  455. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  456. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  457. break;
  458. }
  459. case 13:
  460. {
  461. cSpellComps* aReg = new cSpellComps(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_dwValue,1,pcModel->m_wBurden);
  462. pcClient->AddPacket( WORLD_SERVER, aReg->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  463. pcClient->m_pcAvatar->AddInventory(aReg);
  464. this->ApproachVendor(pcClient);
  465. cMessage cmInsInv;
  466. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aReg->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  467. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  468. //Done
  469. cMessage cmActionComplete;
  470. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  471. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  472. break;
  473. }
  474. case 14:
  475. {
  476. cGems* aGem = new cGems(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_dwValue,pcModel->m_wBurden);
  477. pcClient->AddPacket( WORLD_SERVER, aGem->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  478. pcClient->m_pcAvatar->AddInventory(aGem);
  479. this->ApproachVendor(pcClient);
  480. cMessage cmInsInv;
  481. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aGem->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  482. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  483. //Done
  484. cMessage cmActionComplete;
  485. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  486. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  487. break;
  488. }
  489. case 18:
  490. {
  491. cClothes* aShirt = new cClothes(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),1.0,TRUE,pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_dwValue,pcModel->m_wBurden);
  492. pcClient->AddPacket( WORLD_SERVER, aShirt->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  493. pcClient->m_pcAvatar->AddInventory(aShirt);
  494. this->ApproachVendor(pcClient);
  495. cMessage cmInsInv;
  496. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aShirt->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  497. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  498. //Done
  499. cMessage cmActionComplete;
  500. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  501. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  502. break;
  503. }
  504. case 19:
  505. {
  506. cJewelry* aRing = new cJewelry(cWorldManager::NewGUID_Object(),adwGUID,ObjectBuy->GetItemModelID(),1.0,TRUE,pcModel->m_wIcon,pcModel->m_strName,pcModel->m_strDescription,pcModel->m_dwValue,pcModel->m_wBurden);
  507. pcClient->AddPacket( WORLD_SERVER, aRing->CreatePacketContainer(adwGUID,pcModel->m_dwModelID),3);
  508. pcClient->m_pcAvatar->AddInventory(aRing);
  509. this->ApproachVendor(pcClient);
  510. cMessage cmInsInv;
  511. cmInsInv << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++m_dwF7B0Sequence << 0x0022L << aRing->GetGUID() << pcClient->m_pcAvatar->GetGUID( ) << 0L << 0L;
  512. pcClient->AddPacket( WORLD_SERVER, cmInsInv, 4 );
  513. //Done
  514. cMessage cmActionComplete;
  515. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  516. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  517. break;
  518. }
  519. }
  520. cMessage cmActionComplete;
  521. cmActionComplete << 0xF7B0L << pcClient->m_pcAvatar->GetGUID( ) << ++pcClient->m_dwF7B0Sequence << 0x01C7L << 0L;
  522. pcClient->AddPacket(WORLD_SERVER,cmActionComplete,4);
  523. }
  524. /**
  525. * Handles trade interaction with vendor NPCs.
  526. *
  527. * This function is called whenever a player approaches a vendor.
  528. *
  529. * @param *who - A pointer to the client whose avatar approaching the vendor.
  530. */
  531. void cNPC::ApproachVendor(cClient *who)
  532. {
  533. if(GetIsVendor() == 1)
  534. {
  535. cMasterServer::ServerMessage(ColorYellow,NULL,"inven size is: %d",this->m_NPC_lstInventory.size());
  536. if (this->m_NPC_lstInventory.size() == 0)
  537. {
  538. //If inventory size is zero, nothing will happen.
  539. cMessage cmActionComplete;
  540. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  541. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  542. }
  543. else
  544. {
  545. //Cubem0j0: Vendor Stuff
  546. DWORD BuyCategories = 0x000cb000; //0x000410A0; //Will figure these out later.
  547. DWORD unk1 = 0x00000000;
  548. DWORD HighestBuy = 0x000186A0; //0x000186A0; //100,000.
  549. DWORD unk2 = 0x00000001;
  550. float BuyRate = 0.9f; //Corrected values
  551. float SellRate = 1.55f; //Corrected values
  552. DWORD Inventory = 0xFFFFFFFF;
  553. /* OLD VARS
  554. DWORD ItemCount = 0x0002L;//0012
  555. DWORD Item_ID = 0x90873824; //number is odd, anything lower causes crash.
  556. DWORD flags = 0x10207019; //add 1 if item stacks.
  557. char* name = "Health Potion";
  558. WORD Model = 0x0179;
  559. WORD Icon = 0x1D72;
  560. DWORD Sell_Categories = 0x00000100;
  561. */
  562. cMessage cmApproachVendor;
  563. cmApproachVendor << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x0062L
  564. << m_dwGUID //Vendor GUID
  565. << BuyCategories
  566. << unk1
  567. << HighestBuy //Highest Buy? (unconfirmed)
  568. << unk2
  569. << BuyRate //Buy Rate (unconfirmed)
  570. << SellRate //Sell Rate (Unconfirmed)
  571. << this->m_NPC_lstInventory.size(); //Does not appear to be item count
  572. //Loop through inventory and find all items.
  573. for (int i = 0; i < this->m_NPC_lstInventory.size(); i++)
  574. {
  575. //Find each item by it's GUID
  576. cObject *v_item = this->FindInventory(this->v_guids[i]);
  577. //Associate model with item
  578. cItemModels *v_model = cItemModels::FindModel(v_item->GetItemModelID());
  579. //The v_model->m_dwObjectFlags1 will determine the sell categories for the vendor.
  580. //So we add logic to send the correctly formatted message
  581. //Note: * are sections that are complete.
  582. switch(v_model->m_dwObjectFlags1)
  583. {
  584. case 0x00000001: //Weapons (NOTE: Vendor works, Corpse works, GS works)
  585. {
  586. cmApproachVendor
  587. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  588. << WORD(0xFFFF)
  589. << v_item->GetGUID() //Item GUID
  590. << v_model->m_dwFlags2 //10214218
  591. << v_model->m_strName.c_str() //Item Name
  592. << v_model->m_wModel //Model
  593. << v_model->m_wIcon //Icon
  594. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  595. << v_model->m_dwObjectFlags2 //Object flags 2
  596. << v_model->m_dwValue //Value
  597. << v_model->m_dwUnknown_v2 //Unknown_10 - use Unknown_v2 from database
  598. << v_model->m_bWieldType //Wield type (Byte, padded)
  599. << m_dwGUID //Container ID
  600. << DWORD(0x100000)//v_model->m_dwEquipPossible //EquipMask :the potential equipment slots this object may be placed in
  601. << v_model->m_wBurden //Burden (WORD, no padding)
  602. << v_model->m_wHooks //Hook Type (WORD, no padding)
  603. //Below is padding DO NOT REMOVE!
  604. << WORD(0x0000)
  605. << BYTE(0x00);
  606. //cMasterServer::ServerMessage(ColorYellow,NULL,"Value is : %d",v_model->m_dwValue);
  607. break;
  608. }
  609. case 0x00000002: //Armor (NOTE: Vendor works, Corpse works, GS works)
  610. {
  611. cmApproachVendor
  612. << WORD(0xFFFF)
  613. << WORD(0xFFFF)
  614. << v_item->GetGUID()
  615. << v_model->m_dwFlags2
  616. << v_item->Name()
  617. << v_model->m_wModel
  618. << v_model->m_wIcon
  619. << v_model->m_dwObjectFlags1
  620. << v_model->m_dwObjectFlags2;
  621. if(v_model->m_ItemType == 3)
  622. {
  623. if(v_model->m_dwFlags2 & 0x00000008)
  624. {
  625. cmApproachVendor
  626. << v_model->m_dwValue;
  627. }
  628. if(v_model->m_dwFlags2 & 0x00000010)
  629. {
  630. cmApproachVendor
  631. << v_model->m_dwUnknown_v2;
  632. }
  633. if(v_model->m_dwFlags2 & 0x00004000)
  634. {
  635. cmApproachVendor
  636. << m_dwGUID;
  637. }
  638. if(v_model->m_dwFlags2 & 0x00010000)
  639. {
  640. cmApproachVendor
  641. << v_model->m_dwEquipPossible;
  642. }
  643. if(v_model->m_dwFlags2 & 0x00040000)
  644. {
  645. cmApproachVendor
  646. << v_model->m_dwCoverage;
  647. }
  648. if(v_model->m_dwFlags2 & 0x00200000)
  649. {
  650. cmApproachVendor
  651. << v_model->m_wBurden;
  652. }
  653. if(v_model->m_dwFlags2 & 0x10000000)
  654. {
  655. cmApproachVendor
  656. << v_model->m_wHooks;
  657. }
  658. else
  659. {
  660. cmApproachVendor
  661. << WORD(0x0000);
  662. }
  663. }
  664. if(v_model->m_ItemType == 12)
  665. {
  666. if(v_model->m_dwFlags2 & 0x00000008)
  667. cmApproachVendor << v_model->m_dwValue;
  668. if(v_model->m_dwFlags2 & 0x00000010)
  669. cmApproachVendor << v_model->m_dwUnknown_v2;
  670. if(v_model->m_dwFlags2 & 0x00000080)
  671. cmApproachVendor << v_model->m_dwIconHighlight;
  672. if(v_model->m_dwFlags2 & 0x00000200)
  673. cmApproachVendor << BYTE(0x04);
  674. if(v_model->m_dwFlags2 & 0x00004000)
  675. cmApproachVendor << m_dwGUID;
  676. if(v_model->m_dwFlags2 & 0x00010000)
  677. cmApproachVendor << v_model->m_dwEquipPossible;
  678. if(v_model->m_dwFlags2 & 0x00200000)
  679. cmApproachVendor << v_model->m_wBurden;
  680. if(v_model->m_dwFlags2 & 0x01000000)
  681. cmApproachVendor << v_model->m_fWorkmanship;
  682. if(v_model->m_dwFlags2 & 0x10000000)
  683. cmApproachVendor << v_model->m_wHooks;
  684. if(v_model->m_dwFlags2 & 0x80000000)
  685. cmApproachVendor << v_model->m_dwMaterialType;
  686. else
  687. {
  688. cmApproachVendor << WORD(0x0000)
  689. << BYTE(0x00);
  690. }
  691. }
  692. break;
  693. }
  694. case 0x00000004: //Clothes
  695. {
  696. cmApproachVendor
  697. << WORD(0xFFFF)
  698. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  699. << v_item->GetGUID() //Item GUID
  700. << v_model->m_dwFlags2 //10254018
  701. << v_model->m_strName.c_str() //Item Name
  702. << v_model->m_wModel //Model
  703. << v_model->m_wIcon //Icon
  704. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  705. << v_model->m_dwObjectFlags2; //Object flags 2
  706. if(v_model->m_dwFlags2 & 0x00000008)
  707. cmApproachVendor << v_model->m_dwValue;
  708. if(v_model->m_dwFlags2 & 0x00000010)
  709. cmApproachVendor << v_model->m_dwUnknown_v2;
  710. if(v_model->m_dwFlags2 & 0x00000080)
  711. cmApproachVendor << v_model->m_dwIconHighlight;
  712. if(v_model->m_dwFlags2 & 0x00004000)
  713. cmApproachVendor << m_dwGUID;
  714. if(v_model->m_dwFlags2 & 0x00010000)
  715. cmApproachVendor << v_model->m_dwEquipPossible;
  716. if(v_model->m_dwFlags2 & 0x00040000)
  717. cmApproachVendor << v_model->m_dwCoverage;
  718. if(v_model->m_dwFlags2 & 0x00200000)
  719. cmApproachVendor << v_model->m_wBurden;
  720. if(v_model->m_dwFlags2 & 0x01000000)
  721. cmApproachVendor << v_model->m_fWorkmanship;
  722. if(v_model->m_dwFlags2 & 0x10000000)
  723. {
  724. cmApproachVendor
  725. << v_model->m_wHooks;
  726. }
  727. else
  728. {
  729. cmApproachVendor
  730. << WORD(0x0000);
  731. }
  732. if(v_model->m_dwFlags2 & 0x80000000)
  733. cmApproachVendor << v_model->m_dwMaterialType;
  734. break;
  735. }
  736. case 0x00000008: //Jewelry
  737. {
  738. cmApproachVendor
  739. << WORD(0xFFFF)
  740. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  741. << v_item->GetGUID() //Item GUID
  742. << v_model->m_dwFlags2 //10254018
  743. << v_model->m_strName.c_str() //Item Name
  744. << v_model->m_wModel //Model
  745. << v_model->m_wIcon //Icon
  746. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  747. << v_model->m_dwObjectFlags2; //Object flags 2
  748. if(v_model->m_dwFlags2 & 0x00000008)
  749. cmApproachVendor << v_model->m_dwValue;
  750. if(v_model->m_dwFlags2 & 0x00000010)
  751. cmApproachVendor << v_model->m_dwUnknown_v2;
  752. if(v_model->m_dwFlags2 & 0x00000080)
  753. cmApproachVendor << v_model->m_dwIconHighlight;
  754. if(v_model->m_dwFlags2 & 0x00004000)
  755. cmApproachVendor << m_dwGUID;
  756. if(v_model->m_dwFlags2 & 0x00010000)
  757. cmApproachVendor << v_model->m_dwEquipPossible;
  758. if(v_model->m_dwFlags2 & 0x00200000)
  759. cmApproachVendor << v_model->m_wBurden;
  760. if(v_model->m_dwFlags2 & 0x01000000)
  761. cmApproachVendor << v_model->m_fWorkmanship;
  762. if(v_model->m_dwFlags2 & 0x10000000)
  763. {
  764. cmApproachVendor
  765. << v_model->m_wHooks;
  766. }
  767. //else
  768. // {
  769. // cmApproachVendor
  770. // << WORD(0x0000);
  771. // }
  772. if(v_model->m_dwFlags2 & 0x80000000)
  773. cmApproachVendor << v_model->m_dwMaterialType;
  774. cmApproachVendor
  775. << WORD(0x0000);
  776. break;
  777. }
  778. case 0x00000020: //Food*
  779. {
  780. cmApproachVendor
  781. << WORD(0xFFFF)
  782. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  783. << v_item->GetGUID() //Item GUID
  784. << v_model->m_dwFlags2 //00207018
  785. << v_model->m_strName.c_str() //Item Name
  786. << v_model->m_wModel //Model
  787. << v_model->m_wIcon //Icon
  788. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  789. << v_model->m_dwObjectFlags2 //Object flags 2
  790. << v_model->m_dwValue //Value
  791. << v_model->m_dwUnknown_v2 //Unknown_10
  792. << v_model->m_wStack //NUmber of items in stack
  793. << v_model->m_wStackLimit //Stack limit
  794. << m_dwGUID //Container ID
  795. << v_model->m_wBurden; //Burden (WORD, no padding)
  796. break;
  797. }
  798. case 0x00000080: //Misc (may need to define further)
  799. {
  800. cmApproachVendor
  801. << WORD(0xFFFF)
  802. << WORD(0xFFFF)
  803. << v_item->GetGUID()
  804. << v_model->m_dwFlags2
  805. << v_model->m_strName.c_str()
  806. << v_model->m_wModel
  807. << v_model->m_wIcon
  808. << v_model->m_dwObjectFlags1
  809. << v_model->m_dwObjectFlags2;
  810. if(v_model->m_dwFlags2 & 0x00000008)
  811. cmApproachVendor << v_model->m_dwValue;
  812. if(v_model->m_dwFlags2 & 0x00000010)
  813. cmApproachVendor << v_model->m_dwUnknown_v2;
  814. if(v_model->m_dwFlags2 & 0x00000400)
  815. cmApproachVendor << v_model->m_wUses;
  816. if(v_model->m_dwFlags2 & 0x00000800)
  817. cmApproachVendor << v_model->m_wUseLimit;
  818. if(v_model->m_dwFlags2 & 0x00001000)
  819. cmApproachVendor << v_model->m_wStack;
  820. if(v_model->m_dwFlags2 & 0x00002000)
  821. cmApproachVendor << v_model->m_wStackLimit;
  822. if(v_model->m_dwFlags2 & 0x00004000)
  823. cmApproachVendor << m_dwGUID;
  824. if(v_model->m_dwFlags2 & 0x00200000)
  825. cmApproachVendor << v_model->m_wBurden;
  826. if(v_model->m_dwFlags2 & 0x10000000)
  827. cmApproachVendor << v_model->m_wHooks;
  828. else
  829. {
  830. cmApproachVendor << WORD(0x0000);
  831. }
  832. break;
  833. }
  834. case 0x00000100: //Missile Weapons/Ammunition
  835. {
  836. cmApproachVendor
  837. << WORD(0xFFFF)
  838. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  839. << v_item->GetGUID() //Item GUID
  840. << v_model->m_dwFlags2 //10254018
  841. << v_model->m_strName.c_str() //Item Name
  842. << v_model->m_wModel //Model
  843. << v_model->m_wIcon //Icon
  844. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  845. << v_model->m_dwObjectFlags2; //Object flags 2
  846. //Cube: NOTE: For ammo, ammo type comes before value
  847. if(v_model->m_dwFlags2 & 0x00000100)
  848. {
  849. cmApproachVendor
  850. << v_model->m_wAmmoType;
  851. }
  852. if(v_model->m_dwFlags2 & 0x00000008)
  853. {
  854. cmApproachVendor
  855. << v_model->m_dwValue;
  856. }
  857. if(v_model->m_dwFlags2 & 0x00000010)
  858. {
  859. cmApproachVendor
  860. << v_model->m_dwUnknown_v2;
  861. }
  862. if(v_model->m_dwFlags2 & 0x00000080)
  863. cmApproachVendor << v_model->m_dwIconHighlight;
  864. if(v_model->m_dwFlags2 & 0x00000200)
  865. {
  866. cmApproachVendor
  867. << v_model->m_bWieldType;
  868. }
  869. if(v_model->m_dwFlags2 & 0x00001000)
  870. {
  871. cmApproachVendor
  872. << v_model->m_wStack;
  873. }
  874. if(v_model->m_dwFlags2 & 0x00002000)
  875. {
  876. cmApproachVendor
  877. << v_model->m_wStackLimit;
  878. }
  879. if(v_model->m_dwFlags2 & 0x00004000)
  880. {
  881. cmApproachVendor
  882. << m_dwGUID;
  883. }
  884. if(v_model->m_dwFlags2 & 0x00010000)
  885. {
  886. cmApproachVendor
  887. << v_model->m_dwEquipPossible;
  888. }
  889. if(v_model->m_dwFlags2 & 0x00200000)
  890. {
  891. cmApproachVendor
  892. << v_model->m_wBurden;
  893. }
  894. if(v_model->m_dwFlags2 & 0x10000000)
  895. {
  896. cmApproachVendor
  897. << v_model->m_wHooks;
  898. }
  899. //Below is padding DO NOT REMOVE!
  900. cmApproachVendor
  901. << WORD(0x0000)
  902. << BYTE(0x00);
  903. break;
  904. }
  905. case 0x00000200: //Containers
  906. {
  907. cmApproachVendor
  908. << Inventory //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  909. << v_item->GetGUID() //Item GUID
  910. << v_model->m_dwFlags2 //10254018
  911. << v_model->m_strName.c_str() //Item Name
  912. << v_model->m_wModel //Model
  913. << v_model->m_wIcon //Icon
  914. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  915. << v_model->m_dwObjectFlags2 //Object flags 2
  916. << v_model->m_dwValue //Value
  917. << v_model->m_dwUnknown_v2 //Unknown_10
  918. << m_dwGUID //Container ID
  919. << v_model->m_dwEquipPossible //EquipMask :the potential equipment slots this object may be placed in
  920. << v_model->m_dwCoverage //Coverage
  921. << v_model->m_wBurden //Burden (WORD, no padding)
  922. << v_model->m_wHooks; //Hook Type (WORD, no padding)
  923. break;
  924. }
  925. case 0x00000400: //Fletching Supplies, Decorations
  926. {
  927. cmApproachVendor
  928. << Inventory //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  929. << v_item->GetGUID() //Item GUID
  930. << v_model->m_dwFlags2 //10254018
  931. << v_model->m_strName.c_str() //Item Name
  932. << v_model->m_wModel //Model
  933. << v_model->m_wIcon //Icon
  934. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  935. << v_model->m_dwObjectFlags2 //Object flags 2
  936. << v_model->m_dwValue //Value
  937. << v_model->m_dwUnknown_v2 //Unknown_10
  938. << m_dwGUID //Container ID
  939. << v_model->m_dwEquipPossible //EquipMask :the potential equipment slots this object may be placed in
  940. << v_model->m_dwCoverage //Coverage
  941. << v_model->m_wBurden //Burden (WORD, no padding)
  942. << v_model->m_wHooks; //Hook Type (WORD, no padding)
  943. break;
  944. }
  945. case 0x00000800: //Gems
  946. {
  947. cmApproachVendor
  948. << WORD(0xFFFF)
  949. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  950. << v_item->GetGUID() //Item GUID
  951. << v_model->m_dwFlags2 //10254018
  952. << v_model->m_strName.c_str() //Item Name
  953. << v_model->m_wModel //Model
  954. << v_model->m_wIcon //Icon
  955. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  956. << v_model->m_dwObjectFlags2; //Object flags 2
  957. if(v_model->m_dwFlags2 & 0x00000008)
  958. cmApproachVendor << v_model->m_dwValue;
  959. if(v_model->m_dwFlags2 & 0x00000010)
  960. cmApproachVendor << v_model->m_dwUnknown_v2;
  961. if(v_model->m_dwFlags2 & 0x00000080)
  962. cmApproachVendor << v_model->m_dwIconHighlight;
  963. if(v_model->m_dwFlags2 & 0x00001000)
  964. cmApproachVendor << v_model->m_wStack;
  965. if(v_model->m_dwFlags2 & 0x00002000)
  966. cmApproachVendor << v_model->m_wStackLimit;
  967. if(v_model->m_dwFlags2 & 0x00004000)
  968. cmApproachVendor << m_dwGUID;
  969. if(v_model->m_dwFlags2 & 0x00200000)
  970. cmApproachVendor << v_model->m_wBurden;
  971. if(v_model->m_dwFlags2 & 0x00400000)
  972. cmApproachVendor << v_model->m_wSpellID;
  973. if(v_model->m_dwFlags2 & 0x01000000)
  974. cmApproachVendor << v_model->m_fWorkmanship;
  975. if(v_model->m_dwFlags2 & 0x80000000)
  976. cmApproachVendor << v_model->m_dwMaterialType;
  977. cmApproachVendor << WORD(0x0000);
  978. break;
  979. }
  980. case 0x00001000: //Spell Components
  981. {
  982. cmApproachVendor
  983. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  984. << WORD(0xFFFF)
  985. << v_item->GetGUID() //Item GUID
  986. << v_model->m_dwFlags2 //00207019
  987. << v_model->m_strName.c_str() //Item Name
  988. << v_model->m_wModel //Model
  989. << v_model->m_wIcon //Icon
  990. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  991. << v_model->m_dwObjectFlags2 //Object flags 2
  992. << v_model->m_dwValue //Value
  993. << v_model->m_dwUnknown_v2 //Unknown_10
  994. << v_model->m_wStack //NUmber of items in stack
  995. << v_model->m_wStackLimit //Stack limit
  996. << m_dwGUID //Container ID
  997. << v_model->m_wBurden //Burden (WORD, no padding)
  998. << WORD(0x0000);
  999. // if _DEBUG
  1000. // char* debug = ("%s Value is: %d",v_model->m_strName.c_str(),v_model->m_dwValue);
  1001. // cMasterServer::WriteToFile(debug);
  1002. break;
  1003. }
  1004. case 0x00002000: //Books,Parchment,scrolls
  1005. {
  1006. cmApproachVendor
  1007. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  1008. << WORD(0xFFFF)
  1009. << v_item->GetGUID() //Item GUID
  1010. << v_model->m_dwFlags2 //10254018
  1011. << v_model->m_strName.c_str() //Item Name
  1012. << v_model->m_wModel //Model
  1013. << v_model->m_wIcon //Icon
  1014. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  1015. << v_model->m_dwObjectFlags2 //Object flags 2
  1016. << v_model->m_dwValue //Value
  1017. << v_model->m_dwUnknown_v2 //Unknown_10
  1018. << m_dwGUID //Container ID
  1019. << v_model->m_wBurden //Burden (WORD, no padding)
  1020. << v_model->m_wSpellID; //SpellID
  1021. break;
  1022. }
  1023. case 0x00004000: //Lockpicks/Keys
  1024. {
  1025. cmApproachVendor
  1026. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  1027. << WORD(0xFFFF)
  1028. << v_item->GetGUID() //Item GUID
  1029. << v_model->m_dwFlags2 //10254018
  1030. << v_model->m_strName.c_str() //Item Name
  1031. << v_model->m_wModel //Model
  1032. << v_model->m_wIcon //Icon
  1033. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  1034. << v_model->m_dwObjectFlags2; //Object flags 2
  1035. if(v_model->m_dwFlags2 & 0x00000008)
  1036. cmApproachVendor << v_model->m_dwValue;
  1037. if(v_model->m_dwFlags2 & 0x00000010)
  1038. cmApproachVendor << DWORD(0x00200008);
  1039. if(v_model->m_dwFlags2 & 0x00080000)
  1040. cmApproachVendor << v_model->m_dwUseableOn;
  1041. if(v_model->m_dwFlags2 & 0x00000400)
  1042. cmApproachVendor << v_model->m_wUses;
  1043. if(v_model->m_dwFlags2 & 0x00000800)
  1044. cmApproachVendor << v_model->m_wUseLimit;
  1045. if(v_model->m_dwFlags2 & 0x00004000)
  1046. cmApproachVendor << m_dwGUID;
  1047. if(v_model->m_dwFlags2 & 0x00200000)
  1048. cmApproachVendor << v_model->m_wBurden
  1049. << WORD(0x0000);
  1050. break;
  1051. }
  1052. case 0x00008000: //Casting Items
  1053. {
  1054. cmApproachVendor
  1055. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  1056. << WORD(0xFFFF)
  1057. << v_item->GetGUID() //Item GUID
  1058. << v_model->m_dwFlags2 //10254018
  1059. << v_model->m_strName.c_str() //Item Name
  1060. << v_model->m_wModel //Model
  1061. << v_model->m_wIcon //Icon
  1062. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  1063. << v_model->m_dwObjectFlags2 //Object flags 2
  1064. << v_model->m_dwValue //Value
  1065. << v_model->m_dwUnknown_v2 //Unknown_10
  1066. << DWORD(0x10) //No clue what this is, always 10 apparently.
  1067. << m_dwGUID //Container ID
  1068. << v_model->m_dwEquipPossible //Coverage
  1069. << v_model->m_wBurden //Burden (WORD, no padding)
  1070. << v_model->m_wHooks; //Hook Type (WORD, no padding)
  1071. break;
  1072. }
  1073. case 0x00040000: //Trade Notes*
  1074. {
  1075. cmApproachVendor
  1076. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  1077. << WORD(0xFFFF)
  1078. << v_item->GetGUID() //Item GUID
  1079. << v_model->m_dwFlags2 //00207019
  1080. << v_model->m_strName.c_str() //Item Name
  1081. << v_model->m_wModel //Model
  1082. << v_model->m_wIcon //Icon
  1083. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  1084. << v_model->m_dwObjectFlags2 //Object flags 2
  1085. << v_model->m_dwValue //Value
  1086. << v_model->m_dwUnknown_v2 //Unknown_10
  1087. << v_model->m_wStack //NUmber of items in stack
  1088. << v_model->m_wStackLimit //Stack limit
  1089. << m_dwGUID //Container ID
  1090. << v_model->m_wBurden //Burden (WORD, no padding)
  1091. << WORD(0x0000);
  1092. break;
  1093. }
  1094. case 0x00080000: //Manastones*
  1095. {
  1096. cmApproachVendor
  1097. << WORD(0xFFFF) //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  1098. << WORD(0xFFFF)
  1099. << v_item->GetGUID() //Item GUID
  1100. << v_model->m_dwFlags2 //10254018
  1101. << v_model->m_strName.c_str() //Item Name
  1102. << v_model->m_wModel //Model
  1103. << v_model->m_wIcon //Icon
  1104. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  1105. << v_model->m_dwObjectFlags2 //Object flags 2
  1106. << v_model->m_dwValue //Value
  1107. << v_model->m_dwUnknown_v2; //Unknown_10
  1108. if(v_model->m_dwFlags2 & 0x00000080)
  1109. {
  1110. cmApproachVendor << v_model->m_dwIconHighlight;
  1111. }
  1112. cmApproachVendor
  1113. << DWORD(0x891F) //Usableon
  1114. << m_dwGUID //Container ID
  1115. << v_model->m_wBurden //Burden (WORD, no padding)
  1116. << v_model->m_wHooks; //Hook Type (WORD, no padding)
  1117. break;
  1118. }
  1119. case 0x00100000: //Services*
  1120. {
  1121. cmApproachVendor
  1122. << Inventory //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  1123. << v_item->GetGUID() //Item GUID
  1124. << v_model->m_dwFlags2 //00404018
  1125. << v_model->m_strName.c_str() //Item Name
  1126. << v_model->m_wModel //Model
  1127. << v_model->m_wIcon //Icon
  1128. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  1129. << v_model->m_dwObjectFlags2 //Object flags 2
  1130. << v_model->m_dwValue //Value
  1131. << v_model->m_dwUnknown_v2 //Unknown_10
  1132. << m_dwGUID //Container ID
  1133. << v_model->m_dwSpellID; //Spell ID
  1134. break;
  1135. }
  1136. case 0x00400000: //Cooking Ingredients
  1137. {
  1138. cmApproachVendor
  1139. << Inventory //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  1140. << v_item->GetGUID() //Item GUID
  1141. << v_model->m_dwFlags2 //10254018
  1142. << v_model->m_strName.c_str() //Item Name
  1143. << v_model->m_wModel //Model
  1144. << v_model->m_wIcon //Icon
  1145. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  1146. << v_model->m_dwObjectFlags2 //Object flags 2
  1147. << v_model->m_dwValue //Value
  1148. << v_model->m_dwUnknown_v2 //Unknown_10
  1149. << m_dwGUID //Container ID
  1150. << v_model->m_dwEquipPossible //EquipMask :the potential equipment slots this object may be placed in
  1151. << v_model->m_dwCoverage //Coverage
  1152. << v_model->m_wBurden //Burden (WORD, no padding)
  1153. << v_model->m_wHooks; //Hook Type (WORD, no padding)
  1154. break;
  1155. }
  1156. case 0x08000000: //Loose fletching supplies
  1157. {
  1158. cmApproachVendor
  1159. << Inventory //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  1160. << v_item->GetGUID() //Item GUID
  1161. << v_model->m_dwFlags2 //10254018
  1162. << v_model->m_strName.c_str() //Item Name
  1163. << v_model->m_wModel //Model
  1164. << v_model->m_wIcon //Icon
  1165. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  1166. << v_model->m_dwObjectFlags2; //Object flags 2
  1167. if(v_model->m_dwFlags2 & 0x00000008)
  1168. {
  1169. cmApproachVendor
  1170. << v_model->m_dwValue;
  1171. }
  1172. if(v_model->m_dwFlags2 & 0x00000010)
  1173. {
  1174. cmApproachVendor
  1175. << 0x00080008;
  1176. }
  1177. if(v_model->m_dwFlags2 & 0x00080000)
  1178. {
  1179. cmApproachVendor
  1180. << 0x08000000;
  1181. }
  1182. if(v_model->m_dwFlags2 & 0x00001000)
  1183. {
  1184. cmApproachVendor
  1185. << v_model->m_wStack;
  1186. }
  1187. if(v_model->m_dwFlags2 & 0x00002000)
  1188. {
  1189. cmApproachVendor
  1190. << v_model->m_wStackLimit;
  1191. }
  1192. if(v_model->m_dwFlags2 & 0x00004000)
  1193. {
  1194. cmApproachVendor
  1195. << m_dwGUID;
  1196. }
  1197. if(v_model->m_dwFlags2 & 0x00200000)
  1198. {
  1199. cmApproachVendor
  1200. << v_model->m_wBurden;
  1201. }
  1202. break;
  1203. }
  1204. case 0x04000000: //Alchemy items
  1205. {
  1206. cmApproachVendor
  1207. << Inventory //How many of the item the merchant has (-1 or FFFFFFFF should be unlimited)
  1208. << v_item->GetGUID() //Item GUID
  1209. << v_model->m_dwFlags2 //10254018
  1210. << v_model->m_strName.c_str() //Item Name
  1211. << v_model->m_wModel //Model
  1212. << v_model->m_wIcon //Icon
  1213. << v_model->m_dwObjectFlags1 //Object Flags 1 (determines sell cats for vendor)
  1214. << v_model->m_dwObjectFlags2 //Object flags 2
  1215. << v_model->m_dwValue //Value
  1216. << v_model->m_dwUnknown_v2 //Unknown_10
  1217. << m_dwGUID //Container ID
  1218. << v_model->m_dwEquipPossible //EquipMask :the potential equipment slots this object may be placed in
  1219. << v_model->m_dwCoverage //Coverage
  1220. << v_model->m_wBurden //Burden (WORD, no padding)
  1221. << v_model->m_wHooks; //Hook Type (WORD, no padding)
  1222. break;
  1223. }
  1224. }
  1225. }
  1226. who->AddPacket(WORLD_SERVER,cmApproachVendor,4);
  1227. cMessage cmActionComplete;
  1228. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_dwF7B0Sequence << 0x01C7L << 0L;
  1229. who->AddPacket(WORLD_SERVER,cmActionComplete,4);
  1230. }
  1231. }
  1232. }
  1233. /**
  1234. * Handles the giving of items to NPCs.
  1235. *
  1236. * This function is called whenever a player gives an NPC an item.
  1237. * If the NPC is a Town Crier, the NPC should access the item.
  1238. * Other NPCs should only accept particular items or types of items.
  1239. *
  1240. * @param *who - A pointer to the client whose avatar is giving the item.
  1241. * @param itemid - The GUID of the item being given.
  1242. */
  1243. void cNPC::GiveItem(cClient *who, DWORD npcid, DWORD itemid)
  1244. {
  1245. //Find the appropriate response to receiving the item in the database.
  1246. char szCommand[100];
  1247. RETCODE retcode;
  1248. SQLCHAR FinishText[512];
  1249. DWORD quest_id;
  1250. DWORD reward_xp;
  1251. sprintf( szCommand, "SELECT * FROM quests WHERE item_id = %d;",this->m_qitem_id1 );
  1252. cMasterServer::ServerMessage(ColorBrown,who,"npc id is: %d, quest item id is: %d",npcid,this->m_qitem_id1);
  1253. retcode = SQLPrepare( cDatabase::m_hStmt, (unsigned char *)szCommand, SQL_NTS ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1254. retcode = SQLExecute( cDatabase::m_hStmt );
  1255. int iCol = 2;
  1256. retcode = SQLBindCol( cDatabase::m_hStmt, iCol, SQL_C_ULONG, &quest_id, sizeof( quest_id ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  1257. iCol += 2;
  1258. retcode = SQLBindCol( cDatabase::m_hStmt, iCol, SQL_C_ULONG, &reward_xp, sizeof( reward_xp ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, 1)
  1259. iCol += 2;
  1260. retcode = SQLBindCol( cDatabase::m_hStmt, iCol, SQL_C_CHAR, FinishText, sizeof( FinishText ), NULL ); CHECKRETURN(1, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1261. //If we get here, things are good....
  1262. //Find the item in the avatars inventory
  1263. cObject *pcObj2 = who->m_pcAvatar->FindInventory(itemid);
  1264. //Send the appropriate give message to server
  1265. cMessage cmGiveItem;
  1266. cmGiveItem << 0xF7B0L << who->m_pcAvatar->GetGUID() << ++who->m_pcAvatar->m_dwF7B0Sequence << 0x0022L
  1267. << itemid << npcid << 0L << 0L;
  1268. who->AddPacket(WORLD_SERVER,cmGiveItem,4);
  1269. if( SQLFetch( cDatabase::m_hStmt ) == SQL_SUCCESS )
  1270. {
  1271. //Convert the data
  1272. std::string ft;
  1273. char *szFT = reinterpret_cast<char *>(FinishText);
  1274. ft.assign(szFT);
  1275. retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1276. //Send the appropriate quest finish message
  1277. cMasterServer::ServerMessage(ColorBrown,who,"%s tells you, \"%s\"",m_strName.c_str(),ft.c_str());
  1278. //Give any experience rewards
  1279. cMasterServer::ServerMessage(ColorGreen,who,"You've recieved %d experience.",reward_xp);
  1280. who->AddPacket( WORLD_SERVER, who->m_pcAvatar->UpdateUnassignedExp(reward_xp), 4 );
  1281. who->m_pcAvatar->UpdateUnassignedXPDB(who,reward_xp);
  1282. who->AddPacket( WORLD_SERVER, who->m_pcAvatar->UpdateTotalExp(reward_xp), 4);
  1283. who->m_pcAvatar->UpdateTotalXPDB(who,reward_xp);
  1284. who->AddPacket( WORLD_SERVER, who->m_pcAvatar->UpdateLevel(), 4);
  1285. who->m_pcAvatar->UpdateLevelDB(who);
  1286. //retcode = SQLCloseCursor( cDatabase::m_hStmt ); CHECKRETURN(0, SQL_HANDLE_STMT, cDatabase::m_hStmt, NULL)
  1287. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  1288. who->m_pcAvatar->UpdateQuestCompletedTable(who->m_pcAvatar->GetGUID(),quest_id);
  1289. }
  1290. else
  1291. {
  1292. //clean up
  1293. retcode = SQLFreeStmt( cDatabase::m_hStmt, SQL_UNBIND );
  1294. }
  1295. //Remove the item
  1296. who->m_pcAvatar->DeleteFromInventory(pcObj2);
  1297. cMessage cmRemoveItem;
  1298. cmRemoveItem << 0x0024L << pcObj2->GetGUID();
  1299. who->AddPacket(WORLD_SERVER,cmRemoveItem,4);
  1300. cWorldManager::RemoveObject(pcObj2,true,true);
  1301. //Done
  1302. cMessage cmActionComplete;
  1303. cmActionComplete << 0xF7B0L << who->m_pcAvatar->GetGUID( ) << ++who->m_pcAvatar->m_dwF7B0Sequence << 0x01C7L << 0L;
  1304. who->AddPacket( WORLD_SERVER,cmActionComplete,4);
  1305. }