IPB

Welcome Guest ( Log In | Register )

2 Pages V   1 2 >  
Reply to this topicStart new topic
> Monster spawning formula?
Mordion
post Sep 27 2018, 03:34 AM
Post #1


Vagabond
**

Group: Members Plus
Posts: 101
Joined: 30-September 07
Member No.: 3,924
referrer:The Super Seer



Does anyone know how monsters are spawned? I assume that, like item drops, a list of candidates are generated and then the odds are monster chance/sum of all candidate chances. But how is that list generated? Is it the set of all monsters from the current floor with a type that matches the areas spawn flags? I know sometimes easier monsters show up. Are all monsters from the previous floor candidates too? How are their chance scores modified, if at all? How are the odds modified by laired monsters?
Go to the top of the page
 
+Quote Post
Nudibranch
post Sep 28 2018, 03:34 AM
Post #2


Fire Master
*********

Group: Mordor MP Prog
Posts: 1,613
Joined: 19-November 04
Member No.: 71
referrer:search



An examination of the source reveals the following. I might have misread some of it, it's very tangled. I didn't look into how the "companions" of the lead monster are generated, though Wabbit's editor gives a general idea (num group, in group, comp type, companions).

- If there's a laired monster, there's a 75% chance of it showing up.
- If it's a stud room, the maximum level of the lead monster in that room is the current level+1 (as advertised!). There's a 2/3 chance that its minimum level is the current level. Otherwise, the min level is the same as for a normal room (see next step).
- If it's a normal room, the minimum level is about 80% of the current level (not sure how it's rounded off), with a 20% chance of it being an additional -1 level, a 20% chance of it being -2 levels, and a 10% chance of -3 levels. (This would suggest that the lowest possible level of a lead monster on level 15 will be 9, and you might still meet level 1 groups on level 5.)
- For the general monster type (insect, demon, thief, etc.), there's a 1% chance it's randomly chosen from all possible types - otherwise, the type is randomly chosen out of what types are assigned to the room.
- For the specific monster within that type, the selection is weighted by each valid monster's "chance". Monsters above or below the previously determined max or min level are excluded.

On level 1, rooms #1 to #17 have special restrictions on what monsters can appear. These rooms are all within 2 rooms of the entry stairs, plus a few directly to the east of the stairs up to about 5 rooms away.
- They can only have one monster group.
- They can never have a random type.
- They can never be higher than "guild level 2", so no Orcs, Slaves, or Twisted Dwarves. Also no Margoyles or Zombies even in the couple of sub-#18 rooms that allow devils or undead. It looks like Tengus are possible, though still rare.

I still can't discern why T'Manas and Dragon Turtles never show up.


--------------------
I would have started with lasers. Eight o'clock. Day one.
Go to the top of the page
 
+Quote Post
Roland
post Sep 28 2018, 04:32 AM
Post #3


Mentor
****

Group: Members Plus
Posts: 302
Joined: 20-September 16
From: Maryland
Member No.: 8,408
referrer:Google



QUOTE (Nudibranch @ Sep 27 2018, 11:34 PM) *
I still can't discern why T'Manas and Dragon Turtles never show up.

I run a mod by DarkerMuffin that fixes the spawning of a number or problematic monsters, including T'Manas and Dragon Turtles. When he posted the mod, DarkerMuffin explained the spawning problems and how he fixed them. Most of the spawning problems result from the monster being assigned a companion type that can never spawn with it. In the case of Dragon Turtles, they are supposed to spawn with cascading Kyu-type Water Dwellers. But the first one, the Kyu t'Salli, is just a level-10 monster and therefore can't spawn in the second slot on level 14. When that happens, the game apparently goes back to the drawing board and re-rolls the encounter.

DarkerMuffin fixed Indiginis by assigning them animals as companions. It seems to have worked. Immediately after I installed the mod, I started encountering Indiginis, and I've seen lots of T'Manas.

If you want more detail, read DarkerMuffin's original post. He posted it in this forum in 2015, so you won't have to scroll down very far to find it.
Go to the top of the page
 
+Quote Post
Mordion
post Sep 28 2018, 08:51 PM
Post #4


Vagabond
**

Group: Members Plus
Posts: 101
Joined: 30-September 07
Member No.: 3,924
referrer:The Super Seer



QUOTE (Nudibranch @ Sep 27 2018, 11:34 PM) *
An examination of the source reveals the following. I might have misread some of it, it's very tangled. I didn't look into how the "companions" of the lead monster are generated, though Wabbit's editor gives a general idea (num group, in group, comp type, companions).

