Jarvy Posted December 12, 2022 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? 0 Quote Share this post Link to post
Edward850 Posted December 12, 2022 (edited) 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 December 12, 2022 by Edward850 1 Quote Share this post Link to post
Jarvy Posted December 12, 2022 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. 0 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.