Jump to content
MakeWebGames

Recommended Posts

Posted

 

Yea the formula was annoying i recoded the crime system

Tell me about it do you have or does anyone you know have maybe a mod that changes the create a crime function to set crime pass based on level or stats??

Posted

In docrime.php, the $sucrate (or success rate) is determined, by default, using basic maths - algebra, to be exact.

$find = ['LEVEL', 'CRIMEXP', 'EXP', 'WILL', 'IQ'];
$repl = [$ir['level'], $ir['crimexp'], $ir['exp'], $ir['will'], $ir['IQ']];
$sucrate = str_replace($find, $repl, $r['crimePERCFORM']);

 

The default formula upon crime creation is

((WILL*0.8)/2.5)+(LEVEL/4)

Remember that "BODMAS", BIDMAS", "PEMDAS", or however you remember it, all play in here - I was taught the "BIDMAS" method, though they all mean basically the same thing.

  • Brackets
  • Indices
  • Division
  • Multiplication
  • Addition
  • Subtraction

(in that order)

Now, for example, we'll use the "stats" that would be there as a brand new player (i.e. Will = 100, Level = 1, CrimeXP = 0, EXP = 0, IQ = 10)

Break up the formula, brackets comes first.

((100 * 0.8) / 2.5) = 80 / 2.5 = 32

(1 / 4) = 0.25

32 + 0.25 = 32.25

So, that leaves us with 32.25. Now, because of the way that the docrime.php is setup, the closer to 100 the formula equals, the easier the crime (anything above 100 is treated as success anyway).

With that logic, and with a newbie (to your game), there's at least 32.25% chance of successfully completing that crime. I say "at least" because there's also a rand() in there too, adding to the chances of success

The output from the crime failure is simple. It's a 50% chance of just a fail or jail time.

---------

You can easily add to that str_replace() logic at the top, adding more things like 'TOTAL_STATS', 'STRENGTH', 'MONEY', etc. (and obviously add the replacements too) to be able to use more modifiers.

  • 2 months later...
Posted (edited)

No matter what I try I get division by zero. My first crime is just set at 100, so everyone can begin crimes. My next set I wanted to be their will % -.- zero=zero=zero

Just saying I graduated from school about 15 years ago and .92 = 92%

My issue is NOT going over 100 -.-

Edited by boionfire81
hating math
Posted

I think it is because that .92 is less than zero. I have never been a big fan of this approach, I guess its to make it more dynamic but just putting in a number for it makes life a lot easier. Also, makes crimes tougher for all the stat whores out there

Posted

Yeah I didn't mean less than zero lol. But you can't divide by zero hence your error. In regards to issue of not going over 100%, it doesn't matter 310% is the same as 100%. You just work out the calculations like MTG showed you can see what you may expect.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...