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

Function PlaceGroup

Source/monster.cpp:827–897  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

825#endif
826
827void PlaceGroup(int mtype, int num, int leaderf, int leader)
828{
829 int placed, try1, try2, j;
830 int xp, yp, x1, y1;
831
832 placed = 0;
833
834 for (try1 = 0; try1 < 10; try1++) {
835 while (placed) {
836 nummonsters--;
837 placed--;
838 dMonster[monster[nummonsters]._mx][monster[nummonsters]._my] = 0;
839 }
840
841 if (leaderf & 1) {
842 int offset = random_(92, 8);
843 x1 = xp = monster[leader]._mx + offset_x[offset];
844 y1 = yp = monster[leader]._my + offset_y[offset];
845 } else {
846 do {
847 x1 = xp = random_(93, 80) + 16;
848 y1 = yp = random_(93, 80) + 16;
849 } while (!MonstPlace(xp, yp));
850 }
851
852 if (num + nummonsters > totalmonsters) {
853 num = totalmonsters - nummonsters;
854 }
855
856 j = 0;
857 for (try2 = 0; j < num && try2 < 100; xp += offset_x[random_(94, 8)], yp += offset_x[random_(94, 8)]) {
858 if (!MonstPlace(xp, yp)
859 || (dTransVal[xp][yp] != dTransVal[x1][y1])
860 || (leaderf & 2) && ((abs(xp - x1) >= 4) || (abs(yp - y1) >= 4))) {
861 try2++;
862 continue;
863 }
864
865 PlaceMonster(nummonsters, mtype, xp, yp);
866 if (leaderf & 1) {
867 monster[nummonsters]._mmaxhp *= 2;
868 monster[nummonsters]._mhitpoints = monster[nummonsters]._mmaxhp;
869 monster[nummonsters]._mint = monster[leader]._mint;
870
871 if (leaderf & 2) {
872 monster[nummonsters].leader = leader;
873 monster[nummonsters].leaderflag = 1;
874 monster[nummonsters]._mAi = monster[leader]._mAi;
875 }
876
877 if (monster[nummonsters]._mAi != AI_GARG) {
878 monster[nummonsters]._mAnimData = monster[nummonsters].MType->Anims[MA_STAND].Data[monster[nummonsters]._mdir];
879 monster[nummonsters]._mAnimFrame = random_(88, monster[nummonsters]._mAnimLen - 1) + 1;
880 monster[nummonsters]._mFlags &= ~MFLAG_ALLOW_SPECIAL;
881 monster[nummonsters]._mmode = MM_STAND;
882 }
883 }
884 nummonsters++;

Callers 2

PlaceUniqueMonstFunction · 0.85
InitMonstersFunction · 0.85

Calls 3

random_Function · 0.85
MonstPlaceFunction · 0.85
PlaceMonsterFunction · 0.85

Tested by

no test coverage detected