Skip to content

Commit

Permalink
[hellfire] SpawnBoy
Browse files Browse the repository at this point in the history
  • Loading branch information
AJenbo committed Dec 27, 2020
1 parent 31f7861 commit 557af48
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
104 changes: 103 additions & 1 deletion Source/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5344,6 +5344,31 @@ void SpawnBoy(int lvl)
{
int itype;

#ifdef HELLFIRE
int ivalue;
int count = 0;

int strength = get_max_strength(plr[myplr]._pClass);
int dexterity = get_max_dexterity(plr[myplr]._pClass);
int magic = get_max_magic(plr[myplr]._pClass);
int pc = plr[myplr]._pClass;

if (strength < plr[myplr]._pStrength) {
strength = plr[myplr]._pStrength;
}
strength *= 1.2;

if (dexterity < plr[myplr]._pDexterity) {
dexterity = plr[myplr]._pDexterity;
}
dexterity *= 1.2;

if (magic < plr[myplr]._pMagic) {
magic = plr[myplr]._pMagic;
}
magic *= 1.2;
#endif

if (boylevel < (lvl >> 1) || boyitem._itype == ITYPE_NONE) {
do {
item[0]._iSeed = GetRndSeed();
Expand All @@ -5352,10 +5377,87 @@ void SpawnBoy(int lvl)
GetItemAttrs(0, itype, lvl);
#ifdef HELLFIRE
GetItemBonus(0, itype, lvl, 2 * lvl, TRUE, TRUE);

ivalue = 0;

int itemType = item[0]._itype;

switch (itemType) {
case ITYPE_LARMOR:
case ITYPE_MARMOR:
case ITYPE_HARMOR:
ivalue = get_armor_max_value(myplr);
break;
case ITYPE_SHIELD:
ivalue = get_shield_max_value(myplr);
break;
case ITYPE_AXE:
ivalue = get_axe_max_value(myplr);
break;
case ITYPE_BOW:
ivalue = get_bow_max_value(myplr);
break;
case ITYPE_MACE:
ivalue = get_mace_max_value(myplr);
break;
case ITYPE_SWORD:
ivalue = get_sword_max_value(myplr);
break;
case ITYPE_HELM:
ivalue = get_helm_max_value(myplr);
break;
case ITYPE_STAFF:
ivalue = get_staff_max_value(myplr);
break;
case ITYPE_RING:
ivalue = get_ring_max_value(myplr);
break;
case ITYPE_AMULET:
ivalue = get_amulet_max_value(myplr);
break;
}
ivalue *= 0.8;

count++;

if (count < 200) {
switch (pc) {
case PC_WARRIOR:
if (itemType == ITYPE_BOW || itemType == ITYPE_STAFF)
ivalue = INT_MAX;
break;
case PC_ROGUE:
if (itemType == ITYPE_SWORD || itemType == ITYPE_STAFF || itemType == ITYPE_AXE || itemType == ITYPE_MACE || itemType == ITYPE_SHIELD)
ivalue = INT_MAX;
break;
case PC_SORCERER:
if (itemType == ITYPE_STAFF || itemType == ITYPE_AXE || itemType == ITYPE_BOW || itemType == ITYPE_MACE)
ivalue = INT_MAX;
break;
case PC_MONK:
if (itemType == ITYPE_BOW || itemType == ITYPE_MARMOR || itemType == ITYPE_SHIELD || itemType == ITYPE_MACE)
ivalue = INT_MAX;
break;
case PC_BARD:
if (itemType == ITYPE_AXE || itemType == ITYPE_MACE || itemType == ITYPE_STAFF)
ivalue = INT_MAX;
break;
case PC_BARBARIAN:
if (itemType == ITYPE_BOW || itemType == ITYPE_STAFF)
ivalue = INT_MAX;
break;
}
}
} while ((item[0]._iIvalue > BOY_MAX_VALUE
|| item[0]._iMinStr > strength
|| item[0]._iMinMag > magic
|| item[0]._iMinDex > dexterity
|| item[0]._iIvalue < ivalue)
&& count < 250);
#else
GetItemBonus(0, itype, lvl, 2 * lvl, TRUE);
} while (item[0]._iIvalue > BOY_MAX_VALUE);
#endif
} while (item[0]._iIvalue > 90000);
boyitem = item[0];
boyitem._iCreateInfo = lvl | CF_BOY;
boyitem._iIdentified = TRUE;
Expand Down
2 changes: 2 additions & 0 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
// todo: enums
#ifdef HELLFIRE
#define NUMLEVELS 25
#define BOY_MAX_VALUE 200000
#define WITCH_ITEMS 25
#define SMITH_ITEMS 25
#define SMITH_PREMIUM_ITEMS 15
Expand All @@ -108,6 +109,7 @@
#define STORE_LINES 104
#else
#define NUMLEVELS 17
#define BOY_MAX_VALUE 90000
#define WITCH_ITEMS 20
#define SMITH_ITEMS 20
#define SMITH_PREMIUM_ITEMS 6
Expand Down

0 comments on commit 557af48

Please sign in to comment.