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

Function SpawnWitch

Source/items.cpp:3569–3613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3567}
3568
3569void SpawnWitch(int lvl)
3570{
3571 int i, iCnt;
3572 int idata, maxlvl;
3573
3574 GetItemAttrs(0, IDI_MANA, 1);
3575 witchitem[0] = item[0];
3576 witchitem[0]._iCreateInfo = lvl;
3577 witchitem[0]._iStatFlag = TRUE;
3578 GetItemAttrs(0, IDI_FULLMANA, 1);
3579 witchitem[1] = item[0];
3580 witchitem[1]._iCreateInfo = lvl;
3581 witchitem[1]._iStatFlag = TRUE;
3582 GetItemAttrs(0, IDI_PORTAL, 1);
3583 witchitem[2] = item[0];
3584 witchitem[2]._iCreateInfo = lvl;
3585 witchitem[2]._iStatFlag = TRUE;
3586 iCnt = random_(51, 8) + 10;
3587
3588 for (i = 3; i < iCnt; i++) {
3589 do {
3590 item[0]._iSeed = GetRndSeed();
3591 SetRndSeed(item[0]._iSeed);
3592 idata = RndWitchItem(lvl) - 1;
3593 GetItemAttrs(0, idata, lvl);
3594 maxlvl = -1;
3595 if (random_(51, 100) <= 5)
3596 maxlvl = 2 * lvl;
3597 if (maxlvl == -1 && item[0]._iMiscId == IMISC_STAFF)
3598 maxlvl = 2 * lvl;
3599 if (maxlvl != -1)
3600 GetItemBonus(0, idata, maxlvl >> 1, maxlvl, TRUE);
3601 } while (item[0]._iIvalue > 140000);
3602 witchitem[i] = item[0];
3603 witchitem[i]._iCreateInfo = lvl | 0x2000;
3604 witchitem[i]._iIdentified = TRUE;
3605 WitchBookLevel(i);
3606 witchitem[i]._iStatFlag = StoreStatOk(&witchitem[i]);
3607 }
3608
3609 for (i = iCnt; i < 20; i++)
3610 witchitem[i]._itype = ITYPE_NONE;
3611
3612 SortWitch();
3613}
3614
3615int RndBoyItem(int lvl)
3616{

Callers 2

SetupTownStoresFunction · 0.85
StoresCheatFunction · 0.85

Calls 9

GetItemAttrsFunction · 0.85
random_Function · 0.85
GetRndSeedFunction · 0.85
SetRndSeedFunction · 0.85
RndWitchItemFunction · 0.85
GetItemBonusFunction · 0.85
WitchBookLevelFunction · 0.85
StoreStatOkFunction · 0.85
SortWitchFunction · 0.85

Tested by

no test coverage detected