We initialize NM
(the number of monsters created for this dungeon level) to 0 and loop 10 times.
2000 NM = 0: FOR X = 1 TO 10
X
, our loop variable will be the monster level/type.
We set MZ%(X,0)
for the monster to 0 and the number of HIT POINTS it has (MZ%(X,1)
) to 3 + monster level + dungeon level (although oddly we override this once we actually place the monster below).
2005 MZ%(X,0) = 0:MZ%(X,1) = X + 3 + INOUT
If the monster is more than two levels higher than the dungeon level, we skip it and continue the loop. Even if the monster in consideration is an okay level, there's still only a 40% chance we have one.
2010 IF X - 2 > INO OR RND (1) > .4 THEN 2090
Next we pick a location for the monster.
2020 ML%(X,0) = INT ( RND (1) * 9 + 1):ML%(X,1) = INT ( RND (1) * 9 + 1)
If it's already occupied (not just by a monster but anything, like a wall) we go back and pick a new location:
2030 IF DNG%(ML%(X,0),ML%(X,1)) < > 0 THEN 2020
If it's the same location as the player, we go back and pick a new location:
2040 IF ML%(X,0) = PX AND ML%(X,1) = PY THEN 2020
Now that we've established we definitely have a monster, we place it in DNG%()
(by putting the monster type/level in the tens column):
2050 DNG%(ML%(X,0),ML%(X,1)) = X * 10
We set MZ%(X,0) to 1 for the monster and increment our monster count for the dungeon level.
2051 MZ%(X,0) = 1
2052 NM = NM + 1
Finally we set the HIT POINTS to be 2 * (monster level + dungeon level * player difficulty level).
2055 MZ%(X,1) = X * 2 + IN * 2 * LP
And we loop back for the next monster type before returning.
2090 NEXT : RETURN