- If there's a laired monster, there's a 75% chance of it showing up.
- If it's a stud room, the maximum level of the lead monster in that room is the current level+1 (as advertised!). There's a 2/3 chance that its minimum level is the current level. Otherwise, the min level is the same as for a normal room (see next step).
- If it's a normal room, the minimum level is about 80% of the current level (not sure how it's rounded off), with a 20% chance of it being an additional -1 level, a 20% chance of it being -2 levels, and a 10% chance of -3 levels. (This would suggest that the lowest possible level of a lead monster on level 15 will be 9, and you might still meet level 1 groups on level 5.)
- For the general monster type (insect, demon, thief, etc.), there's a 1% chance it's randomly chosen from all possible types - otherwise, the type is randomly chosen out of what types are assigned to the room.
- For the specific monster within that type, the selection is weighted by each valid monster's "chance". Monsters above or below the previously determined max or min level are excluded.

On level 1, rooms #1 to #17 have special restrictions on what monsters can appear. These rooms are all within 2 rooms of the entry stairs, plus a few directly to the east of the stairs up to about 5 rooms away.
- They can only have one monster group.
- They can never have a random type.
- They can never be higher than "guild level 2", so no Orcs, Slaves, or Twisted Dwarves. Also no Margoyles or Zombies even in the couple of sub-#18 rooms that allow devils or undead. It looks like Tengus are possible, though still rare.

I still can't discern why T'Manas and Dragon Turtles never show up.


Does it pick a type and then pick a monster of the type or does it put all monsters of allowed types in a pile and pick from the pile?

What line of what file is the function? My copy of the source is from a VB3 decompiler and it has no annotations.

I remember getting violated by a Tengu close to the stairs the first time I played M2. Thought I was a Mordor pro at the time. Didn't see it coming.
Go to the top of the page
 
+Quote Post
Mordion
post Sep 28 2018, 08:53 PM
Post #5


Vagabond
**

Group: Members Plus
Posts: 101
Joined: 30-September 07
Member No.: 3,924
referrer:The Super Seer



QUOTE (Roland @ Sep 28 2018, 12:32 AM) *
I run a mod by DarkerMuffin that fixes the spawning of a number or problematic monsters, including T'Manas and Dragon Turtles. When he posted the mod, DarkerMuffin explained the spawning problems and how he fixed them. Most of the spawning problems result from the monster being assigned a companion type that can never spawn with it. In the case of Dragon Turtles, they are supposed to spawn with cascading Kyu-type Water Dwellers. But the first one, the Kyu t'Salli, is just a level-10 monster and therefore can't spawn in the second slot on level 14. When that happens, the game apparently goes back to the drawing board and re-rolls the encounter.

DarkerMuffin fixed Indiginis by assigning them animals as companions. It seems to have worked. Immediately after I installed the mod, I started encountering Indiginis, and I've seen lots of T'Manas.

If you want more detail, read DarkerMuffin's original post. He posted it in this forum in 2015, so you won't have to scroll down very far to find it.


This one?
http://dejenol.com/forum/index.php?showtopic=4928
Go to the top of the page
 
+Quote Post
Roland
post Sep 29 2018, 01:15 AM
Post #6


Mentor
****

Group: Members Plus
Posts: 302
Joined: 20-September 16
From: Maryland
Member No.: 8,408
referrer:Google



This is the one I meant:
http://dejenol.com/forum/index.php?showtopic=4968

But it looks like there is even more detail in the one you posted, which I had not seen previously. Thanks for digging it up.

This post has been edited by Roland: Sep 29 2018, 01:49 AM
Go to the top of the page
 
+Quote Post
Nudibranch
post Sep 29 2018, 04:36 AM
Post #7


Fire Master
*********

Group: Mordor MP Prog
Posts: 1,613
Joined: 19-November 04
Member No.: 71
referrer:search



QUOTE (Mordion @ Sep 28 2018, 04:51 PM) *
Does it pick a type and then pick a monster of the type or does it put all monsters of allowed types in a pile and pick from the pile?

What line of what file is the function? My copy of the source is from a VB3 decompiler and it has no annotations.

I remember getting violated by a Tengu close to the stairs the first time I played M2. Thought I was a Mordor pro at the time. Didn't see it coming.

It picks a type then a monster of the type.

Module4.bas, line 1354.


--------------------
I would have started with lasers. Eight o'clock. Day one.
Go to the top of the page
 
+Quote Post
fischsemmel
post Dec 10 2018, 04:21 PM
Post #8


Soldier
***

Group: Members Plus
Posts: 269
Joined: 28-February 11
Member No.: 6,580
referrer:Search engine



