# 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
`static`

keyword. 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