Browse Source

All items list (#567)

* Clean up RndAllItems

* Clean up SmithItemOk

* Clean PremiumItemOk

* Clean RndSmithItem

* Clean up RndPremiumItem

* Clean up RndBoyItem

* Clean up RndHealerItem

* Clean up RndWitchItem

* Clean up WitchItemOk
pull/25/head
Anders Jenbo 7 years ago committed by Robin Eklind
parent
commit
62b48e4788
  1. 247
      Source/items.cpp
  2. 8
      Source/items.h

247
Source/items.cpp

@ -2518,10 +2518,14 @@ int __fastcall RndItem(int m)
ri = 0; ri = 0;
for (i = 0; AllItemsList[i].iLoc != -1; i++) { for (i = 0; AllItemsList[i].iLoc != -1; i++) {
if (AllItemsList[i].iRnd == 2 && monster[m].mLevel >= AllItemsList[i].iMinMLvl) if (AllItemsList[i].iRnd == 2 && monster[m].mLevel >= AllItemsList[i].iMinMLvl) {
ril[ri++] = i; ril[ri] = i;
if (AllItemsList[i].iRnd && monster[m].mLevel >= AllItemsList[i].iMinMLvl) ri++;
ril[ri++] = i; }
if (AllItemsList[i].iRnd && monster[m].mLevel >= AllItemsList[i].iMinMLvl) {
ril[ri] = i;
ri++;
}
if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1) if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1)
ri--; ri--;
if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1)
@ -2565,41 +2569,39 @@ int __fastcall RndUItem(int m)
okflag = FALSE; okflag = FALSE;
if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1)
okflag = FALSE; okflag = FALSE;
if (okflag) if (okflag) {
ril[ri++] = i; ril[ri] = i;
ri++;
}
} }
return ril[random(25, ri)]; return ril[random(25, ri)];
} }
// 679660: using guessed type char gbMaxPlayers; // 679660: using guessed type char gbMaxPlayers;
// 421B32: using guessed type int var_800[512];
int __cdecl RndAllItems() int __cdecl RndAllItems()
{ {
int ri; // esi int i, ri;
int i; // edi int ril[512];
int ril[512]; // [esp+0h] [ebp-800h]
if (random(26, 100) > 25) if (random(26, 100) > 25)
return 0; return 0;
ri = 0; ri = 0;
i = 0; for (i = 0; AllItemsList[i].iLoc != -1; i++) {
if (AllItemsList[0].iLoc != -1) { if (AllItemsList[i].iRnd && 2 * currlevel >= AllItemsList[i].iMinMLvl) {
do { ril[ri] = i;
if (AllItemsList[i].iRnd && 2 * currlevel >= AllItemsList[i].iMinMLvl) ri++;
ril[ri++] = i; }
if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1) if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1)
--ri; ri--;
if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1) if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1)
--ri; ri--;
++i;
} while (AllItemsList[i].iLoc != -1);
} }
return ril[random(26, ri)]; return ril[random(26, ri)];
} }
// 679660: using guessed type char gbMaxPlayers; // 679660: using guessed type char gbMaxPlayers;
// 421C2A: using guessed type int var_800[512];
int __fastcall RndTypeItems(int itype, int imid) int __fastcall RndTypeItems(int itype, int imid)
{ {
@ -4137,39 +4139,46 @@ BOOLEAN __fastcall StoreStatOk(ItemStruct *h)
return sf; return sf;
} }
BOOLEAN __fastcall SmithItemOk(int i) BOOL __fastcall SmithItemOk(int i)
{ {
unsigned char v1; // cl BOOL rv;
BOOLEAN rv; // eax
v1 = AllItemsList[i].itype;
rv = TRUE; rv = TRUE;
if (!v1 || v1 == ITYPE_GOLD || v1 == ITYPE_0E || v1 == ITYPE_STAFF || v1 == ITYPE_RING || v1 == ITYPE_AMULET) if (AllItemsList[i].itype == ITYPE_MISC)
rv = FALSE;
if (AllItemsList[i].itype == ITYPE_GOLD)
rv = FALSE;
if (AllItemsList[i].itype == ITYPE_0E)
rv = FALSE;
if (AllItemsList[i].itype == ITYPE_STAFF)
rv = FALSE; rv = FALSE;
if (AllItemsList[i].itype == ITYPE_RING)
rv = FALSE;
if (AllItemsList[i].itype == ITYPE_AMULET)
rv = FALSE;
return rv; return rv;
} }
int __fastcall RndSmithItem(int lvl) int __fastcall RndSmithItem(int lvl)
{ {
int ri; // edx int i, ri;
int i; // edi int ril[512];
int ril[512]; // [esp+4h] [ebp-804h]
ri = 0; ri = 0;
i = 1; for (i = 1; AllItemsList[i].iLoc != -1; i++) {
if (AllItemsList[1].iLoc != -1) { if (AllItemsList[i].iRnd && SmithItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) {
do { ril[ri] = i;
if (AllItemsList[i].iRnd && SmithItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) { ri++;
ril[ri++] = i; if (AllItemsList[i].iRnd == 2) {
if (AllItemsList[i].iRnd == 2) ril[ri] = i;
ril[ri++] = i; ri++;
} }
++i; }
} while (AllItemsList[i].iLoc != -1);
} }
return ril[random(50, ri)] + 1; return ril[random(50, ri)] + 1;
} }
// 424252: using guessed type int var_804[512];
void __fastcall BubbleSwapItem(ItemStruct *a, ItemStruct *b) void __fastcall BubbleSwapItem(ItemStruct *a, ItemStruct *b)
{ {
@ -4251,41 +4260,46 @@ void __fastcall SpawnSmith(int lvl)
SortSmith(); SortSmith();
} }
BOOLEAN __fastcall PremiumItemOk(int i) BOOL __fastcall PremiumItemOk(int i)
{ {
unsigned char v1; // cl BOOL rv;
BOOLEAN rv; // eax
rv = TRUE;
if (AllItemsList[i].itype == ITYPE_MISC)
rv = FALSE;
if (AllItemsList[i].itype == ITYPE_GOLD)
rv = FALSE;
if (AllItemsList[i].itype == ITYPE_0E)
rv = FALSE;
if (AllItemsList[i].itype == ITYPE_STAFF)
rv = FALSE;
v1 = AllItemsList[i].itype; if (gbMaxPlayers != 1) {
rv = 1; if (AllItemsList[i].itype == ITYPE_RING)
if (!v1 || v1 == ITYPE_GOLD || v1 == ITYPE_0E || v1 == ITYPE_STAFF) rv = FALSE;
rv = 0; if (AllItemsList[i].itype == ITYPE_AMULET)
if (gbMaxPlayers != 1 && (v1 == ITYPE_RING || v1 == ITYPE_AMULET)) { rv = FALSE;
rv = 0;
} }
return rv; return rv;
} }
// 679660: using guessed type char gbMaxPlayers; // 679660: using guessed type char gbMaxPlayers;
int __fastcall RndPremiumItem(int minlvl, int maxlvl) int __fastcall RndPremiumItem(int minlvl, int maxlvl)
{ {
int ri; // edx int i, ri;
int i; // edi int ril[512];
int ril[512]; // [esp+8h] [ebp-804h]
ri = 0; ri = 0;
i = 1; for (i = 1; AllItemsList[i].iLoc != -1; i++) {
if (AllItemsList[1].iLoc != -1) { if (AllItemsList[i].iRnd) {
do { if (PremiumItemOk(i)) {
if (AllItemsList[i].iRnd) { if (AllItemsList[i].iMinMLvl >= minlvl && AllItemsList[i].iMinMLvl <= maxlvl)
if (PremiumItemOk(i)) { ril[ri++] = i;
if (AllItemsList[i].iMinMLvl >= minlvl && AllItemsList[i].iMinMLvl <= maxlvl)
ril[ri++] = i;
}
} }
++i; }
} while (AllItemsList[i].iLoc != -1);
} }
return ril[random(50, ri)] + 1; return ril[random(50, ri)] + 1;
} }
// 42445F: using guessed type int ril[512]; // 42445F: using guessed type int ril[512];
@ -4337,57 +4351,49 @@ void __fastcall SpawnPremium(int lvl)
} }
// 69FB38: using guessed type int talker; // 69FB38: using guessed type int talker;
BOOLEAN __fastcall WitchItemOk(int i) BOOL __fastcall WitchItemOk(int i)
{ {
BOOLEAN rv; // eax BOOL rv;
unsigned char v3; // dl
int v4; // edx rv = FALSE;
int v5; // ecx if (AllItemsList[i].itype == ITYPE_MISC)
rv = TRUE;
rv = 0; if (AllItemsList[i].itype == ITYPE_STAFF)
v3 = AllItemsList[i].itype; rv = TRUE;
if (!v3) if (AllItemsList[i].iMiscId == IMISC_MANA)
rv = 1; rv = FALSE;
if (v3 == ITYPE_STAFF) if (AllItemsList[i].iMiscId == IMISC_FULLMANA)
rv = 1; rv = FALSE;
v4 = AllItemsList[i].iMiscId; if (AllItemsList[i].iSpell == SPL_TOWN)
if (v4 == IMISC_MANA) rv = FALSE;
rv = 0; if (AllItemsList[i].iMiscId == IMISC_FULLHEAL)
if (v4 == IMISC_FULLMANA) rv = FALSE;
rv = 0; if (AllItemsList[i].iMiscId == IMISC_HEAL)
if (v4 == IMISC_FULLHEAL) rv = FALSE;
rv = 0; if (AllItemsList[i].iSpell == SPL_RESURRECT && gbMaxPlayers == 1)
if (v4 == IMISC_HEAL) rv = FALSE;
rv = 0; if (AllItemsList[i].iSpell == SPL_HEALOTHER && gbMaxPlayers == 1)
v5 = AllItemsList[i].iSpell; rv = FALSE;
if (v5 == SPL_TOWN)
rv = 0;
if (v5 == SPL_RESURRECT && gbMaxPlayers == 1)
rv = 0;
if (v5 == SPL_HEALOTHER && gbMaxPlayers == 1)
rv = 0;
return rv; return rv;
} }
// 679660: using guessed type char gbMaxPlayers; // 679660: using guessed type char gbMaxPlayers;
int __fastcall RndWitchItem(int lvl) int __fastcall RndWitchItem(int lvl)
{ {
int ri; // ebx int i, ri;
int i; // edi int ril[512];
int ril[512]; // [esp+8h] [ebp-804h]
ri = 0; ri = 0;
i = 1; for (i = 1; AllItemsList[i].iLoc != -1; i++) {
if (AllItemsList[1].iLoc != -1) { if (AllItemsList[i].iRnd && WitchItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) {
do { ril[ri] = i;
if (AllItemsList[i].iRnd && WitchItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) ri++;
ril[ri++] = i; }
++i;
} while (AllItemsList[i].iLoc != -1);
} }
return ril[random(51, ri)] + 1; return ril[random(51, ri)] + 1;
} }
// 4246D2: using guessed type int var_804[512];
void __cdecl SortWitch() void __cdecl SortWitch()
{ {
@ -4507,19 +4513,17 @@ void __fastcall SpawnWitch(int lvl)
int __fastcall RndBoyItem(int lvl) int __fastcall RndBoyItem(int lvl)
{ {
int ri; // edx int i, ri;
int i; // edi int ril[512];
int ril[512]; // [esp+8h] [ebp-800h]
ri = 0; ri = 0;
i = 1; for (i = 1; AllItemsList[i].iLoc != -1; i++) {
if (AllItemsList[1].iLoc != -1) { if (AllItemsList[i].iRnd && PremiumItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) {
do { ril[ri] = i;
if (AllItemsList[i].iRnd && PremiumItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) ri++;
ril[ri++] = i; }
++i;
} while (AllItemsList[i].iLoc != -1);
} }
return ril[random(49, ri)] + 1; return ril[random(49, ri)] + 1;
} }
// 4249A4: using guessed type int var_800[512]; // 4249A4: using guessed type int var_800[512];
@ -4545,7 +4549,7 @@ void __fastcall SpawnBoy(int lvl)
} }
// 6A8A3C: using guessed type int boylevel; // 6A8A3C: using guessed type int boylevel;
BOOLEAN __fastcall HealerItemOk(int i) BOOL __fastcall HealerItemOk(int i)
{ {
int v1; // ecx int v1; // ecx
BOOLEAN result; // eax BOOLEAN result; // eax
@ -4602,22 +4606,19 @@ LABEL_21:
int __fastcall RndHealerItem(int lvl) int __fastcall RndHealerItem(int lvl)
{ {
int ri; // ebx int i, ri;
int i; // edi int ril[512];
int ril[512]; // [esp+8h] [ebp-804h]
ri = 0; ri = 0;
i = 1; for (i = 1; AllItemsList[i].iLoc != -1; i++) {
if (AllItemsList[1].iLoc != -1) { if (AllItemsList[i].iRnd && HealerItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) {
do { ril[ri] = i;
if (AllItemsList[i].iRnd && HealerItemOk(i) && lvl >= AllItemsList[i].iMinMLvl) ri++;
ril[ri++] = i; }
++i;
} while (AllItemsList[i].iLoc != -1);
} }
return ril[random(50, ri)] + 1; return ril[random(50, ri)] + 1;
} }
// 424B49: using guessed type int var_804[512];
void __cdecl SortHealer() void __cdecl SortHealer()
{ {

8
Source/items.h

@ -89,23 +89,23 @@ void __fastcall PrintItemDetails(ItemStruct *x);
void __fastcall PrintItemDur(ItemStruct *x); void __fastcall PrintItemDur(ItemStruct *x);
void __fastcall UseItem(int p, int Mid, int spl); void __fastcall UseItem(int p, int Mid, int spl);
BOOLEAN __fastcall StoreStatOk(ItemStruct *h); BOOLEAN __fastcall StoreStatOk(ItemStruct *h);
BOOLEAN __fastcall SmithItemOk(int i); BOOL __fastcall SmithItemOk(int i);
int __fastcall RndSmithItem(int lvl); int __fastcall RndSmithItem(int lvl);
void __fastcall BubbleSwapItem(ItemStruct *a, ItemStruct *b); void __fastcall BubbleSwapItem(ItemStruct *a, ItemStruct *b);
void __cdecl SortSmith(); void __cdecl SortSmith();
void __fastcall SpawnSmith(int lvl); void __fastcall SpawnSmith(int lvl);
BOOLEAN __fastcall PremiumItemOk(int i); BOOL __fastcall PremiumItemOk(int i);
int __fastcall RndPremiumItem(int minlvl, int maxlvl); int __fastcall RndPremiumItem(int minlvl, int maxlvl);
void __fastcall SpawnOnePremium(int i, int plvl); void __fastcall SpawnOnePremium(int i, int plvl);
void __fastcall SpawnPremium(int lvl); void __fastcall SpawnPremium(int lvl);
BOOLEAN __fastcall WitchItemOk(int i); BOOL __fastcall WitchItemOk(int i);
int __fastcall RndWitchItem(int lvl); int __fastcall RndWitchItem(int lvl);
void __cdecl SortWitch(); void __cdecl SortWitch();
void __fastcall WitchBookLevel(int ii); void __fastcall WitchBookLevel(int ii);
void __fastcall SpawnWitch(int lvl); void __fastcall SpawnWitch(int lvl);
int __fastcall RndBoyItem(int lvl); int __fastcall RndBoyItem(int lvl);
void __fastcall SpawnBoy(int lvl); void __fastcall SpawnBoy(int lvl);
BOOLEAN __fastcall HealerItemOk(int i); BOOL __fastcall HealerItemOk(int i);
int __fastcall RndHealerItem(int lvl); int __fastcall RndHealerItem(int lvl);
void __cdecl SortHealer(); void __cdecl SortHealer();
void __fastcall SpawnHealer(int lvl); void __fastcall SpawnHealer(int lvl);

Loading…
Cancel
Save