FRandom() Failures

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

FRandom() Failures

Post by NeuralStunner »

I'm trying to implement some custom inaccuracy code and keep running into a snag: FRandom only evaluates as a float when used alone. Even multiple FRandoms have to each be multiplied by 1.0 for the resulting expression to remain a float.

Here's some test code. I recommend E1M1, right across from the start is a wide flat wall.

Use TimeFreeze so you can see the shot patterns. The first gun (Slot 3) simply uses 10 degrees in either direction. The second (Slot 4) adds together two random results of 5 degrees, giving it a 10 degree spread but making the extremes less likely.

With both guns, primary fire will give a desired result (an irregular but continuous line of puffs) while alternate fire gives a bad result (only on whole angles, giving a uniform dotted-line of puffs).
Spoiler: Decorate.txt
In short: If I want to use FRandom() more than once in an expression, I have to replace it with (FRandom() * 1.0), which is really bizarre.

I hope I explained well enough.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: FRandom() Failures

Post by wildweasel »

You can't just write FRandom(-10.0,10.0)?
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: FRandom() Failures

Post by NeuralStunner »

The output of FRandom is supposed to be a float, which is why it's strange.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: FRandom() Failures

Post by wildweasel »

Well, the problem I ran into (I think) is that in order for it to work properly, the values you feed into FRandom should be floats to begin with, i.e. should be suffixed with .0 to actually work. That's a thing I ran into with ww-nazis' shotguns, if I remember correctly.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: FRandom() Failures

Post by NeuralStunner »

I just gave that a try but it didn't help. There's definitely something up with the expression evaluator.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: FRandom() Failures

Post by randi »

Fixed in r3721.
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: FRandom() Failures

Post by NeuralStunner »

Thanks a bunch. :)
Post Reply

Return to “Closed Bugs [GZDoom]”