MantisBT - Zandronum
View Issue Details
0000031Zandronum[All Projects] Suggestionpublic2010-09-16 23:222018-09-30 22:43
AlexMax 
Torr Samaho 
normalminorN/A
closedfixed 
98c 
 
0000031: New DMFlag: "Use Classic PRNG"
This is a well known issue with modern source ports, but since there isn't a bug for it on the bugtracker I'll post it here.

Basically, the doom PRNG resulted in higher than average SSG damage, and many oldschool players complain that the skulltag SSG feels "nerfed" compared to the Doom 2 rendition. It would be nice if there was a DMFlag to switch back to the old PRNG.
The Doom wiki covers the major points:

'http://doomwiki.org/wiki/Random [^]'
No tags attached.
has duplicate 0000192closed Torr Samaho compat_hitscan implementation tweak to replicate oldschool damage more effectively 
Issue History
2010-09-16 23:22AlexMaxNew Issue
2010-09-17 09:49unknownnaNote Added: 0000067
2010-09-17 20:34TIHanNote Added: 0000071
2010-09-18 20:47AnonymousNote Added: 0000078
2010-09-21 14:36AnonymousNote Deleted: 0000078
2010-09-22 12:10unknownnaNote Added: 0000131
2010-09-22 15:10AnonymousNote Added: 0000132
2010-09-25 07:59unknownnaNote Edited: 0000131bug_revision_view_page.php?bugnote_id=131#r66
2010-09-25 15:52AnonymousNote Deleted: 0000132
2010-09-27 05:15unknownnaNote Edited: 0000131bug_revision_view_page.php?bugnote_id=131#r76
2010-10-05 11:31unknownnaNote Edited: 0000131bug_revision_view_page.php?bugnote_id=131#r115
2011-01-25 02:07Torr SamahoNote Added: 0000872
2011-01-25 02:07Torr SamahoAssigned To => Torr Samaho
2011-01-25 02:07Torr SamahoStatusnew => feedback
2011-01-25 02:22AlexMaxNote Added: 0000873
2011-01-25 02:22AlexMaxStatusfeedback => assigned
2011-01-29 01:11Torr SamahoNote Added: 0000886
2011-01-29 01:11Torr SamahoStatusassigned => feedback
2011-01-29 04:24unknownnaNote Added: 0000889
2011-01-29 04:28unknownnaNote Edited: 0000889bug_revision_view_page.php?bugnote_id=889#r406
2011-01-29 08:19unknownnaNote Edited: 0000889bug_revision_view_page.php?bugnote_id=889#r407
2011-01-29 13:03Torr SamahoNote Added: 0000893
2011-01-29 13:29unknownnaNote Added: 0000894
2011-01-29 13:39unknownnaNote Edited: 0000894bug_revision_view_page.php?bugnote_id=894#r409
2011-01-29 13:40unknownnaNote Edited: 0000894bug_revision_view_page.php?bugnote_id=894#r410
2011-01-29 14:03unknownnaNote Edited: 0000894bug_revision_view_page.php?bugnote_id=894#r411
2011-01-29 14:22AlexMaxNote Added: 0000895
2011-01-29 14:22AlexMaxStatusfeedback => assigned
2011-01-29 14:28Torr SamahoNote Added: 0000896
2011-01-29 14:37unknownnaNote Added: 0000897
2011-01-29 15:22Torr SamahoNote Added: 0000898
2011-01-29 18:51AlexMaxNote Added: 0000899
2011-01-29 19:06AlexMaxNote Edited: 0000899bug_revision_view_page.php?bugnote_id=899#r413
2011-01-29 19:06AlexMaxNote Edited: 0000899bug_revision_view_page.php?bugnote_id=899#r414
2011-01-29 19:11AlexMaxNote Edited: 0000899bug_revision_view_page.php?bugnote_id=899#r415
2011-01-29 19:43XenaeroNote Added: 0000900
2011-01-29 23:19Torr SamahoNote Added: 0000902
2011-01-30 16:26unknownnaNote Edited: 0000131bug_revision_view_page.php?bugnote_id=131#r416
2011-01-30 18:03unknownnaNote Edited: 0000131bug_revision_view_page.php?bugnote_id=131#r417
2011-01-30 18:07unknownnaNote Edited: 0000067bug_revision_view_page.php?bugnote_id=67#r419
2011-01-30 21:24unknownnaNote Added: 0000906
2011-01-30 22:29Torr SamahoNote Added: 0000907
2011-02-01 07:11unknownnaNote Added: 0000912
2011-02-01 08:47unknownnaNote Edited: 0000912bug_revision_view_page.php?bugnote_id=912#r425
2011-02-01 12:01Edward-sanNote Added: 0000914
2011-02-03 01:25Torr SamahoNote Added: 0000934
2011-02-03 11:37unknownnaNote Added: 0000939
2011-02-03 12:38unknownnaNote Edited: 0000939bug_revision_view_page.php?bugnote_id=939#r450
2011-02-03 13:23Edward-sanNote Added: 0000942
2011-02-03 13:31Torr SamahoNote Added: 0000943
2011-02-07 16:47WagiNote Added: 0001014
2011-02-18 20:53unknownnaRelationship addedhas duplicate 0000192
2014-05-14 18:52DuskStatusassigned => resolved
2014-05-14 18:52DuskResolutionopen => fixed
2014-05-14 18:52DuskAdditional Information Updatedbug_revision_view_page.php?rev_id=4767#r4767
2018-09-30 22:43Blzut3Statusresolved => closed

