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

Function Theme_Library

Source/themes.cpp:704–743  ·  view source on GitHub ↗

Theme_Library initializes the library theme. Parameters: - t: theme number (index into themes array).

Source from the content-addressed store, hash-verified

702// Parameters:
703// - t: theme number (index into themes array).
704void Theme_Library(int t)
705{
706 int xp, yp, oi;
707 char librnd[4] = { 1, 2, 2, 5 };
708 char monstrnd[4] = { 5, 7, 3, 9 };
709
710 TFit_Shrine(t);
711
712 if (themeVar1 == 1) {
713 AddObject(OBJ_BOOKCANDLE, themex - 1, themey);
714 AddObject(OBJ_BOOKCASER, themex, themey);
715 AddObject(OBJ_BOOKCANDLE, themex + 1, themey);
716 } else {
717 AddObject(OBJ_BOOKCANDLE, themex, themey - 1);
718 AddObject(OBJ_BOOKCASEL, themex, themey);
719 AddObject(OBJ_BOOKCANDLE, themex, themey + 1);
720 }
721
722 for (yp = 1; yp < MAXDUNY - 1; yp++) {
723 for (xp = 1; xp < MAXDUNX - 1; xp++) {
724 if (CheckThemeObj3(xp, yp, t, -1) && dMonster[xp][yp] == 0 && random_(0, librnd[leveltype - 1]) == 0) {
725 AddObject(OBJ_BOOKSTAND, xp, yp);
726 if (random_(0, 2 * librnd[leveltype - 1]) != 0 && dObject[xp][yp]) { /// BUGFIX: check dObject[xp][yp] was populated by AddObject (fixed)
727 oi = dObject[xp][yp] - 1;
728 object[oi]._oSelFlag = 0;
729 object[oi]._oAnimFrame += 2;
730 }
731 }
732 }
733 }
734
735 if (QuestStatus(QTYPE_ZHAR)) {
736 if (t == zharlib) {
737 return;
738 }
739 PlaceThemeMonsts(t, monstrnd[leveltype]); /// BUGFIX: `leveltype - 1`
740 } else {
741 PlaceThemeMonsts(t, monstrnd[leveltype]); /// BUGFIX: `leveltype - 1`
742 }
743}
744
745// Theme_Torture initializes the torture theme.
746//

Callers 1

CreateThemeRoomsFunction · 0.85

Calls 6

TFit_ShrineFunction · 0.85
AddObjectFunction · 0.85
CheckThemeObj3Function · 0.85
random_Function · 0.85
QuestStatusFunction · 0.85
PlaceThemeMonstsFunction · 0.85

Tested by

no test coverage detected