Devilution
Diablo devolved - magic behind the 1996 computer game
items.cpp
Go to the documentation of this file.
1 
6 #include "all.h"
7 
9 
11 BOOL uitemflag;
16 BOOL itemhold[3][3];
18 BOOL UniqueItemFlag[128];
21 
22 /* data */
23 
24 BYTE ItemCAnimTbl[169] = {
25  20, 16, 16, 16, 4, 4, 4, 12, 12, 12,
26  12, 12, 12, 12, 12, 21, 21, 25, 12, 28,
27  28, 28, 0, 0, 0, 32, 0, 0, 0, 24,
28  24, 26, 2, 25, 22, 23, 24, 25, 27, 27,
29  29, 0, 0, 0, 12, 12, 12, 12, 12, 0,
30  8, 8, 0, 8, 8, 8, 8, 8, 8, 6,
31  8, 8, 8, 6, 8, 8, 6, 8, 8, 6,
32  6, 6, 8, 8, 8, 5, 9, 13, 13, 13,
33  5, 5, 5, 15, 5, 5, 18, 18, 18, 30,
34  5, 5, 14, 5, 14, 13, 16, 18, 5, 5,
35  7, 1, 3, 17, 1, 15, 10, 14, 3, 11,
36  8, 0, 1, 7, 0, 7, 15, 7, 3, 3,
37  3, 6, 6, 11, 11, 11, 31, 14, 14, 14,
38  6, 6, 7, 3, 8, 14, 0, 14, 14, 0,
39  33, 1, 1, 1, 1, 1, 7, 7, 7, 14,
40  14, 17, 17, 17, 0, 34, 1, 0, 3, 17,
41  8, 8, 6, 1, 3, 3, 11, 3, 4
42 };
44  "Armor2",
45  "Axe",
46  "FBttle",
47  "Bow",
48  "GoldFlip",
49  "Helmut",
50  "Mace",
51  "Shield",
52  "SwrdFlip",
53  "Rock",
54  "Cleaver",
55  "Staff",
56  "Ring",
57  "CrownF",
58  "LArmor",
59  "WShield",
60  "Scroll",
61  "FPlateAr",
62  "FBook",
63  "Food",
64  "FBttleBB",
65  "FBttleDY",
66  "FBttleOR",
67  "FBttleBR",
68  "FBttleBL",
69  "FBttleBY",
70  "FBttleWH",
71  "FBttleDB",
72  "FEar",
73  "FBrain",
74  "FMush",
75  "Innsign",
76  "Bldstn",
77  "Fanvil",
78  "FLazStaf"
79 };
81  15,
82  13,
83  16,
84  13,
85  10,
86  13,
87  13,
88  13,
89  13,
90  10,
91  13,
92  13,
93  13,
94  13,
95  13,
96  13,
97  13,
98  13,
99  13,
100  1,
101  16,
102  16,
103  16,
104  16,
105  16,
106  16,
107  16,
108  16,
109  13,
110  12,
111  12,
112  13,
113  13,
114  13,
115  8
116 };
118  IS_FHARM,
119  IS_FAXE,
120  IS_FPOT,
121  IS_FBOW,
122  IS_GOLD,
123  IS_FCAP,
124  IS_FSWOR,
125  IS_FSHLD,
126  IS_FSWOR,
127  IS_FROCK,
128  IS_FAXE,
129  IS_FSTAF,
130  IS_FRING,
131  IS_FCAP,
132  IS_FLARM,
133  IS_FSHLD,
134  IS_FSCRL,
135  IS_FHARM,
136  IS_FBOOK,
137  IS_FLARM,
138  IS_FPOT,
139  IS_FPOT,
140  IS_FPOT,
141  IS_FPOT,
142  IS_FPOT,
143  IS_FPOT,
144  IS_FPOT,
145  IS_FPOT,
146  IS_FBODY,
147  IS_FBODY,
148  IS_FMUSH,
149  IS_ISIGN,
150  IS_FBLST,
151  IS_FANVL,
152  IS_FSTAF
153 };
155  IS_IHARM,
156  IS_IAXE,
157  IS_IPOT,
158  IS_IBOW,
159  IS_GOLD,
160  IS_ICAP,
161  IS_ISWORD,
162  IS_ISHIEL,
163  IS_ISWORD,
164  IS_IROCK,
165  IS_IAXE,
166  IS_ISTAF,
167  IS_IRING,
168  IS_ICAP,
169  IS_ILARM,
170  IS_ISHIEL,
171  IS_ISCROL,
172  IS_IHARM,
173  IS_IBOOK,
174  IS_IHARM,
175  IS_IPOT,
176  IS_IPOT,
177  IS_IPOT,
178  IS_IPOT,
179  IS_IPOT,
180  IS_IPOT,
181  IS_IPOT,
182  IS_IPOT,
183  IS_IBODY,
184  IS_IBODY,
185  IS_IMUSH,
186  IS_ISIGN,
187  IS_IBLST,
188  IS_IANVL,
189  IS_ISTAF
190 };
191 int idoppely = 16;
192 int premiumlvladd[6] = { -1, -1, 0, 0, 1, 2 };
193 
195 {
196  int i;
197  char arglist[64];
198 
199  for (i = 0; i < ITEMTYPES; i++) {
200  sprintf(arglist, "Items\\%s.CEL", ItemDropNames[i]);
201  itemanims[i] = LoadFileInMem(arglist, NULL);
202  }
203  memset(UniqueItemFlag, 0, sizeof(UniqueItemFlag));
204 }
205 
206 BOOL ItemPlace(int xp, int yp)
207 {
208  if (dMonster[xp][yp])
209  return FALSE;
210  if (dPlayer[xp][yp])
211  return FALSE;
212  if (dItem[xp][yp])
213  return FALSE;
214  if (dObject[xp][yp])
215  return FALSE;
216  if (dFlags[xp][yp] & BFLAG_POPULATED)
217  return FALSE;
218  if (nSolidTable[dPiece[xp][yp]])
219  return FALSE;
220 
221  return TRUE;
222 }
223 
225 {
226  int x, y, i, j, rnd;
227 
228  rnd = random_(11, 3) + 3;
229  for (j = 0; j < rnd; j++) {
230  i = itemavail[0];
231  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
232  itemactive[numitems] = i;
233  x = random_(12, 80) + 16;
234  y = random_(12, 80) + 16;
235  while (!ItemPlace(x, y)) {
236  x = random_(12, 80) + 16;
237  y = random_(12, 80) + 16;
238  }
239  item[i]._ix = x;
240  item[i]._iy = y;
241  dItem[x][y] = i + 1;
242  item[i]._iSeed = GetRndSeed();
243  SetRndSeed(item[i]._iSeed);
244  if (random_(12, 2))
246  else
248  item[i]._iCreateInfo = currlevel - 0x8000;
249  SetupItem(i);
250  item[i]._iAnimFrame = item[i]._iAnimLen;
251  item[i]._iAnimFlag = FALSE;
252  item[i]._iSelFlag = 1;
253  DeltaAddItem(i);
254  numitems++;
255  }
256 }
257 
258 void InitItems()
259 {
260  int i;
261  long s;
262 
263  GetItemAttrs(0, IDI_GOLD, 1);
264  golditem = item[0];
265  golditem._iStatFlag = TRUE;
266  numitems = 0;
267 
268  for (i = 0; i < MAXITEMS; i++) {
269  item[i]._itype = ITYPE_MISC;
270  item[i]._ix = 0;
271  item[i]._iy = 0;
272  item[i]._iAnimFlag = FALSE;
273  item[i]._iSelFlag = 0;
274  item[i]._iIdentified = FALSE;
275  item[i]._iPostDraw = FALSE;
276  }
277 
278  for (i = 0; i < MAXITEMS; i++) {
279  itemavail[i] = i;
280  itemactive[i] = 0;
281  }
282 
283  if (!setlevel) {
284  s = GetRndSeed(); /* unused */
285  if (QuestStatus(Q_ROCK))
286  SpawnRock();
287  if (QuestStatus(Q_ANVIL))
288  SpawnQuestItem(IDI_ANVIL, 2 * setpc_x + 27, 2 * setpc_y + 27, 0, 1);
289  if (currlevel > 0 && currlevel < 16)
290  AddInitItems();
291  }
292 
293  uitemflag = FALSE;
294 }
295 
296 void CalcPlrItemVals(int p, BOOL Loadgfx)
297 {
298  int pvid, d;
299 
300  int mind = 0; // min damage
301  int maxd = 0; // max damage
302  int tac = 0; // accuracy
303 
304  int g;
305  int i;
306  int mi;
307 
308  int bdam = 0; // bonus damage
309  int btohit = 0; // bonus chance to hit
310  int bac = 0; // bonus accuracy
311 
312  int iflgs = ISPL_NONE; // item_special_effect flags
313 
314  int sadd = 0; // added strength
315  int madd = 0; // added magic
316  int dadd = 0; // added dexterity
317  int vadd = 0; // added vitality
318 
319  unsigned __int64 spl = 0; // bitarray for all enabled/active spells
320 
321  int fr = 0; // fire resistance
322  int lr = 0; // lightning resistance
323  int mr = 0; // magic resistance
324 
325  int dmod = 0; // bonus damage mod?
326  int ghit = 0; // increased damage from enemies
327 
328  int lrad = 10; // light radius
329 
330  int ihp = 0; // increased HP
331  int imana = 0; // increased mana
332 
333  int spllvladd = 0; // increased spell level
334  int enac = 0; // enhanced accuracy
335 
336  int fmin = 0; // minimum fire damage
337  int fmax = 0; // maximum fire damage
338  int lmin = 0; // minimum lightning damage
339  int lmax = 0; // maximum lightning damage
340 
341  for (i = 0; i < NUM_INVLOC; i++) {
342  ItemStruct *itm = &plr[p].InvBody[i];
343  if (itm->_itype != ITYPE_NONE && itm->_iStatFlag) {
344 
345  mind += itm->_iMinDam;
346  tac += itm->_iAC;
347  maxd += itm->_iMaxDam;
348 
349  if (itm->_iSpell != SPL_NULL) {
350  spl |= (unsigned __int64)1 << (itm->_iSpell - 1);
351  }
352 
353  if (itm->_iMagical == ITEM_QUALITY_NORMAL || itm->_iIdentified) {
354  bdam += itm->_iPLDam;
355  btohit += itm->_iPLToHit;
356  if (itm->_iPLAC) {
357  int tmpac = itm->_iPLAC * itm->_iAC / 100;
358  if (tmpac == 0)
359  tmpac = 1;
360  bac += tmpac;
361  }
362  dmod += itm->_iPLDamMod;
363  iflgs |= itm->_iFlags;
364  sadd += itm->_iPLStr;
365  madd += itm->_iPLMag;
366  dadd += itm->_iPLDex;
367  vadd += itm->_iPLVit;
368  fr += itm->_iPLFR;
369  lr += itm->_iPLLR;
370  mr += itm->_iPLMR;
371  ghit += itm->_iPLGetHit;
372  lrad += itm->_iPLLight;
373  ihp += itm->_iPLHP;
374  imana += itm->_iPLMana;
375  spllvladd += itm->_iSplLvlAdd;
376  enac += itm->_iPLEnAc;
377  fmin += itm->_iFMinDam;
378  fmax += itm->_iFMaxDam;
379  lmin += itm->_iLMinDam;
380  lmax += itm->_iLMaxDam;
381  }
382  }
383  }
384 
385  if (mind == 0 && maxd == 0) {
386  mind = 1;
387  maxd = 1;
388 
389  if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) {
390  maxd = 3;
391  }
392 
393  if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) {
394  maxd = 3;
395  }
396  }
397 
398  plr[p]._pIMaxDam = maxd;
399  plr[p]._pIAC = tac;
400  plr[p]._pIBonusDam = bdam;
401  plr[p]._pIBonusToHit = btohit;
402  plr[p]._pIBonusAC = bac;
403  plr[p]._pIFlags = iflgs;
404  plr[p]._pIGetHit = ghit;
405  plr[p]._pIMinDam = mind;
406  plr[p]._pIBonusDamMod = dmod;
407 
408  if (lrad < 2) {
409  lrad = 2;
410  }
411  if (lrad > 15) {
412  lrad = 15;
413  }
414 
415  if (plr[p]._pLightRad != lrad && p == myplr) {
416  ChangeLightRadius(plr[p]._plid, lrad);
417 
418  pvid = plr[p]._pvid;
419  if (lrad >= 10) {
420  ChangeVisionRadius(pvid, lrad);
421  } else {
422  ChangeVisionRadius(pvid, 10);
423  }
424 
425  plr[p]._pLightRad = lrad;
426  }
427 
428  plr[p]._pStrength = sadd + plr[p]._pBaseStr;
429  if (plr[myplr]._pStrength <= 0) {
430  plr[myplr]._pStrength = 0;
431  }
432 
433  plr[p]._pMagic = madd + plr[p]._pBaseMag;
434  if (plr[myplr]._pMagic <= 0) {
435  plr[myplr]._pMagic = 0;
436  }
437 
438  plr[p]._pDexterity = dadd + plr[p]._pBaseDex;
439  if (plr[myplr]._pDexterity <= 0) {
440  plr[myplr]._pDexterity = 0;
441  }
442 
443  plr[p]._pVitality = vadd + plr[p]._pBaseVit;
444  if (plr[myplr]._pVitality <= 0) {
445  plr[myplr]._pVitality = 0;
446  }
447 
448  if (plr[p]._pClass == PC_ROGUE) {
449  plr[p]._pDamageMod = plr[p]._pLevel * (plr[p]._pStrength + plr[p]._pDexterity) / 200;
450  } else {
451  plr[p]._pDamageMod = plr[p]._pLevel * plr[p]._pStrength / 100;
452  }
453 
454  plr[p]._pISpells = spl;
455 
456  // check if the current RSplType is a valid/allowed spell
457  if (plr[p]._pRSplType == RSPLTYPE_CHARGES
458  && !(spl & ((unsigned __int64)1 << (plr[p]._pRSpell - 1)))) {
459  plr[p]._pRSpell = SPL_INVALID;
461  force_redraw = 255;
462  }
463 
464  plr[p]._pISplLvlAdd = spllvladd;
465  plr[p]._pIEnAc = enac;
466 
467  if (iflgs & ISPL_ALLRESZERO) {
468  // reset resistances to zero if the respective special effect is active
469  mr = 0;
470  fr = 0;
471  lr = 0;
472  }
473 
474  if (mr > 75) {
475  mr = 75;
476  }
477  plr[p]._pMagResist = mr;
478 
479  if (fr > 75) {
480  fr = 75;
481  }
482  plr[p]._pFireResist = fr;
483 
484  if (lr > 75) {
485  lr = 75;
486  }
487  plr[p]._pLghtResist = lr;
488 
489  if (plr[p]._pClass == PC_WARRIOR) {
490  vadd *= 2;
491  }
492  if (plr[p]._pClass == PC_ROGUE) {
493  vadd += vadd >> 1;
494  }
495  ihp += (vadd << 6);
496 
497  if (plr[p]._pClass == PC_SORCERER) {
498  madd *= 2;
499  }
500  if (plr[p]._pClass == PC_ROGUE) {
501  madd += madd >> 1;
502  }
503  imana += (madd << 6);
504 
505  plr[p]._pHitPoints = ihp + plr[p]._pHPBase;
506  plr[p]._pMaxHP = ihp + plr[p]._pMaxHPBase;
507 
508  if (p == myplr && (plr[p]._pHitPoints >> 6) <= 0) {
509  SetPlayerHitPoints(p, 0);
510  }
511 
512  plr[p]._pMana = imana + plr[p]._pManaBase;
513  plr[p]._pMaxMana = imana + plr[p]._pMaxManaBase;
514 
515  plr[p]._pIFMinDam = fmin;
516  plr[p]._pIFMaxDam = fmax;
517  plr[p]._pILMinDam = lmin;
518  plr[p]._pILMaxDam = lmax;
519 
520  if (iflgs & ISPL_INFRAVISION) {
521  plr[p]._pInfraFlag = TRUE;
522  } else {
523  plr[p]._pInfraFlag = FALSE;
524  }
525 
526  plr[p]._pBlockFlag = FALSE;
527  plr[p]._pwtype = WT_MELEE;
528 
529  g = 0;
530 
531  if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE
532  && plr[p].InvBody[INVLOC_HAND_LEFT]._iClass == ICLASS_WEAPON
533  && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) {
535  }
536 
537  if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE
538  && plr[p].InvBody[INVLOC_HAND_RIGHT]._iClass == ICLASS_WEAPON
539  && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) {
541  }
542 
543  switch (g) {
544  case ITYPE_SWORD:
545  g = ANIM_ID_SWORD;
546  break;
547  case ITYPE_AXE:
548  g = ANIM_ID_AXE;
549  break;
550  case ITYPE_BOW:
551  plr[p]._pwtype = WT_RANGED;
552  g = ANIM_ID_BOW;
553  break;
554  case ITYPE_MACE:
555  g = ANIM_ID_MACE;
556  break;
557  case ITYPE_STAFF:
558  g = ANIM_ID_STAFF;
559  break;
560  }
561 
562  if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag) {
563  plr[p]._pBlockFlag = TRUE;
564  g++;
565  }
566  if (plr[p].InvBody[INVLOC_HAND_RIGHT]._itype == ITYPE_SHIELD && plr[p].InvBody[INVLOC_HAND_RIGHT]._iStatFlag) {
567  plr[p]._pBlockFlag = TRUE;
568  g++;
569  }
570 
571 #ifndef SPAWN
572  if (plr[p].InvBody[INVLOC_CHEST]._itype == ITYPE_MARMOR && plr[p].InvBody[INVLOC_CHEST]._iStatFlag) {
574  }
575  if (plr[p].InvBody[INVLOC_CHEST]._itype == ITYPE_HARMOR && plr[p].InvBody[INVLOC_CHEST]._iStatFlag) {
576  g += ANIM_ID_HEAVY_ARMOR;
577  }
578 #endif
579 
580  if (plr[p]._pgfxnum != g && Loadgfx) {
581  plr[p]._pgfxnum = g;
582  plr[p]._pGFXLoad = 0;
584  SetPlrAnims(p);
585 
586  d = plr[p]._pdir;
587 
588  // TODO: Add debug assert here ( plr[p]._pNAnim[d] != NULL )
589  plr[p]._pAnimData = plr[p]._pNAnim[d];
590 
591  plr[p]._pAnimLen = plr[p]._pNFrames;
592  plr[p]._pAnimFrame = 1;
593  plr[p]._pAnimCnt = 0;
594  plr[p]._pAnimDelay = 3;
595  plr[p]._pAnimWidth = plr[p]._pNWidth;
596  plr[p]._pAnimWidth2 = (plr[p]._pNWidth - 64) >> 1;
597  } else {
598  plr[p]._pgfxnum = g;
599  }
600 
601  for (i = 0; i < nummissiles; i++) {
602  mi = missileactive[i];
603  if (missile[mi]._mitype == MIS_MANASHIELD && missile[mi]._misource == p) {
604  missile[mi]._miVar1 = plr[p]._pHitPoints;
605  missile[mi]._miVar2 = plr[p]._pHPBase;
606  }
607  }
608 
609  drawmanaflag = TRUE;
610  drawhpflag = TRUE;
611 }
612 
613 void CalcPlrScrolls(int p)
614 {
615  int i, j;
616 
617  plr[p]._pScrlSpells = 0;
618  for (i = 0; i < plr[p]._pNumInv; i++) {
619  if (plr[p].InvList[i]._itype != ITYPE_NONE && (plr[p].InvList[i]._iMiscId == IMISC_SCROLL || plr[p].InvList[i]._iMiscId == IMISC_SCROLLT)) {
620  if (plr[p].InvList[i]._iStatFlag)
621  plr[p]._pScrlSpells |= (__int64)1 << (plr[p].InvList[i]._iSpell - 1);
622  }
623  }
624 
625  for (j = 0; j < MAXBELTITEMS; j++) {
626  if (plr[p].SpdList[j]._itype != ITYPE_NONE && (plr[p].SpdList[j]._iMiscId == IMISC_SCROLL || plr[p].SpdList[j]._iMiscId == IMISC_SCROLLT)) {
627  if (plr[p].SpdList[j]._iStatFlag)
628  plr[p]._pScrlSpells |= (__int64)1 << (plr[p].SpdList[j]._iSpell - 1);
629  }
630  }
631  if (plr[p]._pRSplType == RSPLTYPE_SCROLL) {
632  if (!(plr[p]._pScrlSpells & 1 << (plr[p]._pRSpell - 1))) {
633  plr[p]._pRSpell = SPL_INVALID;
635  force_redraw = 255;
636  }
637  }
638 }
639 
640 void CalcPlrStaff(int p)
641 {
642  plr[p]._pISpells = 0;
643  if (plr[p].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE
644  && plr[p].InvBody[INVLOC_HAND_LEFT]._iStatFlag
645  && plr[p].InvBody[INVLOC_HAND_LEFT]._iCharges > 0) {
646  plr[p]._pISpells |= (__int64)1 << (plr[p].InvBody[INVLOC_HAND_LEFT]._iSpell - 1);
647  }
648 }
649 
650 void CalcSelfItems(int pnum)
651 {
652  int i;
653  PlayerStruct *p;
654  BOOL sf, changeflag;
655  int sa, ma, da;
656 
657  p = &plr[pnum];
658 
659  sa = 0;
660  ma = 0;
661  da = 0;
662  for (i = 0; i < NUM_INVLOC; i++) {
663  if (p->InvBody[i]._itype != ITYPE_NONE) {
664  p->InvBody[i]._iStatFlag = TRUE;
665  if (p->InvBody[i]._iIdentified) {
666  sa += p->InvBody[i]._iPLStr;
667  ma += p->InvBody[i]._iPLMag;
668  da += p->InvBody[i]._iPLDex;
669  }
670  }
671  }
672  do {
673  changeflag = FALSE;
674  for (i = 0; i < NUM_INVLOC; i++) {
675  if (p->InvBody[i]._itype != ITYPE_NONE && p->InvBody[i]._iStatFlag) {
676  sf = TRUE;
677  if (sa + p->_pBaseStr < p->InvBody[i]._iMinStr)
678  sf = FALSE;
679  if (ma + p->_pBaseMag < p->InvBody[i]._iMinMag)
680  sf = FALSE;
681  if (da + p->_pBaseDex < p->InvBody[i]._iMinDex)
682  sf = FALSE;
683  if (!sf) {
684  changeflag = TRUE;
685  p->InvBody[i]._iStatFlag = FALSE;
686  if (p->InvBody[i]._iIdentified) {
687  sa -= p->InvBody[i]._iPLStr;
688  ma -= p->InvBody[i]._iPLMag;
689  da -= p->InvBody[i]._iPLDex;
690  }
691  }
692  }
693  }
694  } while (changeflag);
695 }
696 
697 void CalcPlrItemMin(int pnum)
698 {
699  PlayerStruct *p;
700  ItemStruct *pi;
701  int i;
702 
703  p = &plr[pnum];
704  pi = p->InvList;
705  i = p->_pNumInv;
706 
707  while (i--) {
708  pi->_iStatFlag = ItemMinStats(p, pi);
709  pi++;
710  }
711 
712  pi = p->SpdList;
713  for (i = MAXBELTITEMS; i != 0; i--) {
714  if (pi->_itype != ITYPE_NONE) {
715  pi->_iStatFlag = ItemMinStats(p, pi);
716  }
717  pi++;
718  }
719 }
720 
722 {
723  if (p->_pMagic < x->_iMinMag)
724  return FALSE;
725 
726  if (p->_pStrength < x->_iMinStr)
727  return FALSE;
728 
729  if (p->_pDexterity < x->_iMinDex)
730  return FALSE;
731 
732  return TRUE;
733 }
734 
735 void CalcPlrBookVals(int p)
736 {
737  int i, slvl;
738 
739  if (!currlevel) {
740  for (i = 1; witchitem[i]._itype != ITYPE_NONE; i++) {
741  WitchBookLevel(i);
743  }
744  }
745 
746  for (i = 0; i < plr[p]._pNumInv; i++) {
747  if (plr[p].InvList[i]._itype == ITYPE_MISC && plr[p].InvList[i]._iMiscId == IMISC_BOOK) {
749  slvl = plr[p]._pSplLvl[plr[p].InvList[i]._iSpell];
750 
751  while (slvl) {
752  plr[p].InvList[i]._iMinMag += 20 * plr[p].InvList[i]._iMinMag / 100;
753  slvl--;
754  if (plr[p].InvList[i]._iMinMag + 20 * plr[p].InvList[i]._iMinMag / 100 > 255) {
755  plr[p].InvList[i]._iMinMag = 255;
756  slvl = 0;
757  }
758  }
759  plr[p].InvList[i]._iStatFlag = ItemMinStats(&plr[p], &plr[p].InvList[i]);
760  }
761  }
762 }
763 
764 void CalcPlrInv(int p, BOOL Loadgfx)
765 {
766  CalcPlrItemMin(p);
767  CalcSelfItems(p);
768  CalcPlrItemVals(p, Loadgfx);
769  CalcPlrItemMin(p);
770  if (p == myplr) {
771  CalcPlrBookVals(p);
772  CalcPlrScrolls(p);
773  CalcPlrStaff(p);
774  if (p == myplr && !currlevel)
776  }
777 }
778 
779 void SetPlrHandItem(ItemStruct *h, int idata)
780 {
781  ItemDataStruct *pAllItem;
782 
783  pAllItem = &AllItemsList[idata];
784 
785  // zero-initialize struct
786  memset(h, 0, sizeof(*h));
787 
788  h->_itype = pAllItem->itype;
789  h->_iCurs = pAllItem->iCurs;
790  strcpy(h->_iName, pAllItem->iName);
791  strcpy(h->_iIName, pAllItem->iName);
792  h->_iLoc = pAllItem->iLoc;
793  h->_iClass = pAllItem->iClass;
794  h->_iMinDam = pAllItem->iMinDam;
795  h->_iMaxDam = pAllItem->iMaxDam;
796  h->_iAC = pAllItem->iMinAC;
797  h->_iMiscId = pAllItem->iMiscId;
798  h->_iSpell = pAllItem->iSpell;
799 
800  if (pAllItem->iMiscId == IMISC_STAFF) {
801  h->_iCharges = 40;
802  }
803 
804  h->_iMaxCharges = h->_iCharges;
805  h->_iDurability = pAllItem->iDurability;
806  h->_iMaxDur = pAllItem->iDurability;
807  h->_iMinStr = pAllItem->iMinStr;
808  h->_iMinMag = pAllItem->iMinMag;
809  h->_iMinDex = pAllItem->iMinDex;
810  h->_ivalue = pAllItem->iValue;
811  h->_iIvalue = pAllItem->iValue;
812  h->_iPrePower = -1;
813  h->_iSufPower = -1;
815  h->IDidx = idata;
816 }
817 
819 {
820  h->_iSeed = GetRndSeed();
821 }
822 
823 void GetGoldSeed(int pnum, ItemStruct *h)
824 {
825  int i, ii, s;
826  BOOL doneflag;
827 
828  do {
829  doneflag = TRUE;
830  s = GetRndSeed();
831  for (i = 0; i < numitems; i++) {
832  ii = itemactive[i];
833  if (item[ii]._iSeed == s)
834  doneflag = FALSE;
835  }
836  if (pnum == myplr) {
837  for (i = 0; i < plr[pnum]._pNumInv; i++) {
838  if (plr[pnum].InvList[i]._iSeed == s)
839  doneflag = FALSE;
840  }
841  }
842  } while (!doneflag);
843 
844  h->_iSeed = s;
845 }
846 
847 void SetPlrHandSeed(ItemStruct *h, int iseed)
848 {
849  h->_iSeed = iseed;
850 }
851 
853 {
854  if (h->_ivalue >= GOLD_MEDIUM_LIMIT)
856  else if (h->_ivalue <= GOLD_SMALL_LIMIT)
858  else
860 }
861 
862 void CreatePlrItems(int p)
863 {
864  int i;
865  ItemStruct *pi = plr[p].InvBody;
866 
867  for (i = NUM_INVLOC; i != 0; i--) {
868  pi->_itype = ITYPE_NONE;
869  pi++;
870  }
871 
872  // converting this to a for loop creates a `rep stosd` instruction,
873  // so this probably actually was a memset
874  memset(&plr[p].InvGrid, 0, sizeof(plr[p].InvGrid));
875 
876  pi = plr[p].InvList;
877  for (i = NUM_INV_GRID_ELEM; i != 0; i--) {
878  pi->_itype = ITYPE_NONE;
879  pi++;
880  }
881 
882  plr[p]._pNumInv = 0;
883 
884  pi = plr[p].SpdList;
885  for (i = MAXBELTITEMS; i != 0; i--) {
886  pi->_itype = ITYPE_NONE;
887  pi++;
888  }
889 
890  switch (plr[p]._pClass) {
891  case PC_WARRIOR:
893  GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]);
894 
896  GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_RIGHT]);
897 
898 #ifdef _DEBUG
899  if (!debug_mode_key_w) {
900 #endif
901  SetPlrHandItem(&plr[p].HoldItem, IDI_WARRCLUB);
902  GetPlrHandSeed(&plr[p].HoldItem);
903  AutoPlace(p, 0, 1, 3, TRUE);
904 #ifdef _DEBUG
905  }
906 #endif
907 
908  SetPlrHandItem(&plr[p].SpdList[0], IDI_HEAL);
909  GetPlrHandSeed(&plr[p].SpdList[0]);
910 
911  SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL);
912  GetPlrHandSeed(&plr[p].SpdList[1]);
913  break;
914 #ifndef SPAWN
915  case PC_ROGUE:
917  GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]);
918 
919  SetPlrHandItem(&plr[p].SpdList[0], IDI_HEAL);
920  GetPlrHandSeed(&plr[p].SpdList[0]);
921 
922  SetPlrHandItem(&plr[p].SpdList[1], IDI_HEAL);
923  GetPlrHandSeed(&plr[p].SpdList[1]);
924  break;
925  case PC_SORCERER:
927  GetPlrHandSeed(&plr[p].InvBody[INVLOC_HAND_LEFT]);
928 
929  SetPlrHandItem(&plr[p].SpdList[0], IDI_MANA);
930  GetPlrHandSeed(&plr[p].SpdList[0]);
931 
932  SetPlrHandItem(&plr[p].SpdList[1], IDI_MANA);
933  GetPlrHandSeed(&plr[p].SpdList[1]);
934  break;
935 #endif
936  }
937 
938  SetPlrHandItem(&plr[p].HoldItem, IDI_GOLD);
939  GetPlrHandSeed(&plr[p].HoldItem);
940 
941 #ifdef _DEBUG
942  if (!debug_mode_key_w) {
943 #endif
944  plr[p].HoldItem._ivalue = 100;
946  plr[p]._pGold = plr[p].HoldItem._ivalue;
947  plr[p].InvList[plr[p]._pNumInv++] = plr[p].HoldItem;
948  plr[p].InvGrid[30] = plr[p]._pNumInv;
949 #ifdef _DEBUG
950  } else {
953  plr[p]._pGold = plr[p].HoldItem._ivalue * 40;
954  for (i = 0; i < NUM_INV_GRID_ELEM; i++) {
955  GetPlrHandSeed(&plr[p].HoldItem);
956  plr[p].InvList[plr[p]._pNumInv++] = plr[p].HoldItem;
957  plr[p].InvGrid[i] = plr[p]._pNumInv;
958  }
959  }
960 #endif
961 
962  CalcPlrItemVals(p, FALSE);
963 }
964 
965 BOOL ItemSpaceOk(int i, int j)
966 {
967  int oi;
968 
969  // BUGFIX: Check `i + 1 >= MAXDUNX` and `j + 1 >= MAXDUNY` (applied)
970  if (i < 0 || i + 1 >= MAXDUNX || j < 0 || j + 1 >= MAXDUNY)
971  return FALSE;
972 
973  if (dMonster[i][j])
974  return FALSE;
975 
976  if (dPlayer[i][j])
977  return FALSE;
978 
979  if (dItem[i][j])
980  return FALSE;
981 
982  if (dObject[i][j]) {
983  oi = dObject[i][j] > 0 ? dObject[i][j] - 1 : -(dObject[i][j] + 1);
984  if (object[oi]._oSolidFlag)
985  return FALSE;
986  }
987 
988  if (dObject[i + 1][j + 1] > 0 && object[dObject[i + 1][j + 1] - 1]._oSelFlag != 0)
989  return FALSE;
990 
991  if (dObject[i + 1][j + 1] < 0 && object[-(dObject[i + 1][j + 1] + 1)]._oSelFlag != 0)
992  return FALSE;
993 
994  if (dObject[i + 1][j] > 0
995  && dObject[i][j + 1] > 0
996  && object[dObject[i + 1][j] - 1]._oSelFlag != 0
997  && object[dObject[i][j + 1] - 1]._oSelFlag != 0) {
998  return FALSE;
999  }
1000 
1001  return !nSolidTable[dPiece[i][j]];
1002 }
1003 
1004 BOOL GetItemSpace(int x, int y, char inum)
1005 {
1006  int i, j, rs;
1007  int xx, yy;
1008  BOOL savail;
1009 
1010  yy = 0;
1011  for (j = y - 1; j <= y + 1; j++) {
1012  xx = 0;
1013  for (i = x - 1; i <= x + 1; i++) {
1014  itemhold[xx][yy] = ItemSpaceOk(i, j);
1015  xx++;
1016  }
1017  yy++;
1018  }
1019 
1020  savail = FALSE;
1021  for (j = 0; j < 3; j++) {
1022  for (i = 0; i < 3; i++) {
1023  if (itemhold[i][j])
1024  savail = TRUE;
1025  }
1026  }
1027 
1028  rs = random_(13, 15) + 1;
1029 
1030  if (!savail)
1031  return FALSE;
1032 
1033  xx = 0;
1034  yy = 0;
1035  while (rs > 0) {
1036  if (itemhold[xx][yy])
1037  rs--;
1038  if (rs > 0) {
1039  xx++;
1040  if (xx == 3) {
1041  xx = 0;
1042  yy++;
1043  if (yy == 3)
1044  yy = 0;
1045  }
1046  }
1047  }
1048 
1049  xx += x - 1;
1050  yy += y - 1;
1051  item[inum]._ix = xx;
1052  item[inum]._iy = yy;
1053  dItem[xx][yy] = inum + 1;
1054 
1055  return TRUE;
1056 }
1057 
1058 void GetSuperItemSpace(int x, int y, char inum)
1059 {
1060  int xx, yy;
1061  int i, j, k;
1062 
1063  if (!GetItemSpace(x, y, inum)) {
1064  for (k = 2; k < 50; k++) {
1065  for (j = -k; j <= k; j++) {
1066  yy = y + j;
1067  for (i = -k; i <= k; i++) {
1068  xx = i + x;
1069  if (ItemSpaceOk(xx, yy)) {
1070  item[inum]._ix = xx;
1071  item[inum]._iy = yy;
1072  dItem[xx][yy] = inum + 1;
1073  return;
1074  }
1075  }
1076  }
1077  }
1078  }
1079 }
1080 
1081 void GetSuperItemLoc(int x, int y, int *xx, int *yy)
1082 {
1083  int i, j, k;
1084 
1085  for (k = 1; k < 50; k++) {
1086  for (j = -k; j <= k; j++) {
1087  *yy = y + j;
1088  for (i = -k; i <= k; i++) {
1089  *xx = i + x;
1090  if (ItemSpaceOk(*xx, *yy)) {
1091  return;
1092  }
1093  }
1094  }
1095  }
1096 }
1097 
1098 void CalcItemValue(int i)
1099 {
1100  int v;
1101 
1102  v = item[i]._iVMult1 + item[i]._iVMult2;
1103  if (v > 0) {
1104  v *= item[i]._ivalue;
1105  }
1106  if (v < 0) {
1107  v = item[i]._ivalue / v;
1108  }
1109  v = item[i]._iVAdd1 + item[i]._iVAdd2 + v;
1110  if (v <= 0) {
1111  v = 1;
1112  }
1113  item[i]._iIvalue = v;
1114 }
1115 
1116 void GetBookSpell(int i, int lvl)
1117 {
1118  int rv, s, bs;
1119 
1120  if (lvl == 0)
1121  lvl = 1;
1122  rv = random_(14, MAX_SPELLS) + 1;
1123 #ifdef SPAWN
1124  if (lvl > 5)
1125  lvl = 5;
1126 #endif
1127  s = 1;
1128  while (rv > 0) {
1129  if (spelldata[s].sBookLvl != -1 && lvl >= spelldata[s].sBookLvl) {
1130  rv--;
1131  bs = s;
1132  }
1133  s++;
1134  if (gbMaxPlayers == 1) {
1135  if (s == SPL_RESURRECT)
1136  s = SPL_TELEKINESIS;
1137  }
1138  if (gbMaxPlayers == 1) {
1139  if (s == SPL_HEALOTHER)
1140  s = SPL_FLARE;
1141  }
1142  if (s == MAX_SPELLS)
1143  s = 1;
1144  }
1145  strcat(item[i]._iName, spelldata[bs].sNameText);
1146  strcat(item[i]._iIName, spelldata[bs].sNameText);
1147  item[i]._iSpell = bs;
1148  item[i]._iMinMag = spelldata[bs].sMinInt;
1149  item[i]._ivalue += spelldata[bs].sBookCost;
1150  item[i]._iIvalue += spelldata[bs].sBookCost;
1151  if (spelldata[bs].sType == STYPE_FIRE)
1152  item[i]._iCurs = ICURS_BOOK_RED;
1153  if (spelldata[bs].sType == STYPE_LIGHTNING)
1155  if (spelldata[bs].sType == STYPE_MAGIC)
1157 }
1158 
1159 void GetStaffPower(int i, int lvl, int bs, BOOL onlygood)
1160 {
1161  int l[256];
1162  char istr[128];
1163  int nl, j, preidx;
1164  BOOL addok;
1165  int tmp;
1166 
1167  tmp = random_(15, 10);
1168  preidx = -1;
1169  if (tmp == 0 || onlygood) {
1170  nl = 0;
1171  for (j = 0; PL_Prefix[j].PLPower != -1; j++) {
1172  if (PL_Prefix[j].PLIType & PLT_STAFF && PL_Prefix[j].PLMinLvl <= lvl) {
1173  addok = TRUE;
1174  if (onlygood && !PL_Prefix[j].PLOk)
1175  addok = FALSE;
1176  if (addok) {
1177  l[nl] = j;
1178  nl++;
1179  if (PL_Prefix[j].PLDouble) {
1180  l[nl] = j;
1181  nl++;
1182  }
1183  }
1184  }
1185  }
1186  if (nl != 0) {
1187  preidx = l[random_(16, nl)];
1188  sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
1189  strcpy(item[i]._iIName, istr);
1191  SaveItemPower(
1192  i,
1193  PL_Prefix[preidx].PLPower,
1194  PL_Prefix[preidx].PLParam1,
1195  PL_Prefix[preidx].PLParam2,
1196  PL_Prefix[preidx].PLMinVal,
1197  PL_Prefix[preidx].PLMaxVal,
1198  PL_Prefix[preidx].PLMultVal);
1199  item[i]._iPrePower = PL_Prefix[preidx].PLPower;
1200  }
1201  }
1202  if (!control_WriteStringToBuffer((BYTE *)item[i]._iIName)) {
1203  strcpy(item[i]._iIName, AllItemsList[item[i].IDidx].iSName);
1204  if (preidx != -1) {
1205  sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
1206  strcpy(item[i]._iIName, istr);
1207  }
1208  sprintf(istr, "%s of %s", item[i]._iIName, spelldata[bs].sNameText);
1209  strcpy(item[i]._iIName, istr);
1210  if (item[i]._iMagical == ITEM_QUALITY_NORMAL)
1211  strcpy(item[i]._iName, item[i]._iIName);
1212  }
1213  CalcItemValue(i);
1214 }
1215 
1216 void GetStaffSpell(int i, int lvl, BOOL onlygood)
1217 {
1218  int l, rv, s, minc, maxc, v, bs;
1219  char istr[64];
1220 
1221  if (!random_(17, 4)) {
1222  GetItemPower(i, lvl >> 1, lvl, PLT_STAFF, onlygood);
1223  } else {
1224  l = lvl >> 1;
1225  if (l == 0)
1226  l = 1;
1227  rv = random_(18, MAX_SPELLS) + 1;
1228 #ifdef SPAWN
1229  if (lvl > 10)
1230  lvl = 10;
1231 #endif
1232  s = 1;
1233  while (rv > 0) {
1234  if (spelldata[s].sStaffLvl != -1 && l >= spelldata[s].sStaffLvl) {
1235  rv--;
1236  bs = s;
1237  }
1238  s++;
1239  if (gbMaxPlayers == 1 && s == SPL_RESURRECT)
1240  s = SPL_TELEKINESIS;
1241  if (gbMaxPlayers == 1 && s == SPL_HEALOTHER)
1242  s = SPL_FLARE;
1243  if (s == MAX_SPELLS)
1244  s = 1;
1245  }
1246  sprintf(istr, "%s of %s", item[i]._iName, spelldata[bs].sNameText);
1247  if (!control_WriteStringToBuffer((BYTE *)istr))
1248  sprintf(istr, "Staff of %s", spelldata[bs].sNameText);
1249  strcpy(item[i]._iName, istr);
1250  strcpy(item[i]._iIName, istr);
1251 
1252  minc = spelldata[bs].sStaffMin;
1253  maxc = spelldata[bs].sStaffMax - minc + 1;
1254  item[i]._iSpell = bs;
1255  item[i]._iCharges = minc + random_(19, maxc);
1256  item[i]._iMaxCharges = item[i]._iCharges;
1257 
1258  item[i]._iMinMag = spelldata[bs].sMinInt;
1259  v = item[i]._iCharges * spelldata[bs].sStaffCost / 5;
1260  item[i]._ivalue += v;
1261  item[i]._iIvalue += v;
1262  GetStaffPower(i, lvl, bs, onlygood);
1263  }
1264 }
1265 
1266 void GetItemAttrs(int i, int idata, int lvl)
1267 {
1268  int rndv;
1269 
1270  item[i]._itype = AllItemsList[idata].itype;
1271  item[i]._iCurs = AllItemsList[idata].iCurs;
1272  strcpy(item[i]._iName, AllItemsList[idata].iName);
1273  strcpy(item[i]._iIName, AllItemsList[idata].iName);
1274  item[i]._iLoc = AllItemsList[idata].iLoc;
1275  item[i]._iClass = AllItemsList[idata].iClass;
1276  item[i]._iMinDam = AllItemsList[idata].iMinDam;
1277  item[i]._iMaxDam = AllItemsList[idata].iMaxDam;
1278  item[i]._iAC = AllItemsList[idata].iMinAC + random_(20, AllItemsList[idata].iMaxAC - AllItemsList[idata].iMinAC + 1);
1279  item[i]._iFlags = AllItemsList[idata].iFlags;
1280  item[i]._iMiscId = AllItemsList[idata].iMiscId;
1281  item[i]._iSpell = AllItemsList[idata].iSpell;
1283  item[i]._ivalue = AllItemsList[idata].iValue;
1284  item[i]._iIvalue = AllItemsList[idata].iValue;
1285  item[i]._iVAdd1 = 0;
1286  item[i]._iVMult1 = 0;
1287  item[i]._iVAdd2 = 0;
1288  item[i]._iVMult2 = 0;
1289  item[i]._iPLDam = 0;
1290  item[i]._iPLToHit = 0;
1291  item[i]._iPLAC = 0;
1292  item[i]._iPLStr = 0;
1293  item[i]._iPLMag = 0;
1294  item[i]._iPLDex = 0;
1295  item[i]._iPLVit = 0;
1296  item[i]._iCharges = 0;
1297  item[i]._iMaxCharges = 0;
1299  item[i]._iMaxDur = AllItemsList[idata].iDurability;
1300  item[i]._iMinStr = AllItemsList[idata].iMinStr;
1301  item[i]._iMinMag = AllItemsList[idata].iMinMag;
1302  item[i]._iMinDex = AllItemsList[idata].iMinDex;
1303  item[i]._iPLFR = 0;
1304  item[i]._iPLLR = 0;
1305  item[i]._iPLMR = 0;
1306  item[i].IDidx = idata;
1307  item[i]._iPLDamMod = 0;
1308  item[i]._iPLGetHit = 0;
1309  item[i]._iPLLight = 0;
1310  item[i]._iSplLvlAdd = 0;
1311  item[i]._iRequest = FALSE;
1312  item[i]._iFMinDam = 0;
1313  item[i]._iFMaxDam = 0;
1314  item[i]._iLMinDam = 0;
1315  item[i]._iLMaxDam = 0;
1316  item[i]._iPLEnAc = 0;
1317  item[i]._iPLMana = 0;
1318  item[i]._iPLHP = 0;
1319  item[i]._iPrePower = -1;
1320  item[i]._iSufPower = -1;
1321 
1322  if (item[i]._iMiscId == IMISC_BOOK)
1323  GetBookSpell(i, lvl);
1324 
1325  if (item[i]._itype == ITYPE_GOLD) {
1326  if (gnDifficulty == DIFF_NORMAL)
1327  rndv = 5 * currlevel + random_(21, 10 * currlevel);
1329  rndv = 5 * (currlevel + 16) + random_(21, 10 * (currlevel + 16));
1330  if (gnDifficulty == DIFF_HELL)
1331  rndv = 5 * (currlevel + 32) + random_(21, 10 * (currlevel + 32));
1332  if (leveltype == DTYPE_HELL)
1333  rndv += rndv >> 3;
1334  if (rndv > GOLD_MAX_LIMIT)
1335  rndv = GOLD_MAX_LIMIT;
1336 
1337  item[i]._ivalue = rndv;
1338 
1339  if (rndv >= GOLD_MEDIUM_LIMIT)
1341  else
1342  item[i]._iCurs = (rndv > GOLD_SMALL_LIMIT) + 4;
1343  }
1344 }
1345 
1346 int RndPL(int param1, int param2)
1347 {
1348  return param1 + random_(22, param2 - param1 + 1);
1349 }
1350 
1351 int PLVal(int pv, int p1, int p2, int minv, int maxv)
1352 {
1353  if (p1 == p2)
1354  return minv;
1355  if (minv == maxv)
1356  return minv;
1357  return minv + (maxv - minv) * (100 * (pv - p1) / (p2 - p1)) / 100;
1358 }
1359 
1360 void SaveItemPower(int i, int power, int param1, int param2, int minval, int maxval, int multval)
1361 {
1362  int r, r2;
1363 
1364  r = RndPL(param1, param2);
1365  switch (power) {
1366  case IPL_TOHIT:
1367  item[i]._iPLToHit += r;
1368  break;
1369  case IPL_TOHIT_CURSE:
1370  item[i]._iPLToHit -= r;
1371  break;
1372  case IPL_DAMP:
1373  item[i]._iPLDam += r;
1374  break;
1375  case IPL_DAMP_CURSE:
1376  item[i]._iPLDam -= r;
1377  break;
1378  case IPL_TOHIT_DAMP:
1379  r = RndPL(param1, param2);
1380  item[i]._iPLDam += r;
1381  if (param1 == 20)
1382  r2 = RndPL(1, 5);
1383  if (param1 == 36)
1384  r2 = RndPL(6, 10);
1385  if (param1 == 51)
1386  r2 = RndPL(11, 15);
1387  if (param1 == 66)
1388  r2 = RndPL(16, 20);
1389  if (param1 == 81)
1390  r2 = RndPL(21, 30);
1391  if (param1 == 96)
1392  r2 = RndPL(31, 40);
1393  if (param1 == 111)
1394  r2 = RndPL(41, 50);
1395  if (param1 == 126)
1396  r2 = RndPL(51, 75);
1397  if (param1 == 151)
1398  r2 = RndPL(76, 100);
1399  item[i]._iPLToHit += r2;
1400  break;
1401  case IPL_TOHIT_DAMP_CURSE:
1402  item[i]._iPLDam -= r;
1403  if (param1 == 25)
1404  r2 = RndPL(1, 5);
1405  if (param1 == 50)
1406  r2 = RndPL(6, 10);
1407  item[i]._iPLToHit -= r2;
1408  break;
1409  case IPL_ACP:
1410  item[i]._iPLAC += r;
1411  break;
1412  case IPL_ACP_CURSE:
1413  item[i]._iPLAC -= r;
1414  break;
1415  case IPL_SETAC:
1416  item[i]._iAC = r;
1417  break;
1418  case IPL_AC_CURSE:
1419  item[i]._iAC -= r;
1420  break;
1421  case IPL_FIRERES:
1422  item[i]._iPLFR += r;
1423  break;
1424  case IPL_LIGHTRES:
1425  item[i]._iPLLR += r;
1426  break;
1427  case IPL_MAGICRES:
1428  item[i]._iPLMR += r;
1429  break;
1430  case IPL_ALLRES:
1431  item[i]._iPLFR += r;
1432  item[i]._iPLLR += r;
1433  item[i]._iPLMR += r;
1434  if (item[i]._iPLFR < 0)
1435  item[i]._iPLFR = 0;
1436  if (item[i]._iPLLR < 0)
1437  item[i]._iPLLR = 0;
1438  if (item[i]._iPLMR < 0)
1439  item[i]._iPLMR = 0;
1440  break;
1441  case IPL_SPLLVLADD:
1442  item[i]._iSplLvlAdd = r;
1443  break;
1444  case IPL_CHARGES:
1445  item[i]._iCharges *= param1;
1446  item[i]._iMaxCharges = item[i]._iCharges;
1447  break;
1448  case IPL_SPELL:
1449  item[i]._iSpell = param1;
1450  item[i]._iCharges = param1;
1451  item[i]._iMaxCharges = param2;
1452  break;
1453  case IPL_FIREDAM:
1454  item[i]._iFlags |= ISPL_FIREDAM;
1455  item[i]._iFMinDam = param1;
1456  item[i]._iFMaxDam = param2;
1457  break;
1458  case IPL_LIGHTDAM:
1459  item[i]._iFlags |= ISPL_LIGHTDAM;
1460  item[i]._iLMinDam = param1;
1461  item[i]._iLMaxDam = param2;
1462  break;
1463  case IPL_STR:
1464  item[i]._iPLStr += r;
1465  break;
1466  case IPL_STR_CURSE:
1467  item[i]._iPLStr -= r;
1468  break;
1469  case IPL_MAG:
1470  item[i]._iPLMag += r;
1471  break;
1472  case IPL_MAG_CURSE:
1473  item[i]._iPLMag -= r;
1474  break;
1475  case IPL_DEX:
1476  item[i]._iPLDex += r;
1477  break;
1478  case IPL_DEX_CURSE:
1479  item[i]._iPLDex -= r;
1480  break;
1481  case IPL_VIT:
1482  item[i]._iPLVit += r;
1483  break;
1484  case IPL_VIT_CURSE:
1485  item[i]._iPLVit -= r;
1486  break;
1487  case IPL_ATTRIBS:
1488  item[i]._iPLStr += r;
1489  item[i]._iPLMag += r;
1490  item[i]._iPLDex += r;
1491  item[i]._iPLVit += r;
1492  break;
1493  case IPL_ATTRIBS_CURSE:
1494  item[i]._iPLStr -= r;
1495  item[i]._iPLMag -= r;
1496  item[i]._iPLDex -= r;
1497  item[i]._iPLVit -= r;
1498  break;
1499  case IPL_GETHIT_CURSE:
1500  item[i]._iPLGetHit += r;
1501  break;
1502  case IPL_GETHIT:
1503  item[i]._iPLGetHit -= r;
1504  break;
1505  case IPL_LIFE:
1506  item[i]._iPLHP += r << 6;
1507  break;
1508  case IPL_LIFE_CURSE:
1509  item[i]._iPLHP -= r << 6;
1510  break;
1511  case IPL_MANA:
1512  item[i]._iPLMana += r << 6;
1513  drawmanaflag = TRUE;
1514  break;
1515  case IPL_MANA_CURSE:
1516  item[i]._iPLMana -= r << 6;
1517  drawmanaflag = TRUE;
1518  break;
1519  case IPL_DUR:
1520  r2 = r * item[i]._iMaxDur / 100;
1521  item[i]._iMaxDur += r2;
1522  item[i]._iDurability += r2;
1523  break;
1524  case IPL_DUR_CURSE:
1525  item[i]._iMaxDur -= r * item[i]._iMaxDur / 100;
1526  if (item[i]._iMaxDur < 1)
1527  item[i]._iMaxDur = 1;
1528  item[i]._iDurability = item[i]._iMaxDur;
1529  break;
1530  case IPL_INDESTRUCTIBLE:
1533  break;
1534  case IPL_LIGHT:
1535  item[i]._iPLLight += param1;
1536  break;
1537  case IPL_LIGHT_CURSE:
1538  item[i]._iPLLight -= param1;
1539  break;
1540  case IPL_FIRE_ARROWS:
1542  item[i]._iFMinDam = param1;
1543  item[i]._iFMaxDam = param2;
1544  break;
1545  case IPL_LIGHT_ARROWS:
1547  item[i]._iLMinDam = param1;
1548  item[i]._iLMaxDam = param2;
1549  break;
1550  case IPL_THORNS:
1551  item[i]._iFlags |= ISPL_THORNS;
1552  break;
1553  case IPL_NOMANA:
1554  item[i]._iFlags |= ISPL_NOMANA;
1555  drawmanaflag = TRUE;
1556  break;
1557  case IPL_NOHEALPLR:
1558  item[i]._iFlags |= ISPL_NOHEALPLR;
1559  break;
1560  case IPL_ABSHALFTRAP:
1562  break;
1563  case IPL_KNOCKBACK:
1564  item[i]._iFlags |= ISPL_KNOCKBACK;
1565  break;
1566  case IPL_3XDAMVDEM:
1567  item[i]._iFlags |= ISPL_3XDAMVDEM;
1568  break;
1569  case IPL_ALLRESZERO:
1571  break;
1572  case IPL_NOHEALMON:
1573  item[i]._iFlags |= ISPL_NOHEALMON;
1574  break;
1575  case IPL_STEALMANA:
1576  if (param1 == 3)
1578  if (param1 == 5)
1580  drawmanaflag = TRUE;
1581  break;
1582  case IPL_STEALLIFE:
1583  if (param1 == 3)
1585  if (param1 == 5)
1587  drawhpflag = TRUE;
1588  break;
1589  case IPL_TARGAC:
1590  item[i]._iPLEnAc += r;
1591  break;
1592  case IPL_FASTATTACK:
1593  if (param1 == 1)
1595  if (param1 == 2)
1597  if (param1 == 3)
1599  if (param1 == 4)
1601  break;
1602  case IPL_FASTRECOVER:
1603  if (param1 == 1)
1605  if (param1 == 2)
1607  if (param1 == 3)
1609  break;
1610  case IPL_FASTBLOCK:
1611  item[i]._iFlags |= ISPL_FASTBLOCK;
1612  break;
1613  case IPL_DAMMOD:
1614  item[i]._iPLDamMod += r;
1615  break;
1616  case IPL_RNDARROWVEL:
1618  break;
1619  case IPL_SETDAM:
1620  item[i]._iMinDam = param1;
1621  item[i]._iMaxDam = param2;
1622  break;
1623  case IPL_SETDUR:
1624  item[i]._iDurability = param1;
1625  item[i]._iMaxDur = param1;
1626  break;
1627  case IPL_FASTSWING:
1629  break;
1630  case IPL_ONEHAND:
1631  item[i]._iLoc = ILOC_ONEHAND;
1632  break;
1633  case IPL_DRAINLIFE:
1634  item[i]._iFlags |= ISPL_DRAINLIFE;
1635  break;
1636  case IPL_RNDSTEALLIFE:
1638  break;
1639  case IPL_INFRAVISION:
1641  break;
1642  case IPL_NOMINSTR:
1643  item[i]._iMinStr = 0;
1644  break;
1645  case IPL_INVCURS:
1646  item[i]._iCurs = param1;
1647  break;
1648  case IPL_ADDACLIFE:
1649  item[i]._iPLHP = (plr[myplr]._pIBonusAC + plr[myplr]._pIAC + plr[myplr]._pDexterity / 5) << 6;
1650  break;
1651  case IPL_ADDMANAAC:
1652  item[i]._iAC += (plr[myplr]._pMaxManaBase >> 6) / 10;
1653  break;
1654  case IPL_FIRERESCLVL:
1655  item[i]._iPLFR = 30 - plr[myplr]._pLevel;
1656  if (item[i]._iPLFR < 0)
1657  item[i]._iPLFR = 0;
1658  break;
1659  }
1660  if (item[i]._iVAdd1 || item[i]._iVMult1) {
1661  item[i]._iVAdd2 = PLVal(r, param1, param2, minval, maxval);
1662  item[i]._iVMult2 = multval;
1663  } else {
1664  item[i]._iVAdd1 = PLVal(r, param1, param2, minval, maxval);
1665  item[i]._iVMult1 = multval;
1666  }
1667 }
1668 
1669 void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
1670 {
1671  int pre, post, nt, nl, j, preidx, sufidx;
1672  int l[256];
1673  char istr[128];
1674  BYTE goe;
1675 
1676  pre = random_(23, 4);
1677  post = random_(23, 3);
1678  if (pre != 0 && post == 0) {
1679  if (random_(23, 2))
1680  post = 1;
1681  else
1682  pre = 0;
1683  }
1684  preidx = -1;
1685  sufidx = -1;
1686  goe = 0;
1687  if (!onlygood && random_(0, 3))
1688  onlygood = TRUE;
1689  if (!pre) {
1690  nt = 0;
1691  for (j = 0; PL_Prefix[j].PLPower != -1; j++) {
1692  if (flgs & PL_Prefix[j].PLIType) {
1693  if (PL_Prefix[j].PLMinLvl >= minlvl && PL_Prefix[j].PLMinLvl <= maxlvl && (!onlygood || PL_Prefix[j].PLOk) && (flgs != 256 || PL_Prefix[j].PLPower != 15)) {
1694  l[nt] = j;
1695  nt++;
1696  if (PL_Prefix[j].PLDouble) {
1697  l[nt] = j;
1698  nt++;
1699  }
1700  }
1701  }
1702  }
1703  if (nt) {
1704  preidx = l[random_(23, nt)];
1705  sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
1706  strcpy(item[i]._iIName, istr);
1708  SaveItemPower(
1709  i,
1710  PL_Prefix[preidx].PLPower,
1711  PL_Prefix[preidx].PLParam1,
1712  PL_Prefix[preidx].PLParam2,
1713  PL_Prefix[preidx].PLMinVal,
1714  PL_Prefix[preidx].PLMaxVal,
1715  PL_Prefix[preidx].PLMultVal);
1716  item[i]._iPrePower = PL_Prefix[preidx].PLPower;
1717  goe = PL_Prefix[preidx].PLGOE;
1718  }
1719  }
1720  if (post != 0) {
1721  nl = 0;
1722  for (j = 0; PL_Suffix[j].PLPower != -1; j++) {
1723  if (PL_Suffix[j].PLIType & flgs
1724  && PL_Suffix[j].PLMinLvl >= minlvl && PL_Suffix[j].PLMinLvl <= maxlvl
1725  && (goe | PL_Suffix[j].PLGOE) != 0x11
1726  && (!onlygood || PL_Suffix[j].PLOk)) {
1727  l[nl] = j;
1728  nl++;
1729  }
1730  }
1731  if (nl) {
1732  sufidx = l[random_(23, nl)];
1733  sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName);
1734  strcpy(item[i]._iIName, istr);
1736  SaveItemPower(
1737  i,
1738  PL_Suffix[sufidx].PLPower,
1739  PL_Suffix[sufidx].PLParam1,
1740  PL_Suffix[sufidx].PLParam2,
1741  PL_Suffix[sufidx].PLMinVal,
1742  PL_Suffix[sufidx].PLMaxVal,
1743  PL_Suffix[sufidx].PLMultVal);
1744  item[i]._iSufPower = PL_Suffix[sufidx].PLPower;
1745  }
1746  }
1747  if (!control_WriteStringToBuffer((BYTE *)item[i]._iIName)) {
1748  strcpy(item[i]._iIName, AllItemsList[item[i].IDidx].iSName);
1749  if (preidx != -1) {
1750  sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
1751  strcpy(item[i]._iIName, istr);
1752  }
1753  if (sufidx != -1) {
1754  sprintf(istr, "%s of %s", item[i]._iIName, PL_Suffix[sufidx].PLName);
1755  strcpy(item[i]._iIName, istr);
1756  }
1757  }
1758  if (preidx != -1 || sufidx != -1)
1759  CalcItemValue(i);
1760 }
1761 
1762 void GetItemBonus(int i, int idata, int minlvl, int maxlvl, BOOL onlygood)
1763 {
1764  if (item[i]._iClass != ICLASS_GOLD) {
1765  if (minlvl > 25)
1766  minlvl = 25;
1767 
1768  switch (item[i]._itype) {
1769  case ITYPE_SWORD:
1770  case ITYPE_AXE:
1771  case ITYPE_MACE:
1772  GetItemPower(i, minlvl, maxlvl, PLT_WEAP, onlygood);
1773  break;
1774  case ITYPE_BOW:
1775  GetItemPower(i, minlvl, maxlvl, PLT_BOW, onlygood);
1776  break;
1777  case ITYPE_SHIELD:
1778  GetItemPower(i, minlvl, maxlvl, PLT_SHLD, onlygood);
1779  break;
1780  case ITYPE_LARMOR:
1781  case ITYPE_HELM:
1782  case ITYPE_MARMOR:
1783  case ITYPE_HARMOR:
1784  GetItemPower(i, minlvl, maxlvl, PLT_ARMO, onlygood);
1785  break;
1786  case ITYPE_STAFF:
1787  GetStaffSpell(i, maxlvl, onlygood);
1788  break;
1789  case ITYPE_RING:
1790  case ITYPE_AMULET:
1791  GetItemPower(i, minlvl, maxlvl, PLT_MISC, onlygood);
1792  break;
1793  }
1794  }
1795 }
1796 
1797 void SetupItem(int i)
1798 {
1799  int it;
1800 
1801  it = ItemCAnimTbl[item[i]._iCurs];
1802  item[i]._iAnimData = itemanims[it];
1803  item[i]._iAnimLen = ItemAnimLs[it];
1804  item[i]._iAnimWidth = 96;
1805  item[i]._iAnimWidth2 = 16;
1806  item[i]._iIdentified = FALSE;
1807  item[i]._iPostDraw = FALSE;
1808 
1809  if (!plr[myplr].pLvlLoad) {
1810  item[i]._iAnimFrame = 1;
1811  item[i]._iAnimFlag = TRUE;
1812  item[i]._iSelFlag = 0;
1813  } else {
1814  item[i]._iAnimFrame = item[i]._iAnimLen;
1815  item[i]._iAnimFlag = FALSE;
1816  item[i]._iSelFlag = 1;
1817  }
1818 }
1819 
1820 int RndItem(int m)
1821 {
1822  int i, ri;
1823  int ril[512];
1824 
1825  if ((monster[m].MData->mTreasure & 0x8000) != 0)
1826  return -1 - (monster[m].MData->mTreasure & 0xFFF);
1827 
1828  if (monster[m].MData->mTreasure & 0x4000)
1829  return 0;
1830 
1831  if (random_(24, 100) > 40)
1832  return 0;
1833 
1834  if (random_(24, 100) > 25)
1835  return 1;
1836 
1837  ri = 0;
1838  for (i = 0; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
1839  if (AllItemsList[i].iRnd == 2 && monster[m].mLevel >= AllItemsList[i].iMinMLvl) {
1840  ril[ri] = i;
1841  ri++;
1842  }
1843  if (AllItemsList[i].iRnd && monster[m].mLevel >= AllItemsList[i].iMinMLvl) {
1844  ril[ri] = i;
1845  ri++;
1846  }
1847  if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1)
1848  ri--;
1849  if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1)
1850  ri--;
1851  }
1852 
1853  return ril[random_(24, ri)] + 1;
1854 }
1855 
1856 int RndUItem(int m)
1857 {
1858  int i, ri;
1859  int ril[512];
1860  BOOL okflag;
1861 
1862  if (m != -1 && (monster[m].MData->mTreasure & 0x8000) != 0 && gbMaxPlayers == 1)
1863  return -1 - (monster[m].MData->mTreasure & 0xFFF);
1864 
1865  ri = 0;
1866  for (i = 0; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
1867  okflag = TRUE;
1868  if (!AllItemsList[i].iRnd)
1869  okflag = FALSE;
1870  if (m != -1) {
1871  if (monster[m].mLevel < AllItemsList[i].iMinMLvl)
1872  okflag = FALSE;
1873  } else {
1874  if (2 * currlevel < AllItemsList[i].iMinMLvl)
1875  okflag = FALSE;
1876  }
1877  if (AllItemsList[i].itype == ITYPE_MISC)
1878  okflag = FALSE;
1879  if (AllItemsList[i].itype == ITYPE_GOLD)
1880  okflag = FALSE;
1881  if (AllItemsList[i].itype == ITYPE_MEAT)
1882  okflag = FALSE;
1883  if (AllItemsList[i].iMiscId == IMISC_BOOK)
1884  okflag = TRUE;
1885  if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1)
1886  okflag = FALSE;
1887  if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1)
1888  okflag = FALSE;
1889  if (okflag) {
1890  ril[ri] = i;
1891  ri++;
1892  }
1893  }
1894 
1895  return ril[random_(25, ri)];
1896 }
1897 
1899 {
1900  int i, ri;
1901  int ril[512];
1902 
1903  if (random_(26, 100) > 25)
1904  return 0;
1905 
1906  ri = 0;
1907  for (i = 0; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
1908  if (AllItemsList[i].iRnd && 2 * currlevel >= AllItemsList[i].iMinMLvl) {
1909  ril[ri] = i;
1910  ri++;
1911  }
1912  if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1)
1913  ri--;
1914  if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1)
1915  ri--;
1916  }
1917 
1918  return ril[random_(26, ri)];
1919 }
1920 
1921 int RndTypeItems(int itype, int imid)
1922 {
1923  int i, ri;
1924  BOOL okflag;
1925  int ril[512];
1926 
1927  ri = 0;
1928  for (i = 0; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
1929  okflag = TRUE;
1930  if (!AllItemsList[i].iRnd)
1931  okflag = FALSE;
1932  if (currlevel << 1 < AllItemsList[i].iMinMLvl)
1933  okflag = FALSE;
1934  if (AllItemsList[i].itype != itype)
1935  okflag = FALSE;
1936  if (imid != -1 && AllItemsList[i].iMiscId != imid)
1937  okflag = FALSE;
1938  if (okflag) {
1939  ril[ri] = i;
1940  ri++;
1941  }
1942  }
1943 
1944  return ril[random_(27, ri)];
1945 }
1946 
1947 int CheckUnique(int i, int lvl, int uper, BOOL recreate)
1948 {
1949  int j, idata, numu;
1950  BOOLEAN uok[128];
1951 
1952  if (random_(28, 100) > uper)
1953  return -1;
1954 
1955  numu = 0;
1956  memset(uok, 0, sizeof(uok));
1957  for (j = 0; UniqueItemList[j].UIItemId != UITYPE_INVALID; j++) {
1958  if (UniqueItemList[j].UIItemId == AllItemsList[item[i].IDidx].iItemId
1959  && lvl >= UniqueItemList[j].UIMinLvl
1960  && (recreate || !UniqueItemFlag[j] || gbMaxPlayers != 1)) {
1961  uok[j] = TRUE;
1962  numu++;
1963  }
1964  }
1965 
1966  if (!numu)
1967  return -1;
1968 
1969  random_(29, 10);
1970  idata = 0;
1971  while (numu > 0) {
1972  if (uok[idata])
1973  numu--;
1974  if (numu > 0) {
1975  idata++;
1976  if (idata == 128)
1977  idata = 0;
1978  }
1979  }
1980 
1981  return idata;
1982 }
1983 
1984 void GetUniqueItem(int i, int uid)
1985 {
1986  UniqueItemFlag[uid] = TRUE;
1987  SaveItemPower(i, UniqueItemList[uid].UIPower1, UniqueItemList[uid].UIParam1, UniqueItemList[uid].UIParam2, 0, 0, 1);
1988 
1989  if (UniqueItemList[uid].UINumPL > 1)
1990  SaveItemPower(i, UniqueItemList[uid].UIPower2, UniqueItemList[uid].UIParam3, UniqueItemList[uid].UIParam4, 0, 0, 1);
1991  if (UniqueItemList[uid].UINumPL > 2)
1992  SaveItemPower(i, UniqueItemList[uid].UIPower3, UniqueItemList[uid].UIParam5, UniqueItemList[uid].UIParam6, 0, 0, 1);
1993  if (UniqueItemList[uid].UINumPL > 3)
1994  SaveItemPower(i, UniqueItemList[uid].UIPower4, UniqueItemList[uid].UIParam7, UniqueItemList[uid].UIParam8, 0, 0, 1);
1995  if (UniqueItemList[uid].UINumPL > 4)
1996  SaveItemPower(i, UniqueItemList[uid].UIPower5, UniqueItemList[uid].UIParam9, UniqueItemList[uid].UIParam10, 0, 0, 1);
1997  if (UniqueItemList[uid].UINumPL > 5)
1998  SaveItemPower(i, UniqueItemList[uid].UIPower6, UniqueItemList[uid].UIParam11, UniqueItemList[uid].UIParam12, 0, 0, 1);
1999 
2000  strcpy(item[i]._iIName, UniqueItemList[uid].UIName);
2001  item[i]._iIvalue = UniqueItemList[uid].UIValue;
2002 
2003  if (item[i]._iMiscId == IMISC_UNIQUE)
2004  item[i]._iSeed = uid;
2005 
2006  item[i]._iUid = uid;
2008  item[i]._iCreateInfo |= 0x0200;
2009 }
2010 
2011 void SpawnUnique(int uid, int x, int y)
2012 {
2013  int ii, itype;
2014 
2015  if (numitems >= MAXITEMS)
2016  return;
2017 
2018  ii = itemavail[0];
2019  GetSuperItemSpace(x, y, ii);
2020  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
2021  itemactive[numitems] = ii;
2022 
2023  itype = 0;
2024  while (AllItemsList[itype].iItemId != UniqueItemList[uid].UIItemId) {
2025  itype++;
2026  }
2027 
2028  GetItemAttrs(ii, itype, currlevel);
2029  GetUniqueItem(ii, uid);
2030  SetupItem(ii);
2031  numitems++;
2032 }
2033 
2034 void ItemRndDur(int ii)
2035 {
2036  if (item[ii]._iDurability && item[ii]._iDurability != DUR_INDESTRUCTIBLE)
2037  item[ii]._iDurability = random_(0, item[ii]._iMaxDur >> 1) + (item[ii]._iMaxDur >> 2) + 1;
2038 }
2039 
2040 void SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood, BOOL recreate, BOOL pregen)
2041 {
2042  int iblvl, uid;
2043 
2044  item[ii]._iSeed = iseed;
2045  SetRndSeed(iseed);
2046  GetItemAttrs(ii, idx, lvl >> 1);
2047  item[ii]._iCreateInfo = lvl;
2048 
2049  if (pregen)
2050  item[ii]._iCreateInfo = lvl | 0x8000;
2051  if (onlygood)
2052  item[ii]._iCreateInfo |= 0x40;
2053 
2054  if (uper == 15)
2055  item[ii]._iCreateInfo |= 0x80;
2056  else if (uper == 1)
2057  item[ii]._iCreateInfo |= 0x0100;
2058 
2059  if (item[ii]._iMiscId != IMISC_UNIQUE) {
2060  iblvl = -1;
2061  if (random_(32, 100) <= 10 || random_(33, 100) <= lvl) {
2062  iblvl = lvl;
2063  }
2064  if (iblvl == -1 && item[ii]._iMiscId == IMISC_STAFF) {
2065  iblvl = lvl;
2066  }
2067  if (iblvl == -1 && item[ii]._iMiscId == IMISC_RING) {
2068  iblvl = lvl;
2069  }
2070  if (iblvl == -1 && item[ii]._iMiscId == IMISC_AMULET) {
2071  iblvl = lvl;
2072  }
2073  if (onlygood)
2074  iblvl = lvl;
2075  if (uper == 15)
2076  iblvl = lvl + 4;
2077  if (iblvl != -1) {
2078  uid = CheckUnique(ii, iblvl, uper, recreate);
2079  if (uid == UITYPE_INVALID) {
2080  GetItemBonus(ii, idx, iblvl >> 1, iblvl, onlygood);
2081  } else {
2082  GetUniqueItem(ii, uid);
2083  item[ii]._iCreateInfo |= 0x0200;
2084  }
2085  }
2086  if (item[ii]._iMagical != ITEM_QUALITY_UNIQUE)
2087  ItemRndDur(ii);
2088  } else {
2089  if (item[ii]._iLoc != ILOC_UNEQUIPABLE) {
2090  //uid = CheckUnique(ii, iblvl, uper, recreate);
2091  //if (uid != UITYPE_INVALID) {
2092  // GetUniqueItem(ii, uid);
2093  //}
2094  GetUniqueItem(ii, iseed); // BUG: the second argument to GetUniqueItem should be uid.
2095  }
2096  }
2097  SetupItem(ii);
2098 }
2099 
2100 void SpawnItem(int m, int x, int y, BOOL sendmsg)
2101 {
2102  int ii, onlygood, idx;
2103 
2104  if (monster[m]._uniqtype || ((monster[m].MData->mTreasure & 0x8000) && gbMaxPlayers != 1)) {
2105  idx = RndUItem(m);
2106  if (idx < 0) {
2107  SpawnUnique(-(idx + 1), x, y);
2108  return;
2109  }
2110  onlygood = 1;
2111  } else if (quests[Q_MUSHROOM]._qactive != QUEST_ACTIVE || quests[Q_MUSHROOM]._qvar1 != QS_MUSHGIVEN) {
2112  idx = RndItem(m);
2113  if (!idx)
2114  return;
2115  if (idx > 0) {
2116  idx--;
2117  onlygood = 0;
2118  } else {
2119  SpawnUnique(-(idx + 1), x, y);
2120  return;
2121  }
2122  } else {
2123  idx = IDI_BRAIN;
2125  }
2126 
2127  if (numitems < MAXITEMS) {
2128  ii = itemavail[0];
2129  GetSuperItemSpace(x, y, ii);
2130  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
2131  itemactive[numitems] = ii;
2132  if (monster[m]._uniqtype) {
2133  SetupAllItems(ii, idx, GetRndSeed(), monster[m].MData->mLevel, 15, onlygood, FALSE, FALSE);
2134  } else {
2135  SetupAllItems(ii, idx, GetRndSeed(), monster[m].MData->mLevel, 1, onlygood, FALSE, FALSE);
2136  }
2137  numitems++;
2138  if (sendmsg)
2139  NetSendCmdDItem(FALSE, ii);
2140  }
2141 }
2142 
2143 void CreateItem(int uid, int x, int y)
2144 {
2145  int ii, idx;
2146 
2147  if (numitems < MAXITEMS) {
2148  ii = itemavail[0];
2149  GetSuperItemSpace(x, y, ii);
2150  idx = 0;
2151  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
2152  itemactive[numitems] = ii;
2153 
2154  while (AllItemsList[idx].iItemId != UniqueItemList[uid].UIItemId) {
2155  idx++;
2156  }
2157 
2158  GetItemAttrs(ii, idx, currlevel);
2159  GetUniqueItem(ii, uid);
2160  SetupItem(ii);
2162  numitems++;
2163  }
2164 }
2165 
2166 void CreateRndItem(int x, int y, BOOL onlygood, BOOL sendmsg, BOOL delta)
2167 {
2168  int idx, ii;
2169 
2170  if (onlygood)
2171  idx = RndUItem(-1);
2172  else
2173  idx = RndAllItems();
2174 
2175  if (numitems < MAXITEMS) {
2176  ii = itemavail[0];
2177  GetSuperItemSpace(x, y, ii);
2178  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
2179  itemactive[numitems] = ii;
2180  SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, onlygood, FALSE, delta);
2181  if (sendmsg)
2182  NetSendCmdDItem(FALSE, ii);
2183  if (delta)
2184  DeltaAddItem(ii);
2185  numitems++;
2186  }
2187 }
2188 
2189 void SetupAllUseful(int ii, int iseed, int lvl)
2190 {
2191  int idx;
2192 
2193  item[ii]._iSeed = iseed;
2194  SetRndSeed(iseed);
2195 
2196  if (random_(34, 2))
2197  idx = IDI_HEAL;
2198  else
2199  idx = IDI_MANA;
2200 
2201  if (lvl > 1 && !random_(34, 3))
2202  idx = IDI_PORTAL;
2203 
2204  GetItemAttrs(ii, idx, lvl);
2205  item[ii]._iCreateInfo = lvl + 384;
2206  SetupItem(ii);
2207 }
2208 
2209 void CreateRndUseful(int pnum, int x, int y, BOOL sendmsg)
2210 {
2211  int ii;
2212 
2213  if (numitems < MAXITEMS) {
2214  ii = itemavail[0];
2215  GetSuperItemSpace(x, y, ii);
2216  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
2217  itemactive[numitems] = ii;
2219  if (sendmsg) {
2220  NetSendCmdDItem(FALSE, ii);
2221  }
2222  numitems++;
2223  }
2224 }
2225 
2226 void CreateTypeItem(int x, int y, BOOL onlygood, int itype, int imisc, BOOL sendmsg, BOOL delta)
2227 {
2228  int idx, ii;
2229 
2230  if (itype != ITYPE_GOLD)
2231  idx = RndTypeItems(itype, imisc);
2232  else
2233  idx = 0;
2234 
2235  if (numitems < MAXITEMS) {
2236  ii = itemavail[0];
2237  GetSuperItemSpace(x, y, ii);
2238  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
2239  itemactive[numitems] = ii;
2240  SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, onlygood, FALSE, delta);
2241 
2242  if (sendmsg)
2243  NetSendCmdDItem(FALSE, ii);
2244  if (delta)
2245  DeltaAddItem(ii);
2246 
2247  numitems++;
2248  }
2249 }
2250 
2251 void RecreateItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue)
2252 {
2253  int uper, onlygood, recreate;
2254  BOOL pregen;
2255 
2256  if (!idx) {
2257  SetPlrHandItem(&item[ii], IDI_GOLD);
2258  item[ii]._iSeed = iseed;
2259  item[ii]._iCreateInfo = icreateinfo;
2260  item[ii]._ivalue = ivalue;
2261  if (ivalue >= GOLD_MEDIUM_LIMIT)
2263  else if (ivalue <= GOLD_SMALL_LIMIT)
2265  else
2267  } else {
2268  if (!icreateinfo) {
2269  SetPlrHandItem(&item[ii], idx);
2270  SetPlrHandSeed(&item[ii], iseed);
2271  } else {
2272  if (icreateinfo & 0x7C00) {
2273  RecreateTownItem(ii, idx, icreateinfo, iseed, ivalue);
2274  } else if ((icreateinfo & 0x0180) == 0x0180) {
2275  SetupAllUseful(ii, iseed, icreateinfo & 0x3F);
2276  } else {
2277  uper = 0;
2278  onlygood = 0;
2279  recreate = 0;
2280  pregen = FALSE;
2281  if (icreateinfo & 0x0100)
2282  uper = 1;
2283  if (icreateinfo & 0x80)
2284  uper = 15;
2285  if (icreateinfo & 0x40)
2286  onlygood = 1;
2287  if (icreateinfo & 0x0200)
2288  recreate = 1;
2289  if (icreateinfo & 0x8000)
2290  pregen = TRUE;
2291  SetupAllItems(ii, idx, iseed, icreateinfo & 0x3F, uper, onlygood, recreate, pregen);
2292  }
2293  }
2294  }
2295 }
2296 
2297 void RecreateEar(int ii, WORD ic, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, int ibuff)
2298 {
2299  SetPlrHandItem(&item[ii], IDI_EAR);
2300  tempstr[0] = (ic >> 8) & 0x7F;
2301  tempstr[1] = ic & 0x7F;
2302  tempstr[2] = (iseed >> 24) & 0x7F;
2303  tempstr[3] = (iseed >> 16) & 0x7F;
2304  tempstr[4] = (iseed >> 8) & 0x7F;
2305  tempstr[5] = iseed & 0x7F;
2306  tempstr[6] = Id & 0x7F;
2307  tempstr[7] = dur & 0x7F;
2308  tempstr[8] = mdur & 0x7F;
2309  tempstr[9] = ch & 0x7F;
2310  tempstr[10] = mch & 0x7F;
2311  tempstr[11] = (ivalue >> 8) & 0x7F;
2312  tempstr[12] = (ibuff >> 24) & 0x7F;
2313  tempstr[13] = (ibuff >> 16) & 0x7F;
2314  tempstr[14] = (ibuff >> 8) & 0x7F;
2315  tempstr[15] = ibuff & 0x7F;
2316  tempstr[16] = '\0';
2317  sprintf(item[ii]._iName, "Ear of %s", tempstr);
2318  item[ii]._iCurs = ((ivalue >> 6) & 3) + 19;
2319  item[ii]._ivalue = ivalue & 0x3F;
2320  item[ii]._iCreateInfo = ic;
2321  item[ii]._iSeed = iseed;
2322 }
2323 
2324 void SpawnQuestItem(int itemid, int x, int y, int randarea, int selflag)
2325 {
2326  BOOL failed;
2327  int i, j, tries;
2328 
2329  if (randarea) {
2330  tries = 0;
2331  while (1) {
2332  tries++;
2333  if (tries > 1000 && randarea > 1)
2334  randarea--;
2335  x = random_(0, MAXDUNX);
2336  y = random_(0, MAXDUNY);
2337  failed = FALSE;
2338  for (i = 0; i < randarea && !failed; i++) {
2339  for (j = 0; j < randarea && !failed; j++) {
2340  failed = !ItemSpaceOk(i + x, j + y);
2341  }
2342  }
2343  if (!failed)
2344  break;
2345  }
2346  }
2347 
2348  if (numitems < MAXITEMS) {
2349  i = itemavail[0];
2350  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
2351  itemactive[numitems] = i;
2352  item[i]._ix = x;
2353  item[i]._iy = y;
2354  dItem[x][y] = i + 1;
2355  GetItemAttrs(i, itemid, currlevel);
2356  SetupItem(i);
2357  item[i]._iPostDraw = TRUE;
2358  if (selflag) {
2359  item[i]._iSelFlag = selflag;
2360  item[i]._iAnimFrame = item[i]._iAnimLen;
2361  item[i]._iAnimFlag = FALSE;
2362  }
2363  numitems++;
2364  }
2365 }
2366 
2368 {
2369  int i, ii;
2370  int xx, yy;
2371  int ostand;
2372 
2373  ostand = FALSE;
2374  for (i = 0; i < nobjects && !ostand; i++) {
2375  ii = objectactive[i];
2376  ostand = object[ii]._otype == OBJ_STAND;
2377  }
2378  if (ostand) {
2379  i = itemavail[0];
2380  itemavail[0] = itemavail[127 - numitems - 1];
2381  itemactive[numitems] = i;
2382  xx = object[ii]._ox;
2383  yy = object[ii]._oy;
2384  item[i]._ix = xx;
2385  item[i]._iy = yy;
2386  dItem[xx][item[i]._iy] = i + 1;
2388  SetupItem(i);
2389  item[i]._iSelFlag = 2;
2390  item[i]._iPostDraw = TRUE;
2391  item[i]._iAnimFrame = 11;
2392  numitems++;
2393  }
2394 }
2395 
2396 void RespawnItem(int i, BOOL FlipFlag)
2397 {
2398  int it;
2399 
2400  it = ItemCAnimTbl[item[i]._iCurs];
2401  item[i]._iAnimData = itemanims[it];
2402  item[i]._iAnimLen = ItemAnimLs[it];
2403  item[i]._iAnimWidth = 96;
2404  item[i]._iAnimWidth2 = 16;
2405  item[i]._iPostDraw = FALSE;
2406  item[i]._iRequest = FALSE;
2407  if (FlipFlag) {
2408  item[i]._iAnimFrame = 1;
2409  item[i]._iAnimFlag = TRUE;
2410  item[i]._iSelFlag = 0;
2411  } else {
2412  item[i]._iAnimFrame = item[i]._iAnimLen;
2413  item[i]._iAnimFlag = FALSE;
2414  item[i]._iSelFlag = 1;
2415  }
2416 
2417  if (item[i]._iCurs == ICURS_MAGIC_ROCK) {
2418  item[i]._iSelFlag = 1;
2419  PlaySfxLoc(ItemDropSnds[it], item[i]._ix, item[i]._iy);
2420  }
2421  if (item[i]._iCurs == ICURS_TAVERN_SIGN)
2422  item[i]._iSelFlag = 1;
2423  if (item[i]._iCurs == ICURS_ANVIL_OF_FURY)
2424  item[i]._iSelFlag = 1;
2425 }
2426 
2427 void DeleteItem(int ii, int i)
2428 {
2429  itemavail[MAXITEMS - numitems] = ii;
2430  numitems--;
2431  if (numitems > 0 && i != numitems)
2433 }
2434 
2436 {
2437  int idoppelx;
2438  ItemStruct *i;
2439 
2440  if (gbMaxPlayers != 1) {
2441  for (idoppelx = 16; idoppelx < 96; idoppelx++) {
2442  if (dItem[idoppelx][idoppely]) {
2443  i = &item[dItem[idoppelx][idoppely] - 1];
2444  if (i->_ix != idoppelx || i->_iy != idoppely)
2445  dItem[idoppelx][idoppely] = 0;
2446  }
2447  }
2448  idoppely++;
2449  if (idoppely == 96)
2450  idoppely = 16;
2451  }
2452 }
2453 
2455 {
2456  int i, ii;
2457 
2458  for (i = 0; i < numitems; i++) {
2459  ii = itemactive[i];
2460  if (item[ii]._iAnimFlag) {
2461  item[ii]._iAnimFrame++;
2462  if (item[ii]._iCurs == ICURS_MAGIC_ROCK) {
2463  if (item[ii]._iSelFlag == 1 && item[ii]._iAnimFrame == 11)
2464  item[ii]._iAnimFrame = 1;
2465  if (item[ii]._iSelFlag == 2 && item[ii]._iAnimFrame == 21)
2466  item[ii]._iAnimFrame = 11;
2467  } else {
2468  if (item[ii]._iAnimFrame == item[ii]._iAnimLen >> 1)
2469  PlaySfxLoc(ItemDropSnds[ItemCAnimTbl[item[ii]._iCurs]], item[ii]._ix, item[ii]._iy);
2470 
2471  if (item[ii]._iAnimFrame >= item[ii]._iAnimLen) {
2472  item[ii]._iAnimFrame = item[ii]._iAnimLen;
2473  item[ii]._iAnimFlag = FALSE;
2474  item[ii]._iSelFlag = 1;
2475  }
2476  }
2477  }
2478  }
2479  ItemDoppel();
2480 }
2481 
2483 {
2484  int i;
2485 
2486  for (i = 0; i < 35; i++) {
2487  MemFreeDbg(itemanims[i]);
2488  }
2489 }
2490 
2491 void GetItemFrm(int i)
2492 {
2494 }
2495 
2496 void GetItemStr(int i)
2497 {
2498  int nGold;
2499 
2500  if (item[i]._itype != ITYPE_GOLD) {
2501  if (item[i]._iIdentified)
2502  strcpy(infostr, item[i]._iIName);
2503  else
2504  strcpy(infostr, item[i]._iName);
2505 
2506  if (item[i]._iMagical == ITEM_QUALITY_MAGIC)
2507  infoclr = COL_BLUE;
2508  if (item[i]._iMagical == ITEM_QUALITY_UNIQUE)
2509  infoclr = COL_GOLD;
2510  } else {
2511  nGold = item[i]._ivalue;
2512  sprintf(infostr, "%i gold %s", nGold, get_pieces_str(nGold));
2513  }
2514 }
2515 
2516 void CheckIdentify(int pnum, int cii)
2517 {
2518  ItemStruct *pi;
2519 
2520  if (cii >= NUM_INVLOC)
2521  pi = &plr[pnum].InvList[cii - NUM_INVLOC];
2522  else
2523  pi = &plr[pnum].InvBody[cii];
2524 
2525  pi->_iIdentified = TRUE;
2526  CalcPlrInv(pnum, TRUE);
2527 
2528  if (pnum == myplr)
2530 }
2531 
2532 void DoRepair(int pnum, int cii)
2533 {
2534  PlayerStruct *p;
2535  ItemStruct *pi;
2536 
2537  p = &plr[pnum];
2538  PlaySfxLoc(IS_REPAIR, p->WorldX, p->WorldY);
2539 
2540  if (cii >= NUM_INVLOC) {
2541  pi = &p->InvList[cii - NUM_INVLOC];
2542  } else {
2543  pi = &p->InvBody[cii];
2544  }
2545 
2546  RepairItem(pi, p->_pLevel);
2547  CalcPlrInv(pnum, TRUE);
2548 
2549  if (pnum == myplr)
2551 }
2552 
2553 void RepairItem(ItemStruct *i, int lvl)
2554 {
2555  int rep, d;
2556 
2557  if (i->_iDurability == i->_iMaxDur) {
2558  return;
2559  }
2560 
2561  if (i->_iMaxDur <= 0) {
2562  i->_itype = ITYPE_NONE;
2563  return;
2564  }
2565 
2566  rep = 0;
2567  do {
2568  rep += lvl + random_(37, lvl);
2569  d = i->_iMaxDur / (lvl + 9);
2570  if (d < 1)
2571  d = 1;
2572  i->_iMaxDur = i->_iMaxDur - d;
2573  if (!i->_iMaxDur) {
2574  i->_itype = ITYPE_NONE;
2575  return;
2576  }
2577  } while (rep + i->_iDurability < i->_iMaxDur);
2578 
2579  i->_iDurability += rep;
2580  if (i->_iDurability > i->_iMaxDur)
2581  i->_iDurability = i->_iMaxDur;
2582 }
2583 
2584 void DoRecharge(int pnum, int cii)
2585 {
2586  PlayerStruct *p;
2587  ItemStruct *pi;
2588  int r;
2589 
2590  p = &plr[pnum];
2591  if (cii >= NUM_INVLOC) {
2592  pi = &p->InvList[cii - NUM_INVLOC];
2593  } else {
2594  pi = &p->InvBody[cii];
2595  }
2596  if (pi->_itype == ITYPE_STAFF && pi->_iSpell) {
2597  r = spelldata[pi->_iSpell].sBookLvl;
2598  r = random_(38, p->_pLevel / r) + 1;
2599  RechargeItem(pi, r);
2600  CalcPlrInv(pnum, TRUE);
2601  }
2602 
2603  if (pnum == myplr)
2605 }
2606 
2607 void RechargeItem(ItemStruct *i, int r)
2608 {
2609  while (i->_iCharges != i->_iMaxCharges) {
2610  i->_iMaxCharges--;
2611  if (i->_iMaxCharges == 0) {
2612  break;
2613  }
2614  i->_iCharges += r;
2615  if (i->_iCharges >= i->_iMaxCharges) {
2616  if (i->_iCharges > i->_iMaxCharges)
2617  i->_iCharges = i->_iMaxCharges;
2618  return;
2619  }
2620  }
2621 }
2622 
2623 void PrintItemOil(char IDidx)
2624 {
2625  switch (IDidx) {
2626  case IMISC_FULLHEAL:
2627  strcpy(tempstr, "fully recover life");
2628  AddPanelString(tempstr, TRUE);
2629  break;
2630  case IMISC_HEAL:
2631  strcpy(tempstr, "recover partial life");
2632  AddPanelString(tempstr, TRUE);
2633  break;
2634  case IMISC_OLDHEAL:
2635  strcpy(tempstr, "recover life");
2636  AddPanelString(tempstr, TRUE);
2637  break;
2638  case IMISC_DEADHEAL:
2639  strcpy(tempstr, "deadly heal");
2640  AddPanelString(tempstr, TRUE);
2641  break;
2642  case IMISC_MANA:
2643  strcpy(tempstr, "recover mana");
2644  AddPanelString(tempstr, TRUE);
2645  break;
2646  case IMISC_FULLMANA:
2647  strcpy(tempstr, "fully recover mana");
2648  AddPanelString(tempstr, TRUE);
2649  break;
2650  case IMISC_ELIXSTR:
2651  strcpy(tempstr, "increase strength");
2652  AddPanelString(tempstr, TRUE);
2653  break;
2654  case IMISC_ELIXMAG:
2655  strcpy(tempstr, "increase magic");
2656  AddPanelString(tempstr, TRUE);
2657  break;
2658  case IMISC_ELIXDEX:
2659  strcpy(tempstr, "increase dexterity");
2660  AddPanelString(tempstr, TRUE);
2661  break;
2662  case IMISC_ELIXVIT:
2663  strcpy(tempstr, "increase vitality");
2664  AddPanelString(tempstr, TRUE);
2665  break;
2666  case IMISC_ELIXWEAK:
2667  strcpy(tempstr, "decrease strength");
2668  AddPanelString(tempstr, TRUE);
2669  break;
2670  case IMISC_ELIXDIS:
2671  strcpy(tempstr, "decrease strength");
2672  AddPanelString(tempstr, TRUE);
2673  break;
2674  case IMISC_ELIXCLUM:
2675  strcpy(tempstr, "decrease dexterity");
2676  AddPanelString(tempstr, TRUE);
2677  break;
2678  case IMISC_ELIXSICK:
2679  strcpy(tempstr, "decrease vitality");
2680  AddPanelString(tempstr, TRUE);
2681  break;
2682  case IMISC_REJUV:
2683  strcpy(tempstr, "recover life and mana");
2684  AddPanelString(tempstr, TRUE);
2685  break;
2686  case IMISC_FULLREJUV:
2687  strcpy(tempstr, "fully recover life and mana");
2688  AddPanelString(tempstr, TRUE);
2689  break;
2690  }
2691 }
2692 
2693 void PrintItemPower(char plidx, ItemStruct *x)
2694 {
2695  switch (plidx) {
2696  case IPL_TOHIT:
2697  case IPL_TOHIT_CURSE:
2698  sprintf(tempstr, "chance to hit : %+i%%", x->_iPLToHit);
2699  break;
2700  case IPL_DAMP:
2701  case IPL_DAMP_CURSE:
2702  sprintf(tempstr, "%+i%% damage", x->_iPLDam);
2703  break;
2704  case IPL_TOHIT_DAMP:
2705  case IPL_TOHIT_DAMP_CURSE:
2706  sprintf(tempstr, "to hit: %+i%%, %+i%% damage", x->_iPLToHit, x->_iPLDam);
2707  break;
2708  case IPL_ACP:
2709  case IPL_ACP_CURSE:
2710  sprintf(tempstr, "%+i%% armor", x->_iPLAC);
2711  break;
2712  case IPL_SETAC:
2713  sprintf(tempstr, "armor class: %i", x->_iAC);
2714  break;
2715  case IPL_AC_CURSE:
2716  sprintf(tempstr, "armor class: %i", x->_iAC);
2717  break;
2718  case IPL_FIRERES:
2719  if (x->_iPLFR < 75)
2720  sprintf(tempstr, "Resist Fire : %+i%%", x->_iPLFR);
2721  if (x->_iPLFR >= 75)
2722  sprintf(tempstr, "Resist Fire : 75%% MAX");
2723  break;
2724  case IPL_LIGHTRES:
2725  if (x->_iPLLR < 75)
2726  sprintf(tempstr, "Resist Lightning : %+i%%", x->_iPLLR);
2727  if (x->_iPLLR >= 75)
2728  sprintf(tempstr, "Resist Lightning : 75%% MAX");
2729  break;
2730  case IPL_MAGICRES:
2731  if (x->_iPLMR < 75)
2732  sprintf(tempstr, "Resist Magic : %+i%%", x->_iPLMR);
2733  if (x->_iPLMR >= 75)
2734  sprintf(tempstr, "Resist Magic : 75%% MAX");
2735  break;
2736  case IPL_ALLRES:
2737  if (x->_iPLFR < 75)
2738  sprintf(tempstr, "Resist All : %+i%%", x->_iPLFR);
2739  if (x->_iPLFR >= 75)
2740  sprintf(tempstr, "Resist All : 75%% MAX");
2741  break;
2742  case IPL_SPLLVLADD:
2743  if (x->_iSplLvlAdd == 1)
2744  strcpy(tempstr, "spells are increased 1 level");
2745  if (x->_iSplLvlAdd == 2)
2746  strcpy(tempstr, "spells are increased 2 levels");
2747  if (x->_iSplLvlAdd < 1)
2748  strcpy(tempstr, "spells are decreased 1 level");
2749  break;
2750  case IPL_CHARGES:
2751  strcpy(tempstr, "Extra charges");
2752  break;
2753  case IPL_SPELL:
2754  sprintf(tempstr, "%i %s charges", x->_iMaxCharges, spelldata[x->_iSpell].sNameText);
2755  break;
2756  case IPL_FIREDAM:
2757  sprintf(tempstr, "Fire hit damage: %i-%i", x->_iFMinDam, x->_iFMaxDam);
2758  break;
2759  case IPL_LIGHTDAM:
2760  sprintf(tempstr, "Lightning hit damage: %i-%i", x->_iLMinDam, x->_iLMaxDam);
2761  break;
2762  case IPL_STR:
2763  case IPL_STR_CURSE:
2764  sprintf(tempstr, "%+i to strength", x->_iPLStr);
2765  break;
2766  case IPL_MAG:
2767  case IPL_MAG_CURSE:
2768  sprintf(tempstr, "%+i to magic", x->_iPLMag);
2769  break;
2770  case IPL_DEX:
2771  case IPL_DEX_CURSE:
2772  sprintf(tempstr, "%+i to dexterity", x->_iPLDex);
2773  break;
2774  case IPL_VIT:
2775  case IPL_VIT_CURSE:
2776  sprintf(tempstr, "%+i to vitality", x->_iPLVit);
2777  break;
2778  case IPL_ATTRIBS:
2779  case IPL_ATTRIBS_CURSE:
2780  sprintf(tempstr, "%+i to all attributes", x->_iPLStr);
2781  break;
2782  case IPL_GETHIT_CURSE:
2783  case IPL_GETHIT:
2784  sprintf(tempstr, "%+i damage from enemies", x->_iPLGetHit);
2785  break;
2786  case IPL_LIFE:
2787  case IPL_LIFE_CURSE:
2788  sprintf(tempstr, "Hit Points : %+i", x->_iPLHP >> 6);
2789  break;
2790  case IPL_MANA:
2791  case IPL_MANA_CURSE:
2792  sprintf(tempstr, "Mana : %+i", x->_iPLMana >> 6);
2793  break;
2794  case IPL_DUR:
2795  strcpy(tempstr, "high durability");
2796  break;
2797  case IPL_DUR_CURSE:
2798  strcpy(tempstr, "decreased durability");
2799  break;
2800  case IPL_INDESTRUCTIBLE:
2801  strcpy(tempstr, "indestructible");
2802  break;
2803  case IPL_LIGHT:
2804  sprintf(tempstr, "+%i%% light radius", 10 * x->_iPLLight);
2805  break;
2806  case IPL_LIGHT_CURSE:
2807  sprintf(tempstr, "-%i%% light radius", -10 * x->_iPLLight);
2808  break;
2809  case IPL_FIRE_ARROWS:
2810  sprintf(tempstr, "fire arrows damage: %i-%i", x->_iFMinDam, x->_iFMaxDam);
2811  break;
2812  case IPL_LIGHT_ARROWS:
2813  sprintf(tempstr, "lightning arrows damage %i-%i", x->_iLMinDam, x->_iLMaxDam);
2814  break;
2815  case IPL_THORNS:
2816  strcpy(tempstr, "attacker takes 1-3 damage");
2817  break;
2818  case IPL_NOMANA:
2819  strcpy(tempstr, "user loses all mana");
2820  break;
2821  case IPL_NOHEALPLR:
2822  strcpy(tempstr, "you can't heal");
2823  break;
2824  case IPL_ABSHALFTRAP:
2825  strcpy(tempstr, "absorbs half of trap damage");
2826  break;
2827  case IPL_KNOCKBACK:
2828  strcpy(tempstr, "knocks target back");
2829  break;
2830  case IPL_3XDAMVDEM:
2831  strcpy(tempstr, "+200% damage vs. demons");
2832  break;
2833  case IPL_ALLRESZERO:
2834  strcpy(tempstr, "All Resistance equals 0");
2835  break;
2836  case IPL_NOHEALMON:
2837  strcpy(tempstr, "hit monster doesn't heal");
2838  break;
2839  case IPL_STEALMANA:
2840  if (x->_iFlags & ISPL_STEALMANA_3)
2841  strcpy(tempstr, "hit steals 3% mana");
2842  if (x->_iFlags & ISPL_STEALMANA_5)
2843  strcpy(tempstr, "hit steals 5% mana");
2844  break;
2845  case IPL_STEALLIFE:
2846  if (x->_iFlags & ISPL_STEALLIFE_3)
2847  strcpy(tempstr, "hit steals 3% life");
2848  if (x->_iFlags & ISPL_STEALLIFE_5)
2849  strcpy(tempstr, "hit steals 5% life");
2850  break;
2851  case IPL_TARGAC:
2852  strcpy(tempstr, "damages target's armor");
2853  break;
2854  case IPL_FASTATTACK:
2855  if (x->_iFlags & ISPL_QUICKATTACK)
2856  strcpy(tempstr, "quick attack");
2857  if (x->_iFlags & ISPL_FASTATTACK)
2858  strcpy(tempstr, "fast attack");
2859  if (x->_iFlags & ISPL_FASTERATTACK)
2860  strcpy(tempstr, "faster attack");
2861  if (x->_iFlags & ISPL_FASTESTATTACK)
2862  strcpy(tempstr, "fastest attack");
2863  break;
2864  case IPL_FASTRECOVER:
2865  if (x->_iFlags & ISPL_FASTRECOVER)
2866  strcpy(tempstr, "fast hit recovery");
2867  if (x->_iFlags & ISPL_FASTERRECOVER)
2868  strcpy(tempstr, "faster hit recovery");
2869  if (x->_iFlags & ISPL_FASTESTRECOVER)
2870  strcpy(tempstr, "fastest hit recovery");
2871  break;
2872  case IPL_FASTBLOCK:
2873  strcpy(tempstr, "fast block");
2874  break;
2875  case IPL_DAMMOD:
2876  sprintf(tempstr, "adds %i points to damage", x->_iPLDamMod);
2877  break;
2878  case IPL_RNDARROWVEL:
2879  strcpy(tempstr, "fires random speed arrows");
2880  break;
2881  case IPL_SETDAM:
2882  sprintf(tempstr, "unusual item damage");
2883  break;
2884  case IPL_SETDUR:
2885  strcpy(tempstr, "altered durability");
2886  break;
2887  case IPL_FASTSWING:
2888  strcpy(tempstr, "Faster attack swing");
2889  break;
2890  case IPL_ONEHAND:
2891  strcpy(tempstr, "one handed sword");
2892  break;
2893  case IPL_DRAINLIFE:
2894  strcpy(tempstr, "constantly lose hit points");
2895  break;
2896  case IPL_RNDSTEALLIFE:
2897  strcpy(tempstr, "life stealing");
2898  break;
2899  case IPL_NOMINSTR:
2900  strcpy(tempstr, "no strength requirement");
2901  break;
2902  case IPL_INFRAVISION:
2903  strcpy(tempstr, "see with infravision");
2904  break;
2905  case IPL_INVCURS:
2906  strcpy(tempstr, " ");
2907  break;
2908  case IPL_ADDACLIFE:
2909  strcpy(tempstr, "Armor class added to life");
2910  break;
2911  case IPL_ADDMANAAC:
2912  strcpy(tempstr, "10% of mana added to armor");
2913  break;
2914  case IPL_FIRERESCLVL:
2915  if (x->_iPLFR <= 0)
2916  sprintf(tempstr, " ");
2917  else if (x->_iPLFR >= 1)
2918  sprintf(tempstr, "Resist Fire : %+i%%", x->_iPLFR);
2919  break;
2920  default:
2921  strcpy(tempstr, "Another ability (NW)");
2922  break;
2923  }
2924 }
2925 
2927 {
2928  CelDraw(RIGHT_PANEL_X - SPANEL_WIDTH + 24, SCREEN_Y + 327, pSTextBoxCels, 1, 271);
2929  trans_rect(RIGHT_PANEL - SPANEL_WIDTH + 27, 28, 265, 297);
2930 }
2931 
2932 void PrintUString(int x, int y, BOOL cjustflag, char *str, int col)
2933 {
2934  int len, width, sx, sy, i, k;
2935  BYTE c;
2936 
2937  sx = x + 96;
2938  sy = y * 12 + 204;
2939  len = strlen(str);
2940  k = 0;
2941  if (cjustflag) {
2942  width = 0;
2943  for (i = 0; i < len; i++)
2944  width += fontkern[fontframe[gbFontTransTbl[(BYTE)str[i]]]] + 1;
2945  if (width < 257)
2946  k = (257 - width) >> 1;
2947  sx += k;
2948  }
2949 
2950  for (i = 0; i < len; i++) {
2951  c = fontframe[gbFontTransTbl[(BYTE)str[i]]];
2952  k += fontkern[c] + 1;
2953  if (c && k <= 257) {
2954  PrintChar(sx, sy, c, col);
2955  }
2956  sx += fontkern[c] + 1;
2957  }
2958 }
2959 
2960 void DrawULine(int y)
2961 {
2963 
2964  int i;
2965  BYTE *src, *dst;
2966 
2967  src = &gpBuffer[SCREENXY(26 + RIGHT_PANEL - SPANEL_WIDTH, 25)];
2968  dst = &gpBuffer[BUFFER_WIDTH * (y * 12 + 198) + 26 + RIGHT_PANEL_X - SPANEL_WIDTH];
2969 
2970  for (i = 0; i < 3; i++, src += BUFFER_WIDTH, dst += BUFFER_WIDTH)
2971  memcpy(dst, src, 266);
2972 }
2973 
2975 {
2976  int uid, y;
2977 
2978  if ((!chrflag && !questlog) || SCREEN_WIDTH >= SPANEL_WIDTH * 3) {
2979  uid = curruitem._iUid;
2980  DrawUTextBack();
2981  PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, 2, TRUE, UniqueItemList[uid].UIName, 3);
2982  DrawULine(5);
2983  PrintItemPower(UniqueItemList[uid].UIPower1, &curruitem);
2984  y = 6 - UniqueItemList[uid].UINumPL + 8;
2985  PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y, TRUE, tempstr, 0);
2986  if (UniqueItemList[uid].UINumPL > 1) {
2987  PrintItemPower(UniqueItemList[uid].UIPower2, &curruitem);
2988  PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 2, TRUE, tempstr, 0);
2989  }
2990  if (UniqueItemList[uid].UINumPL > 2) {
2991  PrintItemPower(UniqueItemList[uid].UIPower3, &curruitem);
2992  PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 4, TRUE, tempstr, 0);
2993  }
2994  if (UniqueItemList[uid].UINumPL > 3) {
2995  PrintItemPower(UniqueItemList[uid].UIPower4, &curruitem);
2996  PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 6, TRUE, tempstr, 0);
2997  }
2998  if (UniqueItemList[uid].UINumPL > 4) {
2999  PrintItemPower(UniqueItemList[uid].UIPower5, &curruitem);
3000  PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 8, TRUE, tempstr, 0);
3001  }
3002  if (UniqueItemList[uid].UINumPL > 5) {
3003  PrintItemPower(UniqueItemList[uid].UIPower6, &curruitem);
3004  PrintUString(0 + RIGHT_PANEL - SPANEL_WIDTH, y + 10, TRUE, tempstr, 0);
3005  }
3006  }
3007 }
3008 
3010 {
3011  if (x->_iMiscId == IMISC_SCROLL) {
3012  strcpy(tempstr, "Right-click to read");
3013  AddPanelString(tempstr, TRUE);
3014  }
3015  if (x->_iMiscId == IMISC_SCROLLT) {
3016  strcpy(tempstr, "Right-click to read, then");
3017  AddPanelString(tempstr, TRUE);
3018  strcpy(tempstr, "left-click to target");
3019  AddPanelString(tempstr, TRUE);
3020  }
3021  if (x->_iMiscId >= IMISC_USEFIRST && x->_iMiscId <= IMISC_USELAST) {
3022  PrintItemOil(x->_iMiscId);
3023  strcpy(tempstr, "Right click to use");
3024  AddPanelString(tempstr, TRUE);
3025  }
3026  if (x->_iMiscId == IMISC_BOOK) {
3027  strcpy(tempstr, "Right click to read");
3028  AddPanelString(tempstr, TRUE);
3029  }
3030  if (x->_iMiscId == IMISC_MAPOFDOOM) {
3031  strcpy(tempstr, "Right click to view");
3032  AddPanelString(tempstr, TRUE);
3033  }
3034  if (x->_iMiscId == IMISC_EAR) {
3035  sprintf(tempstr, "Level : %i", x->_ivalue);
3036  AddPanelString(tempstr, TRUE);
3037  }
3038 }
3039 
3041 {
3042  if (x->_iClass == ICLASS_WEAPON) {
3043  if (x->_iMaxDur == DUR_INDESTRUCTIBLE)
3044  sprintf(tempstr, "damage: %i-%i Indestructible", x->_iMinDam, x->_iMaxDam);
3045  else
3046  sprintf(tempstr, "damage: %i-%i Dur: %i/%i", x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur);
3047  AddPanelString(tempstr, TRUE);
3048  }
3049  if (x->_iClass == ICLASS_ARMOR) {
3050  if (x->_iMaxDur == DUR_INDESTRUCTIBLE)
3051  sprintf(tempstr, "armor: %i Indestructible", x->_iAC);
3052  else
3053  sprintf(tempstr, "armor: %i Dur: %i/%i", x->_iAC, x->_iDurability, x->_iMaxDur);
3054  AddPanelString(tempstr, TRUE);
3055  }
3056  if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) {
3057  sprintf(tempstr, "dam: %i-%i Dur: %i/%i", x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur);
3058  sprintf(tempstr, "Charges: %i/%i", x->_iCharges, x->_iMaxCharges);
3059  AddPanelString(tempstr, TRUE);
3060  }
3061  if (x->_iPrePower != -1) {
3062  PrintItemPower(x->_iPrePower, x);
3063  AddPanelString(tempstr, TRUE);
3064  }
3065  if (x->_iSufPower != -1) {
3066  PrintItemPower(x->_iSufPower, x);
3067  AddPanelString(tempstr, TRUE);
3068  }
3069  if (x->_iMagical == ITEM_QUALITY_UNIQUE) {
3070  AddPanelString("unique item", TRUE);
3071  uitemflag = TRUE;
3072  curruitem = *x;
3073  }
3074  PrintItemMisc(x);
3075  if (x->_iMinMag + x->_iMinDex + x->_iMinStr) {
3076  strcpy(tempstr, "Required:");
3077  if (x->_iMinStr)
3078  sprintf(tempstr, "%s %i Str", tempstr, x->_iMinStr);
3079  if (x->_iMinMag)
3080  sprintf(tempstr, "%s %i Mag", tempstr, x->_iMinMag);
3081  if (x->_iMinDex)
3082  sprintf(tempstr, "%s %i Dex", tempstr, x->_iMinDex);
3083  AddPanelString(tempstr, TRUE);
3084  }
3085  pinfoflag = TRUE;
3086 }
3087 
3089 {
3090  if (x->_iClass == ICLASS_WEAPON) {
3091  if (x->_iMaxDur == DUR_INDESTRUCTIBLE)
3092  sprintf(tempstr, "damage: %i-%i Indestructible", x->_iMinDam, x->_iMaxDam);
3093  else
3094  sprintf(tempstr, "damage: %i-%i Dur: %i/%i", x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur);
3095  AddPanelString(tempstr, TRUE);
3096  if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) {
3097  sprintf(tempstr, "Charges: %i/%i", x->_iCharges, x->_iMaxCharges);
3098  AddPanelString(tempstr, TRUE);
3099  }
3100  if (x->_iMagical != ITEM_QUALITY_NORMAL)
3101  AddPanelString("Not Identified", TRUE);
3102  }
3103  if (x->_iClass == ICLASS_ARMOR) {
3104  if (x->_iMaxDur == DUR_INDESTRUCTIBLE)
3105  sprintf(tempstr, "armor: %i Indestructible", x->_iAC);
3106  else
3107  sprintf(tempstr, "armor: %i Dur: %i/%i", x->_iAC, x->_iDurability, x->_iMaxDur);
3108  AddPanelString(tempstr, TRUE);
3109  if (x->_iMagical != ITEM_QUALITY_NORMAL)
3110  AddPanelString("Not Identified", TRUE);
3111  if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) {
3112  sprintf(tempstr, "Charges: %i/%i", x->_iCharges, x->_iMaxCharges);
3113  AddPanelString(tempstr, TRUE);
3114  }
3115  }
3116  if (x->_itype == ITYPE_RING || x->_itype == ITYPE_AMULET)
3117  AddPanelString("Not Identified", TRUE);
3118  PrintItemMisc(x);
3119  if (x->_iMinMag + x->_iMinDex + x->_iMinStr) {
3120  strcpy(tempstr, "Required:");
3121  if (x->_iMinStr)
3122  sprintf(tempstr, "%s %i Str", tempstr, x->_iMinStr);
3123  if (x->_iMinMag)
3124  sprintf(tempstr, "%s %i Mag", tempstr, x->_iMinMag);
3125  if (x->_iMinDex)
3126  sprintf(tempstr, "%s %i Dex", tempstr, x->_iMinDex);
3127  AddPanelString(tempstr, TRUE);
3128  }
3129  pinfoflag = TRUE;
3130 }
3131 
3132 void UseItem(int p, int Mid, int spl)
3133 {
3134  int l, j;
3135 
3136  switch (Mid) {
3137  case IMISC_HEAL:
3138  case IMISC_MEAT:
3139  j = plr[p]._pMaxHP >> 8;
3140  l = ((j >> 1) + random_(39, j)) << 6;
3141  if (plr[p]._pClass == PC_WARRIOR)
3142  l *= 2;
3143  if (plr[p]._pClass == PC_ROGUE)
3144  l += l >> 1;
3145  plr[p]._pHitPoints += l;
3146  if (plr[p]._pHitPoints > plr[p]._pMaxHP)
3147  plr[p]._pHitPoints = plr[p]._pMaxHP;
3148  plr[p]._pHPBase += l;
3149  if (plr[p]._pHPBase > plr[p]._pMaxHPBase)
3150  plr[p]._pHPBase = plr[p]._pMaxHPBase;
3151  drawhpflag = TRUE;
3152  break;
3153  case IMISC_FULLHEAL:
3154  plr[p]._pHitPoints = plr[p]._pMaxHP;
3155  plr[p]._pHPBase = plr[p]._pMaxHPBase;
3156  drawhpflag = TRUE;
3157  break;
3158  case IMISC_MANA:
3159  j = plr[p]._pMaxMana >> 8;
3160  l = ((j >> 1) + random_(40, j)) << 6;
3161  if (plr[p]._pClass == PC_SORCERER)
3162  l *= 2;
3163  if (plr[p]._pClass == PC_ROGUE)
3164  l += l >> 1;
3165  if (!(plr[p]._pIFlags & ISPL_NOMANA)) {
3166  plr[p]._pMana += l;
3167  if (plr[p]._pMana > plr[p]._pMaxMana)
3168  plr[p]._pMana = plr[p]._pMaxMana;
3169  plr[p]._pManaBase += l;
3170  if (plr[p]._pManaBase > plr[p]._pMaxManaBase)
3171  plr[p]._pManaBase = plr[p]._pMaxManaBase;
3172  drawmanaflag = TRUE;
3173  }
3174  break;
3175  case IMISC_FULLMANA:
3176  if (!(plr[p]._pIFlags & ISPL_NOMANA)) {
3177  plr[p]._pMana = plr[p]._pMaxMana;
3178  plr[p]._pManaBase = plr[p]._pMaxManaBase;
3179  drawmanaflag = TRUE;
3180  }
3181  break;
3182  case IMISC_ELIXSTR:
3183  ModifyPlrStr(p, 1);
3184  break;
3185  case IMISC_ELIXMAG:
3186  ModifyPlrMag(p, 1);
3187  break;
3188  case IMISC_ELIXDEX:
3189  ModifyPlrDex(p, 1);
3190  break;
3191  case IMISC_ELIXVIT:
3192  ModifyPlrVit(p, 1);
3193  break;
3194  case IMISC_REJUV:
3195  j = plr[p]._pMaxHP >> 8;
3196  l = ((j >> 1) + random_(39, j)) << 6;
3197  if (plr[p]._pClass == PC_WARRIOR)
3198  l *= 2;
3199  if (plr[p]._pClass == PC_ROGUE)
3200  l += l >> 1;
3201  plr[p]._pHitPoints += l;
3202  if (plr[p]._pHitPoints > plr[p]._pMaxHP)
3203  plr[p]._pHitPoints = plr[p]._pMaxHP;
3204  plr[p]._pHPBase += l;
3205  if (plr[p]._pHPBase > plr[p]._pMaxHPBase)
3206  plr[p]._pHPBase = plr[p]._pMaxHPBase;
3207  drawhpflag = TRUE;
3208  j = plr[p]._pMaxMana >> 8;
3209  l = ((j >> 1) + random_(40, j)) << 6;
3210  if (plr[p]._pClass == PC_SORCERER)
3211  l *= 2;
3212  if (plr[p]._pClass == PC_ROGUE)
3213  l += l >> 1;
3214  if (!(plr[p]._pIFlags & ISPL_NOMANA)) {
3215  plr[p]._pMana += l;
3216  if (plr[p]._pMana > plr[p]._pMaxMana)
3217  plr[p]._pMana = plr[p]._pMaxMana;
3218  plr[p]._pManaBase += l;
3219  if (plr[p]._pManaBase > plr[p]._pMaxManaBase)
3220  plr[p]._pManaBase = plr[p]._pMaxManaBase;
3221  drawmanaflag = TRUE;
3222  }
3223  break;
3224  case IMISC_FULLREJUV:
3225  plr[p]._pHitPoints = plr[p]._pMaxHP;
3226  plr[p]._pHPBase = plr[p]._pMaxHPBase;
3227  drawhpflag = TRUE;
3228  if (!(plr[p]._pIFlags & ISPL_NOMANA)) {
3229  plr[p]._pMana = plr[p]._pMaxMana;
3230  plr[p]._pManaBase = plr[p]._pMaxManaBase;
3231  drawmanaflag = TRUE;
3232  }
3233  break;
3234  case IMISC_SCROLL:
3235  if (spelldata[spl].sTargeted) {
3236  plr[p]._pTSpell = spl;
3238  if (p == myplr)
3240  } else {
3241  ClrPlrPath(p);
3242  plr[p]._pSpell = spl;
3244  plr[p]._pSplFrom = 3;
3246  plr[p].destParam1 = cursmx;
3247  plr[p].destParam2 = cursmy;
3248  if (p == myplr && spl == SPL_NOVA)
3250  }
3251  break;
3252  case IMISC_SCROLLT:
3253  if (spelldata[spl].sTargeted) {
3254  plr[p]._pTSpell = spl;
3256  if (p == myplr)
3258  } else {
3259  ClrPlrPath(p);
3260  plr[p]._pSpell = spl;
3262  plr[p]._pSplFrom = 3;
3264  plr[p].destParam1 = cursmx;
3265  plr[p].destParam2 = cursmy;
3266  }
3267  break;
3268  case IMISC_BOOK:
3269  plr[p]._pMemSpells |= (__int64)1 << (spl - 1);
3270  if (plr[p]._pSplLvl[spl] < 15)
3271  plr[p]._pSplLvl[spl]++;
3272  plr[p]._pMana += spelldata[spl].sManaCost << 6;
3273  if (plr[p]._pMana > plr[p]._pMaxMana)
3274  plr[p]._pMana = plr[p]._pMaxMana;
3275  plr[p]._pManaBase += spelldata[spl].sManaCost << 6;
3276  if (plr[p]._pManaBase > plr[p]._pMaxManaBase)
3277  plr[p]._pManaBase = plr[p]._pMaxManaBase;
3278  if (p == myplr)
3279  CalcPlrBookVals(p);
3280  drawmanaflag = TRUE;
3281  break;
3282  case IMISC_MAPOFDOOM:
3283  doom_init();
3284  break;
3285  case IMISC_SPECELIX:
3286  ModifyPlrStr(p, 3);
3287  ModifyPlrMag(p, 3);
3288  ModifyPlrDex(p, 3);
3289  ModifyPlrVit(p, 3);
3290  break;
3291  }
3292 }
3293 
3295 {
3296  BOOL sf;
3297 
3298  sf = TRUE;
3299  if (plr[myplr]._pStrength < h->_iMinStr)
3300  sf = FALSE;
3301  if (plr[myplr]._pMagic < h->_iMinMag)
3302  sf = FALSE;
3303  if (plr[myplr]._pDexterity < h->_iMinDex)
3304  sf = FALSE;
3305 
3306  return sf;
3307 }
3308 
3309 BOOL SmithItemOk(int i)
3310 {
3311  BOOL rv;
3312 
3313  rv = TRUE;
3314  if (AllItemsList[i].itype == ITYPE_MISC)
3315  rv = FALSE;
3316  if (AllItemsList[i].itype == ITYPE_GOLD)
3317  rv = FALSE;
3318  if (AllItemsList[i].itype == ITYPE_MEAT)
3319  rv = FALSE;
3320  if (AllItemsList[i].itype == ITYPE_STAFF)
3321  rv = FALSE;
3322  if (AllItemsList[i].itype == ITYPE_RING)
3323  rv = FALSE;
3324  if (AllItemsList[i].itype == ITYPE_AMULET)
3325  rv = FALSE;
3326 
3327  return rv;
3328 }
3329 
3330 int RndSmithItem(int lvl)
3331 {
3332  int i, ri;
3333  int ril[512];
3334 
3335  ri = 0;
3336  for (i = 1; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
3337  if (AllItemsList[i].iRnd && SmithItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) {
3338  ril[ri] = i;
3339  ri++;
3340  if (AllItemsList[i].iRnd == 2) {
3341  ril[ri] = i;
3342  ri++;
3343  }
3344  }
3345  }
3346 
3347  return ril[random_(50, ri)] + 1;
3348 }
3349 
3351 {
3352  ItemStruct h;
3353 
3354  h = *a;
3355  *a = *b;
3356  *b = h;
3357 }
3358 
3360 {
3361  int j, k;
3362  BOOL sorted;
3363 
3364  j = 0;
3365  while (smithitem[j + 1]._itype != ITYPE_NONE) {
3366  j++;
3367  }
3368 
3369  sorted = FALSE;
3370  while (j > 0 && !sorted) {
3371  sorted = TRUE;
3372  for (k = 0; k < j; k++) {
3373  if (smithitem[k].IDidx > smithitem[k + 1].IDidx) {
3374  BubbleSwapItem(&smithitem[k], &smithitem[k + 1]);
3375  sorted = FALSE;
3376  }
3377  }
3378  j--;
3379  }
3380 }
3381 
3382 void SpawnSmith(int lvl)
3383 {
3384  int i, iCnt, idata;
3385 
3386  iCnt = random_(50, SMITH_ITEMS - 10) + 10;
3387  for (i = 0; i < iCnt; i++) {
3388  do {
3389  item[0]._iSeed = GetRndSeed();
3390  SetRndSeed(item[0]._iSeed);
3391  idata = RndSmithItem(lvl) - 1;
3392  GetItemAttrs(0, idata, lvl);
3393  } while (item[0]._iIvalue > SMITH_MAX_VALUE);
3394  smithitem[i] = item[0];
3395  smithitem[i]._iCreateInfo = lvl | 0x400;
3396  smithitem[i]._iIdentified = TRUE;
3398  }
3399  for (i = iCnt; i < SMITH_ITEMS; i++)
3400  smithitem[i]._itype = ITYPE_NONE;
3401 
3402  SortSmith();
3403 }
3404 
3405 BOOL PremiumItemOk(int i)
3406 {
3407  BOOL rv;
3408 
3409  rv = TRUE;
3410  if (AllItemsList[i].itype == ITYPE_MISC)
3411  rv = FALSE;
3412  if (AllItemsList[i].itype == ITYPE_GOLD)
3413  rv = FALSE;
3414  if (AllItemsList[i].itype == ITYPE_MEAT)
3415  rv = FALSE;
3416  if (AllItemsList[i].itype == ITYPE_STAFF)
3417  rv = FALSE;
3418 
3419  if (gbMaxPlayers != 1) {
3420  if (AllItemsList[i].itype == ITYPE_RING)
3421  rv = FALSE;
3422  if (AllItemsList[i].itype == ITYPE_AMULET)
3423  rv = FALSE;
3424  }
3425 
3426  return rv;
3427 }
3428 
3429 int RndPremiumItem(int minlvl, int maxlvl)
3430 {
3431  int i, ri;
3432  int ril[512];
3433 
3434  ri = 0;
3435  for (i = 1; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
3436  if (AllItemsList[i].iRnd) {
3437  if (PremiumItemOk(i)) {
3438  if (AllItemsList[i].iMinMLvl >= minlvl && AllItemsList[i].iMinMLvl <= maxlvl) {
3439  ril[ri] = i;
3440  ri++;
3441  }
3442  }
3443  }
3444  }
3445 
3446  return ril[random_(50, ri)] + 1;
3447 }
3448 
3449 void SpawnOnePremium(int i, int plvl)
3450 {
3451  int itype;
3452  ItemStruct holditem;
3453 
3454  holditem = item[0];
3455  if (plvl > 30)
3456  plvl = 30;
3457  if (plvl < 1)
3458  plvl = 1;
3459  do {
3460  item[0]._iSeed = GetRndSeed();
3461  SetRndSeed(item[0]._iSeed);
3462  itype = RndPremiumItem(plvl >> 2, plvl) - 1;
3463  GetItemAttrs(0, itype, plvl);
3464  GetItemBonus(0, itype, plvl >> 1, plvl, TRUE);
3465  } while (item[0]._iIvalue > SMITH_MAX_PREMIUM_VALUE);
3466  premiumitem[i] = item[0];
3467  premiumitem[i]._iCreateInfo = plvl | 0x800;
3468  premiumitem[i]._iIdentified = TRUE;
3470  item[0] = holditem;
3471 }
3472 
3473 void SpawnPremium(int lvl)
3474 {
3475  int i;
3476 
3478  for (i = 0; i < SMITH_PREMIUM_ITEMS; i++) {
3479  if (premiumitem[i]._itype == ITYPE_NONE)
3481  }
3483  }
3484  while (premiumlevel < lvl) {
3485  premiumlevel++;
3486  premiumitem[0] = premiumitem[2];
3487  premiumitem[1] = premiumitem[3];
3488  premiumitem[2] = premiumitem[4];
3490  premiumitem[4] = premiumitem[5];
3492  }
3493 }
3494 
3495 BOOL WitchItemOk(int i)
3496 {
3497  BOOL rv;
3498 
3499  rv = FALSE;
3500  if (AllItemsList[i].itype == ITYPE_MISC)
3501  rv = TRUE;
3502  if (AllItemsList[i].itype == ITYPE_STAFF)
3503  rv = TRUE;
3504  if (AllItemsList[i].iMiscId == IMISC_MANA)
3505  rv = FALSE;
3506  if (AllItemsList[i].iMiscId == IMISC_FULLMANA)
3507  rv = FALSE;
3508  if (AllItemsList[i].iSpell == SPL_TOWN)
3509  rv = FALSE;
3510  if (AllItemsList[i].iMiscId == IMISC_FULLHEAL)
3511  rv = FALSE;
3512  if (AllItemsList[i].iMiscId == IMISC_HEAL)
3513  rv = FALSE;
3514  if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1)
3515  rv = FALSE;
3516  if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1)
3517  rv = FALSE;
3518 
3519  return rv;
3520 }
3521 
3522 int RndWitchItem(int lvl)
3523 {
3524  int i, ri;
3525  int ril[512];
3526 
3527  ri = 0;
3528  for (i = 1; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
3529  if (AllItemsList[i].iRnd && WitchItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) {
3530  ril[ri] = i;
3531  ri++;
3532  }
3533  }
3534 
3535  return ril[random_(51, ri)] + 1;
3536 }
3537 
3539 {
3540  int j, k;
3541  BOOL sorted;
3542 
3543  j = 3;
3544  while (witchitem[j + 1]._itype != ITYPE_NONE) {
3545  j++;
3546  }
3547 
3548  sorted = FALSE;
3549  while (j > 3 && !sorted) {
3550  sorted = TRUE;
3551  for (k = 3; k < j; k++) {
3552  if (witchitem[k].IDidx > witchitem[k + 1].IDidx) {
3553  BubbleSwapItem(&witchitem[k], &witchitem[k + 1]);
3554  sorted = FALSE;
3555  }
3556  }
3557  j--;
3558  }
3559 }
3560 
3561 void WitchBookLevel(int ii)
3562 {
3563  int slvl;
3564 
3565  if (witchitem[ii]._iMiscId == IMISC_BOOK) {
3567  slvl = plr[myplr]._pSplLvl[witchitem[ii]._iSpell];
3568  while (slvl) {
3569  witchitem[ii]._iMinMag += 20 * witchitem[ii]._iMinMag / 100;
3570  slvl--;
3571  if (witchitem[ii]._iMinMag + 20 * witchitem[ii]._iMinMag / 100 > 255) {
3572  witchitem[ii]._iMinMag = 255;
3573  slvl = 0;
3574  }
3575  }
3576  }
3577 }
3578 
3579 void SpawnWitch(int lvl)
3580 {
3581  int i, iCnt;
3582  int idata, maxlvl;
3583 
3584  GetItemAttrs(0, IDI_MANA, 1);
3585  witchitem[0] = item[0];
3586  witchitem[0]._iCreateInfo = lvl;
3587  witchitem[0]._iStatFlag = TRUE;
3588  GetItemAttrs(0, IDI_FULLMANA, 1);
3589  witchitem[1] = item[0];
3590  witchitem[1]._iCreateInfo = lvl;
3591  witchitem[1]._iStatFlag = TRUE;
3592  GetItemAttrs(0, IDI_PORTAL, 1);
3593  witchitem[2] = item[0];
3594  witchitem[2]._iCreateInfo = lvl;
3595  witchitem[2]._iStatFlag = TRUE;
3596  iCnt = random_(51, 8) + 10;
3597 
3598  for (i = 3; i < iCnt; i++) {
3599  do {
3600  item[0]._iSeed = GetRndSeed();
3601  SetRndSeed(item[0]._iSeed);
3602  idata = RndWitchItem(lvl) - 1;
3603  GetItemAttrs(0, idata, lvl);
3604  maxlvl = -1;
3605  if (random_(51, 100) <= 5)
3606  maxlvl = 2 * lvl;
3607  if (maxlvl == -1 && item[0]._iMiscId == IMISC_STAFF)
3608  maxlvl = 2 * lvl;
3609  if (maxlvl != -1)
3610  GetItemBonus(0, idata, maxlvl >> 1, maxlvl, TRUE);
3611  } while (item[0]._iIvalue > 140000);
3612  witchitem[i] = item[0];
3613  witchitem[i]._iCreateInfo = lvl | 0x2000;
3614  witchitem[i]._iIdentified = TRUE;
3615  WitchBookLevel(i);
3617  }
3618 
3619  for (i = iCnt; i < 20; i++)
3620  witchitem[i]._itype = ITYPE_NONE;
3621 
3622  SortWitch();
3623 }
3624 
3625 int RndBoyItem(int lvl)
3626 {
3627  int i, ri;
3628  int ril[512];
3629 
3630  ri = 0;
3631  for (i = 1; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
3632  if (AllItemsList[i].iRnd && PremiumItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) {
3633  ril[ri] = i;
3634  ri++;
3635  }
3636  }
3637 
3638  return ril[random_(49, ri)] + 1;
3639 }
3640 
3641 void SpawnBoy(int lvl)
3642 {
3643  int itype;
3644 
3645  if (boylevel<lvl>> 1 || boyitem._itype == ITYPE_NONE) {
3646  do {
3647  item[0]._iSeed = GetRndSeed();
3648  SetRndSeed(item[0]._iSeed);
3649  itype = RndBoyItem(lvl) - 1;
3650  GetItemAttrs(0, itype, lvl);
3651  GetItemBonus(0, itype, lvl, 2 * lvl, TRUE);
3652  } while (item[0]._iIvalue > 90000);
3653  boyitem = item[0];
3654  boyitem._iCreateInfo = lvl | 0x1000;
3655  boyitem._iIdentified = TRUE;
3657  boylevel = lvl >> 1;
3658  }
3659 }
3660 
3661 BOOL HealerItemOk(int i)
3662 {
3663  BOOL result;
3664 
3665  result = FALSE;
3666  if (AllItemsList[i].itype != ITYPE_MISC)
3667  return FALSE;
3668 
3669  if (AllItemsList[i].iMiscId == IMISC_SCROLL && AllItemsList[i].iSpell == SPL_HEAL)
3670  result = TRUE;
3671  if (AllItemsList[i].iMiscId == IMISC_SCROLLT && AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers != 1)
3672  result = FALSE;
3673  if (AllItemsList[i].iMiscId == IMISC_SCROLLT && AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers != 1)
3674  result = TRUE;
3675 
3676  if (gbMaxPlayers == 1) {
3677  if (AllItemsList[i].iMiscId == IMISC_ELIXSTR)
3678  result = TRUE;
3679  if (AllItemsList[i].iMiscId == IMISC_ELIXMAG)
3680  result = TRUE;
3681  if (AllItemsList[i].iMiscId == IMISC_ELIXDEX)
3682  result = TRUE;
3683  if (AllItemsList[i].iMiscId == IMISC_ELIXVIT)
3684  result = TRUE;
3685  }
3686 
3687  if (AllItemsList[i].iMiscId == IMISC_FULLHEAL) // BUGFIX this is a duplicate with the wrong case
3688  result = TRUE;
3689 
3690  if (AllItemsList[i].iMiscId == IMISC_REJUV)
3691  result = TRUE;
3692  if (AllItemsList[i].iMiscId == IMISC_FULLREJUV)
3693  result = TRUE;
3694  if (AllItemsList[i].iMiscId == IMISC_HEAL)
3695  result = FALSE;
3696  if (AllItemsList[i].iMiscId == IMISC_FULLHEAL)
3697  result = FALSE;
3698  if (AllItemsList[i].iMiscId == IMISC_MANA)
3699  result = FALSE;
3700  if (AllItemsList[i].iMiscId == IMISC_FULLMANA)
3701  result = FALSE;
3702 
3703  return result;
3704 }
3705 
3706 int RndHealerItem(int lvl)
3707 {
3708  int i, ri;
3709  int ril[512];
3710 
3711  ri = 0;
3712  for (i = 1; AllItemsList[i].iLoc != ILOC_INVALID; i++) {
3713  if (AllItemsList[i].iRnd && HealerItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) {
3714  ril[ri] = i;
3715  ri++;
3716  }
3717  }
3718 
3719  return ril[random_(50, ri)] + 1;
3720 }
3721 
3723 {
3724  int j, k;
3725  BOOL sorted;
3726 
3727  j = 2;
3728  while (healitem[j + 1]._itype != ITYPE_NONE) {
3729  j++;
3730  }
3731 
3732  sorted = FALSE;
3733  while (j > 2 && !sorted) {
3734  sorted = TRUE;
3735  for (k = 2; k < j; k++) {
3736  if (healitem[k].IDidx > healitem[k + 1].IDidx) {
3737  BubbleSwapItem(&healitem[k], &healitem[k + 1]);
3738  sorted = FALSE;
3739  }
3740  }
3741  j--;
3742  }
3743 }
3744 
3745 void SpawnHealer(int lvl)
3746 {
3747  int i, nsi, srnd, itype;
3748 
3749  GetItemAttrs(0, IDI_HEAL, 1);
3750  healitem[0] = item[0];
3751  healitem[0]._iCreateInfo = lvl;
3752  healitem[0]._iStatFlag = TRUE;
3753 
3754  GetItemAttrs(0, IDI_FULLHEAL, 1);
3755  healitem[1] = item[0];
3756  healitem[1]._iCreateInfo = lvl;
3757  healitem[1]._iStatFlag = TRUE;
3758 
3759  if (gbMaxPlayers != 1) {
3760  GetItemAttrs(0, IDI_RESURRECT, 1);
3761  healitem[2] = item[0];
3762  healitem[2]._iCreateInfo = lvl;
3763  healitem[2]._iStatFlag = TRUE;
3764 
3765  srnd = 3;
3766  } else {
3767  srnd = 2;
3768  }
3769  nsi = random_(50, 8) + 10;
3770  for (i = srnd; i < nsi; i++) {
3771  item[0]._iSeed = GetRndSeed();
3772  SetRndSeed(item[0]._iSeed);
3773  itype = RndHealerItem(lvl) - 1;
3774  GetItemAttrs(0, itype, lvl);
3775  healitem[i] = item[0];
3776  healitem[i]._iCreateInfo = lvl | 0x4000;
3777  healitem[i]._iIdentified = TRUE;
3779  }
3780  for (i = nsi; i < 20; i++) {
3781  healitem[i]._itype = ITYPE_NONE;
3782  }
3783  SortHealer();
3784 }
3785 
3787 {
3788  GetItemAttrs(0, IDI_GOLD, 1);
3789  golditem = item[0];
3790  golditem._iStatFlag = TRUE;
3791 }
3792 
3793 void RecreateSmithItem(int ii, int idx, int lvl, int iseed)
3794 {
3795  int itype;
3796 
3797  SetRndSeed(iseed);
3798  itype = RndSmithItem(lvl) - 1;
3799  GetItemAttrs(ii, itype, lvl);
3800 
3801  item[ii]._iSeed = iseed;
3802  item[ii]._iCreateInfo = lvl | 0x400;
3803  item[ii]._iIdentified = TRUE;
3804 }
3805 
3806 void RecreatePremiumItem(int ii, int idx, int plvl, int iseed)
3807 {
3808  int itype;
3809 
3810  SetRndSeed(iseed);
3811  itype = RndPremiumItem(plvl >> 2, plvl) - 1;
3812  GetItemAttrs(ii, itype, plvl);
3813  GetItemBonus(ii, itype, plvl >> 1, plvl, TRUE);
3814 
3815  item[ii]._iSeed = iseed;
3816  item[ii]._iCreateInfo = plvl | 0x800;
3817  item[ii]._iIdentified = TRUE;
3818 }
3819 
3820 void RecreateBoyItem(int ii, int idx, int lvl, int iseed)
3821 {
3822  int itype;
3823 
3824  SetRndSeed(iseed);
3825  itype = RndBoyItem(lvl) - 1;
3826  GetItemAttrs(ii, itype, lvl);
3827  GetItemBonus(ii, itype, lvl, 2 * lvl, TRUE);
3828  item[ii]._iSeed = iseed;
3829  item[ii]._iCreateInfo = lvl | 0x1000;
3830  item[ii]._iIdentified = TRUE;
3831 }
3832 
3833 void RecreateWitchItem(int ii, int idx, int lvl, int iseed)
3834 {
3835  int iblvl, itype;
3836 
3837  if (idx == IDI_MANA || idx == IDI_FULLMANA || idx == IDI_PORTAL) {
3838  GetItemAttrs(ii, idx, lvl);
3839  } else {
3840  SetRndSeed(iseed);
3841  itype = RndWitchItem(lvl) - 1;
3842  GetItemAttrs(ii, itype, lvl);
3843  iblvl = -1;
3844  if (random_(51, 100) <= 5)
3845  iblvl = 2 * lvl;
3846  if (iblvl == -1 && item[ii]._iMiscId == IMISC_STAFF)
3847  iblvl = 2 * lvl;
3848  if (iblvl != -1)
3849  GetItemBonus(ii, itype, iblvl >> 1, iblvl, TRUE);
3850  }
3851 
3852  item[ii]._iSeed = iseed;
3853  item[ii]._iCreateInfo = lvl | 0x2000;
3854  item[ii]._iIdentified = TRUE;
3855 }
3856 
3857 void RecreateHealerItem(int ii, int idx, int lvl, int iseed)
3858 {
3859  int itype;
3860 
3861  if (idx == IDI_HEAL || idx == IDI_FULLHEAL || idx == IDI_RESURRECT) {
3862  GetItemAttrs(ii, idx, lvl);
3863  } else {
3864  SetRndSeed(iseed);
3865  itype = RndHealerItem(lvl) - 1;
3866  GetItemAttrs(ii, itype, lvl);
3867  }
3868 
3869  item[ii]._iSeed = iseed;
3870  item[ii]._iCreateInfo = lvl | 0x4000;
3871  item[ii]._iIdentified = TRUE;
3872 }
3873 
3874 void RecreateTownItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue)
3875 {
3876  if (icreateinfo & 0x400)
3877  RecreateSmithItem(ii, idx, icreateinfo & 0x3F, iseed);
3878  else if (icreateinfo & 0x800)
3879  RecreatePremiumItem(ii, idx, icreateinfo & 0x3F, iseed);
3880  else if (icreateinfo & 0x1000)
3881  RecreateBoyItem(ii, idx, icreateinfo & 0x3F, iseed);
3882  else if (icreateinfo & 0x2000)
3883  RecreateWitchItem(ii, idx, icreateinfo & 0x3F, iseed);
3884  else if (icreateinfo & 0x4000)
3885  RecreateHealerItem(ii, idx, icreateinfo & 0x3F, iseed);
3886 }
3887 
3889 {
3890  int i;
3891 
3892  for (i = 0; i < SMITH_ITEMS; i++) {
3893  if (smithitem[i]._itype != ITYPE_NONE) {
3895  }
3896  }
3897  for (i = 0; i < SMITH_PREMIUM_ITEMS; i++) {
3898  if (premiumitem[i]._itype != ITYPE_NONE) {
3900  }
3901  }
3902  for (i = 0; i < 20; i++) {
3903  if (witchitem[i]._itype != ITYPE_NONE) {
3905  }
3906  }
3907  for (i = 0; i < 20; i++) {
3908  if (healitem[i]._itype != ITYPE_NONE) {
3910  }
3911  }
3913 }
3914 
3916 {
3917  int r;
3918 
3919  r = itemactive[numitems - 1];
3920  item[r]._iAnimFrame = item[r]._iAnimLen;
3921  item[r]._iAnimFlag = FALSE;
3922  item[r]._iSelFlag = 1;
3923 
3924  return r;
3925 }
3926 
3927 void CreateSpellBook(int x, int y, int ispell, BOOL sendmsg, BOOL delta)
3928 {
3929  int ii, idx;
3930  BOOL done;
3931 
3932  done = FALSE;
3934  if (numitems < MAXITEMS) {
3935  ii = itemavail[0];
3936  GetSuperItemSpace(x, y, ii);
3937  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
3938  itemactive[numitems] = ii;
3939  while (!done) {
3940  SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, TRUE, FALSE, delta);
3941  if (item[ii]._iMiscId == IMISC_BOOK && item[ii]._iSpell == ispell)
3942  done = TRUE;
3943  }
3944  if (sendmsg)
3945  NetSendCmdDItem(FALSE, ii);
3946  if (delta)
3947  DeltaAddItem(ii);
3948  numitems++;
3949  }
3950 }
3951 
3952 void CreateMagicArmor(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL delta)
3953 {
3954  int ii, idx;
3955  BOOL done;
3956 
3957  done = FALSE;
3958  if (numitems < MAXITEMS) {
3959  ii = itemavail[0];
3960  GetSuperItemSpace(x, y, ii);
3961  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
3962  itemactive[numitems] = ii;
3963  idx = RndTypeItems(imisc, IMISC_NONE);
3964  while (!done) {
3965  SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, TRUE, FALSE, delta);
3966  if (item[ii]._iCurs == icurs)
3967  done = TRUE;
3968  else
3969  idx = RndTypeItems(imisc, IMISC_NONE);
3970  }
3971  if (sendmsg)
3972  NetSendCmdDItem(FALSE, ii);
3973  if (delta)
3974  DeltaAddItem(ii);
3975  numitems++;
3976  }
3977 }
3978 
3979 void CreateMagicWeapon(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL delta)
3980 {
3981  int ii, idx;
3982  BOOL done;
3983 
3984  done = FALSE;
3985  if (numitems < MAXITEMS) {
3986  ii = itemavail[0];
3987  GetSuperItemSpace(x, y, ii);
3988  itemavail[0] = itemavail[MAXITEMS - numitems - 1];
3989  itemactive[numitems] = ii;
3990  idx = RndTypeItems(imisc, IMISC_NONE);
3991  while (!done) {
3992  SetupAllItems(ii, idx, GetRndSeed(), 2 * currlevel, 1, TRUE, FALSE, delta);
3993  if (item[ii]._iCurs == icurs)
3994  done = TRUE;
3995  else
3996  idx = RndTypeItems(imisc, IMISC_NONE);
3997  }
3998  if (sendmsg)
3999  NetSendCmdDItem(FALSE, ii);
4000  if (delta)
4001  DeltaAddItem(ii);
4002  numitems++;
4003  }
4004 }
4005 
4006 BOOL GetItemRecord(int nSeed, WORD wCI, int nIndex)
4007 {
4008  int i;
4009  DWORD dwTicks;
4010 
4011  dwTicks = SDL_GetTicks();
4012 
4013  for (i = 0; i < gnNumGetRecords; i++) {
4014  if (dwTicks - itemrecord[i].dwTimestamp > 6000) {
4015  NextItemRecord(i);
4016  i--;
4017  } else if (nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) {
4018  return FALSE;
4019  }
4020  }
4021 
4022  return TRUE;
4023 }
4024 
4025 void NextItemRecord(int i)
4026 {
4027  gnNumGetRecords--;
4028 
4029  if (gnNumGetRecords == 0) {
4030  return;
4031  }
4032 
4037 }
4038 
4039 void SetItemRecord(int nSeed, WORD wCI, int nIndex)
4040 {
4041  DWORD dwTicks;
4042 
4043  dwTicks = SDL_GetTicks();
4044 
4045  if (gnNumGetRecords == MAXITEMS) {
4046  return;
4047  }
4048 
4050  itemrecord[gnNumGetRecords].nSeed = nSeed;
4052  itemrecord[gnNumGetRecords].nIndex = nIndex;
4053  gnNumGetRecords++;
4054 }
4055 
4056 void PutItemRecord(int nSeed, WORD wCI, int nIndex)
4057 {
4058  int i;
4059  DWORD dwTicks;
4060 
4061  dwTicks = SDL_GetTicks();
4062 
4063  for (i = 0; i < gnNumGetRecords; i++) {
4064  if (dwTicks - itemrecord[i].dwTimestamp > 6000) {
4065  NextItemRecord(i);
4066  i--;
4067  } else if (nSeed == itemrecord[i].nSeed && wCI == itemrecord[i].wCI && nIndex == itemrecord[i].nIndex) {
4068  NextItemRecord(i);
4069  break;
4070  }
4071  }
4072 }
4073 
ISPL_FASTATTACK
@ ISPL_FASTATTACK
Definition: enums.h:2771
ISPL_STEALLIFE_3
@ ISPL_STEALLIFE_3
Definition: enums.h:2768
ItemStruct::_iSeed
int _iSeed
Definition: structs.h:100
trans_rect
void trans_rect(int sx, int sy, int width, int height)
Draws a half-transparent rectangle by blacking out odd pixels on odd lines, even pixels on even lines...
Definition: render.cpp:342
PL_Suffix
const PLStruct PL_Suffix[]
Contains the data related to each item suffix.
Definition: itemdat.cpp:266
PlayerStruct::_pManaBase
int _pManaBase
Definition: structs.h:261
gpBuffer
BYTE * gpBuffer
ISPL_FASTRECOVER
@ ISPL_FASTRECOVER
Definition: enums.h:2774
ItemStruct::_iAnimLen
int _iAnimLen
Definition: structs.h:107
IPL_ABSHALFTRAP
@ IPL_ABSHALFTRAP
Definition: enums.h:134
GOLD_MAX_LIMIT
#define GOLD_MAX_LIMIT
Definition: defs.h:68
WitchItemOk
BOOL WitchItemOk(int i)
Definition: items.cpp:3495
IPL_GETHIT
@ IPL_GETHIT
Definition: enums.h:116
PlayerStruct::_pMagResist
char _pMagResist
Definition: structs.h:272
RechargeItem
void RechargeItem(ItemStruct *i, int r)
Definition: items.cpp:2607
IMISC_FULLMANA
@ IMISC_FULLMANA
Definition: enums.h:2438
ISPL_FIRE_ARROWS
@ ISPL_FIRE_ARROWS
Definition: enums.h:2756
cursmx
int cursmx
Definition: cursor.cpp:24
CreatePlrItems
void CreatePlrItems(int p)
Definition: items.cpp:862
PlayerStruct::_pGold
int _pGold
Definition: structs.h:275
ICURS_ANVIL_OF_FURY
@ ICURS_ANVIL_OF_FURY
Definition: enums.h:261
itemanims
BYTE * itemanims[ITEMTYPES]
Definition: items.cpp:17
quests
QuestStruct quests[MAXQUESTS]
Definition: quests.cpp:8
Q_ANVIL
@ Q_ANVIL
Definition: enums.h:2558
ItemStruct::_iLoc
char _iLoc
Definition: structs.h:118
ItemStruct::_iVAdd1
int _iVAdd1
Definition: structs.h:162
ItemStruct::_iy
int _iy
Definition: structs.h:104
IPL_LIGHTRES
@ IPL_LIGHTRES
Definition: enums.h:96
SpawnPremium
void SpawnPremium(int lvl)
Definition: items.cpp:3473
DoRepair
void DoRepair(int pnum, int cii)
Definition: items.cpp:2532
ItemStruct::_iMiscId
int _iMiscId
Definition: structs.h:130
IS_ILARM
@ IS_ILARM
Definition: enums.h:335
IPL_TARGAC
@ IPL_TARGAC
Definition: enums.h:139
ISPL_FASTESTATTACK
@ ISPL_FASTESTATTACK
Definition: enums.h:2773
PlayerStruct::InvGrid
char InvGrid[NUM_INV_GRID_ELEM]
Definition: structs.h:316
ItemDropSnds
int ItemDropSnds[ITEMTYPES]
Definition: items.cpp:117
DrawULine
void DrawULine(int y)
Definition: items.cpp:2960
IS_FANVL
@ IS_FANVL
Definition: enums.h:304
ItemStruct::_iPLDex
int _iPLDex
Definition: structs.h:142
IMISC_UNIQUE
@ IMISC_UNIQUE
Definition: enums.h:2458
SetPlayerHitPoints
void SetPlayerHitPoints(int pnum, int val)
Definition: player.cpp:3971
ItemStruct::_iSpell
int _iSpell
Definition: structs.h:132
PrintItemDur
void PrintItemDur(ItemStruct *x)
Definition: items.cpp:3088
IPL_NOMINSTR
@ IPL_NOMINSTR
Definition: enums.h:147
PlayerStruct::_pBaseStr
int _pBaseStr
Definition: structs.h:246
RecreateBoyItem
void RecreateBoyItem(int ii, int idx, int lvl, int iseed)
Definition: items.cpp:3820
PlayerStruct::_pIGetHit
int _pIGetHit
Definition: structs.h:328
SCREENXY
#define SCREENXY(x, y)
Definition: defs.h:155
ITEM_QUALITY_MAGIC
@ ITEM_QUALITY_MAGIC
Definition: enums.h:9
ItemStruct::_iMinStr
char _iMinStr
Definition: structs.h:166
PlayerStruct::_pgfxnum
int _pgfxnum
Definition: structs.h:204
force_redraw
int force_redraw
Definition: diablo.cpp:30
GetItemFrm
void GetItemFrm(int i)
Definition: items.cpp:2491
PlayerStruct::_pAnimFrame
int _pAnimFrame
Definition: structs.h:209
IDI_SORCEROR
@ IDI_SORCEROR
Definition: enums.h:2504
currlevel
BYTE currlevel
Definition: gendung.cpp:40
PlayerStruct::_pMaxHP
int _pMaxHP
Definition: structs.h:259
PlayerStruct::_pMana
int _pMana
Definition: structs.h:263
SPL_RESURRECT
@ SPL_RESURRECT
Definition: enums.h:2162
RndPL
int RndPL(int param1, int param2)
Definition: items.cpp:1346
GetBookSpell
void GetBookSpell(int i, int lvl)
Definition: items.cpp:1116
ItemStruct::_iCurs
int _iCurs
Definition: structs.h:121
ItemStruct::_ix
int _ix
Definition: structs.h:103
SPL_HEALOTHER
@ SPL_HEALOTHER
Definition: enums.h:2164
IMISC_DEADHEAL
@ IMISC_DEADHEAL
Definition: enums.h:2436
ItemPlace
BOOL ItemPlace(int xp, int yp)
Definition: items.cpp:206
AddInitItems
void AddInitItems()
Definition: items.cpp:224
SPL_NULL
@ SPL_NULL
Definition: enums.h:2130
ISPL_FASTERRECOVER
@ ISPL_FASTERRECOVER
Definition: enums.h:2775
RSPLTYPE_CHARGES
@ RSPLTYPE_CHARGES
Definition: enums.h:2061
ISPL_NONE
@ ISPL_NONE
Definition: enums.h:2752
DoRecharge
void DoRecharge(int pnum, int cii)
Definition: items.cpp:2584
IPL_VIT_CURSE
@ IPL_VIT_CURSE
Definition: enums.h:112
SetCursor_
void SetCursor_(int i)
Definition: cursor.cpp:99
SCREEN_Y
#define SCREEN_Y
Definition: defs.h:126
ISPL_STEALMANA_5
@ ISPL_STEALMANA_5
Definition: enums.h:2767
ItemStruct::_iPLAC
int _iPLAC
Definition: structs.h:139
PlayerStruct::destAction
int destAction
Definition: structs.h:182
QuestStatus
BOOL QuestStatus(int i)
Definition: quests.cpp:239
setpc_x
int setpc_x
Definition: gendung.cpp:72
ISPL_STEALLIFE_5
@ ISPL_STEALLIFE_5
Definition: enums.h:2769
NUM_INVLOC
@ NUM_INVLOC
Definition: enums.h:2796
IPL_FIREDAM
@ IPL_FIREDAM
Definition: enums.h:103
GetItemStr
void GetItemStr(int i)
Definition: items.cpp:2496
PlayerStruct::_pAnimCnt
int _pAnimCnt
Definition: structs.h:207
Q_MUSHROOM
@ Q_MUSHROOM
Definition: enums.h:2549
IPL_LIFE
@ IPL_LIFE
Definition: enums.h:117
IPL_DAMP_CURSE
@ IPL_DAMP_CURSE
Definition: enums.h:90
DIFF_HELL
@ DIFF_HELL
Definition: enums.h:2008
SetRndSeed
void SetRndSeed(int s)
Set the RNG seed.
Definition: engine.cpp:728
GOLD_MEDIUM_LIMIT
#define GOLD_MEDIUM_LIMIT
Definition: defs.h:67
ICURS_BOOK_BLUE
@ ICURS_BOOK_BLUE
Definition: enums.h:223
IS_ISIGN
@ IS_ISIGN
Definition: enums.h:342
IPL_ACP_CURSE
@ IPL_ACP_CURSE
Definition: enums.h:94
IS_FBOOK
@ IS_FBOOK
Definition: enums.h:308
PlayerStruct::_pSpell
int _pSpell
Definition: structs.h:215
ISPL_STEALMANA_3
@ ISPL_STEALMANA_3
Definition: enums.h:2766
PlayerStruct::_pAnimLen
int _pAnimLen
Definition: structs.h:208
ItemStruct::_iLMinDam
int _iLMinDam
Definition: structs.h:157
ItemDataStruct::iMinStr
char iMinStr
Definition: structs.h:78
idoppely
int idoppely
Definition: items.cpp:191
CreateMagicWeapon
void CreateMagicWeapon(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL delta)
Definition: items.cpp:3979
ISPL_LIGHTDAM
@ ISPL_LIGHTDAM
Definition: enums.h:2758
get_pieces_str
char * get_pieces_str(int nGold)
Definition: control.cpp:1891
IDI_ROGUE
@ IDI_ROGUE
Definition: enums.h:2503
premiumlevel
int premiumlevel
Definition: stores.cpp:12
IPL_KNOCKBACK
@ IPL_KNOCKBACK
Definition: enums.h:135
SpellData::sManaCost
unsigned char sManaCost
Definition: structs.h:1017
IPL_DEX
@ IPL_DEX
Definition: enums.h:109
ICLASS_GOLD
@ ICLASS_GOLD
Definition: enums.h:2741
UniqueItemFlag
BOOL UniqueItemFlag[128]
Definition: items.cpp:18
PlayerStruct::_pMaxHPBase
int _pMaxHPBase
Definition: structs.h:257
PlayerStruct::_pBaseDex
int _pBaseDex
Definition: structs.h:250
pSTextBoxCels
BYTE * pSTextBoxCels
Definition: stores.cpp:11
PutItemRecord
void PutItemRecord(int nSeed, WORD wCI, int nIndex)
Definition: items.cpp:4056
PlayerStruct::_pIBonusDamMod
int _pIBonusDamMod
Definition: structs.h:325
ItemStruct::_iSelFlag
char _iSelFlag
Definition: structs.h:112
ItemStruct::_iStatFlag
BOOL _iStatFlag
Definition: structs.h:169
nobjects
int nobjects
Definition: objects.cpp:10
IPL_ATTRIBS
@ IPL_ATTRIBS
Definition: enums.h:113
IPL_SPELL
@ IPL_SPELL
Definition: enums.h:148
MissileStruct::_miVar2
int _miVar2
Definition: structs.h:445
SpawnStoreGold
void SpawnStoreGold()
Definition: items.cpp:3786
INVLOC_CHEST
@ INVLOC_CHEST
Definition: enums.h:2795
ICURS_TAVERN_SIGN
@ ICURS_TAVERN_SIGN
Definition: enums.h:250
PlayerStruct::_pNumInv
int _pNumInv
Definition: structs.h:315
RndBoyItem
int RndBoyItem(int lvl)
Definition: items.cpp:3625
PlayerStruct::WorldX
int WorldX
Definition: structs.h:188
CalcPlrScrolls
void CalcPlrScrolls(int p)
Definition: items.cpp:613
PlayerStruct::_pHPBase
int _pHPBase
Definition: structs.h:256
ItemStruct::_iIvalue
int _iIvalue
Definition: structs.h:123
PlayerStruct::_pRSpell
int _pRSpell
Definition: structs.h:220
PlayerStruct::_pIFlags
int _pIFlags
Definition: structs.h:327
CURSOR_HAND
@ CURSOR_HAND
Definition: enums.h:2067
MAXDUNX
#define MAXDUNX
Definition: defs.h:25
ItemStruct::_iDurability
int _iDurability
Definition: structs.h:135
ItemStruct::_iMinDam
int _iMinDam
Definition: structs.h:124
IPL_CHARGES
@ IPL_CHARGES
Definition: enums.h:102
SMITH_PREMIUM_ITEMS
#define SMITH_PREMIUM_ITEMS
Definition: defs.h:58
ItemStruct::_iMinMag
unsigned char _iMinMag
Definition: structs.h:167
InitItemGFX
void InitItemGFX()
Definition: items.cpp:194
IMISC_FULLHEAL
@ IMISC_FULLHEAL
Definition: enums.h:2433
IS_FCAP
@ IS_FCAP
Definition: enums.h:310
BubbleSwapItem
void BubbleSwapItem(ItemStruct *a, ItemStruct *b)
Definition: items.cpp:3350
PlayerStruct::_pAnimWidth2
int _pAnimWidth2
Definition: structs.h:211
ANIM_ID_AXE
@ ANIM_ID_AXE
Definition: enums.h:2860
ItemStruct::_iAnimWidth2
int _iAnimWidth2
Definition: structs.h:110
ItemStruct::_iLMaxDam
int _iLMaxDam
Definition: structs.h:158
item
ItemStruct item[MAXITEMS+1]
Definition: items.cpp:15
PlayerStruct::_pISpells
uint64_t _pISpells
Definition: structs.h:326
MAXITEMS
#define MAXITEMS
Definition: defs.h:27
IMISC_SPECELIX
@ IMISC_SPECELIX
Definition: enums.h:2475
IPL_SETAC
@ IPL_SETAC
Definition: enums.h:156
GetPlrHandSeed
void GetPlrHandSeed(ItemStruct *h)
Definition: items.cpp:818
ICURS_GOLD_MEDIUM
@ ICURS_GOLD_MEDIUM
Definition: enums.h:178
ItemDataStruct::iLoc
char iLoc
Definition: structs.h:66
IPL_THORNS
@ IPL_THORNS
Definition: enums.h:130
ItemStruct::_iFlags
int _iFlags
Definition: structs.h:128
ItemStruct::_itype
int _itype
Definition: structs.h:102
SPL_TOWN
@ SPL_TOWN
Definition: enums.h:2137
ItemDoppel
void ItemDoppel()
Definition: items.cpp:2435
ISPL_DRAINLIFE
@ ISPL_DRAINLIFE
Definition: enums.h:2759
PlayerStruct::_pIEnAc
int _pIEnAc
Definition: structs.h:332
AllItemsList
DEVILUTION_BEGIN_NAMESPACE ItemDataStruct AllItemsList[]
Contains the data related to each item ID.
Definition: itemdat.cpp:11
CreateMagicArmor
void CreateMagicArmor(int x, int y, int imisc, int icurs, BOOL sendmsg, BOOL delta)
Definition: items.cpp:3952
PlayerStruct::HoldItem
ItemStruct HoldItem
Definition: structs.h:318
MIS_MANASHIELD
@ MIS_MANASHIELD
Definition: enums.h:1207
questlog
BOOL questlog
Definition: quests.cpp:6
PlayerStruct::_pNFrames
int _pNFrames
Definition: structs.h:289
IPL_FASTSWING
@ IPL_FASTSWING
Definition: enums.h:149
RndItem
int RndItem(int m)
Definition: items.cpp:1820
itemactive
DEVILUTION_BEGIN_NAMESPACE int itemactive[MAXITEMS]
Definition: items.cpp:10
DUR_INDESTRUCTIBLE
#define DUR_INDESTRUCTIBLE
Definition: defs.h:50
ItemStruct::_iFMaxDam
int _iFMaxDam
Definition: structs.h:156
ItemStruct::_iPLDam
int _iPLDam
Definition: structs.h:137
missile
MissileStruct missile[MAXMISSILES]
Definition: missiles.cpp:12
ANIM_ID_BOW
@ ANIM_ID_BOW
Definition: enums.h:2859
ITYPE_NONE
@ ITYPE_NONE
Definition: enums.h:2495
IPL_NOHEALPLR
@ IPL_NOHEALPLR
Definition: enums.h:132
IS_FSTAF
@ IS_FSTAF
Definition: enums.h:322
IDI_EAR
@ IDI_EAR
Definition: enums.h:2524
PlayerStruct::_pSplLvl
char _pSplLvl[64]
Definition: structs.h:225
ISPL_3XDAMVDEM
@ ISPL_3XDAMVDEM
Definition: enums.h:2783
INVLOC_HAND_LEFT
@ INVLOC_HAND_LEFT
Definition: enums.h:2793
ISPL_QUICKATTACK
@ ISPL_QUICKATTACK
Definition: enums.h:2770
MonsterStruct::mLevel
char mLevel
Definition: structs.h:595
IPL_STR_CURSE
@ IPL_STR_CURSE
Definition: enums.h:106
IPL_AC_CURSE
@ IPL_AC_CURSE
Definition: enums.h:160
IMISC_ELIXSICK
@ IMISC_ELIXSICK
Definition: enums.h:2448
STYPE_LIGHTNING
@ STYPE_LIGHTNING
Definition: enums.h:1944
ACTION_SPELL
@ ACTION_SPELL
Definition: enums.h:2909
PlayerStruct::InvList
ItemStruct InvList[NUM_INV_GRID_ELEM]
Definition: structs.h:314
PlayerStruct::_pVitality
int _pVitality
Definition: structs.h:251
IS_IBODY
@ IS_IBODY
Definition: enums.h:329
COL_GOLD
@ COL_GOLD
Definition: enums.h:1996
MemFreeDbg
#define MemFreeDbg(p)
Definition: defs.h:157
IS_IHARM
@ IS_IHARM
Definition: enums.h:334
ITYPE_MARMOR
@ ITYPE_MARMOR
Definition: enums.h:2488
IS_IANVL
@ IS_IANVL
Definition: enums.h:326
WT_RANGED
@ WT_RANGED
Definition: enums.h:2733
gnDifficulty
int gnDifficulty
Definition: gendung.cpp:31
IS_IBOW
@ IS_IBOW
Definition: enums.h:331
IPL_VIT
@ IPL_VIT
Definition: enums.h:111
IMISC_ELIXWEAK
@ IMISC_ELIXWEAK
Definition: enums.h:2445
ISPL_FASTERATTACK
@ ISPL_FASTERATTACK
Definition: enums.h:2772
IS_IAXE
@ IS_IAXE
Definition: enums.h:327
PlayerStruct::_pIBonusToHit
int _pIBonusToHit
Definition: structs.h:323
IPL_DUR
@ IPL_DUR
Definition: enums.h:121
ISPL_FASTBLOCK
@ ISPL_FASTBLOCK
Definition: enums.h:2777
boylevel
int boylevel
Definition: stores.cpp:35
IMISC_ELIXDIS
@ IMISC_ELIXDIS
Definition: enums.h:2446
ISPL_NOMANA
@ ISPL_NOMANA
Definition: enums.h:2780
ClrPlrPath
void ClrPlrPath(int pnum)
Definition: player.cpp:3466
ItemStruct::_iPLVit
int _iPLVit
Definition: structs.h:143
IPL_SETDAM
@ IPL_SETDAM
Definition: enums.h:145
RecreateTownItem
void RecreateTownItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue)
Definition: items.cpp:3874
PlayerStruct::_pNWidth
int _pNWidth
Definition: structs.h:290
PLT_MISC
@ PLT_MISC
Definition: enums.h:165
IDI_BRAIN
@ IDI_BRAIN
Definition: enums.h:2518
PlayerStruct::_pdir
int _pdir
Definition: structs.h:202
SpawnQuestItem
void SpawnQuestItem(int itemid, int x, int y, int randarea, int selflag)
Definition: items.cpp:2324
PlayerStruct::_pLevel
char _pLevel
Definition: structs.h:266
ANIM_ID_MEDIUM_ARMOR
@ ANIM_ID_MEDIUM_ARMOR
Definition: enums.h:2869
CalcPlrInv
void CalcPlrInv(int p, BOOL Loadgfx)
Definition: items.cpp:764
ItemStruct::_ivalue
int _ivalue
Definition: structs.h:122
IS_IMUSH
@ IS_IMUSH
Definition: enums.h:336
doom_init
void doom_init()
Definition: doom.cpp:67
SpawnUnique
void SpawnUnique(int uid, int x, int y)
Definition: items.cpp:2011
all.h
FreeItemGFX
void FreeItemGFX()
Definition: items.cpp:2482
IMISC_MEAT
@ IMISC_MEAT
Definition: enums.h:2459
RecreateItem
void RecreateItem(int ii, int idx, WORD icreateinfo, int iseed, int ivalue)
Definition: items.cpp:2251
ANIM_ID_STAFF
@ ANIM_ID_STAFF
Definition: enums.h:2863
ItemGetRecordStruct::nSeed
int nSeed
Definition: structs.h:93
SmithItemOk
BOOL SmithItemOk(int i)
Definition: items.cpp:3309
IS_IPOT
@ IS_IPOT
Definition: enums.h:337
PlayerStruct::SpdList
ItemStruct SpdList[MAXBELTITEMS]
Definition: structs.h:317
DeleteItem
void DeleteItem(int ii, int i)
Definition: items.cpp:2427
GetGoldSeed
void GetGoldSeed(int pnum, ItemStruct *h)
Definition: items.cpp:823
IPL_ACP
@ IPL_ACP
Definition: enums.h:93
ItemStruct::_iMagical
char _iMagical
Definition: structs.h:115
CheckIdentify
void CheckIdentify(int pnum, int cii)
Definition: items.cpp:2516
PlayerStruct::_pIMaxDam
int _pIMaxDam
Definition: structs.h:320
PlayerStruct::_pSplType
char _pSplType
Definition: structs.h:216
dObject
char dObject[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:19
ITYPE_AMULET
@ ITYPE_AMULET
Definition: enums.h:2493
curruitem
ItemStruct curruitem
Definition: items.cpp:13
RespawnItem
void RespawnItem(int i, BOOL FlipFlag)
Definition: items.cpp:2396
IPL_TOHIT_DAMP
@ IPL_TOHIT_DAMP
Definition: enums.h:91
premiumitem
ItemStruct premiumitem[SMITH_PREMIUM_ITEMS]
Definition: stores.cpp:10
ItemStruct::_iAnimData
unsigned char * _iAnimData
Definition: structs.h:106
ModifyPlrDex
void ModifyPlrDex(int p, int l)
Definition: player.cpp:3912
itemrecord
ItemGetRecordStruct itemrecord[MAXITEMS]
Definition: items.cpp:14
PlayerStruct::_pIFMinDam
int _pIFMinDam
Definition: structs.h:333
PFILE_STAND
@ PFILE_STAND
Definition: enums.h:2840
SortSmith
void SortSmith()
Definition: items.cpp:3359
GOLD_SMALL_LIMIT
#define GOLD_SMALL_LIMIT
Definition: defs.h:66
NetSendCmdDItem
void NetSendCmdDItem(BOOL bHiPri, int ii)
Definition: msg.cpp:916
RndAllItems
int RndAllItems()
Definition: items.cpp:1898
PlayerStruct::destParam1
int destParam1
Definition: structs.h:183
PlayerStruct::_pMagic
int _pMagic
Definition: structs.h:247
ProcessItems
void ProcessItems()
Definition: items.cpp:2454
PLT_SHLD
@ PLT_SHLD
Definition: enums.h:169
spelldata
DEVILUTION_BEGIN_NAMESPACE SpellData spelldata[]
Data related to each spell ID.
Definition: spelldat.cpp:6
infostr
char infostr[256]
Definition: control.cpp:52
ItemDataStruct::iMinMag
char iMinMag
Definition: structs.h:79
MAXBELTITEMS
#define MAXBELTITEMS
Definition: defs.h:28
IS_GOLD
@ IS_GOLD
Definition: enums.h:324
ItemStruct
Definition: structs.h:99
gbMaxPlayers
BYTE gbMaxPlayers
Specifies the maximum number of players in a game, where 1 represents a single player game and 4 repr...
Definition: multi.cpp:34
SetItemRecord
void SetItemRecord(int nSeed, WORD wCI, int nIndex)
Definition: items.cpp:4039
SaveItemPower
void SaveItemPower(int i, int power, int param1, int param2, int minval, int maxval, int multval)
Definition: items.cpp:1360
IPL_LIFE_CURSE
@ IPL_LIFE_CURSE
Definition: enums.h:118
ItemStruct::_iVMult2
int _iVMult2
Definition: structs.h:165
SCREEN_WIDTH
#define SCREEN_WIDTH
Definition: defs.h:105
ItemStruct::_iPLToHit
int _iPLToHit
Definition: structs.h:138
RIGHT_PANEL
#define RIGHT_PANEL
Definition: defs.h:143
PLStruct::PLGOE
BYTE PLGOE
Definition: structs.h:29
PlayerStruct::destParam2
int destParam2
Definition: structs.h:184
STYPE_MAGIC
@ STYPE_MAGIC
Definition: enums.h:1945
ItemStruct::_iMaxDur
int _iMaxDur
Definition: structs.h:136
IS_FSHLD
@ IS_FSHLD
Definition: enums.h:320
QS_MUSHGIVEN
@ QS_MUSHGIVEN
Definition: enums.h:2579
ISPL_LIGHT_ARROWS
@ ISPL_LIGHT_ARROWS
Definition: enums.h:2778
SpawnItem
void SpawnItem(int m, int x, int y, BOOL sendmsg)
Definition: items.cpp:2100
MAXDUNY
#define MAXDUNY
Definition: defs.h:26
SortHealer
void SortHealer()
Definition: items.cpp:3722
CheckUnique
int CheckUnique(int i, int lvl, int uper, BOOL recreate)
Definition: items.cpp:1947
UItemStruct::UIValue
int UIValue
Definition: structs.h:42
ItemDataStruct::iMinAC
int iMinAC
Definition: structs.h:76
INVLOC_HAND_RIGHT
@ INVLOC_HAND_RIGHT
Definition: enums.h:2794
ItemStruct::_iAnimFrame
int _iAnimFrame
Definition: structs.h:108
IPL_NOMANA
@ IPL_NOMANA
Definition: enums.h:131
SpawnSmith
void SpawnSmith(int lvl)
Definition: items.cpp:3382
IPL_FASTATTACK
@ IPL_FASTATTACK
Definition: enums.h:140
ItemStruct::_iPLHP
int _iPLHP
Definition: structs.h:148
IPL_LIGHT_CURSE
@ IPL_LIGHT_CURSE
Definition: enums.h:125
PlayerStruct::_pTSplType
char _pTSplType
Definition: structs.h:219
IMISC_EAR
@ IMISC_EAR
Definition: enums.h:2474
IS_IROCK
@ IS_IROCK
Definition: enums.h:339
ICURS_GOLD_SMALL
@ ICURS_GOLD_SMALL
Definition: enums.h:177
PlayerStruct::_pMaxMana
int _pMaxMana
Definition: structs.h:264
ItemDataStruct::iMinDam
int iMinDam
Definition: structs.h:74
dPiece
int dPiece[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:26
CalcSelfItems
void CalcSelfItems(int pnum)
Definition: items.cpp:650
ItemGetRecordStruct
Definition: structs.h:92
CalcPlrStaff
void CalcPlrStaff(int p)
Definition: items.cpp:640
ILOC_UNEQUIPABLE
@ ILOC_UNEQUIPABLE
Definition: enums.h:1188
ItemSpaceOk
BOOL ItemSpaceOk(int i, int j)
Definition: items.cpp:965
ItemDataStruct::iFlags
int iFlags
Definition: structs.h:82
nSolidTable
BOOLEAN nSolidTable[2049]
List of path blocking dPieces.
Definition: gendung.cpp:45
IMISC_STAFF
@ IMISC_STAFF
Definition: enums.h:2454
IDI_PORTAL
@ IDI_PORTAL
Definition: enums.h:2528
ItemStruct::_iVMult1
int _iVMult1
Definition: structs.h:163
RndWitchItem
int RndWitchItem(int lvl)
Definition: items.cpp:3522
UseItem
void UseItem(int p, int Mid, int spl)
Definition: items.cpp:3132
ICURS_GOLD_LARGE
@ ICURS_GOLD_LARGE
Definition: enums.h:179
ModifyPlrMag
void ModifyPlrMag(int p, int l)
Definition: player.cpp:3877
CalcPlrBookVals
void CalcPlrBookVals(int p)
Definition: items.cpp:735
PrintItemPower
void PrintItemPower(char plidx, ItemStruct *x)
Definition: items.cpp:2693
PlayerStruct::_pLightRad
char _pLightRad
Definition: structs.h:235
PLT_BOW
@ PLT_BOW
Definition: enums.h:166
ItemStruct::_iUid
int _iUid
Definition: structs.h:154
PlayerStruct::_pGFXLoad
int _pGFXLoad
Definition: structs.h:287
IS_IRING
@ IS_IRING
Definition: enums.h:338
RndTypeItems
int RndTypeItems(int itype, int imid)
Definition: items.cpp:1921
IDI_MANA
@ IDI_MANA
Definition: enums.h:2526
ItemStruct::_iClass
char _iClass
Definition: structs.h:120
IPL_STR
@ IPL_STR
Definition: enums.h:105
PlayerStruct::_pFireResist
char _pFireResist
Definition: structs.h:273
IMISC_RING
@ IMISC_RING
Definition: enums.h:2456
PLT_WEAP
@ PLT_WEAP
Definition: enums.h:168
SpellData::sNameText
char * sNameText
Definition: structs.h:1019
ITYPE_HELM
@ ITYPE_HELM
Definition: enums.h:2487
RndHealerItem
int RndHealerItem(int lvl)
Definition: items.cpp:3706
ICURS_BOOK_RED
@ ICURS_BOOK_RED
Definition: enums.h:222
ILOC_INVALID
@ ILOC_INVALID
Definition: enums.h:1190
IMISC_USELAST
@ IMISC_USELAST
Definition: enums.h:2451
uitemflag
BOOL uitemflag
Definition: items.cpp:11
smithitem
ItemStruct smithitem[SMITH_ITEMS]
Definition: stores.cpp:36
SetPlrAnims
void SetPlrAnims(int pnum)
Definition: player.cpp:425
DEVILUTION_END_NAMESPACE
#define DEVILUTION_END_NAMESPACE
Definition: types.h:10
ITYPE_GOLD
@ ITYPE_GOLD
Definition: enums.h:2491
ItemStruct::_iRequest
char _iRequest
Definition: structs.h:153
DIFF_NORMAL
@ DIFF_NORMAL
Definition: enums.h:2006
IPL_LIGHT
@ IPL_LIGHT
Definition: enums.h:124
IPL_ALLRESZERO
@ IPL_ALLRESZERO
Definition: enums.h:152
PlayerStruct::_pvid
int _pvid
Definition: structs.h:214
OBJ_STAND
@ OBJ_STAND
Definition: enums.h:2352
PlayerStruct::_pAnimData
unsigned char * _pAnimData
Definition: structs.h:205
monster
MonsterStruct monster[MAXMONSTERS]
Definition: monster.cpp:19
SetPlrHandItem
void SetPlrHandItem(ItemStruct *h, int idata)
Definition: items.cpp:779
PlayerStruct::_pISplLvlAdd
char _pISplLvlAdd
Definition: structs.h:329
MonsterStruct::MData
MonsterData * MData
Definition: structs.h:613
ISPL_RNDSTEALLIFE
@ ISPL_RNDSTEALLIFE
Definition: enums.h:2754
AddPanelString
void AddPanelString(char *str, BOOL just)
Definition: control.cpp:550
IPL_FIRERES
@ IPL_FIRERES
Definition: enums.h:95
ItemStruct::_iAnimFlag
BOOL _iAnimFlag
Definition: structs.h:105
RecreateSmithItem
void RecreateSmithItem(int ii, int idx, int lvl, int iseed)
Definition: items.cpp:3793
ISPL_INFRAVISION
@ ISPL_INFRAVISION
Definition: enums.h:2753
ANIM_ID_MACE
@ ANIM_ID_MACE
Definition: enums.h:2861
PlayerStruct::_pDamageMod
int _pDamageMod
Definition: structs.h:254
GetStaffPower
void GetStaffPower(int i, int lvl, int bs, BOOL onlygood)
Definition: items.cpp:1159
IDI_FULLMANA
@ IDI_FULLMANA
Definition: enums.h:2531
IS_ISWORD
@ IS_ISWORD
Definition: enums.h:344
DeltaAddItem
void DeltaAddItem(int ii)
Definition: msg.cpp:411
RSPLTYPE_SCROLL
@ RSPLTYPE_SCROLL
Definition: enums.h:2060
SPL_TELEKINESIS
@ SPL_TELEKINESIS
Definition: enums.h:2163
ITYPE_BOW
@ ITYPE_BOW
Definition: enums.h:2483
ISPL_RNDARROWVEL
@ ISPL_RNDARROWVEL
Definition: enums.h:2755
RSPLTYPE_INVALID
@ RSPLTYPE_INVALID
Definition: enums.h:2062
LoadFileInMem
BYTE * LoadFileInMem(char *pszName, DWORD *pdwFileLen)
Load a file in to a buffer.
Definition: engine.cpp:801
HealerItemOk
BOOL HealerItemOk(int i)
Definition: items.cpp:3661
NextItemRecord
void NextItemRecord(int i)
Definition: items.cpp:4025
RndUItem
int RndUItem(int m)
Definition: items.cpp:1856
IS_IBOOK
@ IS_IBOOK
Definition: enums.h:330
ModifyPlrStr
void ModifyPlrStr(int p, int l)
Definition: player.cpp:3848
PlayerStruct::_pBaseMag
int _pBaseMag
Definition: structs.h:248
ItemInvSnds
int ItemInvSnds[ITEMTYPES]
Definition: items.cpp:154
CelDraw
void CelDraw(int sx, int sy, BYTE *pCelBuff, int nCel, int nWidth)
Blit CEL sprite to the back buffer at the given coordinates.
Definition: engine.cpp:47
SPL_FLARE
@ SPL_FLARE
Definition: enums.h:2165
ItemStruct::_iPLLR
int _iPLLR
Definition: structs.h:145
IMISC_BOOK
@ IMISC_BOOK
Definition: enums.h:2455
ICURS_BOOK_GREY
@ ICURS_BOOK_GREY
Definition: enums.h:221
ItemDataStruct::iMinDex
char iMinDex
Definition: structs.h:80
SortWitch
void SortWitch()
Definition: items.cpp:3538
ItemDataStruct::iClass
char iClass
Definition: structs.h:65
CreateRndUseful
void CreateRndUseful(int pnum, int x, int y, BOOL sendmsg)
Definition: items.cpp:2209
ITYPE_MEAT
@ ITYPE_MEAT
Definition: enums.h:2494
golditem
ItemStruct golditem
Definition: stores.cpp:24
ItemStruct::_iAnimWidth
int _iAnimWidth
Definition: structs.h:109
RIGHT_PANEL_X
#define RIGHT_PANEL_X
Definition: defs.h:144
dItem
char dItem[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:57
IPL_MANA_CURSE
@ IPL_MANA_CURSE
Definition: enums.h:120
MissileStruct::_miVar1
int _miVar1
Definition: structs.h:444
GetUniqueItem
void GetUniqueItem(int i, int uid)
Definition: items.cpp:1984
IPL_TOHIT
@ IPL_TOHIT
Definition: enums.h:87
ISPL_FIREDAM
@ ISPL_FIREDAM
Definition: enums.h:2757
IPL_TOHIT_DAMP_CURSE
@ IPL_TOHIT_DAMP_CURSE
Definition: enums.h:92
PlayerStruct::_pIAC
int _pIAC
Definition: structs.h:321
boyitem
ItemStruct boyitem
Definition: stores.cpp:8
ItemAnimLs
BYTE ItemAnimLs[ITEMTYPES]
Definition: items.cpp:80
IS_ISHIEL
@ IS_ISHIEL
Definition: enums.h:341
objectactive
int objectactive[MAXOBJECTS]
Definition: objects.cpp:9
WT_MELEE
@ WT_MELEE
Definition: enums.h:2732
IMISC_ELIXCLUM
@ IMISC_ELIXCLUM
Definition: enums.h:2447
IS_FPOT
@ IS_FPOT
Definition: enums.h:316
ItemStruct::_iSplLvlAdd
char _iSplLvlAdd
Definition: structs.h:152
control_WriteStringToBuffer
BOOL control_WriteStringToBuffer(BYTE *str)
Definition: control.cpp:1170
GetSuperItemSpace
void GetSuperItemSpace(int x, int y, char inum)
Definition: items.cpp:1058
NewCursor
void NewCursor(int i)
Definition: cursor.cpp:107
IDI_WARRSHLD
@ IDI_WARRSHLD
Definition: enums.h:2501
ITYPE_STAFF
@ ITYPE_STAFF
Definition: enums.h:2490
IDI_GOLD
@ IDI_GOLD
Definition: enums.h:2499
SPL_HEAL
@ SPL_HEAL
Definition: enums.h:2132
ItemDataStruct
Definition: structs.h:63
SetupItem
void SetupItem(int i)
Definition: items.cpp:1797
PlayerStruct::_pMaxManaBase
int _pMaxManaBase
Definition: structs.h:262
PlayerStruct::_pLghtResist
char _pLghtResist
Definition: structs.h:274
STYPE_FIRE
@ STYPE_FIRE
Definition: enums.h:1943
ISPL_FASTESTRECOVER
@ ISPL_FASTESTRECOVER
Definition: enums.h:2776
CreateTypeItem
void CreateTypeItem(int x, int y, BOOL onlygood, int itype, int imisc, BOOL sendmsg, BOOL delta)
Definition: items.cpp:2226
RecreateWitchItem
void RecreateWitchItem(int ii, int idx, int lvl, int iseed)
Definition: items.cpp:3833
ICURS_MAGIC_ROCK
@ ICURS_MAGIC_ROCK
Definition: enums.h:216
missileactive
DEVILUTION_BEGIN_NAMESPACE int missileactive[MAXMISSILES]
Definition: missiles.cpp:10
GetItemSpace
BOOL GetItemSpace(int x, int y, char inum)
Definition: items.cpp:1004
IPL_FASTBLOCK
@ IPL_FASTBLOCK
Definition: enums.h:142
IPL_INVCURS
@ IPL_INVCURS
Definition: enums.h:129
GetRndSeed
int GetRndSeed()
Get the current RNG seed.
Definition: engine.cpp:739
IDI_ANVIL
@ IDI_ANVIL
Definition: enums.h:2516
numpremium
int numpremium
Definition: stores.cpp:22
ItemRndDur
void ItemRndDur(int ii)
Definition: items.cpp:2034
PlayerStruct::_pMemSpells
uint64_t _pMemSpells
Definition: structs.h:226
ITEM_QUALITY_UNIQUE
@ ITEM_QUALITY_UNIQUE
Definition: enums.h:10
PLT_STAFF
@ PLT_STAFF
Definition: enums.h:167
ChangeLightRadius
void ChangeLightRadius(int i, int r)
Definition: lighting.cpp:1056
IPL_INDESTRUCTIBLE
@ IPL_INDESTRUCTIBLE
Definition: enums.h:123
IPL_RNDARROWVEL
@ IPL_RNDARROWVEL
Definition: enums.h:144
StoreStatOk
BOOL StoreStatOk(ItemStruct *h)
Definition: items.cpp:3294
COL_BLUE
@ COL_BLUE
Definition: enums.h:1994
IDI_WARRIOR
@ IDI_WARRIOR
Definition: enums.h:2500
IPL_MAG
@ IPL_MAG
Definition: enums.h:107
ItemStruct::_iCharges
int _iCharges
Definition: structs.h:133
MonsterData::mTreasure
unsigned short mTreasure
Definition: structs.h:515
fontkern
const BYTE fontkern[68]
Maps from smaltext.cel frame number to character width.
Definition: control.cpp:81
PrintUString
void PrintUString(int x, int y, BOOL cjustflag, char *str, int col)
Definition: items.cpp:2932
PlayerStruct::_pBlockFlag
BOOLEAN _pBlockFlag
Definition: structs.h:233
IPL_MAG_CURSE
@ IPL_MAG_CURSE
Definition: enums.h:108
InitItems
void InitItems()
Definition: items.cpp:258
ChangeVisionRadius
void ChangeVisionRadius(int id, int r)
Definition: lighting.cpp:1196
IMISC_HEAL
@ IMISC_HEAL
Definition: enums.h:2434
ITYPE_HARMOR
@ ITYPE_HARMOR
Definition: enums.h:2489
SMITH_MAX_PREMIUM_VALUE
#define SMITH_MAX_PREMIUM_VALUE
Definition: defs.h:60
WitchBookLevel
void WitchBookLevel(int ii)
Definition: items.cpp:3561
CalcPlrItemVals
void CalcPlrItemVals(int p, BOOL Loadgfx)
Definition: items.cpp:296
IPL_NOHEALMON
@ IPL_NOHEALMON
Definition: enums.h:136
ItemStruct::_iName
char _iName[64]
Definition: structs.h:116
PLT_ARMO
@ PLT_ARMO
Definition: enums.h:170
SMITH_ITEMS
#define SMITH_ITEMS
Definition: defs.h:57
witchitem
ItemStruct witchitem[20]
Definition: stores.cpp:20
SetupAllItems
void SetupAllItems(int ii, int idx, int iseed, int lvl, int uper, int onlygood, BOOL recreate, BOOL pregen)
Definition: items.cpp:2040
SPANEL_WIDTH
#define SPANEL_WIDTH
Definition: defs.h:139
setlevel
BOOLEAN setlevel
Definition: gendung.cpp:65
Q_ROCK
@ Q_ROCK
Definition: enums.h:2548
ItemStruct::_iPLEnAc
int _iPLEnAc
Definition: structs.h:159
IPL_DEX_CURSE
@ IPL_DEX_CURSE
Definition: enums.h:110
ItemStruct::_iIdentified
BOOL _iIdentified
Definition: structs.h:114
PlayerStruct::_pIBonusDam
int _pIBonusDam
Definition: structs.h:322
IS_ISTAF
@ IS_ISTAF
Definition: enums.h:343
IS_IBLST
@ IS_IBLST
Definition: enums.h:328
pinfoflag
BOOL pinfoflag
Definition: control.cpp:33
ItemDataStruct::iSpell
int iSpell
Definition: structs.h:86
ItemNoFlippy
int ItemNoFlippy()
Definition: items.cpp:3915
ItemGetRecordStruct::nIndex
int nIndex
Definition: structs.h:95
GetStaffSpell
void GetStaffSpell(int i, int lvl, BOOL onlygood)
Definition: items.cpp:1216
premiumlvladd
int premiumlvladd[6]
Definition: items.cpp:192
DrawUTextBack
void DrawUTextBack()
Definition: items.cpp:2926
ISPL_NOHEALPLR
@ ISPL_NOHEALPLR
Definition: enums.h:2761
CreateSpellBook
void CreateSpellBook(int x, int y, int ispell, BOOL sendmsg, BOOL delta)
Definition: items.cpp:3927
DTYPE_HELL
@ DTYPE_HELL
Definition: enums.h:1872
UItemStruct::UINumPL
char UINumPL
Definition: structs.h:41
IPL_SETDUR
@ IPL_SETDUR
Definition: enums.h:146
ANIM_ID_HEAVY_ARMOR
@ ANIM_ID_HEAVY_ARMOR
Definition: enums.h:2870
numitems
int numitems
Definition: items.cpp:19
IS_FAXE
@ IS_FAXE
Definition: enums.h:305
IMISC_ELIXVIT
@ IMISC_ELIXVIT
Definition: enums.h:2444
PlayerStruct::_pIMinDam
int _pIMinDam
Definition: structs.h:319
IPL_FASTRECOVER
@ IPL_FASTRECOVER
Definition: enums.h:141
PlayerStruct::_pTSpell
int _pTSpell
Definition: structs.h:218
IS_FLARM
@ IS_FLARM
Definition: enums.h:312
IS_FBLST
@ IS_FBLST
Definition: enums.h:306
tempstr
char tempstr[256]
Definition: control.cpp:41
UITYPE_INVALID
@ UITYPE_INVALID
Definition: enums.h:83
IPL_STEALLIFE
@ IPL_STEALLIFE
Definition: enums.h:138
IDI_FULLHEAL
@ IDI_FULLHEAL
Definition: enums.h:2530
SetPlrHandSeed
void SetPlrHandSeed(ItemStruct *h, int iseed)
Definition: items.cpp:847
IMISC_NONE
@ IMISC_NONE
Definition: enums.h:2431
PlayerStruct::_pAnimWidth
int _pAnimWidth
Definition: structs.h:210
IS_FROCK
@ IS_FROCK
Definition: enums.h:318
SMITH_MAX_VALUE
#define SMITH_MAX_VALUE
Definition: defs.h:59
DIFF_NIGHTMARE
@ DIFF_NIGHTMARE
Definition: enums.h:2007
ItemStruct::_iFMinDam
int _iFMinDam
Definition: structs.h:155
IMISC_MAPOFDOOM
@ IMISC_MAPOFDOOM
Definition: enums.h:2473
IMISC_SCROLLT
@ IMISC_SCROLLT
Definition: enums.h:2453
AutoPlace
BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag)
Definition: inv.cpp:450
IS_FSCRL
@ IS_FSCRL
Definition: enums.h:319
PlayerStruct::_pInfraFlag
BOOL _pInfraFlag
Definition: structs.h:276
IS_FMUSH
@ IS_FMUSH
Definition: enums.h:315
SpellData::sStaffMin
int sStaffMin
Definition: structs.h:1030
IPL_FIRERESCLVL
@ IPL_FIRERESCLVL
Definition: enums.h:159
ItemGetRecordStruct::dwTimestamp
unsigned int dwTimestamp
Definition: structs.h:96
PlayerStruct::InvBody
ItemStruct InvBody[NUM_INVLOC]
Definition: structs.h:313
gnNumGetRecords
int gnNumGetRecords
Definition: items.cpp:20
CreateRndItem
void CreateRndItem(int x, int y, BOOL onlygood, BOOL sendmsg, BOOL delta)
Definition: items.cpp:2166
PlayerStruct::_pIBonusAC
int _pIBonusAC
Definition: structs.h:324
RepairItem
void RepairItem(ItemStruct *i, int lvl)
Definition: items.cpp:2553
IDI_ROCK
@ IDI_ROCK
Definition: enums.h:2509
ITEMTYPES
#define ITEMTYPES
Definition: defs.h:43
ItemStruct::IDidx
int IDidx
Definition: structs.h:170
IPL_STEALMANA
@ IPL_STEALMANA
Definition: enums.h:137
ITEM_QUALITY_NORMAL
@ ITEM_QUALITY_NORMAL
Definition: enums.h:8
SetupAllUseful
void SetupAllUseful(int ii, int iseed, int lvl)
Definition: items.cpp:2189
ItemStruct::_iPostDraw
BOOL _iPostDraw
Definition: structs.h:113
chrflag
BOOL chrflag
Definition: control.cpp:49
ItemDataStruct::iDurability
int iDurability
Definition: structs.h:73
PlayerStruct::_pIFMaxDam
int _pIFMaxDam
Definition: structs.h:334
myplr
int myplr
Definition: player.cpp:9
ISPL_NOHEALMON
@ ISPL_NOHEALMON
Definition: enums.h:2765
SPL_NOVA
@ SPL_NOVA
Definition: enums.h:2148
GetItemAttrs
void GetItemAttrs(int i, int idata, int lvl)
Definition: items.cpp:1266
ITYPE_SWORD
@ ITYPE_SWORD
Definition: enums.h:2481
IMISC_ELIXDEX
@ IMISC_ELIXDEX
Definition: enums.h:2443
random_
int random_(BYTE idx, int v)
Main RNG function.
Definition: engine.cpp:752
PlayerStruct::_pAnimDelay
int _pAnimDelay
Definition: structs.h:206
IS_FBODY
@ IS_FBODY
Definition: enums.h:307
PlayerStruct::_pHitPoints
int _pHitPoints
Definition: structs.h:258
ItemStruct::_iPLDamMod
int _iPLDamMod
Definition: structs.h:149
PL_Prefix
const PLStruct PL_Prefix[]
Contains the data related to each item prefix.
Definition: itemdat.cpp:175
cursmy
int cursmy
Definition: cursor.cpp:25
ItemStruct::_iPLMR
int _iPLMR
Definition: structs.h:146
RecreatePremiumItem
void RecreatePremiumItem(int ii, int idx, int plvl, int iseed)
Definition: items.cpp:3806
ItemStruct::_iIName
char _iIName[64]
Definition: structs.h:117
ICLASS_ARMOR
@ ICLASS_ARMOR
Definition: enums.h:2739
ItemStruct::_iMaxCharges
int _iMaxCharges
Definition: structs.h:134
ITYPE_MISC
@ ITYPE_MISC
Definition: enums.h:2480
PC_WARRIOR
@ PC_WARRIOR
Definition: enums.h:2706
drawmanaflag
BOOL drawmanaflag
Definition: control.cpp:24
GetItemRecord
BOOL GetItemRecord(int nSeed, WORD wCI, int nIndex)
Definition: items.cpp:4006
nummissiles
int nummissiles
Definition: missiles.cpp:13
CalcPlrItemMin
void CalcPlrItemMin(int pnum)
Definition: items.cpp:697
BUFFER_WIDTH
#define BUFFER_WIDTH
Definition: defs.h:128
GetSuperItemLoc
void GetSuperItemLoc(int x, int y, int *xx, int *yy)
Definition: items.cpp:1081
QUEST_ACTIVE
@ QUEST_ACTIVE
Definition: enums.h:2569
ItemStruct::_iPLMag
int _iPLMag
Definition: structs.h:141
QuestStruct::_qvar1
unsigned char _qvar1
Definition: structs.h:980
PLVal
int PLVal(int pv, int p1, int p2, int minv, int maxv)
Definition: items.cpp:1351
PremiumItemOk
BOOL PremiumItemOk(int i)
Definition: items.cpp:3405
SpawnOnePremium
void SpawnOnePremium(int i, int plvl)
Definition: items.cpp:3449
PlayerStruct::_pStrength
int _pStrength
Definition: structs.h:245
SpawnBoy
void SpawnBoy(int lvl)
Definition: items.cpp:3641
IPL_MANA
@ IPL_MANA
Definition: enums.h:119
ILOC_ONEHAND
@ ILOC_ONEHAND
Definition: enums.h:1182
ItemDataStruct::iValue
int iValue
Definition: structs.h:88
PlayerStruct::_pScrlSpells
uint64_t _pScrlSpells
Definition: structs.h:228
ItemDataStruct::iName
char * iName
Definition: structs.h:70
PC_ROGUE
@ PC_ROGUE
Definition: enums.h:2707
dMonster
int dMonster[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:17
ItemStruct::_iAC
int _iAC
Definition: structs.h:126
IPL_ONEHAND
@ IPL_ONEHAND
Definition: enums.h:150
IPL_SPLLVLADD
@ IPL_SPLLVLADD
Definition: enums.h:101
PlaySfxLoc
void PlaySfxLoc(int psfx, int x, int y)
Definition: effects.cpp:1142
DEVILUTION_BEGIN_NAMESPACE
Definition: sha.cpp:10
PLStruct::PLPower
int PLPower
Definition: structs.h:24
ITYPE_AXE
@ ITYPE_AXE
Definition: enums.h:2482
ItemStruct::_iPrePower
char _iPrePower
Definition: structs.h:160
ItemStruct::_iVAdd2
int _iVAdd2
Definition: structs.h:164
BFLAG_POPULATED
@ BFLAG_POPULATED
Definition: enums.h:1880
ItemGetRecordStruct::wCI
unsigned short wCI
Definition: structs.h:94
CalcItemValue
void CalcItemValue(int i)
Definition: items.cpp:1098
SpellData::sBookLvl
int sBookLvl
Definition: structs.h:1021
ITYPE_SHIELD
@ ITYPE_SHIELD
Definition: enums.h:2485
IPL_DAMMOD
@ IPL_DAMMOD
Definition: enums.h:143
IPL_DUR_CURSE
@ IPL_DUR_CURSE
Definition: enums.h:122
PlayerStruct::_pILMinDam
int _pILMinDam
Definition: structs.h:335
PlayerStruct::_pNAnim
unsigned char * _pNAnim[8]
Definition: structs.h:288
SpellData::sStaffMax
int sStaffMax
Definition: structs.h:1031
UItemStruct::UIItemId
char UIItemId
Definition: structs.h:39
infoclr
char infoclr
Definition: control.cpp:37
IPL_MAGICRES
@ IPL_MAGICRES
Definition: enums.h:97
ItemStruct::_iPLMana
int _iPLMana
Definition: structs.h:147
IMISC_REJUV
@ IMISC_REJUV
Definition: enums.h:2449
ISPL_ABSHALFTRAP
@ ISPL_ABSHALFTRAP
Definition: enums.h:2781
RecreateHealerItem
void RecreateHealerItem(int ii, int idx, int lvl, int iseed)
Definition: items.cpp:3857
IS_ICAP
@ IS_ICAP
Definition: enums.h:332
IMISC_OLDHEAL
@ IMISC_OLDHEAL
Definition: enums.h:2435
dPlayer
char dPlayer[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:49
ItemStruct::_iSufPower
char _iSufPower
Definition: structs.h:161
IPL_GETHIT_CURSE
@ IPL_GETHIT_CURSE
Definition: enums.h:115
IS_FRING
@ IS_FRING
Definition: enums.h:317
SpawnWitch
void SpawnWitch(int lvl)
Definition: items.cpp:3579
dFlags
char dFlags[MAXDUNX][MAXDUNY]
Definition: gendung.cpp:56
SPL_INVALID
@ SPL_INVALID
Definition: enums.h:2167
PlayerStruct::_pwtype
int _pwtype
Definition: structs.h:232
ISPL_KNOCKBACK
@ ISPL_KNOCKBACK
Definition: enums.h:2764
PrintChar
void PrintChar(int sx, int sy, int nCel, char col)
Print letter to the back buffer.
Definition: control.cpp:504
UniqueItemList
const UItemStruct UniqueItemList[]
Contains the data related to each unique item ID.
Definition: itemdat.cpp:369
ITYPE_MACE
@ ITYPE_MACE
Definition: enums.h:2484
PlayerStruct::_pBaseVit
int _pBaseVit
Definition: structs.h:252
ITYPE_LARMOR
@ ITYPE_LARMOR
Definition: enums.h:2486
fontframe
const BYTE fontframe[128]
Maps from font index to smaltext.cel frame number.
Definition: control.cpp:65
PlayerStruct::_pILMaxDam
int _pILMaxDam
Definition: structs.h:336
IS_FSWOR
@ IS_FSWOR
Definition: enums.h:323
NUM_INV_GRID_ELEM
#define NUM_INV_GRID_ELEM
Definition: defs.h:46
ItemStruct::_iMinDex
char _iMinDex
Definition: structs.h:168
IPL_DAMP
@ IPL_DAMP
Definition: enums.h:89
IMISC_USEFIRST
@ IMISC_USEFIRST
Definition: enums.h:2432
CMD_NOVA
@ CMD_NOVA
Definition: enums.h:2262
gbFontTransTbl
const BYTE gbFontTransTbl[256]
Maps ASCII character code to font index, as used by the small, medium and large sized fonts; which co...
Definition: control.cpp:106
ItemDataStruct::itype
char itype
Definition: structs.h:68
drawhpflag
BOOL drawhpflag
Definition: control.cpp:14
ItemDataStruct::iMiscId
int iMiscId
Definition: structs.h:84
PrintItemDetails
void PrintItemDetails(ItemStruct *x)
Definition: items.cpp:3040
ItemCAnimTbl
BYTE ItemCAnimTbl[169]
Definition: items.cpp:24
PlayerStruct::WorldY
int WorldY
Definition: structs.h:189
SpawnHealer
void SpawnHealer(int lvl)
Definition: items.cpp:3745
SpellData::sMinInt
int sMinInt
Definition: structs.h:1025
IPL_ATTRIBS_CURSE
@ IPL_ATTRIBS_CURSE
Definition: enums.h:114
ItemStruct::_iPLGetHit
int _iPLGetHit
Definition: structs.h:150
NetSendCmdLoc
void NetSendCmdLoc(BOOL bHiPri, BYTE bCmd, BYTE x, BYTE y)
Definition: msg.cpp:640
ITYPE_RING
@ ITYPE_RING
Definition: enums.h:2492
IPL_RNDSTEALLIFE
@ IPL_RNDSTEALLIFE
Definition: enums.h:154
IMISC_SCROLL
@ IMISC_SCROLL
Definition: enums.h:2452
ICLASS_WEAPON
@ ICLASS_WEAPON
Definition: enums.h:2738
CURSOR_TELEPORT
@ CURSOR_TELEPORT
Definition: enums.h:2075
ItemStruct::_iPLFR
int _iPLFR
Definition: structs.h:144
setpc_y
int setpc_y
Definition: gendung.cpp:75
ItemMinStats
BOOL ItemMinStats(PlayerStruct *p, ItemStruct *x)
Definition: items.cpp:721
DrawUniqueInfo
void DrawUniqueInfo()
Definition: items.cpp:2974
IDI_RESURRECT
@ IDI_RESURRECT
Definition: enums.h:2535
QS_BRAINSPAWNED
@ QS_BRAINSPAWNED
Definition: enums.h:2580
IPL_ALLRES
@ IPL_ALLRES
Definition: enums.h:98
ISPL_ALLRESZERO
@ ISPL_ALLRESZERO
Definition: enums.h:2784
RecalcStoreStats
void RecalcStoreStats()
Definition: items.cpp:3888
SpellData::sBookCost
int sBookCost
Definition: structs.h:1032
PlayerStruct::_pSplFrom
char _pSplFrom
Definition: structs.h:217
RecreateEar
void RecreateEar(int ii, WORD ic, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, int ibuff)
Definition: items.cpp:2297
itemhold
BOOL itemhold[3][3]
Definition: items.cpp:16
ItemDataStruct::iMaxDam
int iMaxDam
Definition: structs.h:75
IPL_ADDACLIFE
@ IPL_ADDACLIFE
Definition: enums.h:157
IS_FHARM
@ IS_FHARM
Definition: enums.h:311
leveltype
BYTE leveltype
Definition: gendung.cpp:39
healitem
ItemStruct healitem[20]
Definition: stores.cpp:23
PlayerStruct::_pRSplType
char _pRSplType
Definition: structs.h:222
GetItemBonus
void GetItemBonus(int i, int idata, int minlvl, int maxlvl, BOOL onlygood)
Definition: items.cpp:1762
CreateItem
void CreateItem(int uid, int x, int y)
Definition: items.cpp:2143
IMISC_FULLREJUV
@ IMISC_FULLREJUV
Definition: enums.h:2450
ItemDataStruct::iCurs
int iCurs
Definition: structs.h:67
RndSmithItem
int RndSmithItem(int lvl)
Definition: items.cpp:3330
ItemStruct::_iPLStr
int _iPLStr
Definition: structs.h:140
PrintItemMisc
void PrintItemMisc(ItemStruct *x)
Definition: items.cpp:3009
IPL_LIGHT_ARROWS
@ IPL_LIGHT_ARROWS
Definition: enums.h:128
IDI_WARRCLUB
@ IDI_WARRCLUB
Definition: enums.h:2502
IMISC_MANA
@ IMISC_MANA
Definition: enums.h:2437
plr
PlayerStruct plr[MAX_PLRS]
Definition: player.cpp:10
PlayerStruct
Definition: structs.h:178
MAX_SPELLS
#define MAX_SPELLS
Definition: defs.h:22
PC_SORCERER
@ PC_SORCERER
Definition: enums.h:2708
itemavail
int itemavail[MAXITEMS]
Definition: items.cpp:12
IPL_TOHIT_CURSE
@ IPL_TOHIT_CURSE
Definition: enums.h:88
IPL_DRAINLIFE
@ IPL_DRAINLIFE
Definition: enums.h:153
LoadPlrGFX
void LoadPlrGFX(int pnum, player_graphic gfxflag)
Definition: player.cpp:134
IMISC_ELIXMAG
@ IMISC_ELIXMAG
Definition: enums.h:2442
IS_FBOW
@ IS_FBOW
Definition: enums.h:309
ItemDropNames
char * ItemDropNames[ITEMTYPES]
Definition: items.cpp:43
GetItemPower
void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
Definition: items.cpp:1669
IPL_INFRAVISION
@ IPL_INFRAVISION
Definition: enums.h:155
ItemStruct::_iCreateInfo
WORD _iCreateInfo
Definition: structs.h:101
ISPL_THORNS
@ ISPL_THORNS
Definition: enums.h:2779
RndPremiumItem
int RndPremiumItem(int minlvl, int maxlvl)
Definition: items.cpp:3429
IMISC_ELIXSTR
@ IMISC_ELIXSTR
Definition: enums.h:2441
ModifyPlrVit
void ModifyPlrVit(int p, int l)
Definition: player.cpp:3938
IS_REPAIR
@ IS_REPAIR
Definition: enums.h:368
SetPlrHandGoldCurs
void SetPlrHandGoldCurs(ItemStruct *h)
Definition: items.cpp:852
IDI_HEAL
@ IDI_HEAL
Definition: enums.h:2525
IPL_FIRE_ARROWS
@ IPL_FIRE_ARROWS
Definition: enums.h:127
ANIM_ID_SWORD
@ ANIM_ID_SWORD
Definition: enums.h:2857
ItemStruct::_iPLLight
int _iPLLight
Definition: structs.h:151
IPL_3XDAMVDEM
@ IPL_3XDAMVDEM
Definition: enums.h:151
IS_ISCROL
@ IS_ISCROL
Definition: enums.h:340
IMISC_AMULET
@ IMISC_AMULET
Definition: enums.h:2457
IPL_ADDMANAAC
@ IPL_ADDMANAAC
Definition: enums.h:158
ItemStruct::_iMaxDam
int _iMaxDam
Definition: structs.h:125
PrintItemOil
void PrintItemOil(char IDidx)
Definition: items.cpp:2623
PlayerStruct::_pDexterity
int _pDexterity
Definition: structs.h:249
IPL_LIGHTDAM
@ IPL_LIGHTDAM
Definition: enums.h:104
SpellData::sStaffCost
int sStaffCost
Definition: structs.h:1033
SpawnRock
void SpawnRock()
Definition: items.cpp:2367