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

Function InitMonsters

Source/monster.cpp:919–991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

917#endif
918
919void InitMonsters()
920{
921 int na, nt;
922 int i, s, t;
923 int numplacemonsters;
924 int mtype;
925 int numscattypes;
926 int scattertypes[NUM_MTYPES];
927
928 numscattypes = 0;
929 if (gbMaxPlayers != 1)
930 CheckDungeonClear();
931 if (!setlevel) {
932 AddMonster(1, 0, 0, 0, FALSE);
933 AddMonster(1, 0, 0, 0, FALSE);
934 AddMonster(1, 0, 0, 0, FALSE);
935 AddMonster(1, 0, 0, 0, FALSE);
936 }
937#ifndef SPAWN
938 if (!setlevel && currlevel == 16)
939 LoadDiabMonsts();
940#endif
941 nt = numtrigs;
942 if (currlevel == 15)
943 nt = 1;
944 for (i = 0; i < nt; i++) {
945 for (s = -2; s < 2; s++) {
946 for (t = -2; t < 2; t++)
947 DoVision(s + trigs[i]._tx, t + trigs[i]._ty, 15, FALSE, FALSE);
948 }
949 }
950#ifndef SPAWN
951 PlaceQuestMonsters();
952#endif
953 if (!setlevel) {
954#ifndef SPAWN
955 PlaceUniques();
956#endif
957 na = 0;
958 for (s = 16; s < 96; s++)
959 for (t = 16; t < 96; t++)
960 if (!SolidLoc(s, t))
961 na++;
962 numplacemonsters = na / 30;
963 if (gbMaxPlayers != 1)
964 numplacemonsters += numplacemonsters >> 1;
965 if (nummonsters + numplacemonsters > 190)
966 numplacemonsters = 190 - nummonsters;
967 totalmonsters = nummonsters + numplacemonsters;
968 for (i = 0; i < nummtypes; i++) {
969 if (Monsters[i].mPlaceFlags & 1) {
970 scattertypes[numscattypes] = i;
971 numscattypes++;
972 }
973 }
974 while (nummonsters < totalmonsters) {
975 mtype = scattertypes[random_(95, numscattypes)];
976 if (currlevel == 1 || random_(95, 2) == 0)

Callers 1

LoadGameLevelFunction · 0.85

Calls 10

CheckDungeonClearFunction · 0.85
AddMonsterFunction · 0.85
LoadDiabMonstsFunction · 0.85
DoVisionFunction · 0.85
PlaceQuestMonstersFunction · 0.85
PlaceUniquesFunction · 0.85
SolidLocFunction · 0.85
random_Function · 0.85
PlaceGroupFunction · 0.85
DoUnVisionFunction · 0.85

Tested by

no test coverage detected