Notes
(0000067)
unknownna   
2010-09-17 09:49   
(edited on: 2011-01-30 18:07)
If what you say is true, then IMHO, this should have been added in ages ago. Perhaps a compatibility flag? But wouldn't it need the old blockmap behavior as well?

'http://www.doomworld.com/vb/showthread.php?s=&postid=880116#post880116: [^]'
-restored original Doom behavior for hitscans to only check actors which have their center in the blockmap cells being checked, compatibility optioned by COMPATF_HITSCAN
-re-added the original hitscan checking code using a cross-section of the actor instead of the bounding box, compatibility optioned with COMPATF_HITSCAN

(0000071)
TIHan   
2010-09-17 20:34   
I can see this could be interesting. I have noticed myself that in Odamex and ZDaemon the SSG deals more damage than Skulltag. But then again, you probably want to consult with ZDoom on this.
(0000131)
unknownna   
2010-09-22 12:10   
(edited on: 2011-01-30 18:03)
> ZD's does 4.24% more damage than ST's. IIRC this has not been fixed in ST (So ST's SSG is the same as ZDoom's). In ZD it is a DMFlag and it's typically only on on OS 1on1 servers, not CTF/FFA. The difference is so minor anyway that most people wont notice it, but it IS there.

> I've heard lots of claims that the ZDoom SSG is less powerful, just from gut feeling. Now, gut feeling isn't scientific, so since it was a possible "compatability problem" for me, I decided to go out and research it. Here is what I found. ZDoom uses a pseudo random number generator, Doom2.exe uses a fixed table of 256 numbers, ranging from 0 to 255, all accounted for. Doom2.exe iterates through this table linearly.

> There are exactly 256 different SSG shots patterns possibile in Doom2.exe. Each shot pattern does the same damage every time. I even wrote a little mod that plays back a demo, takes a screenshot of each ssg shot, and points out the profile number for you to look in another chart I made (which contains all the different SSG spread patterns).

> The ZD SSG uses the doom2.exe mode. Dash also did damage calculations (where the 4.24% comes from), and the ZD SSG does more damage on average.

ZDaemon has something called "classic weapon strength". It's toggled by setting "sv_oldrandom" to 1 or 0.

> "Random" numbers on a computer are normally pseudo-random: not truly random. This applies to practically all computer programs out there. The reason is that computers are deterministic machines and it's pretty hard to find a source of true randomness.

> Every pseudo-random number generator (PRNG) generates some sequence of numbers that look random enough to pass statistical tests. That's usually good enough for games and other simulations (but not for crypto work; you need fancier PRNGs there). Whether that's done via some math algorithm or some table is pretty much irrelevant. What really matters is the mean and std. deviation of the sequence.

