Talk:Monster spawner
From DoomWiki.org
If I'm not mistaken, the chance of spawning each monster is different when the skill level is 1-2 (easy) than when it's 3-5. See p_enemy.c in the source code, but this may be the factor that makes the difference:
static int easy = 0;
easy ^= 1;
if (gameskill <= sk_easy && (!easy))
return;
If I am correct, we need to add what this does to the listed probabilities. Who is like God? 17:47, 7 August 2008 (UTC)
- No, this doesn't change the probability in any way. The probability is in A_SpawnFly exclusively:
void A_SpawnFly (mobj_t* mo)
{
mobj_t* newmobj;
mobj_t* fog;
mobj_t* targ;
int r;
mobjtype_t type;
if (--mo->reactiontime)
return; // still flying
targ = mo->target;
// First spawn teleport fog.
fog = P_SpawnMobj (targ->x, targ->y, targ->z, MT_SPAWNFIRE);
S_StartSound (fog, sfx_telept);
// Randomly select monster to spawn.
r = P_Random ();
// Probability distribution (kind of :),
// decreasing likelihood.
if ( r<50 )
type = MT_TROOP;
else if (r<90)
type = MT_SERGEANT;
else if (r<120)
type = MT_SHADOWS;
else if (r<130)
type = MT_PAIN;
else if (r<160)
type = MT_HEAD;
else if (r<162)
type = MT_VILE;
else if (r<172)
type = MT_UNDEAD;
else if (r<192)
type = MT_BABY;
else if (r<222)
type = MT_FATSO;
else if (r<246)
type = MT_KNIGHT;
else
type = MT_BRUISER;
newmobj = P_SpawnMobj (targ->x, targ->y, targ->z, type);
if (P_LookForPlayers (newmobj, true) )
P_SetMobjState (newmobj, newmobj->info->seestate);
// telefrag anything in this spot
P_TeleportMove (newmobj, newmobj->x, newmobj->y);
// remove self (i.e., cube).
P_RemoveMobj (mo);
}
See? Easy isn't involved there. What easy does is determine if something is spawned at all, since it's in A_BrainSpit.
void A_BrainSpit (mobj_t* mo)
{
mobj_t* targ;
mobj_t* newmobj;
static int easy = 0;
easy ^= 1;
if (gameskill <= sk_easy && (!easy))
return;
// shoot a cube at current target
targ = braintargets[braintargeton];
braintargeton = (braintargeton+1)%numbraintargets;
// spawn brain missile
newmobj = P_SpawnMissile (mo, targ, MT_SPAWNSHOT);
newmobj->target = targ;
newmobj->reactiontime =
((targ->y - mo->y)/newmobj->momy) / newmobj->state->tics;
S_StartSound(NULL, sfx_bospit);
}
Now I'm not exactly sure how it works. It inits an int to 0, then bitwise-XORize it with 1 to something like 111..110, which is true, so !easy is false, so the return is never executed. From my understanding of the code at least. However, I think what it's supposed to do is provoke a return every two calls, so that the boss shooter spits a spawn cube half as fast as on harder skill levels. At least, that is how ZDoom does it, but the code has practically nothing in common now.--Gez 21:35, 7 August 2008 (UTC)
- I overlooked the
statickeyword. First it's 0, then 111..1110 on the first call. On the second call to this function, it's XORed again to 0, and on the third it's back to 111..1110, and so on. So yeah. It just makes it so that the cube is spitted only half the time A_BrainSpit is called. --Gez 21:40, 7 August 2008 (UTC)
- I overlooked the
inane crap about Paradise Lost and Greek Mythology[edit]
wow, I'm surprised that the moron who mentioned Paradise Lost and Greek Mythology in the Icon of Sin page didn't fuck up this page, too. Thank god for that. His pseudointellectualist posturing was too much. I hope he burns in hell and his tiny, atrophied brain is destroyed by the heat. —Preceding unsigned comment added by 5.12.80.218 (talk)
- There's no need to be so agressive. That mythology edit was made many years ago, back when people liked to speculate a lot and the wikis were usually less formal. I understand that that part was irrelevant, but you should take it easy. :) --lil'devil (talk) 08:56, 14 January 2019 (CST)
Spawning probability[edit]
The spawning probabilities given here correspond to results with a real random generator, in which the 256 sides of the “dice” are evenly distributed.
However, since Doom uses a pseudo-random generator with an uneven distribution, in which some sides of the dice occur multiple times and some sides do not occur at all.
If you calculate the chances by taking the “rndtable” into account, you get the following probabilities:
| Monster | Doom's RNG probability | True random probability | Difference |
|---|---|---|---|
| Demon | 47 / 256 (18,36%) | 40 / 256 (15,63%) | 7 / 256 (+2,73%) |
| Imp | 43 / 256 (16,80%) | 50 / 256 (19,53%) | -7 / 256 (-2,73%) |
| Spectre | 31 / 256 (12,11%) | 30 / 256 (11,72%) | 1 / 256 (+0,39%) |
| Cacodemon | 28 / 256 (10,94%) | 30 / 256 (11,72%) | -2 / 256 (-0,78%) |
| Mancubus | 26 / 256 (10,16%) | 30 / 256 (11,72%) | -4 / 256 (-1,56%) |
| Hell knight | 25 / 256 (9,77%) | 24 / 256 (9,38%) | 1 / 256 (+0,39%) |
| Arachnotron | 17 / 256 (6,64%) | 20 / 256 (7,81%) | -3 / 256 (-1,17%) |
| Revenant | 13 / 256 (5,08%) | 10 / 256 (3,91%) | 3 / 256 (+1,17%) |
| Baron of Hell | 13 / 256 (5,08%) | 10 / 256 (3,91%) | 3 / 256 (+1,17%) |
| Pain elemental | 10 / 256 (3,91%) | 10 / 256 (3,91%) | 0 / 256 (0,00%) |
| Arch-vile | 3 / 256 (1,17%) | 2 / 256 (0,78%) | 1 / 256 (+0,39%) |
As mentioned in the article, the distribution is so uneven that Demons have a higher chance of spawning than Imps. For the other monsters, the difference is less noticeable, but is sufficient enough that monsters such as Spectres, Cacodemons and Mancubi, which actually have the same chances, are distributed slightly differently.
Can a programmer confirm this and adapt it accordingly in the article?
https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/p_enemy.c
https://github.com/id-Software/DOOM/blob/master/linuxdoom-1.10/m_random.c
—The preceding unsigned comment was added by Chris Retro (talk • contribs) .
