reportingsjr Posted September 26, 2006 Share Posted September 26, 2006 As you may have heard, im making a game right now. Im coming close to releasing it but I now have a major problem . I have absolutely no clue how to write a hit or miss code that involves my own percentages and the users level. The "hit or miss" code im talking about is, if you didnt understand what I meant this, the user has a level of 10, and it takes level 1 to "fish" a catfish. The code will generate a random thing, say 25% of the time you will catch it, and the other 75% you will miss. But since they are level 10 it will be easier for them to catch it, so they are %10 more likely to catch it.Im so lost! I could do a random, but it would be just as hard to catch it if your level 10 as it was at 1, and I think you should get better with each level, so the percentage increases each level.Maybe this would work a bit? $catch_or_not = rand(1,100);$level = $level - 1; //1 is the level it takes to catch this, will make it more fair at higher lvls like 75//if everything stays at 25% then at level 75 all fish you would be able to catch every time lol. //That wouldnt be good!$catch = 25 + $level; //level is presumably 10if($catch_or_not <= $catch){//Yay, you caught it!!}else{//nope =[ missed!!} Do you think that would be sufficient? Or do I need to add less on.. I think that once you hit level 76 (the point at which it becomes 100%) you should be well enough off for this.. Link to comment Share on other sites More sharing options...
reportingsjr Posted September 26, 2006 Author Share Posted September 26, 2006 Well nevermind! I used the exact code I have here and it work presumably well. Its not the best though unfortunately. Its really hard to catch fish lol. But thats the way I want my game! Hard to beat. It will be to.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now