+ 1

How would C++ be used for randomizing something such as loot in a game? And how do you manipulate percentages for certain drops?

I am trying to understand C++ but I need examples I'm familiar with to kind of help me. Not trying to steal any code or anything like that. I just need help understanding. Is rand() used? or is srand() ? please help. I am confusion lol

17th Jul 2018, 2:16 AM
Richard Garibay
7 odpowiedzi
+ 2
I think, it depends on the Developers. they use anything which is suitable and faster executable for the game. You are talking about games like PUBG? PUBG is made in unreal engine, they might used something from the certain engines? who knows? BTW you accidentally posted this question two times please delete the another one.😊
17th Jul 2018, 2:45 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
Those things are not random. the place is random where to you will find those things, but amount is fixed and predefined. Like you will find only 2 medkits from whole map, and only some number of kar98 and all those guns. but the place where they got spawn is random.
17th Jul 2018, 2:51 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
after completing gameplay, it calculates everything, like I have a mission to get one 4x scope, after game completed, it checks that in that game I got a 4x? if yes mission successful and you got rewarded else it will check that again in next game.
17th Jul 2018, 2:56 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
One uses rand() to generate a pseudo-random integer between 0 and RAND_MAX. The srand() function is meant only for providing a seed to the rand function, so that we get a random output on every run. Thus, we pass the system time to srand, as that is the best seed possible. To get a range from rand, you can take the mod of the resulting number in the following way : int rnd = L+(rand()%(U-L+1)); This generates a number between L and U, both inclusive. In case you require random floating point numbers, you will have to use the new C++ random, which is somewhat different.
17th Jul 2018, 2:57 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 1
More like...in Destiny when you get loot how it has a random percentage drop for commons, legendaries, exotics, etc. I'm just curious as to how that works. Also thank, I deleted the duplicate post.
17th Jul 2018, 2:48 AM
Richard Garibay
+ 1
So in a game like The Division, let's say you complete a mission and it gives you a weapon. How does the computer know which reward to give you?
17th Jul 2018, 2:54 AM
Richard Garibay
0
dang that's a lot to process haha
17th Jul 2018, 3:12 AM
Richard Garibay