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

Function Theme_Treasure

Source/themes.cpp:667–698  ·  view source on GitHub ↗

Theme_Treasure initializes the treasure theme. Parameters: - t: theme number (index into themes array).

Source from the content-addressed store, hash-verified

665// Parameters:
666// - t: theme number (index into themes array).
667void Theme_Treasure(int t)
668{
669 int xp, yp;
670 int i;
671 char treasrnd[4] = { 4, 9, 7, 10 };
672 char monstrnd[4] = { 6, 8, 3, 7 };
673
674 GetRndSeed();
675 for (yp = 0; yp < MAXDUNY; yp++) {
676 for (xp = 0; xp < MAXDUNX; xp++) {
677 if (dTransVal[xp][yp] == themes[t].ttval && !nSolidTable[dPiece[xp][yp]]) {
678 int rv = random_(0, treasrnd[leveltype - 1]);
679 // BUGFIX: the `2*` in `2*random_(0, treasrnd...) == 0` has no effect, should probably be `random_(0, 2*treasrnd...) == 0`
680 if ((2 * random_(0, treasrnd[leveltype - 1])) == 0) {
681 CreateTypeItem(xp, yp, FALSE, ITYPE_GOLD, IMISC_NONE, FALSE, TRUE);
682 ItemNoFlippy();
683 }
684 if (rv == 0) {
685 CreateRndItem(xp, yp, FALSE, FALSE, TRUE);
686 ItemNoFlippy();
687 }
688 if (rv == 0 || rv >= treasrnd[leveltype - 1] - 2) {
689 i = ItemNoFlippy();
690 if (rv >= treasrnd[leveltype - 1] - 2 && leveltype != DTYPE_CATHEDRAL) {
691 item[i]._ivalue >>= 1;
692 }
693 }
694 }
695 }
696 }
697 PlaceThemeMonsts(t, monstrnd[leveltype - 1]);
698}
699
700// Theme_Library initializes the library theme.
701//

Callers 1

CreateThemeRoomsFunction · 0.85

Calls 6

GetRndSeedFunction · 0.85
random_Function · 0.85
CreateTypeItemFunction · 0.85
ItemNoFlippyFunction · 0.85
CreateRndItemFunction · 0.85
PlaceThemeMonstsFunction · 0.85

Tested by

no test coverage detected