QUOTE (Nudibranch @ Sep 27 2018, 10:34 PM) *
On level 1, rooms #1 to #17 have special restrictions on what monsters can appear. These rooms are all within 2 rooms of the entry stairs, plus a few directly to the east of the stairs up to about 5 rooms away.
- They can only have one monster group.
- They can never have a random type.
- They can never be higher than "guild level 2", so no Orcs, Slaves, or Twisted Dwarves. Also no Margoyles or Zombies even in the couple of sub-#18 rooms that allow devils or undead. It looks like Tengus are possible, though still rare.

I still can't discern why T'Manas and Dragon Turtles never show up.


Hmm. I saw two groups of 10-12 slaves in the small room immediately right of the stairs (10,11 and 10,10) just an hour ago.
Go to the top of the page
 
+Quote Post
Mordion
post Dec 13 2018, 03:02 AM
Post #9


Vagabond
**

Group: Members Plus
Posts: 101
Joined: 30-September 07
Member No.: 3,924
referrer:The Super Seer



QUOTE (Nudibranch @ Sep 27 2018, 10:34 PM) *
It looks like Tengus are possible, though still rare.


A Tengu near the entrance wrecked my lvl 1 character the first time I played M2. "Welcome to Mordor", right?
Go to the top of the page
 
+Quote Post
Mordion
post Dec 17 2018, 01:36 AM
Post #10


Vagabond
**

Group: Members Plus
Posts: 101
Joined: 30-September 07
Member No.: 3,924
referrer:The Super Seer



QUOTE (Nudibranch @ Sep 27 2018, 10:34 PM) *
- If there's a laired monster, there's a 75% chance of it showing up.
- If it's a stud room, the maximum level of the lead monster in that room is the current level+1 (as advertised!). There's a 2/3 chance that its minimum level is the current level. Otherwise, the min level is the same as for a normal room (see next step).
- If it's a normal room, the minimum level is about 80% of the current level (not sure how it's rounded off), with a 20% chance of it being an additional -1 level, a 20% chance of it being -2 levels, and a 10% chance of -3 levels. (This would suggest that the lowest possible level of a lead monster on level 15 will be 9, and you might still meet level 1 groups on level 5.)
- For the general monster type (insect, demon, thief, etc.), there's a 1% chance it's randomly chosen from all possible types - otherwise, the type is randomly chosen out of what types are assigned to the room.
- For the specific monster within that type, the selection is weighted by each valid monster's "chance". Monsters above or below the previously determined max or min level are excluded.


When is the level picked? Do I pick a type and then select from all the monsters between minLevel and maxLevel by rarity? Or, do I pick a type, pick a level, and then select from all available monsters on the level by rarity?
Go to the top of the page
 
+Quote Post
Nudibranch
post Dec 17 2018, 05:24 PM
Post #11


Fire Master
*********

Group: Mordor MP Prog
Posts: 1,613
Joined: 19-November 04
Member No.: 71
referrer:search



I listed the steps in the order they're performed. The level range is determined, then monster type, then random roll weighted by monster rarity.


--------------------
I would have started with lasers. Eight o'clock. Day one.
Go to the top of the page
 
+Quote Post
Mordion
post Dec 18 2018, 12:05 AM
Post #12


Vagabond
**

Group: Members Plus
Posts: 101
Joined: 30-September 07
Member No.: 3,924
referrer:The Super Seer



QUOTE (Nudibranch @ Dec 17 2018, 12:24 PM) *
I listed the steps in the order they're performed. The level range is determined, then monster type, then random roll weighted by monster rarity.


Thanks. Is it doing any weird stuff where the file order matters? I remember reading that when generating something it finds the first legit something and then scans to the last legit something and selects from those. If a something is out of place, say at the end of the file, then that something isn’t generated. (Where something is either monsters or items, I can’t remember)
Go to the top of the page
 
+Quote Post
Nudibranch
post Dec 20 2018, 08:11 PM
Post #13


Fire Master
*********

Group: Mordor MP Prog
Posts: 1,613
Joined: 19-November 04
Member No.: 71
referrer:search



Looking at the source again, I'm pretty sure I got some things wrong. When I have a chance to comb over it in detail, I'll let you know.


--------------------
I would have started with lasers. Eight o'clock. Day one.
Go to the top of the page
 
+Quote Post
Nudibranch
post Jan 7 2019, 04:49 AM
Post #14


Fire Master
*********

Group: Mordor MP Prog
Posts: 1,613
Joined: 19-November 04
Member No.: 71
referrer:search



