MCPcopy Create free account
hub / github.com/diasurgical/devilution / GetItemPower

Function GetItemPower

Source/items.cpp:1664–1755  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1662}
1663
1664void GetItemPower(int i, int minlvl, int maxlvl, int flgs, BOOL onlygood)
1665{
1666 int pre, post, nt, nl, j, preidx, sufidx;
1667 int l[256];
1668 char istr[128];
1669 BYTE goe;
1670
1671 pre = random_(23, 4);
1672 post = random_(23, 3);
1673 if (pre != 0 && post == 0) {
1674 if (random_(23, 2))
1675 post = 1;
1676 else
1677 pre = 0;
1678 }
1679 preidx = -1;
1680 sufidx = -1;
1681 goe = 0;
1682 if (!onlygood && random_(0, 3))
1683 onlygood = TRUE;
1684 if (!pre) {
1685 nt = 0;
1686 for (j = 0; PL_Prefix[j].PLPower != -1; j++) {
1687 if (flgs & PL_Prefix[j].PLIType) {
1688 if (PL_Prefix[j].PLMinLvl >= minlvl && PL_Prefix[j].PLMinLvl <= maxlvl && (!onlygood || PL_Prefix[j].PLOk) && (flgs != 256 || PL_Prefix[j].PLPower != 15)) {
1689 l[nt] = j;
1690 nt++;
1691 if (PL_Prefix[j].PLDouble) {
1692 l[nt] = j;
1693 nt++;
1694 }
1695 }
1696 }
1697 }
1698 if (nt) {
1699 preidx = l[random_(23, nt)];
1700 sprintf(istr, "%s %s", PL_Prefix[preidx].PLName, item[i]._iIName);
1701 strcpy(item[i]._iIName, istr);
1702 item[i]._iMagical = ITEM_QUALITY_MAGIC;
1703 SaveItemPower(
1704 i,
1705 PL_Prefix[preidx].PLPower,
1706 PL_Prefix[preidx].PLParam1,
1707 PL_Prefix[preidx].PLParam2,
1708 PL_Prefix[preidx].PLMinVal,
1709 PL_Prefix[preidx].PLMaxVal,
1710 PL_Prefix[preidx].PLMultVal);
1711 item[i]._iPrePower = PL_Prefix[preidx].PLPower;
1712 goe = PL_Prefix[preidx].PLGOE;
1713 }
1714 }
1715 if (post != 0) {
1716 nl = 0;
1717 for (j = 0; PL_Suffix[j].PLPower != -1; j++) {
1718 if (PL_Suffix[j].PLIType & flgs
1719 && PL_Suffix[j].PLMinLvl >= minlvl && PL_Suffix[j].PLMinLvl <= maxlvl
1720 && (goe | PL_Suffix[j].PLGOE) != 0x11
1721 && (!onlygood || PL_Suffix[j].PLOk)) {

Callers 2

GetStaffSpellFunction · 0.85
GetItemBonusFunction · 0.85

Calls 4

random_Function · 0.85
SaveItemPowerFunction · 0.85
CalcItemValueFunction · 0.85

Tested by

no test coverage detected