> The dmflag (sv_oldrandom) you're asking about determines if ZDaemon uses the PRNG of Doom (OS) or the one of ZDoom (NS). Their means are not very different, but their std. deviations are (OS PRNG has higher std. dev. than the NS one); that is important with weapons such as the SG, SSG, CG where you fire repeated shots at the opponent (vs. the RL for example where the damage per hit is much larger); the increased std. deviation means that wild shots from downtown will bring the other guy down. Of course there is the flip side of the coin: you might hit someone right on the chest and very little damage happens (which also means that you should not blame every SSG miss to netcode, lag, etc)

> Overall, it's fairly clear that the OS PRNG makes the SG, SSG, CG more effective than otherwise. This is just the way things are; I'm not implying that one way is better than the other. Please avoid turning this into the millionth OS/NS debate. There is no point in that.

> Here is my comment from the X-Doom m_random.cpp source tree:

// [Dash|RD] -- Make random number generation use the original random number chart.
// The way we pick numbers from this chart is NOT the way the original
// game does it, but that's hardly relevant. We aren't trying to play back
// demos afterall. More work may need to be done on this.
//
// Why did I do it? With this chart the game appears to pick consistently higher
// numbers. This should address the reports that the SSG (and various other weapons)
// do less damage in ZDaemon.
//
// SSG damage statistics, 20 shot survey.
// PrBoom -- Max: 245 Min: 165 Median: 210 Average: 206.5 Total: 4,130
// ZDaemon -- Max: 215 Min: 155 Median: 195 Average: 194.5 Total: 3,890
// This Code -- Max: 245 Min: 155 Median: 205 Average: 202.75 Total: 4,055
//
// Obviously you want to give a bit of room for randomness, but has is definitely been my experience that
// this code statistically gives off higher `random' numbers. Other shotgun guru's have also claimed that
// this code fixes their issues with weapon damage.

(0000872)
Torr Samaho   
2011-01-25 02:07   
So, technically speaking, it should be sufficient if I add a compat flag that makes FRandom::operator()() return P_Random() and FRandom::Random2() return "P_Random()-P_Random()" where P_Random() gets the next number from Vanilla Doom's random table?
(0000873)
AlexMax   
2011-01-25 02:22   
I admit that I'm not that familiar with ZDoom's code, so I can't give you a definitive yes. However, that would probably be a good starting point.

Definitely would recommend a numbered 98e beta though, so we can test it using real world conditions. I've been looking forward to the next version of Skulltag anyway because of your fixes to keepteams. :)
(0000886)
Torr Samaho   
2011-01-29 01:11   
Ok, I excavated P_Random from the original Doom source and added the new flag compat_oldrandom that replaces ZDoom's rng in the functions I mentioned above. Before I roll out an official beta build, I'd like somebody to confirm that this at least seems to be somewhat working.
(0000889)
unknownna   
2011-01-29 04:24   
(edited on: 2011-01-29 08:19)
The compat flag isn't cleared when I set another compatibility mode. I also wonder, what is exactly affected by this? The player weapons only? Does it take code pointers such as A_Explode into account?

EDIT:

Ok, it's in compatflags2.

(0000893)
Torr Samaho   
2011-01-29 13:03   
> I also wonder, what is exactly affected by this?

Technically, everything that uses FRandom::operator()() and FRandom::Random2(). Thus, it should affect everything that uses random integers between [0,255] which should include most of the code pointers and definitely all of the pointers used in the Vanilla Doom weapons.
(0000894)
unknownna   
2011-01-29 13:29   
(edited on: 2011-01-29 14:03)
> Doom2.exe uses a fixed table of 256 numbers, ranging from 0 to 255, all accounted for. Doom2.exe iterates through this table linearly. There are exactly 256 different SSG shots patterns possibile in Doom2.exe. Each shot pattern does the same damage every time.

So the compat flag basically does this? Runs through the old table linearly exactly like Vanilla Doom did.

(0000895)
AlexMax   
2011-01-29 14:22   
Well, he did say that he "excavated the old function", so I don't see why not.
(0000896)
Torr Samaho   
2011-01-29 14:28   
> Runs through the old table linearly exactly like Vanilla Doom did.