I did start looking at the spawning source again last night. To be absolutely sure how it works is, to be honest, not worth the hours of analysis for me. It's loops within loops checking something against something else and then putting something else in a table and rolling against the total weighted chance of whatever's in that table. I'm sorry I can't offer more.

The other stuff is less convoluted - the safe zone, stud rooms, min and max level (rounding surprises notwithstanding).


--------------------
I would have started with lasers. Eight o'clock. Day one.
Go to the top of the page
 
+Quote Post
Roland
post Jan 7 2019, 07:59 PM
Post #15


Mentor
****

Group: Members Plus
Posts: 302
Joined: 20-September 16
From: Maryland
Member No.: 8,408
referrer:Google



While we're on the subject of monster spawning . . . It appears to me that the range of hit points for a monster is the official "average hits" +/−25%, apart from rounding oddities. Is that correct?
Go to the top of the page
 
+Quote Post
Nudibranch
post Jan 8 2019, 01:05 AM
Post #16


Fire Master
*********

Group: Mordor MP Prog
Posts: 1,613
Joined: 19-November 04
Member No.: 71
referrer:search



Correct. When created, a monster's base HP has a 25% chance of being lower and a 75% 50%/50% chance of being higher or lower by the following amount:

(random * (base HP * 0.5) / 2) + 1

which is basically +/- 25%.

Edit: Mordion is right, I was incorrectly assuming VB's Int() does rounding.


--------------------
I would have started with lasers. Eight o'clock. Day one.
Go to the top of the page
 
+Quote Post
Mordion
post Jan 8 2019, 01:06 AM
Post #17


Vagabond
**

Group: Members Plus
Posts: 101
Joined: 30-September 07
Member No.: 3,924
referrer:The Super Seer



QUOTE (Roland @ Jan 7 2019, 02:59 PM) *
While we're on the subject of monster spawning . . . It appears to me that the range of hit points for a monster is the official "average hits" +/−25%, apart from rounding oddities. Is that correct?


Found the code in monsmod.bas:1868

50/50 chance of adding or subtracting. Int(Rnd * (averageHits * .5) / 2) + 1

which means a monsters HP can never be exactly averageHits.
Go to the top of the page
 
+Quote Post
Roland
post Jan 8 2019, 08:44 PM
Post #18


Mentor
****

Group: Members Plus
Posts: 302
Joined: 20-September 16
From: Maryland
Member No.: 8,408
referrer:Google



Thanks for the confirmation.

It seems overly complicated to multiply by .5 and divide by 2. If I had written such inefficient code when I was in college, I'm sure it would have drawn a negative comment from my profs. But, then, that was back when computers were slow and efficient coding mattered.
Go to the top of the page
 
+Quote Post
Mordion
post Jan 9 2019, 12:44 AM
Post #19


Vagabond
**

Group: Members Plus
Posts: 101
Joined: 30-September 07
Member No.: 3,924
referrer:The Super Seer



QUOTE (Roland @ Jan 8 2019, 03:44 PM) *
Thanks for the confirmation.

It seems overly complicated to multiply by .5 and divide by 2. If I had written such inefficient code when I was in college, I'm sure it would have drawn a negative comment from my profs. But, then, that was back when computers were slow and efficient coding mattered.


Back in the 90's I was of the opinion you should never use float outside of scientific computing and even when you did you should avoid trig and logarithms. There's a lot of algebra that could be simplified in the code base. Peruse the formula's section on the wiki for a glimpse. I also remember Mordor running really laggy on my 486 DX2 even though I had an FPU.
Go to the top of the page
 
+Quote Post
Nudibranch
post Jan 9 2019, 05:16 AM
Post #20


Fire Master
*********

Group: Mordor MP Prog
Posts: 1,613
Joined: 19-November 04
Member No.: 71
referrer:search



These formulas only have to be run a few times per second, at most (for instance, to resolve combat hits). Mordor's formulas are absurdly elaborate but I doubt they were the source of lag. More likely it's the display code and/or various game logic loops that chew up millions of cycles. I doubt DA ever tried to profile/optimize it unless there was a section of code that causing obvious hangs.

As hairy as the formulas are, I interpret them to be the product of repeated testing and tweaking until DA got the gameplay he wanted. In that regard, I think he did a really good job. The overall game balance is very good.


--------------------
I would have started with lasers. Eight o'clock. Day one.
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



Lo-Fi Version Time is now: 11th December 2019 - 07:07 AM
Bridged By IpbWiki: Integration Of Invision Power Board and MediaWiki © GlobalSoft
Copyrights and Credits