|
|
|
|
@ -9,6 +9,7 @@
|
|
|
|
|
#include "items.h" |
|
|
|
|
#include "monster.h" |
|
|
|
|
#include "objects.h" |
|
|
|
|
#include "path.h" |
|
|
|
|
#include "quests.h" |
|
|
|
|
#include "trigs.h" |
|
|
|
|
|
|
|
|
|
@ -69,8 +70,8 @@ bool TFit_Shrine(int i)
|
|
|
|
|
while (found == 0) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[i].ttval) { |
|
|
|
|
if (nTrapTable[dPiece[xp][yp - 1]] |
|
|
|
|
&& !nSolidTable[dPiece[xp - 1][yp]] |
|
|
|
|
&& !nSolidTable[dPiece[xp + 1][yp]] |
|
|
|
|
&& IsTileNotSolid({ xp - 1, yp }) |
|
|
|
|
&& IsTileNotSolid({ xp + 1, yp }) |
|
|
|
|
&& dTransVal[xp - 1][yp] == themes[i].ttval |
|
|
|
|
&& dTransVal[xp + 1][yp] == themes[i].ttval |
|
|
|
|
&& dObject[xp - 1][yp - 1] == 0 |
|
|
|
|
@ -79,8 +80,8 @@ bool TFit_Shrine(int i)
|
|
|
|
|
} |
|
|
|
|
if (found == 0 |
|
|
|
|
&& nTrapTable[dPiece[xp - 1][yp]] |
|
|
|
|
&& !nSolidTable[dPiece[xp][yp - 1]] |
|
|
|
|
&& !nSolidTable[dPiece[xp][yp + 1]] |
|
|
|
|
&& IsTileNotSolid({ xp, yp - 1 }) |
|
|
|
|
&& IsTileNotSolid({ xp, yp + 1 }) |
|
|
|
|
&& dTransVal[xp][yp - 1] == themes[i].ttval |
|
|
|
|
&& dTransVal[xp][yp + 1] == themes[i].ttval |
|
|
|
|
&& dObject[xp - 1][yp - 1] == 0 |
|
|
|
|
@ -113,7 +114,7 @@ bool TFit_Obj5(int t)
|
|
|
|
|
|
|
|
|
|
while (r > 0) { |
|
|
|
|
bool found = false; |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { |
|
|
|
|
found = true; |
|
|
|
|
for (int i = 0; found && i < 25; i++) { |
|
|
|
|
if (nSolidTable[dPiece[xp + trm5x[i]][yp + trm5y[i]]]) { |
|
|
|
|
@ -374,13 +375,13 @@ bool CheckThemeRoom(int tv)
|
|
|
|
|
for (int i = 0; i < MAXDUNX; i++) { |
|
|
|
|
if (dTransVal[i][j] != tv || nSolidTable[dPiece[i][j]]) |
|
|
|
|
continue; |
|
|
|
|
if (dTransVal[i - 1][j] != tv && !nSolidTable[dPiece[i - 1][j]]) |
|
|
|
|
if (dTransVal[i - 1][j] != tv && IsTileNotSolid({ i - 1, j })) |
|
|
|
|
return false; |
|
|
|
|
if (dTransVal[i + 1][j] != tv && !nSolidTable[dPiece[i + 1][j]]) |
|
|
|
|
if (dTransVal[i + 1][j] != tv && IsTileNotSolid({ i + 1, j })) |
|
|
|
|
return false; |
|
|
|
|
if (dTransVal[i][j - 1] != tv && !nSolidTable[dPiece[i][j - 1]]) |
|
|
|
|
if (dTransVal[i][j - 1] != tv && IsTileNotSolid({ i, j - 1 })) |
|
|
|
|
return false; |
|
|
|
|
if (dTransVal[i][j + 1] != tv && !nSolidTable[dPiece[i][j + 1]]) |
|
|
|
|
if (dTransVal[i][j + 1] != tv && IsTileNotSolid({ i, j + 1 })) |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -489,7 +490,7 @@ void PlaceThemeMonsts(int t, int f)
|
|
|
|
|
int mtype = scattertypes[GenerateRnd(numscattypes)]; |
|
|
|
|
for (int yp = 0; yp < MAXDUNY; yp++) { |
|
|
|
|
for (int xp = 0; xp < MAXDUNX; xp++) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]] && dItem[xp][yp] == 0 && dObject[xp][yp] == 0) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp }) && dItem[xp][yp] == 0 && dObject[xp][yp] == 0) { |
|
|
|
|
if (GenerateRnd(f) == 0) { |
|
|
|
|
AddMonster({ xp, yp }, static_cast<Direction>(GenerateRnd(8)), mtype, true); |
|
|
|
|
} |
|
|
|
|
@ -510,7 +511,7 @@ void Theme_Barrel(int t)
|
|
|
|
|
|
|
|
|
|
for (int yp = 0; yp < MAXDUNY; yp++) { |
|
|
|
|
for (int xp = 0; xp < MAXDUNX; xp++) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { |
|
|
|
|
if (GenerateRnd(barrnd[leveltype - 1]) == 0) { |
|
|
|
|
_object_id r = OBJ_BARREL; |
|
|
|
|
if (GenerateRnd(barrnd[leveltype - 1]) != 0) { |
|
|
|
|
@ -559,7 +560,7 @@ void Theme_MonstPit(int t)
|
|
|
|
|
int ixp = 0; |
|
|
|
|
int iyp = 0; |
|
|
|
|
while (r > 0) { |
|
|
|
|
if (dTransVal[ixp][iyp] == themes[t].ttval && !nSolidTable[dPiece[ixp][iyp]]) { |
|
|
|
|
if (dTransVal[ixp][iyp] == themes[t].ttval && IsTileNotSolid({ ixp, iyp })) { |
|
|
|
|
--r; |
|
|
|
|
} |
|
|
|
|
if (r <= 0) |
|
|
|
|
@ -664,7 +665,7 @@ void Theme_Treasure(int t)
|
|
|
|
|
AdvanceRndSeed(); |
|
|
|
|
for (int yp = 0; yp < MAXDUNY; yp++) { |
|
|
|
|
for (int xp = 0; xp < MAXDUNX; xp++) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { |
|
|
|
|
int rv = GenerateRnd(treasrnd[leveltype - 1]); |
|
|
|
|
// BUGFIX: the `2*` in `2*GenerateRnd(treasrnd...) == 0` has no effect, should probably be `GenerateRnd(2*treasrnd...) == 0`
|
|
|
|
|
if ((2 * GenerateRnd(treasrnd[leveltype - 1])) == 0) { |
|
|
|
|
@ -744,7 +745,7 @@ void Theme_Torture(int t)
|
|
|
|
|
|
|
|
|
|
for (int yp = 1; yp < MAXDUNY - 1; yp++) { |
|
|
|
|
for (int xp = 1; xp < MAXDUNX - 1; xp++) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { |
|
|
|
|
if (CheckThemeObj3(xp, yp, t, -1)) { |
|
|
|
|
if (GenerateRnd(tortrnd[leveltype - 1]) == 0) { |
|
|
|
|
AddObject(OBJ_TNUDEM2, { xp, yp }); |
|
|
|
|
@ -781,7 +782,7 @@ void Theme_Decap(int t)
|
|
|
|
|
|
|
|
|
|
for (int yp = 1; yp < MAXDUNY - 1; yp++) { |
|
|
|
|
for (int xp = 1; xp < MAXDUNX - 1; xp++) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { |
|
|
|
|
if (CheckThemeObj3(xp, yp, t, -1)) { |
|
|
|
|
if (GenerateRnd(decaprnd[leveltype - 1]) == 0) { |
|
|
|
|
AddObject(OBJ_DECAP, { xp, yp }); |
|
|
|
|
@ -823,7 +824,7 @@ void Theme_ArmorStand(int t)
|
|
|
|
|
} |
|
|
|
|
for (int yp = 0; yp < MAXDUNY; yp++) { |
|
|
|
|
for (int xp = 0; xp < MAXDUNX; xp++) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { |
|
|
|
|
if (CheckThemeObj3(xp, yp, t, -1)) { |
|
|
|
|
if (GenerateRnd(armorrnd[leveltype - 1]) == 0) { |
|
|
|
|
AddObject(OBJ_ARMORSTANDN, { xp, yp }); |
|
|
|
|
@ -847,7 +848,7 @@ void Theme_GoatShrine(int t)
|
|
|
|
|
AddObject(OBJ_GOATSHRINE, { themex, themey }); |
|
|
|
|
for (int yy = themey - 1; yy <= themey + 1; yy++) { |
|
|
|
|
for (int xx = themex - 1; xx <= themex + 1; xx++) { |
|
|
|
|
if (dTransVal[xx][yy] == themes[t].ttval && !nSolidTable[dPiece[xx][yy]] && (xx != themex || yy != themey)) { |
|
|
|
|
if (dTransVal[xx][yy] == themes[t].ttval && IsTileNotSolid({ xx, yy }) && (xx != themex || yy != themey)) { |
|
|
|
|
AddMonster({ xx, yy }, DIR_SW, themeVar1, true); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -908,7 +909,7 @@ void Theme_BrnCross(int t)
|
|
|
|
|
|
|
|
|
|
for (int yp = 0; yp < MAXDUNY; yp++) { |
|
|
|
|
for (int xp = 0; xp < MAXDUNX; xp++) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { |
|
|
|
|
if (CheckThemeObj3(xp, yp, t, -1)) { |
|
|
|
|
if (GenerateRnd(bcrossrnd[leveltype - 1]) == 0) { |
|
|
|
|
AddObject(OBJ_TBCROSS, { xp, yp }); |
|
|
|
|
@ -936,7 +937,7 @@ void Theme_WeaponRack(int t)
|
|
|
|
|
} |
|
|
|
|
for (int yp = 0; yp < MAXDUNY; yp++) { |
|
|
|
|
for (int xp = 0; xp < MAXDUNX; xp++) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) { |
|
|
|
|
if (dTransVal[xp][yp] == themes[t].ttval && IsTileNotSolid({ xp, yp })) { |
|
|
|
|
if (CheckThemeObj3(xp, yp, t, -1)) { |
|
|
|
|
if (GenerateRnd(weaponrnd[leveltype - 1]) == 0) { |
|
|
|
|
AddObject(OBJ_WEAPONRACKN, { xp, yp }); |
|
|
|
|
|