ArmsDealerInvInit.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419
  1. #ifdef PRECOMPILEDHEADERS
  2. #include "Tactical All.h"
  3. #else
  4. #include "Types.h"
  5. #include "ArmsDealerInvInit.h"
  6. #include "Item Types.h"
  7. #include "Arms Dealer Init.h"
  8. #include "DEbug.h"
  9. #endif
  10. extern INT8 gbSelectedArmsDealerID;
  11. // This table controls the order items appear in inventory at BR's and dealers, and which kinds of items are sold used
  12. ITEM_SORT_ENTRY DealerItemSortInfo[ ] =
  13. {
  14. // item class weapon class sold used?
  15. { IC_GUN, HANDGUNCLASS, TRUE },
  16. { IC_GUN, SHOTGUNCLASS, TRUE },
  17. { IC_GUN, SMGCLASS, TRUE },
  18. { IC_GUN, RIFLECLASS, TRUE },
  19. { IC_GUN, MGCLASS, FALSE },
  20. { IC_LAUNCHER, NOGUNCLASS, FALSE },
  21. { IC_AMMO, NOGUNCLASS, FALSE },
  22. { IC_GRENADE, NOGUNCLASS, FALSE },
  23. { IC_BOMB, NOGUNCLASS, FALSE },
  24. { IC_BLADE, NOGUNCLASS, FALSE },
  25. { IC_THROWING_KNIFE, NOGUNCLASS, FALSE },
  26. { IC_PUNCH, NOGUNCLASS, FALSE },
  27. { IC_ARMOUR, NOGUNCLASS, TRUE },
  28. { IC_FACE, NOGUNCLASS, TRUE },
  29. { IC_MEDKIT, NOGUNCLASS, FALSE },
  30. { IC_KIT, NOGUNCLASS, FALSE },
  31. { IC_MISC, NOGUNCLASS, TRUE },
  32. { IC_THROWN, NOGUNCLASS, FALSE },
  33. { IC_KEY, NOGUNCLASS, FALSE },
  34. // marks end of list
  35. { IC_NONE, NOGUNCLASS, },
  36. };
  37. //
  38. // Setup the inventory arrays for each of the arms dealers
  39. //
  40. // The arrays are composed of pairs of numbers
  41. // The first is the item index
  42. // The second is the amount of the items the dealer will try to keep in his inventory
  43. //
  44. // Tony ( Weapons only )
  45. //
  46. DEALER_POSSIBLE_INV gTonyInventory[] =
  47. {
  48. //Rare guns/ammo that Tony will buy although he won't ever sell them
  49. { ROCKET_RIFLE, 0 },
  50. { AUTO_ROCKET_RIFLE, 0 },
  51. { AUTOMAG_III, 0 },
  52. // { FLAMETHROWER, 0 },
  53. //Weapons
  54. { GLOCK_17, 1 }, /* Glock 17 */
  55. { GLOCK_18, 1 }, /* Glock 18 */
  56. { BERETTA_92F, 1 }, /* Beretta 92F */
  57. { BERETTA_93R, 1 }, /* Beretta 93R */
  58. { SW38, 1 }, /* .38 S&W Special */
  59. { BARRACUDA, 1 }, /* .357 Barracuda */
  60. { DESERTEAGLE, 1 }, /* .357 DesertEagle*/
  61. { M1911, 1 }, /* .45 M1911 */
  62. { MP5K, 1 }, /* H&K MP5K */
  63. { MAC10, 1 }, /* .45 MAC-10 */
  64. { THOMPSON, 1 }, /* Thompson M1A1 */
  65. { COMMANDO, 1 }, /* Colt Commando */
  66. { MP53, 1 }, /* H&K MP53 */
  67. { AKSU74, 1 }, /* AKSU-74 */
  68. { TYPE85, 1 }, /* Type-85 */
  69. { SKS, 1 }, /* SKS */
  70. { DRAGUNOV, 1 }, /* Dragunov */
  71. { M24, 1 }, /* M24 */
  72. { AUG, 1 }, /* Steyr AUG */
  73. { G41, 1 }, /* H&K G41 */
  74. { MINI14, 1 }, /* Ruger Mini-14 */
  75. { C7, 1 }, /* C-7 */
  76. { FAMAS, 1 }, /* FA-MAS */
  77. { AK74, 1 }, /* AK-74 */
  78. { AKM, 1 }, /* AKM */
  79. { M14, 1 }, /* M-14 */
  80. { G3A3, 1 }, /* H&K G3A3 */
  81. { FNFAL, 1 }, /* FN-FAL */
  82. { MINIMI, 1 },
  83. { RPK74, 1 },
  84. { HK21E, 1 },
  85. { M870, 1 }, /* Remington M870 */
  86. { SPAS15, 1 }, /* SPAS-15 */
  87. { GLAUNCHER, 1 }, /* grenade launcher*/
  88. { UNDER_GLAUNCHER, 1 }, /* underslung g.l. */
  89. { ROCKET_LAUNCHER, 1 }, /* rocket Launcher */
  90. { MORTAR, 1 },
  91. // SAP guns
  92. { G11, 1 },
  93. { CAWS, 1 },
  94. { P90, 1 },
  95. { DART_GUN, 1 },
  96. //Ammo
  97. { CLIP9_15, 8 },
  98. { CLIP9_30, 6 },
  99. { CLIP9_15_AP, 3 }, /* CLIP9_15_AP */
  100. { CLIP9_30_AP, 3 }, /* CLIP9_30_AP */
  101. { CLIP9_15_HP, 3 }, /* CLIP9_15_HP */
  102. { CLIP9_30_HP, 3 }, /* CLIP9_30_HP */
  103. { CLIP38_6, 10}, /* CLIP38_6 */
  104. { CLIP38_6_AP, 5 }, /* CLIP38_6_AP */
  105. { CLIP38_6_HP, 5 }, /* CLIP38_6_HP */
  106. { CLIP45_7, 6 }, /* CLIP45_7 */ // 70
  107. { CLIP45_30, 8 }, /* CLIP45_30 */
  108. { CLIP45_7_AP, 3 }, /* CLIP45_7_AP */
  109. { CLIP45_30_AP, 3 }, /* CLIP45_30_AP */
  110. { CLIP45_7_HP, 3 }, /* CLIP45_7_HP */
  111. { CLIP45_30_HP, 3 }, /* CLIP45_30_HP */
  112. { CLIP357_6, 6 }, /* CLIP357_6 */
  113. { CLIP357_9, 5 }, /* CLIP357_9 */
  114. { CLIP357_6_AP, 3 }, /* CLIP357_6_AP */
  115. { CLIP357_9_AP, 3 }, /* CLIP357_9_AP */
  116. { CLIP357_6_HP, 3 }, /* CLIP357_6_HP */ //80
  117. { CLIP357_9_HP, 3 }, /* CLIP357_9_HP */
  118. { CLIP545_30_AP, 6 }, /* CLIP545_30_AP */
  119. { CLIP545_30_HP, 3 }, /* CLIP545_30_HP */
  120. { CLIP556_30_AP, 6 }, /* CLIP556_30_AP */
  121. { CLIP556_30_HP, 3 }, /* CLIP556_30_HP */
  122. { CLIP762W_10_AP, 6 }, /* CLIP762W_10_AP */
  123. { CLIP762W_30_AP, 5 }, /* CLIP762W_30_AP */
  124. { CLIP762W_10_HP, 3 }, /* CLIP762W_10_HP */
  125. { CLIP762W_30_HP, 3 }, /* CLIP762W_30_HP */
  126. { CLIP762N_5_AP, 8 }, /* CLIP762N_5_AP */ //90
  127. { CLIP762N_20_AP, 5 }, /* CLIP762N_20_AP */
  128. { CLIP762N_5_HP, 3 }, /* CLIP762N_5_HP */
  129. { CLIP762N_20_HP, 3 }, /* CLIP762N_20_HP */
  130. { CLIP47_50_SAP, 5 }, /* CLIP47_50_SAP */
  131. { CLIP57_50_AP, 6 }, /* CLIP57_50_AP */
  132. { CLIP57_50_HP, 3 }, /* CLIP57_50_HP */
  133. { CLIP12G_7, 9 }, /* CLIP12G_7 */
  134. { CLIP12G_7_BUCKSHOT, 9 }, /* CLIP12G_7_BUCKSHOT */
  135. { CLIPCAWS_10_SAP, 5 }, /* CLIPCAWS_10_SAP */
  136. { CLIPCAWS_10_FLECH, 3 }, /* CLIPCAWS_10_FLECH */ //100
  137. { CLIPROCKET_AP, 3 },
  138. { CLIPROCKET_HE, 1 },
  139. { CLIPROCKET_HEAT, 1 },
  140. { CLIPDART_SLEEP, 5 },
  141. // { CLIPFLAME, 5 },
  142. // "launchables" (New! From McCain!) - these are basically ammo
  143. { GL_HE_GRENADE, 2 },
  144. { GL_TEARGAS_GRENADE, 2 },
  145. { GL_STUN_GRENADE, 2 },
  146. { GL_SMOKE_GRENADE, 2 },
  147. { MORTAR_SHELL, 1 },
  148. // knives
  149. { COMBAT_KNIFE, 3 },
  150. { THROWING_KNIFE, 6 },
  151. { BRASS_KNUCKLES, 1 },
  152. { MACHETE, 1 },
  153. // attachments
  154. { SILENCER, 3 },
  155. { SNIPERSCOPE, 3 },
  156. { LASERSCOPE, 1 },
  157. { BIPOD, 3 },
  158. { DUCKBILL, 2 },
  159. /*
  160. // grenades
  161. { STUN_GRENADE, 5 },
  162. { TEARGAS_GRENADE, 5 },
  163. { MUSTARD_GRENADE, 5 },
  164. { MINI_GRENADE, 5 },
  165. { HAND_GRENADE, 5 },
  166. { SMOKE_GRENADE, 5 },
  167. */
  168. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  169. };
  170. //
  171. // Devin ( Explosives )
  172. //
  173. DEALER_POSSIBLE_INV gDevinInventory[] =
  174. {
  175. { STUN_GRENADE, 3 },
  176. { TEARGAS_GRENADE, 3 },
  177. { MUSTARD_GRENADE, 2 },
  178. { MINI_GRENADE, 3 },
  179. { HAND_GRENADE, 2 },
  180. { SMOKE_GRENADE, 3 },
  181. { GL_HE_GRENADE, 2 },
  182. { GL_TEARGAS_GRENADE, 2 },
  183. { GL_STUN_GRENADE, 2 },
  184. { GL_SMOKE_GRENADE, 2 },
  185. { MORTAR_SHELL, 1 },
  186. { CLIPROCKET_AP, 1 },
  187. { CLIPROCKET_HE, 1 },
  188. { CLIPROCKET_HEAT, 1 },
  189. { DETONATOR, 10},
  190. { REMDETONATOR, 5 },
  191. { REMOTEBOMBTRIGGER, 5 },
  192. { MINE, 6 },
  193. { RDX, 5 },
  194. { TNT, 5 },
  195. { C1, 4 },
  196. { HMX, 3 },
  197. { C4, 2 },
  198. { SHAPED_CHARGE, 5 },
  199. // { TRIP_FLARE, 2 },
  200. // { TRIP_KLAXON, 2 },
  201. { GLAUNCHER, 1 }, /* grenade launcher*/
  202. { UNDER_GLAUNCHER, 1 }, /* underslung g.l. */
  203. { ROCKET_LAUNCHER, 1 }, /* rocket Launcher */
  204. { MORTAR, 1 },
  205. { METALDETECTOR, 2 },
  206. { WIRECUTTERS, 1 },
  207. { DUCT_TAPE, 1 },
  208. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  209. };
  210. //
  211. // Franz (Expensive pawn shop )
  212. //
  213. DEALER_POSSIBLE_INV gFranzInventory[] =
  214. {
  215. { NIGHTGOGGLES, 3 },
  216. { LASERSCOPE, 3 },
  217. { METALDETECTOR, 2 },
  218. { EXTENDEDEAR, 2 },
  219. { DART_GUN, 1 },
  220. { KEVLAR_VEST, 1 },
  221. { KEVLAR_LEGGINGS, 1 },
  222. { KEVLAR_HELMET, 1 },
  223. { KEVLAR2_VEST, 1 },
  224. { SPECTRA_VEST, 1 },
  225. { SPECTRA_LEGGINGS, 1 },
  226. { SPECTRA_HELMET, 1 },
  227. { CERAMIC_PLATES, 1 },
  228. { CAMOUFLAGEKIT, 1 },
  229. { VIDEO_CAMERA, 1 }, // for robot quest
  230. { LAME_BOY, 1 },
  231. { FUMBLE_PAK, 1 },
  232. { GOLDWATCH, 1 },
  233. { GOLFCLUBS, 1 },
  234. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  235. };
  236. //
  237. // Keith ( Cheap Pawn Shop )
  238. //
  239. DEALER_POSSIBLE_INV gKeithInventory[] =
  240. {
  241. { FIRSTAIDKIT, 5 },
  242. // WARNING: Keith must not carry any guns, it would conflict with his story/quest
  243. { COMBAT_KNIFE, 2 },
  244. { THROWING_KNIFE, 3 },
  245. { BRASS_KNUCKLES, 1 },
  246. { MACHETE, 1 },
  247. { SUNGOGGLES, 3 },
  248. { FLAK_JACKET, 2 },
  249. { STEEL_HELMET, 3 },
  250. { LEATHER_JACKET, 1 },
  251. { CANTEEN, 5 },
  252. { CROWBAR, 1 },
  253. { JAR, 6 },
  254. { TOOLKIT, 1 },
  255. { GASMASK, 1 },
  256. { SILVER_PLATTER, 1 },
  257. { WALKMAN, 1 },
  258. { PORTABLETV, 1 },
  259. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  260. };
  261. //
  262. // Sam ( Hardware )
  263. //
  264. DEALER_POSSIBLE_INV gSamInventory[] =
  265. {
  266. { FIRSTAIDKIT, 3 },
  267. { LOCKSMITHKIT, 4 },
  268. { TOOLKIT, 3 },
  269. { CANTEEN, 5 },
  270. { CROWBAR, 3 },
  271. { WIRECUTTERS, 3 },
  272. { DUCKBILL, 3 },
  273. { JAR, 12},
  274. { BREAK_LIGHT, 12}, // flares
  275. { METALDETECTOR, 1 },
  276. { VIDEO_CAMERA, 1 },
  277. { QUICK_GLUE, 3 },
  278. { COPPER_WIRE, 5 },
  279. { BATTERIES, 10 },
  280. { CLIP9_15, 5 },
  281. { CLIP9_30, 5 },
  282. { CLIP38_6, 5 },
  283. { CLIP45_7, 5 },
  284. { CLIP45_30, 5 },
  285. { CLIP357_6, 5 },
  286. { CLIP357_9, 5 },
  287. { CLIP12G_7, 9 },
  288. { CLIP12G_7_BUCKSHOT, 9 },
  289. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  290. };
  291. //
  292. // Jake ( Junk )
  293. //
  294. DEALER_POSSIBLE_INV gJakeInventory[] =
  295. {
  296. { FIRSTAIDKIT, 4 },
  297. { MEDICKIT, 3 },
  298. { SW38, 1 },
  299. { CLIP38_6, 5 },
  300. { JAR, 3 },
  301. { CANTEEN, 2 },
  302. { BEER, 6 },
  303. { CROWBAR, 1 },
  304. { WIRECUTTERS, 1 },
  305. { COMBAT_KNIFE, 1 },
  306. { THROWING_KNIFE, 1 },
  307. { BRASS_KNUCKLES, 1 },
  308. { MACHETE, 1 },
  309. { BREAK_LIGHT, 5 }, // flares
  310. { BIPOD, 1 },
  311. { TSHIRT, 6 },
  312. { CIGARS, 3 },
  313. { PORNOS, 1 },
  314. { LOCKSMITHKIT, 1 },
  315. #ifndef JA2DEMO
  316. // "new" items, presumed unsafe for demo
  317. { TSHIRT_DEIDRANNA, 2 },
  318. { XRAY_BULB, 1 },
  319. // additional stuff possible in real game
  320. { GLOCK_17, 1 }, /* Glock 17 */
  321. { GLOCK_18, 1 }, /* Glock 18 */
  322. { BERETTA_92F, 1 }, /* Beretta 92F */
  323. { BERETTA_93R, 1 }, /* Beretta 93R */
  324. { BARRACUDA, 1 }, /* .357 Barracuda */
  325. { DESERTEAGLE, 1 }, /* .357 DesertEagle*/
  326. { M1911, 1 }, /* .45 M1911 */
  327. { DISCARDED_LAW, 1 },
  328. { STEEL_HELMET, 1 },
  329. { TOOLKIT, 1 },
  330. { WINE, 1 },
  331. { ALCOHOL, 1 },
  332. { GOLDWATCH, 1 },
  333. { GOLFCLUBS, 1 },
  334. { WALKMAN, 1 },
  335. { PORTABLETV, 1 },
  336. // stuff a real pawn shop wouldn't have, but it does make him a bit more useful
  337. { COMPOUND18, 1 },
  338. { CERAMIC_PLATES, 1 },
  339. #endif
  340. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  341. };
  342. //
  343. // Howard ( Pharmaceuticals )
  344. //
  345. DEALER_POSSIBLE_INV gHowardInventory[] =
  346. {
  347. { FIRSTAIDKIT, 10},
  348. { MEDICKIT, 5 },
  349. { ADRENALINE_BOOSTER, 5 },
  350. { REGEN_BOOSTER, 5 },
  351. { ALCOHOL, 3 },
  352. { COMBAT_KNIFE, 2 },
  353. { CLIPDART_SLEEP, 5 },
  354. { CHEWING_GUM, 3 },
  355. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  356. };
  357. //
  358. // Gabby ( Creature parts and Blood )
  359. //
  360. DEALER_POSSIBLE_INV gGabbyInventory[] =
  361. {
  362. { JAR, 12 },
  363. { JAR_ELIXIR, 3 },
  364. // buys these, but can't supply them (player is the only source)
  365. { JAR_CREATURE_BLOOD, 0 },
  366. { JAR_QUEEN_CREATURE_BLOOD, 0 },
  367. { BLOODCAT_CLAWS, 0 },
  368. { BLOODCAT_TEETH, 0 },
  369. { BLOODCAT_PELT, 0 },
  370. { CREATURE_PART_CLAWS, 0 },
  371. { CREATURE_PART_FLESH, 0 },
  372. { CREATURE_PART_ORGAN, 0 },
  373. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  374. };
  375. //
  376. // Frank ( Alcohol )
  377. //
  378. DEALER_POSSIBLE_INV gFrankInventory[] =
  379. {
  380. { BEER, 12 },
  381. { WINE, 6 },
  382. { ALCOHOL, 9 },
  383. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  384. };
  385. //
  386. // Elgin ( Alcohol )
  387. //
  388. DEALER_POSSIBLE_INV gElginInventory[] =
  389. {
  390. { BEER, 12 },
  391. { WINE, 6 },
  392. { ALCOHOL, 9 },
  393. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  394. };
  395. //
  396. // Manny ( Alcohol )
  397. //
  398. DEALER_POSSIBLE_INV gMannyInventory[] =
  399. {
  400. { BEER, 12 },
  401. { WINE, 6 },
  402. { ALCOHOL, 9 },
  403. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  404. };
  405. //
  406. // Herve Santos ( Alcohol )
  407. //
  408. DEALER_POSSIBLE_INV gHerveInventory[] =
  409. {
  410. { BEER, 12 },
  411. { WINE, 6 },
  412. { ALCOHOL, 9 },
  413. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  414. };
  415. //
  416. // Peter Santos ( Alcohol )
  417. //
  418. DEALER_POSSIBLE_INV gPeterInventory[] =
  419. {
  420. { BEER, 12 },
  421. { WINE, 6 },
  422. { ALCOHOL, 9 },
  423. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  424. };
  425. //
  426. // Alberto Santos ( Alcohol )
  427. //
  428. DEALER_POSSIBLE_INV gAlbertoInventory[] =
  429. {
  430. { BEER, 12 },
  431. { WINE, 6 },
  432. { ALCOHOL, 9 },
  433. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  434. };
  435. //
  436. // Carlo Santos ( Alcohol )
  437. //
  438. DEALER_POSSIBLE_INV gCarloInventory[] =
  439. {
  440. { BEER, 12 },
  441. { WINE, 6 },
  442. { ALCOHOL, 9 },
  443. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  444. };
  445. //
  446. // Micky ( BUYS Animal / Creature parts )
  447. //
  448. DEALER_POSSIBLE_INV gMickyInventory[] =
  449. {
  450. // ONLY BUYS THIS STUFF, DOESN'T SELL IT
  451. { BLOODCAT_CLAWS, 0 },
  452. { BLOODCAT_TEETH, 0 },
  453. { BLOODCAT_PELT, 0 },
  454. { CREATURE_PART_CLAWS, 0 },
  455. { CREATURE_PART_FLESH, 0 },
  456. { CREATURE_PART_ORGAN, 0 },
  457. { JAR_QUEEN_CREATURE_BLOOD, 0 },
  458. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  459. };
  460. //
  461. // Arnie ( Weapons REPAIR )
  462. //
  463. DEALER_POSSIBLE_INV gArnieInventory[] =
  464. {
  465. // NO INVENTORY
  466. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  467. };
  468. //
  469. // Perko ( REPAIR)
  470. //
  471. DEALER_POSSIBLE_INV gPerkoInventory[] =
  472. {
  473. // NO INVENTORY
  474. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  475. };
  476. //
  477. // Fredo ( Electronics REPAIR)
  478. //
  479. DEALER_POSSIBLE_INV gFredoInventory[] =
  480. {
  481. // NO INVENTORY
  482. { LAST_DEALER_ITEM, NO_DEALER_ITEM }, //Last One
  483. };
  484. // prototypes
  485. INT8 GetMaxItemAmount( DEALER_POSSIBLE_INV *pInv, UINT16 usItemIndex );
  486. INT8 GetDealersMaxItemAmount( UINT8 ubDealerID, UINT16 usItemIndex )
  487. {
  488. switch( ubDealerID )
  489. {
  490. case ARMS_DEALER_TONY:
  491. return( GetMaxItemAmount( gTonyInventory, usItemIndex ) );
  492. break;
  493. case ARMS_DEALER_FRANK:
  494. return( GetMaxItemAmount( gFrankInventory, usItemIndex ) );
  495. break;
  496. case ARMS_DEALER_MICKY:
  497. return( GetMaxItemAmount( gMickyInventory, usItemIndex ) );
  498. break;
  499. case ARMS_DEALER_ARNIE:
  500. return( GetMaxItemAmount( gArnieInventory, usItemIndex ) );
  501. break;
  502. case ARMS_DEALER_PERKO:
  503. return( GetMaxItemAmount( gPerkoInventory, usItemIndex ) );
  504. break;
  505. case ARMS_DEALER_KEITH:
  506. return( GetMaxItemAmount( gKeithInventory, usItemIndex ) );
  507. break;
  508. case ARMS_DEALER_BAR_BRO_1:
  509. return( GetMaxItemAmount( gHerveInventory, usItemIndex ) );
  510. break;
  511. case ARMS_DEALER_BAR_BRO_2:
  512. return( GetMaxItemAmount( gPeterInventory, usItemIndex ) );
  513. break;
  514. case ARMS_DEALER_BAR_BRO_3:
  515. return( GetMaxItemAmount( gAlbertoInventory, usItemIndex ) );
  516. break;
  517. case ARMS_DEALER_BAR_BRO_4:
  518. return( GetMaxItemAmount( gCarloInventory, usItemIndex ) );
  519. break;
  520. case ARMS_DEALER_JAKE:
  521. return( GetMaxItemAmount( gJakeInventory, usItemIndex ) );
  522. break;
  523. case ARMS_DEALER_FRANZ:
  524. return( GetMaxItemAmount( gFranzInventory, usItemIndex ) );
  525. break;
  526. case ARMS_DEALER_HOWARD:
  527. return( GetMaxItemAmount( gHowardInventory, usItemIndex ) );
  528. break;
  529. case ARMS_DEALER_SAM:
  530. return( GetMaxItemAmount( gSamInventory, usItemIndex ) );
  531. break;
  532. case ARMS_DEALER_FREDO:
  533. return( GetMaxItemAmount( gFredoInventory, usItemIndex ) );
  534. break;
  535. case ARMS_DEALER_GABBY:
  536. return( GetMaxItemAmount( gGabbyInventory, usItemIndex ) );
  537. break;
  538. case ARMS_DEALER_DEVIN:
  539. return( GetMaxItemAmount( gDevinInventory, usItemIndex ) );
  540. break;
  541. case ARMS_DEALER_ELGIN:
  542. return( GetMaxItemAmount( gElginInventory, usItemIndex ) );
  543. break;
  544. case ARMS_DEALER_MANNY:
  545. return( GetMaxItemAmount( gMannyInventory, usItemIndex ) );
  546. break;
  547. default:
  548. Assert( FALSE );
  549. return( 0 );
  550. break;
  551. }
  552. }
  553. INT8 GetMaxItemAmount( DEALER_POSSIBLE_INV *pInv, UINT16 usItemIndex )
  554. {
  555. UINT16 usCnt=0;
  556. //loop through the array until a the LAST_DEALER_ITEM is hit
  557. while( pInv[ usCnt ].sItemIndex != LAST_DEALER_ITEM )
  558. {
  559. //if this item is the one we want
  560. if( pInv[ usCnt ].sItemIndex == usItemIndex )
  561. return( pInv[ usCnt ].ubOptimalNumber );
  562. // move to the next item
  563. usCnt++;
  564. }
  565. return( NO_DEALER_ITEM );
  566. }
  567. DEALER_POSSIBLE_INV *GetPointerToDealersPossibleInventory( UINT8 ubArmsDealerID )
  568. {
  569. switch( ubArmsDealerID )
  570. {
  571. case ARMS_DEALER_TONY:
  572. return( gTonyInventory );
  573. break;
  574. case ARMS_DEALER_FRANK:
  575. return( gFrankInventory );
  576. break;
  577. case ARMS_DEALER_MICKY:
  578. return( gMickyInventory );
  579. break;
  580. case ARMS_DEALER_ARNIE:
  581. return( gArnieInventory );
  582. break;
  583. case ARMS_DEALER_PERKO:
  584. return( gPerkoInventory );
  585. break;
  586. case ARMS_DEALER_KEITH:
  587. return( gKeithInventory );
  588. break;
  589. case ARMS_DEALER_BAR_BRO_1:
  590. return( gHerveInventory );
  591. break;
  592. case ARMS_DEALER_BAR_BRO_2:
  593. return( gPeterInventory );
  594. break;
  595. case ARMS_DEALER_BAR_BRO_3:
  596. return( gAlbertoInventory );
  597. break;
  598. case ARMS_DEALER_BAR_BRO_4:
  599. return( gCarloInventory );
  600. break;
  601. case ARMS_DEALER_JAKE:
  602. return( gJakeInventory );
  603. break;
  604. case ARMS_DEALER_FRANZ:
  605. return( gFranzInventory );
  606. break;
  607. case ARMS_DEALER_HOWARD:
  608. return( gHowardInventory );
  609. break;
  610. case ARMS_DEALER_SAM:
  611. return( gSamInventory );
  612. break;
  613. case ARMS_DEALER_FREDO:
  614. return( gFredoInventory );
  615. break;
  616. case ARMS_DEALER_GABBY:
  617. return( gGabbyInventory );
  618. break;
  619. case ARMS_DEALER_DEVIN:
  620. return( gDevinInventory );
  621. break;
  622. case ARMS_DEALER_ELGIN:
  623. return( gElginInventory );
  624. break;
  625. case ARMS_DEALER_MANNY:
  626. return( gMannyInventory );
  627. break;
  628. default:
  629. return( NULL );
  630. }
  631. }
  632. UINT8 GetCurrentSuitabilityForItem( INT8 bArmsDealer, UINT16 usItemIndex )
  633. {
  634. UINT8 ubItemCoolness;
  635. UINT8 ubMinCoolness, ubMaxCoolness;
  636. // item suitability varies with the player's maximum progress through the game. The farther he gets, the better items
  637. // we make available. Weak items become more and more infrequent later in the game, although they never quite vanish.
  638. // items illegal in this game are unsuitable [this checks guns vs. current GunSet!]
  639. if (!ItemIsLegal( usItemIndex ))
  640. {
  641. return(ITEM_SUITABILITY_NONE);
  642. }
  643. // items normally not sold at shops are unsuitable
  644. if ( Item[ usItemIndex ].fFlags & ITEM_NOT_BUYABLE )
  645. {
  646. return(ITEM_SUITABILITY_NONE);
  647. }
  648. ubItemCoolness = Item[ usItemIndex ].ubCoolness;
  649. if (ubItemCoolness == 0)
  650. {
  651. // items without a coolness rating can't be sold to the player by shopkeepers
  652. return(ITEM_SUITABILITY_NONE);
  653. }
  654. // the following staple items are always deemed highly suitable regardless of player's progress:
  655. switch (usItemIndex)
  656. {
  657. case CLIP38_6:
  658. case CLIP9_15:
  659. case CLIP9_30:
  660. case CLIP357_6:
  661. case CLIP357_9:
  662. case CLIP45_7:
  663. case CLIP45_30:
  664. case CLIP12G_7:
  665. case CLIP12G_7_BUCKSHOT:
  666. case CLIP545_30_HP:
  667. case CLIP556_30_HP:
  668. case CLIP762W_10_HP:
  669. case CLIP762W_30_HP:
  670. case CLIP762N_5_HP:
  671. case CLIP762N_20_HP:
  672. case FIRSTAIDKIT:
  673. case MEDICKIT:
  674. case TOOLKIT:
  675. case LOCKSMITHKIT:
  676. case CANTEEN:
  677. case CROWBAR:
  678. case JAR:
  679. case JAR_ELIXIR:
  680. case JAR_CREATURE_BLOOD:
  681. return(ITEM_SUITABILITY_ALWAYS);
  682. }
  683. // If it's not BobbyRay, Tony, or Devin
  684. if ((bArmsDealer != -1) && (bArmsDealer != ARMS_DEALER_TONY) && (bArmsDealer != ARMS_DEALER_DEVIN))
  685. {
  686. // all the other dealers have very limited inventories, so their suitability remains constant at all times in game
  687. return(ITEM_SUITABILITY_HIGH);
  688. }
  689. // figure out the appropriate range of coolness based on player's maximum progress so far
  690. ubMinCoolness = HighestPlayerProgressPercentage() / 10;
  691. ubMaxCoolness = ( HighestPlayerProgressPercentage() / 10 ) + 1;
  692. // Tony has the better stuff sooner (than Bobby R's)
  693. if (bArmsDealer == ARMS_DEALER_TONY)
  694. {
  695. ubMinCoolness += 1;
  696. ubMaxCoolness += 1;
  697. }
  698. else if (bArmsDealer == ARMS_DEALER_DEVIN)
  699. {
  700. // almost everything Devin sells is pretty cool (4+), so gotta apply a minimum or he'd have nothing early on
  701. if ( ubMinCoolness < 3 )
  702. {
  703. ubMinCoolness = 3;
  704. ubMaxCoolness = 4;
  705. }
  706. }
  707. ubMinCoolness = max( 1, min( 9, ubMinCoolness ) );
  708. ubMaxCoolness = max( 2, min( 10, ubMaxCoolness ) );
  709. // if item is too cool for current level of progress
  710. if (ubItemCoolness > ubMaxCoolness)
  711. {
  712. return(ITEM_SUITABILITY_NONE);
  713. }
  714. // if item is exactly within the current coolness window
  715. if ((ubItemCoolness >= ubMinCoolness) && (ubItemCoolness <= ubMaxCoolness))
  716. {
  717. return(ITEM_SUITABILITY_HIGH);
  718. }
  719. // if item is still relatively close to low end of the window
  720. if ((ubItemCoolness + 2) >= ubMinCoolness)
  721. {
  722. return(ITEM_SUITABILITY_MEDIUM);
  723. }
  724. // item is way uncool for player's current progress, but it's still possible for it to make an appearance
  725. return(ITEM_SUITABILITY_LOW);
  726. }
  727. UINT8 ChanceOfItemTransaction( INT8 bArmsDealer, UINT16 usItemIndex, BOOLEAN fDealerIsSelling, BOOLEAN fUsed )
  728. {
  729. UINT8 ubItemCoolness;
  730. UINT8 ubChance = 0;
  731. BOOLEAN fBobbyRay = FALSE;
  732. // make sure dealers don't carry used items that they shouldn't
  733. if ( fUsed && !fDealerIsSelling && !CanDealerItemBeSoldUsed( usItemIndex ) )
  734. return( 0 );
  735. if (bArmsDealer == -1)
  736. {
  737. // Bobby Ray has an easier time getting resupplied than the local dealers do
  738. fBobbyRay = TRUE;
  739. }
  740. ubItemCoolness = Item[ usItemIndex ].ubCoolness;
  741. switch (GetCurrentSuitabilityForItem( bArmsDealer, usItemIndex ) )
  742. {
  743. case ITEM_SUITABILITY_NONE:
  744. if (fDealerIsSelling)
  745. {
  746. // dealer always gets rid of stuff that is too advanced or inappropriate ASAP
  747. ubChance = 100;
  748. }
  749. else // dealer is buying
  750. {
  751. // can't get these at all
  752. ubChance = 0;
  753. }
  754. break;
  755. case ITEM_SUITABILITY_LOW:
  756. ubChance = (fBobbyRay) ? 25 : 15;
  757. break;
  758. case ITEM_SUITABILITY_MEDIUM:
  759. ubChance = (fBobbyRay) ? 50 : 30;
  760. break;
  761. case ITEM_SUITABILITY_HIGH:
  762. ubChance = (fBobbyRay) ? 75 : 50;
  763. break;
  764. case ITEM_SUITABILITY_ALWAYS:
  765. if (fDealerIsSelling)
  766. {
  767. // sells just like suitability high
  768. ubChance = 75;
  769. }
  770. else // dealer is buying
  771. {
  772. // dealer can always get a (re)supply of these
  773. ubChance = 100;
  774. }
  775. break;
  776. default:
  777. Assert(0);
  778. break;
  779. }
  780. // if there's any uncertainty
  781. if ((ubChance > 0) && (ubChance < 100))
  782. {
  783. // cooler items sell faster
  784. if (fDealerIsSelling)
  785. {
  786. ubChance += (5 * ubItemCoolness);
  787. // ARM: New - keep stuff on the shelves longer
  788. ubChance /= 2;
  789. }
  790. // used items are traded more rarely
  791. if (fUsed)
  792. {
  793. ubChance /= 2;
  794. }
  795. }
  796. return(ubChance);
  797. }
  798. BOOLEAN ItemTransactionOccurs( INT8 bArmsDealer, UINT16 usItemIndex, BOOLEAN fDealerIsSelling, BOOLEAN fUsed )
  799. {
  800. UINT8 ubChance;
  801. INT16 sInventorySlot;
  802. ubChance = ChanceOfItemTransaction( bArmsDealer, usItemIndex, fDealerIsSelling, fUsed );
  803. // if the dealer is buying, and a chance exists (i.e. the item is "eligible")
  804. if (!fDealerIsSelling && (ubChance > 0))
  805. {
  806. // mark it as such
  807. if (bArmsDealer == -1)
  808. {
  809. if (fUsed)
  810. {
  811. sInventorySlot = GetInventorySlotForItem(LaptopSaveInfo.BobbyRayUsedInventory, usItemIndex, fUsed);
  812. LaptopSaveInfo.BobbyRayUsedInventory[ sInventorySlot ].fPreviouslyEligible = TRUE;
  813. }
  814. else
  815. {
  816. sInventorySlot = GetInventorySlotForItem(LaptopSaveInfo.BobbyRayInventory, usItemIndex, fUsed);
  817. LaptopSaveInfo.BobbyRayInventory [ sInventorySlot ].fPreviouslyEligible = TRUE;
  818. }
  819. }
  820. else
  821. {
  822. gArmsDealersInventory[ bArmsDealer ][ usItemIndex ].fPreviouslyEligible = TRUE;
  823. }
  824. }
  825. // roll to see if a transaction occurs
  826. if (Random(100) < ubChance)
  827. {
  828. return(TRUE);
  829. }
  830. else
  831. {
  832. return(FALSE);
  833. }
  834. }
  835. UINT8 DetermineInitialInvItems( INT8 bArmsDealerID, UINT16 usItemIndex, UINT8 ubChances, BOOLEAN fUsed)
  836. {
  837. UINT8 ubNumBought;
  838. UINT8 ubCnt;
  839. // initial inventory is now rolled for one item at a time, instead of one type at a time, to improve variety
  840. ubNumBought = 0;
  841. for (ubCnt = 0; ubCnt < ubChances; ubCnt++)
  842. {
  843. if (ItemTransactionOccurs( bArmsDealerID, usItemIndex, DEALER_BUYING, fUsed))
  844. {
  845. ubNumBought++;
  846. }
  847. }
  848. return( ubNumBought );
  849. }
  850. UINT8 HowManyItemsAreSold( INT8 bArmsDealerID, UINT16 usItemIndex, UINT8 ubNumInStock, BOOLEAN fUsed)
  851. {
  852. UINT8 ubNumSold;
  853. UINT8 ubCnt;
  854. // items are now virtually "sold" one at a time
  855. ubNumSold = 0;
  856. for (ubCnt = 0; ubCnt < ubNumInStock; ubCnt++)
  857. {
  858. if (ItemTransactionOccurs( bArmsDealerID, usItemIndex, DEALER_SELLING, fUsed))
  859. {
  860. ubNumSold++;
  861. }
  862. }
  863. return( ubNumSold );
  864. }
  865. UINT8 HowManyItemsToReorder(UINT8 ubWanted, UINT8 ubStillHave)
  866. {
  867. UINT8 ubNumReordered;
  868. Assert(ubStillHave <= ubWanted);
  869. ubNumReordered = ubWanted - ubStillHave;
  870. //randomize the amount. 33% of the time we add to it, 33% we subtract from it, rest leave it alone
  871. switch (Random(3))
  872. {
  873. case 0:
  874. ubNumReordered += ubNumReordered / 2;
  875. break;
  876. case 1:
  877. ubNumReordered -= ubNumReordered / 2;
  878. break;
  879. }
  880. return(ubNumReordered);
  881. }
  882. int BobbyRayItemQsortCompare(const void *pArg1, const void *pArg2)
  883. {
  884. UINT16 usItem1Index;
  885. UINT16 usItem2Index;
  886. UINT8 ubItem1Quality;
  887. UINT8 ubItem2Quality;
  888. usItem1Index = ( ( STORE_INVENTORY * ) pArg1 ) -> usItemIndex;
  889. usItem2Index = ( ( STORE_INVENTORY * ) pArg2 ) -> usItemIndex;
  890. ubItem1Quality = ( ( STORE_INVENTORY * ) pArg1 ) -> ubItemQuality;
  891. ubItem2Quality = ( ( STORE_INVENTORY * ) pArg2 ) -> ubItemQuality;
  892. return( CompareItemsForSorting( usItem1Index, usItem2Index, ubItem1Quality, ubItem2Quality ) );
  893. }
  894. int ArmsDealerItemQsortCompare(const void *pArg1, const void *pArg2)
  895. {
  896. UINT16 usItem1Index;
  897. UINT16 usItem2Index;
  898. UINT8 ubItem1Quality;
  899. UINT8 ubItem2Quality;
  900. usItem1Index = ( ( INVENTORY_IN_SLOT * ) pArg1 ) -> sItemIndex;
  901. usItem2Index = ( ( INVENTORY_IN_SLOT * ) pArg2 ) -> sItemIndex;
  902. ubItem1Quality = ( ( INVENTORY_IN_SLOT * ) pArg1 ) -> ItemObject.bStatus[ 0 ];
  903. ubItem2Quality = ( ( INVENTORY_IN_SLOT * ) pArg2 ) -> ItemObject.bStatus[ 0 ];
  904. return( CompareItemsForSorting( usItem1Index, usItem2Index, ubItem1Quality, ubItem2Quality ) );
  905. }
  906. int RepairmanItemQsortCompare(const void *pArg1, const void *pArg2)
  907. {
  908. INVENTORY_IN_SLOT* pInvSlot1;
  909. INVENTORY_IN_SLOT* pInvSlot2;
  910. UINT32 uiRepairTime1;
  911. UINT32 uiRepairTime2;
  912. pInvSlot1 = ( INVENTORY_IN_SLOT * ) pArg1;
  913. pInvSlot2 = ( INVENTORY_IN_SLOT * ) pArg2;
  914. Assert( pInvSlot1->sSpecialItemElement != -1);
  915. Assert( pInvSlot2->sSpecialItemElement != -1);
  916. uiRepairTime1 = gArmsDealersInventory[ gbSelectedArmsDealerID ][ pInvSlot1->sItemIndex ].SpecialItem[ pInvSlot1->sSpecialItemElement ].uiRepairDoneTime;
  917. uiRepairTime2 = gArmsDealersInventory[ gbSelectedArmsDealerID ][ pInvSlot2->sItemIndex ].SpecialItem[ pInvSlot2->sSpecialItemElement ].uiRepairDoneTime;
  918. // lower reapir time first
  919. if ( uiRepairTime1 < uiRepairTime2 )
  920. {
  921. return( -1 );
  922. }
  923. else
  924. if ( uiRepairTime1 > uiRepairTime2 )
  925. {
  926. return( 1 );
  927. }
  928. else
  929. {
  930. return( 0 );
  931. }
  932. }
  933. int CompareItemsForSorting( UINT16 usItem1Index, UINT16 usItem2Index, UINT8 ubItem1Quality, UINT8 ubItem2Quality )
  934. {
  935. UINT8 ubItem1Category;
  936. UINT8 ubItem2Category;
  937. UINT16 usItem1Price;
  938. UINT16 usItem2Price;
  939. UINT8 ubItem1Coolness;
  940. UINT8 ubItem2Coolness;
  941. ubItem1Category = GetDealerItemCategoryNumber( usItem1Index );
  942. ubItem2Category = GetDealerItemCategoryNumber( usItem2Index );
  943. // lower category first
  944. if ( ubItem1Category < ubItem2Category )
  945. {
  946. return( -1 );
  947. }
  948. else
  949. if ( ubItem1Category > ubItem2Category )
  950. {
  951. return( 1 );
  952. }
  953. else
  954. {
  955. // the same category
  956. if ( Item[ usItem1Index ].usItemClass == IC_AMMO && Item[ usItem2Index ].usItemClass == IC_AMMO )
  957. {
  958. UINT8 ubItem1Calibre;
  959. UINT8 ubItem2Calibre;
  960. UINT8 ubItem1MagSize;
  961. UINT8 ubItem2MagSize;
  962. // AMMO is sorted by caliber first
  963. ubItem1Calibre = Magazine[ Item[ usItem1Index ].ubClassIndex ].ubCalibre;
  964. ubItem2Calibre = Magazine[ Item[ usItem2Index ].ubClassIndex ].ubCalibre;
  965. if ( ubItem1Calibre > ubItem2Calibre )
  966. {
  967. return( -1 );
  968. }
  969. else
  970. if ( ubItem1Calibre < ubItem2Calibre )
  971. {
  972. return( 1 );
  973. }
  974. // the same caliber - compare size of magazine, then fall out of if statement
  975. ubItem1MagSize = Magazine[ Item[ usItem1Index ].ubClassIndex ].ubMagSize;
  976. ubItem2MagSize = Magazine[ Item[ usItem2Index ].ubClassIndex ].ubMagSize;
  977. if ( ubItem1MagSize > ubItem2MagSize )
  978. {
  979. return( -1 );
  980. }
  981. else
  982. if ( ubItem1MagSize < ubItem2MagSize )
  983. {
  984. return( 1 );
  985. }
  986. }
  987. else
  988. {
  989. // items other than ammo are compared on coolness first
  990. ubItem1Coolness = Item[ usItem1Index ].ubCoolness;
  991. ubItem2Coolness = Item[ usItem2Index ].ubCoolness;
  992. // higher coolness first
  993. if ( ubItem1Coolness > ubItem2Coolness )
  994. {
  995. return( -1 );
  996. }
  997. else
  998. if ( ubItem1Coolness < ubItem2Coolness )
  999. {
  1000. return( 1 );
  1001. }
  1002. }
  1003. // the same coolness/caliber - compare base prices then
  1004. usItem1Price = Item[ usItem1Index ].usPrice;
  1005. usItem2Price = Item[ usItem2Index ].usPrice;
  1006. // higher price first
  1007. if ( usItem1Price > usItem2Price )
  1008. {
  1009. return( -1 );
  1010. }
  1011. else
  1012. if ( usItem1Price < usItem2Price )
  1013. {
  1014. return( 1 );
  1015. }
  1016. else
  1017. {
  1018. // the same price - compare item #s, then
  1019. // lower index first
  1020. if ( usItem1Index < usItem2Index )
  1021. {
  1022. return( -1 );
  1023. }
  1024. else
  1025. if ( usItem1Index > usItem2Index )
  1026. {
  1027. return( 1 );
  1028. }
  1029. else
  1030. {
  1031. // same item type = compare item quality, then
  1032. // higher quality first
  1033. if ( ubItem1Quality > ubItem2Quality )
  1034. {
  1035. return( -1 );
  1036. }
  1037. else
  1038. if ( ubItem1Quality < ubItem2Quality )
  1039. {
  1040. return( 1 );
  1041. }
  1042. else
  1043. {
  1044. // identical items!
  1045. return( 0 );
  1046. }
  1047. }
  1048. }
  1049. }
  1050. }
  1051. UINT8 GetDealerItemCategoryNumber( UINT16 usItemIndex )
  1052. {
  1053. UINT32 uiItemClass;
  1054. UINT8 ubWeaponClass;
  1055. UINT8 ubCategory = 0;
  1056. uiItemClass = Item[ usItemIndex ].usItemClass;
  1057. if ( usItemIndex < MAX_WEAPONS )
  1058. {
  1059. ubWeaponClass = Weapon[ usItemIndex ].ubWeaponClass;
  1060. }
  1061. else
  1062. {
  1063. // not a weapon, so no weapon class, this won't be needed
  1064. ubWeaponClass = 0;
  1065. }
  1066. ubCategory = 0;
  1067. // search table until end-of-list marker is encountered
  1068. while ( DealerItemSortInfo[ ubCategory ].uiItemClass != IC_NONE )
  1069. {
  1070. if ( DealerItemSortInfo[ ubCategory ].uiItemClass == uiItemClass )
  1071. {
  1072. // if not a type of gun
  1073. if ( uiItemClass != IC_GUN )
  1074. {
  1075. // then we're found it
  1076. return ( ubCategory );
  1077. }
  1078. else
  1079. {
  1080. // for guns, must also match on weapon class
  1081. if ( DealerItemSortInfo[ ubCategory ].ubWeaponClass == ubWeaponClass )
  1082. {
  1083. // then we're found it
  1084. return ( ubCategory );
  1085. }
  1086. }
  1087. }
  1088. // check vs. next category in the list
  1089. ubCategory++;
  1090. }
  1091. // should never be trying to locate an item that's not covered in the table!
  1092. Assert( FALSE );
  1093. return( 0 );
  1094. }
  1095. BOOLEAN CanDealerItemBeSoldUsed( UINT16 usItemIndex )
  1096. {
  1097. if ( !( Item[ usItemIndex ].fFlags & ITEM_DAMAGEABLE ) )
  1098. return(FALSE);
  1099. // certain items, although they're damagable, shouldn't be sold in a used condition
  1100. return( DealerItemSortInfo[ GetDealerItemCategoryNumber( usItemIndex ) ].fAllowUsed );
  1101. }