1. Hello!

    First of all, welcome to MapleLegends! You are currently viewing the forums as a guest, so you can only view the first post of every topic. We highly recommend registering so you can be part of our community.

    By registering to our forums you can introduce yourself and make your first friends, talk in the shoutbox, contribute, and much more!

    This process only takes a few minutes and you can always decide to lurk even after!

    - MapleLegends Administration-
  2. Experiencing disconnecting after inserting your login info? Make sure you are on the latest MapleLegends version. The current latest version is found by clicking here.
    Dismiss Notice

Leech Cost Calculator

Discussion in 'Help & Advice' started by map1enoobie, Nov 20, 2022.

  1. map1enoobie
    Offline

    map1enoobie Slime

    17
    28
    30
    Nov 10, 2017
    Male
    6:02 AM
    MAP1ENOOBIE
    Hunter
    67
    Ohana
    Hello Maplers,

    This is a simple console program that I use that calculates the cost of leech using EXP/MESO rates. Other leech calculators exist already, but I find this easier to use since it is on a console window.

    All that has to be done is to type the following information:
    1. select percent (P) or exp point (X or anything not P);
    2. select rate in EXP/MESO;
    3. enter start level;
    4. enter start percent or exp point;
    5. enter end level; and
    6. enter end percent or exp point.
    The program may be run in two ways. The first example involves running the program by double clicking (or without arguments from the console). The second example shows how the program works if arguments are given through the console.

    Code:
    $ ./leech
    Use Percent or Exp points? (P/X): P
    What is the rate in EXP/MESO: 3.2
    Start Level: 116
    Start %:     27.79
    End Level:   117
    End %:       4.76
    Total exp:   18539501
    Cost:        5793593
    
    Start Level:
    
    JohnOmok@DESKTOP-TBCH84D MINGW32 /c/Users/JohnOmok/Desktop
    $ ./leech P 3.2 116 27.79 117 4.76
    Total exp:   18539501
    Cost:        5793593
    
    
    JohnOmok@DESKTOP-TBCH84D MINGW32 /c/Users/JohnOmok/Desktop
    $
    
    The C code is available in the spoiler below. It may be compiled on your computer or online. My favorite website for that is cpp.sh.

    A compiled 32-bit Windows executable is in the attachment (leech.txt needs to be renamed to leech.exe).

    Code:
    //Leech cost calculator
    //19 Nov 2022
    //NoobieII (the developer's pseudonym)
    
    //Program calculates cost of leech either by percentage or experience points.
    //Usage
    //
    //leech.exe P <rate> <level start> <percent start> <level end> <percent end>
    //leech.exe X <rate> <level start> <point start>   <level end> <point end>
    
    #include <stdlib.h>
    #include <stdio.h>
    
    int exp_table[200] = {
       15,
       34,
       57,
       92,
       135,
       372,
       560,
       840,
       1242,
       1716,
       2360,
       3216,
       4200,
       5460,
       7050,
       8840,
       11040,
       13716,
       16680,
       20216,
       24402,
       28980,
       34320,
       40512,
       47216,
       54900,
       63666,
       73080,
       83720,
       95700,
       108480,
       122760,
       138666,
       155540,
       174216,
       194832,
       216600,
       240500,
       266682,
       294216,
       324240,
       356916,
       391160,
       428280,
       468450,
       510420,
       555680,
       604416,
       655200,
       709716,
       748608,
       789631,
       832902,
       878545,
       926689,
       977471,
       1031036,
       1087536,
       1147132,
       1209994,
       1276301,
       1346242,
       1420016,
       1497832,
       1579913,
       1666492,
       1757815,
       1854143,
       1955750,
       2062925,
       2175973,
       2295216,
       2420993,
       2553663,
       2693603,
       2841212,
       2996910,
       3161140,
       3334370,
       3517093,
       3709829,
       3913127,
       4127566,
       4353756,
       4592341,
       4844001,
       5109452,
       5389449,
       5684790,
       5996316,
       6324914,
       6671519,
       7037118,
       7422752,
       7829518,
       8258575,
       8711144,
       9188514,
       9692044,
       10223168,
       10783397,
       11374327,
       11997640,
       12655110,
       13348610,
       14080113,
       14851703,
       15665576,
       16524049,
       17429566,
       18384706,
       19392187,
       20454878,
       21575805,
       22758159,
       24005306,
       25320796,
       26708375,
       28171993,
       29715818,
       31344244,
       33061908,
       34873700,
       36784778,
       38800583,
       40926854,
       43169645,
       45535341,
       48030677,
       50662758,
       53439077,
       56367538,
       59456479,
       62714694,
       66151459,
       69776558,
       73600313,
       77633610,
       81887931,
       86375389,
       91108760,
       96101520,
       101367883,
       106922842,
       112782213,
       118962678,
       125481832,
       132358236,
       139611467,
       147262175,
       155332142,
       163844343,
       172823012,
       182293713,
       192283408,
       202820538,
       213935103,
       225658746,
       238024845,
       251068606,
       264827165,
       279339693,
       294647508,
       310794191,
       327825712,
       345790561,
       364739883,
       384727628,
       405810702,
       428049128,
       451506220,
       476248760,
       502347192,
       529875818,
       558913012,
       589541445,
       621848316,
       655925603,
       691870326,
       729784819,
       769777027,
       811960808,
       856456260,
       903390063,
       952895838,
       1005114529,
       1060194805,
       1118293480,
       1179575962,
       1244216724,
       1312399800,
       1384319309,
       1460180007,
       1540197871,
       1624600714,
       1713628833,
       1807535693,
       1906588648,
       2011069705,
       2121276324
    };
    
    #define INPUT_LEN 100
    
    int main(int argc, char *argv[]){
       int i;
       char input[INPUT_LEN];
     
       char pp;
       int level_start, level_end;
       float percent_start, percent_end;
       int exp_start, exp_end;
       long long cumulative_start, cumulative_end;
       float rate;
     
       if(argc == 1){
           do{
               printf("Use Percent or Exp points? (P/X): ");
               fflush(stdout);
               fgets(input, INPUT_LEN, stdin);
           } while(sscanf(input, "%c", &pp) != 1);
       
           do{
               printf("What is the rate in EXP/MESO: ");
               fflush(stdout);
               fgets(input, INPUT_LEN, stdin);
           } while(!(sscanf(input, "%f", &rate) == 1 && rate > 0.0f));
       
           while(1){
               do{
                   printf("Start Level: ");
                   fflush(stdout);
                   fgets(input, INPUT_LEN, stdin);
               } while(!(sscanf(input, "%d", &level_start) == 1 && level_start > 0 && level_start <= 200));
           
               if(pp == 'P' || pp == 'p'){
                   do{
                       printf("Start %%:     ");
                       fflush(stdout);
                       fgets(input, INPUT_LEN, stdin);
                   } while(!(sscanf(input, "%f", &percent_start) == 1 && percent_start >= 0.0f && percent_start < 100.0f));
               }
               else{
                   do{
                       printf("Start EXP:   ");
                       fflush(stdout);
                       fgets(input, INPUT_LEN, stdin);
                   } while(!(sscanf(input, "%d", &exp_start) == 1 && exp_start >= 0 && exp_start <= exp_table[level_start - 1]));
               }
           
               do{
                   printf("End Level:   ");
                   fflush(stdout);
                   fgets(input, INPUT_LEN, stdin);
               } while(!(sscanf(input, "%d", &level_end) == 1 && level_end >= level_start && level_end <= 200));
           
               if(pp == 'P' || pp == 'p'){
                   do{
                       printf("End %%:       ");
                       fflush(stdout);
                       fgets(input, INPUT_LEN, stdin);
                   } while(!(sscanf(input, "%f", &percent_end) == 1 && ((level_start < level_end && percent_end >= 0.0f && percent_end < 100.0f) || (level_start == level_end && percent_end >= percent_start && percent_end < 100.0f))));
               }
               else{
                   do{
                       printf("End EXP:     ");
                       fflush(stdout);
                       fgets(input, INPUT_LEN, stdin);
                   } while(!(sscanf(input, "%d", &exp_end) == 1 && ((level_start < level_end && exp_end >= 0 && exp_end < exp_table[level_end - 1]) || (level_start == level_end && exp_end >= 0 && exp_end >= exp_start && exp_end <= exp_table[level_end - 1]))));
               }
           
               //calculate the exp, input has been verified above
           
               cumulative_start = 0;
               for(i = 0; i < level_start - 1; ++i){
                   cumulative_start += exp_table[i];
               }
               cumulative_end = cumulative_start;
               for(; i < level_end - 1; ++i){
                   cumulative_end += exp_table[i];
               }
               if(pp == 'P' || pp == 'p'){
                   cumulative_start += exp_table[level_start - 1] / 100.0f * percent_start;
                   cumulative_end += exp_table[level_end - 1] / 100.0f * percent_end;
               }
               else{
                   cumulative_end += exp_end;
                   cumulative_start += exp_start;
               }
           
               //printf("cumulative_start = %lld\n", cumulative_start);
               //printf("cumulative_end = %lld\n", cumulative_end);
               printf("Total exp:   %d\n", (int)(cumulative_end - cumulative_start));
               printf("Cost:        %d\n\n", (int)((cumulative_end - cumulative_start) / rate));
               fflush(stdout);
           }//while(1)
       
           return 0; //this code won't run, you must end the program manually
       }//if(argc == 1)
     
       else if(argc == 7){
           if(sscanf(argv[1], "%c", &pp) != 1){
               goto error_message;
           }
           if(!(sscanf(argv[2], "%f", &rate) == 1 && rate > 0.0f)){
               goto error_message;
           }
           if(!(sscanf(argv[3], "%d", &level_start) == 1 && level_start > 0 && level_start <= 200)){
               goto error_message;
           }
           if(!(sscanf(argv[5], "%d", &level_end) == 1 && level_end >= level_start && level_end <= 200)){
               goto error_message;
           }
           if(pp == 'P' || pp == 'p'){
               if(!(sscanf(argv[4], "%f", &percent_start) == 1 && percent_start >= 0.0f && percent_start < 100.0f)){
                   goto error_message;
               }
               if(!(sscanf(argv[6], "%f", &percent_end) == 1 && ((level_start < level_end && percent_end >= 0.0f && percent_end < 100.0f) || (level_start == level_end && percent_end >= percent_start && percent_end < 100.0f)))){
                   goto error_message;
               }
           }
           else{
               if(!(sscanf(argv[4], "%d", &exp_start) == 1 && exp_start >= 0 && exp_start <= exp_table[level_start - 1])){
                   goto error_message;
               }
               if(!(sscanf(argv[6], "%d", &exp_end) == 1 && ((level_start < level_end && exp_end >= 0 && exp_end < exp_table[level_end - 1]) || (level_start == level_end && exp_end >= 0 && exp_end >= exp_start && exp_end <= exp_table[level_end - 1])))){
                   goto error_message;
               }
           }
       
           //calculate the exp, input has been verified above
           cumulative_start = 0;
           for(i = 0; i < level_start - 1; ++i){
               cumulative_start += exp_table[i];
           }
           cumulative_end = cumulative_start;
           for(; i < level_end - 1; ++i){
               cumulative_end += exp_table[i];
           }
           if(pp == 'P' || pp == 'p'){
               cumulative_start += exp_table[level_start - 1] / 100.0f * percent_start;
               cumulative_end += exp_table[level_end - 1] / 100.0f * percent_end;
           }
           else{
               cumulative_end += exp_end;
               cumulative_start += exp_start;
           }
       
           printf("Total exp:   %d\n", (int)(cumulative_end - cumulative_start));
           printf("Cost:        %d\n\n", (int)((cumulative_end - cumulative_start) / rate));
           fflush(stdout);
       
           return 0;
       }
     
    error_message:
       printf("Correct usage:\n");
       printf("leech.exe P <rate> <level start> <percent start> <level end> <percent end>\n");
       printf("leech.exe X <rate> <level start> <point start>   <level end> <point end>\n");
       fflush(stdout);
       return -1;
    }
    
    
    
     

    Attached Files:

Share This Page