Exactly.
(0000897)
unknownna   
2011-01-29 14:37   
Thanks. Now we finally have it. Thank you very much for this, Torr.
(0000898)
Torr Samaho   
2011-01-29 15:22   
You're welcome :). Let's just hope that it is working as expected, so far I didn pretty much no tests with it. To facilitate testing before I make the next official beta release, I created matching Linux and a Windows binaries.
(0000899)
AlexMax   
2011-01-29 18:51   
(edited on: 2011-01-29 19:11)
Preliminary reports:

"Yea, it works, I can tell already"
"It's better than zd's, it feels like choco doom"
"Yeah, it's a lot nicer"

Will keep you updated if there are any complaints, but so far I think you nailed it.

Thanks a million Torr.

(0000900)
Xenaero   
2011-01-29 19:43   
Yeah, this works really well. Great stuff, thanks Torr!
(0000902)
Torr Samaho   
2011-01-29 23:19   
I'm glad to hear that :). If all goes well I'll make an official beta release tomorrow evening so that this can receive more widespread testing.
(0000906)
unknownna   
2011-01-30 21:24   
Perhaps the server dialog box needs to be updated to support this compat flag. It won't allow me to set the flag in "Settings -> Flags... -> Compatibility". Setting the compatflags2 value to 8 has no effect.
(0000907)
Torr Samaho   
2011-01-30 22:29   
You are right. This reminds me of one of the reasons why I hate the Windows server GUI code. Anyway, should be fixed now.
(0000912)
unknownna   
2011-02-01 07:11   
(edited on: 2011-02-01 08:47)
Would it be possible to also have it as a visible option to toggle in the "Oldschool" section? Actually, there are more flags you cannot see in the compatibility options, e.g., compat_noland and compat_clientssendfullbuttoninfo.

Ok, it seems like compat_nocrosshair and compat_disabletaunts is toggled in "Settings -> Flags... -> Players".

I'm also testing the new feature on the tracker.

(0000914)
Edward-san   
2011-02-01 12:01   
It would be useful, indeed. Even better is if it's backported to zdoom code.

Torr: Can I ask Graf to backport this into zdoom code?
(0000934)
Torr Samaho   
2011-02-03 01:25   
> Would it be possible to also have it as a visible option to toggle in the "Oldschool" section? Actually, there are more flags you cannot see in the compatibility options, e.g., compat_noland and compat_clientssendfullbuttoninfo.

That's certainly possible. The main problem is that I really don't like Windows GUI coding ;) (platform independent GUI libs are much nicer).

> Torr: Can I ask Graf to backport this into zdoom code?

Sure, but Skulltag's implementation needs to be adjusted to be used in ZDoom. Otherwise you most likely would get sync problems in ZDoom's multiplayer and in single player demos.
(0000939)
unknownna   
2011-02-03 11:37   
(edited on: 2011-02-03 12:38)
> That's certainly possible. The main problem is that I really don't like Windows GUI coding ;) (platform independent GUI libs are much nicer).

I understand. But it would be nice and practical to have it though.

EDIT:

I just wonder, why are these new compat flags in compatflags2?

(0000942)
Edward-san   
2011-02-03 13:23   
> Sure, but Skulltag's implementation needs to be adjusted to be used in ZDoom. Otherwise you most likely would get sync problems in ZDoom's multiplayer and in single player demos.

Ok, I'll wait for this. Should I make a new suggestion in the tracker about this?
(0000943)
Torr Samaho   
2011-02-03 13:31   
> I just wonder, why are these new compat flags in compatflags2?

compatflags is full.

> Ok, I'll wait for this. Should I make a new suggestion in the tracker about this?

Right now I don't intend to make these adaptions myself because they are not needed in Skulltag at all: ST neither supports single player demos nor ZDoom's P2P networking.
(0001014)
Wagi   
2011-02-07 16:47   
Please note that the claim that all the numbers between 0-255 are "accounted for" is false. In Vanilla Doom's random number table, 1 does not appear at all, for example. 145 appears five times, 0 appears twice.