Jump to content
MakeWebGames

My own engine


WarMad

Recommended Posts

So I’m currently creating my own engine. I am working on crimes but I have no idea how to do a crimes “formula”. The only formula I have worked with was McCraps and that confused the hell out of me and well it sucks IMO… does anyone have any suggestions on something easier then the McCraps crimes formula? I haven’t even started that part yet. I would like it to either go off how much crime exp you have or get harder depending on how much nerve is required to complete it. I don’t even know where to start for it does anyone have any ideas/suggestions for me? I would like the crimes to start off really easy but get Significantly more difficult as you go up in crimes more similar to say torn as much as I don’t want to use it as a reference. Thank you in advance for any ideas/help that anyone gives.

Link to comment
Share on other sites

5 hours ago, WarMad said:

So I’m currently creating my own engine. I am working on crimes but I have no idea how to do a crimes “formula”. The only formula I have worked with was McCraps and that confused the hell out of me and well it sucks IMO… does anyone have any suggestions on something easier then the McCraps crimes formula? I haven’t even started that part yet. I would like it to either go off how much crime exp you have or get harder depending on how much nerve is required to complete it. I don’t even know where to start for it does anyone have any ideas/suggestions for me? I would like the crimes to start off really easy but get Significantly more difficult as you go up in crimes more similar to say torn as much as I don’t want to use it as a reference. Thank you in advance for any ideas/help that anyone gives.

I happened to like MCC crimes formula albeit, it could’ve been a little more dynamic in regards to the user stats used. Also you have to remember that the formula used wasn’t just a formula; if you really wanted to, you could’ve put in a static number like 88 or 12 since the code just turned it into a number 1 to 100 and if your chance was greater that what the “formula” spit out, you succeeded. Or you could’ve just completely rewrote the formula in the input box 🤷‍♂️.

Bottom line, the formula is up to you

Link to comment
Share on other sites

I quite liked MCC's crime success chance calculation. I feel it was a little lacking on the modifiers side of it as default, but easy enough to extend.
I'd suggest doing something similar to it, perhaps incrementally per level range or crime level (don't know what you're intending to do).


Alternatively, keep it simple with an "easy", "medium", "hard" at varying integers and use an RNG?
 

<?php
// Example
// Set array of difficulties with associated percentage of success
$difficulties = [
    'easy' => 95,
    'medium' => 50,
    'hard' => 25,
    'extreme' => 10,
];

// Assume $row is an array of crime data, assume "difficulty" is a valid column name with either "easy", "medium", "hard", or "extreme" set
if ($difficulties[$row['difficulty']] >= mt_rand(0, 100)) {
    // success
} else {
    // fail (maybe and/or jail?)
}

 

There are many ways to achieve your desired effect; experiment as see what works for you

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

59 minutes ago, Magictallguy said:

I quite liked MCC's crime success chance calculation. I feel it was a little lacking on the modifiers side of it as default, but easy enough to extend.
I'd suggest doing something similar to it, perhaps incrementally per level range or crime level (don't know what you're intending to do).


Alternatively, keep it simple with an "easy", "medium", "hard" at varying integers and use an RNG?
 

<?php // Example // Set array of difficulties with associated percentage of success $difficulties = [ 'easy' => 95, 'medium' => 50, 'hard' => 25, 'extreme' => 10, ]; // Assume $row is an array of crime data, assume "difficulty" is a valid column name with either "easy", "medium", "hard", or "extreme" set if ($difficulties[$row['difficulty']] >= mt_rand(0, 100)) { // success } else { // fail (maybe and/or jail?) }

<?php
// Example
// Set array of difficulties with associated percentage of success
$difficulties = [
    'easy' => 95,
    'medium' => 50,
    'hard' => 25,
    'extreme' => 10,
];

// Assume $row is an array of crime data, assume "difficulty" is a valid column name with either "easy", "medium", "hard", or "extreme" set
if ($difficulties[$row['difficulty']] >= mt_rand(0, 100)) {
    // success
} else {
    // fail (maybe and/or jail?)
}

 

There are many ways to achieve your desired effect; experiment as see what works for you

The reason I hate it is I don’t understand it lol I will play with what you just gave and see if I can make something work  I haven’t decided  to do per level or  crime level yet but  I do like that easy medium hard thing it will make it way easier for me haha and as always thank you for the reply my good friend 

Link to comment
Share on other sites

MC Codes crime formula was what allowed people to drop databases if they could get access to an admin account - or reverse engineer that privilidge.

It passes via eval(), which allows you to execute drop table queries.

Oh, the memories and good time 😄

  • Haha 1
Link to comment
Share on other sites

i did find this script a while back but it didn't have support for brackets, i keep meaning to revisit it and add the support into it.

<?php

function evalAsMath($str) {

   $error = false;
   $div_mul = false;
   $add_sub = false;
   $result = 0;

   $str = preg_replace('/[^\d\.\+\-\*\/]/i','',$str);
   $str = rtrim(trim($str, '/*+'),'-');

   if ((strpos($str, '/') !== false ||  strpos($str, '*') !== false)) {
      $div_mul = true;
      $operators = array('*','/');
      while(!$error && $operators) {
         $operator = array_pop($operators);
         while($operator && strpos($str, $operator) !== false) {
           if ($error) {
              break;
            }
           $regex = '/([\d\.]+)\\'.$operator.'(\-?[\d\.]+)/';
           preg_match($regex, $str, $matches);
           if (isset($matches[1]) && isset($matches[2])) {
                if ($operator=='+') $result = (float)$matches[1] + (float)$matches[2];
                if ($operator=='-') $result = (float)$matches[1] - (float)$matches[2]; 
                if ($operator=='*') $result = (float)$matches[1] * (float)$matches[2]; 
                if ($operator=='/') {
                   if ((float)$matches[2]) {
                      $result = (float)$matches[1] / (float)$matches[2];
                   } else {
                      $error = true;
                   }
                }
                $str = preg_replace($regex, $result, $str, 1);
                $str = str_replace(array('++','--','-+','+-'), array('+','+','-','-'), $str);
         } else {
            $error = true;
         }
      }
    }
}

  if (!$error && (strpos($str, '+') !== false ||  strpos($str, '-') !== false)) {
     $add_sub = true;
     preg_match_all('/([\d\.]+|[\+\-])/', $str, $matches);
     if (isset($matches[0])) {
         $result = 0;
         $operator = '+';
         $tokens = $matches[0];
         $count = count($tokens);
         for ($i=0; $i < $count; $i++) { 
             if ($tokens[$i] == '+' || $tokens[$i] == '-') {
                $operator = $tokens[$i];
             } else {
                $result = ($operator == '+') ? ($result + (float)$tokens[$i]) : ($result - (float)$tokens[$i]);
             }
         }
      }
    }

    if (!$error && !$div_mul && !$add_sub) {
       $result = (float)$str;
    }
    return $error ? 0 : $result;
}

echo evalAsMath("2+2*8"); // = 18


 

  • Like 2
Link to comment
Share on other sites

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...