Jump to content

Doom RNG tables?


Jarvy

Recommended Posts

Was wondering, what do DOOM/DOOM II do with the number rolled with p_random? I know that with things like weapon damage it calls p_random which pulls a number from the pre-determined RNG table, but what happens to that number after it gets called? How does 220 (the fourth number in the RNG table) end up as whatever the calculated damage is?

Share this post


Link to post
damage = ((P_Random()%8)+1)*tmthing->info->damage;

It's simply divided. For example in projectile collision damage shown above, it pulls a random number, does a modulo by 8 (divides by 8 and uses the remainder as the result) and adds one, then multiplies by the things set damage value to get the result.

In effect, this gives a dice roll of 1 to 8 multiplied by the damage value.

 

Other similar calculations will use bitwise AND instead of modulo to crunch the random value.

 

Edited by Edward850

Share this post


Link to post
17 minutes ago, Edward850 said:

damage = ((P_Random()%8)+1)*tmthing->info->damage;

It's simply divided. For example in projectile collision damage shown above, it pulls a random number, does a modulo by 8 (divides by 8 and uses the remainder as the result) and adds one, then multiplies by the things set damage value to get the result.

In effect, this gives a dice roll of 1 to 8 multiplied by the damage value.

 

Other similar calculations will use bitwise AND instead of modulo to crunch the random value.

 

Thanks! Although, I'm not very smart when it comes to coding lingo and all that so I might have to read over this and google a few things you said but that gives me the general idea. Much appreciated.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...