Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8253555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:55:03+00:00 2026-06-08T00:55:03+00:00

I am creating a game and I am currently working on the random drop

  • 0

I am creating a game and I am currently working on the random drop system.

I plan on creating a random ID which in turn is a design for the items. If I pass the same ID twice to the createItem function it should create the exact same item.

Anyway. When I create the ID I plan on using input to be able to let some enemies drop a certain item more often. So lets say that the function looks like this for example:

void randID(int level, int diff, float wepChance, float armChance);

If I set the wepChance to 10% (0.1) when I call the function I really want it to be a 10% chance of dropping a weapon. How do I use this input together with a rand() and srand()? How does srand really work (haven’t found anything else than that is creates a seed).

I guess I could write my own code to make it really become 10% chance, but can I use srand to achieve the same result?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:55:04+00:00Added an answer on June 8, 2026 at 12:55 am

    srand will not help you with this.

    If you want a 10% chance of something occurring, then use something like the following:

    int x = rand();
    
    bool hasOccurred = (x < (RAND_MAX * 0.1));
    

    This won’t be exactly 10%, because RAND_MAX probably doesn’t divide exactly by 10, but I imagine it’s close enough for your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a game, and am currently working on the Inventory system for it.
I am currently creating a spelling game which is currently drag and drop .
I am currently working on creating an import-based pipeline for my indie game using
I am creating a game currently and I want users to be able to
I'm creating my first game, and I've currently set up a 'GameState' class, to
I am creating a simple tennis game in Objective-C. Currently, when the player or
Im currently creating a tile-based game for android. Using java via dalvik JVM. im
Currently I'm planning to design a dedicated server in C# for an XNA game
I'm currently working on a small 2D game-engine in C++, but I am now
I'm currently working on my first iPhone game with openGLES- it is amazing! Loving

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.