![]() |
My Fomula - Printable Version +- Mirage Engine (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: General (https://mirage-engine.uk/forums/forumdisplay.php?fid=17) +---- Thread: My Fomula (/showthread.php?tid=839) |
My Fomula - Matt2 - 20-03-2007 Okay.. I have a formula... Serebii.net Wrote:Catch = PokeballEffect (((( 4 * Max HP - 2 * HP ) * Catch Rate ) / Max HP ) + Status + 1 ) / 256 Okay, that's the formula. I have all of the constants. That's not the problem. The problem is determining wether the trainer actually caught the pokemon or not. "What's the problem?" Many of you would say. Well, here it is. The formula, based on the constants given, will produce a number 0-1. If the formula produces a number greater than 1, the trainer will catch the pokemon without fail. The problem comes in when it doesn't calculate 1. According to the page, http://www.serebii.net/games/capture.shtml, just because you got a number lower then one, doesn't mean you didn't catch the pokemon. The number is to be looked at as a percentage, in decimal form. Let's say it produces the number .83. That's 83 percent. You still don't understand the problem? How will I get VB to recognize the percentage and make heads or tail out of it to determine if the player can actually catch the pokemon? Even if the number is 1%, you can still catch the pokemon. But, using VB, I don't know how to go about this problem... The best I got is... Code: Percent = 100 * Rnd + 1 '1 out of 100 chance And that's only a 1:100 ratio, which is viewed as 1%. If I try Code: Percent = 100 * Rnd + 100 That's a 100:100 ratio. 1:1, simplified. 100%. I can't do it any other way. >.< Someone please help me with this problem. >. - Rian - 20-03-2007 I'm at work. I didn't really sink in exactly what you wanted. You want to narrow it down to 50% is what I'm getting out of it... That be the case, I can help when I get home - William - 20-03-2007 Code: A=int(int(A/2)/2) Use this: Code: A=int(A/4) - Spodi - 20-03-2007 Or A \ 4 to avoid the usage of Int() and a bit more speed, since you're asking for the processor to do extra work to give you a floating point result, then asking it to do even more work to take it away. :wink: Yup, I had to spread my crap some time. ![]() - Dark Echo - 20-03-2007 If you want even more speed.. Do A= A * .25 Hahaha... I heard Multiplying is faster than dividing.. Although mate im not really sure.. So yeah.. ![]() - Spodi - 20-03-2007 Except for multiplication still returns a floating-point value, but A is a non-floating point variable, so the result would require a conversion still. :wink: Results: Code: %Faster -71.4| -64.3| -73.3| -64.3| -50| -66.7| -64.3| -66.7| -61.5| -66.7 Tests: Code: Public Sub TestOne() Even if the conversion wasn't happening and a whole number was used like 100, it still would be about half the speed... not sure why in that case. - Matt2 - 20-03-2007 @Dave: Perfect idea. I'm going with it. @one: GSC has ALOT of stuff that isn't used anymore, like Shiney pokemon gaining more.. EVs was it? Yeah, alot of GSC stuff isn't used in the later games. That capture formula is way outdated. The one I gave was from RuSa. xD - Gilgamesch - 20-03-2007 @spodi or someone who can answere that question i never get your tests xD, so is multiplication faster? and, what do the numbers in the row for lets say test number 1 mean? (4,5,4,5....) the ms it took to do this? thanks ![]() - Spodi - 20-03-2007 The numbers is time it took in milliseconds, yes, and the %Faster is how much percent faster Test2 is then Test1 (in this case, its slower, thus negative). http://www.vbgore.com/index.php?title=T ... code_speed I wrote that a while back. It does an amazing job on testing the speed of two chunks of code and comparing them. - Dark Echo - 21-03-2007 OH MY GOD!!!!! Spodi mate.. I have only three words for you.. Mate you are freakin awesome!!! Nifty little program by the way.. I like it.. - Matt - 21-03-2007 Dark Echo Wrote:OH MY GOD!!!!! Spodi mate.. I have only three words for you.. Mate you are freakin awesome!!! Nifty little program by the way.. I like it.. That's 5 words. =P - Spodi - 21-03-2007 Oh gee, make me blush. :oops: :wink: |