viewing paste dynamic rates | Athena

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
//[jaBote] Dynamic rates
// Configurations start in line 4, inside OnInit label.
-   script  dynrates    -1,{
OnInit: // Configurations
    set .dynratetype, 0; // 0 = nothing; 1 = Base rates are dynamic; 2 = Job rates are dynamic; 4 = Drop rates are dynamic. You can add up these, eg: 7 = 1+2+4 = 1|2|4
    // If 0, rates will increase in a linear fashion (rate = A + B*x); 
    // If 1, they'll increase in an exponential fashion (rate = A + B^x);
    // If 2, they'll increase in another exponential fashion (rate = A + x^B).
    // x will be number of people online. If you don't know how they're, you can plot these graphs on http://fooplot.com if you give a value to A and B
    set .fashion, 0; 
    
    if (.dynratetype & 1) { //Rates for Base exp. 100 = 1x; 1000 = 10x and so.
        set .Abase, 500;
        set .Bbase, 10;
        set .capbase, 1000; // Max value to base exp, if our calculations take 
        set .flatbase, 500; // For weekends
    }
    if (.dynratetype & 2) { //Rates for Job exp. 100 = 1x; 1000 = 10x and so.
        set .Ajob, 500;
        set .Bjob, 10;
        set .capjob, 1000; // Max value to job exp, if our calculations take 
        set .flatjob, 500; // For weekends
    }
    if (.dynratetype & 4) { //Rates for Drop percentage. 100 = 1x; 1000 = 10x and so.
        set .Adrop, 500;
        set .Bdrop, 10;
        set .capdrop, 1000; // Max value to drop %, if our calculations take 
        set .flatdrop, 500; // For weekends
        // Array for which configurations you want to set. No special setting for any of these values. See /conf/battle/drops.conf
        setarray .dropsettings$[0],"item_rate_common","item_rate_heal","item_rate_use","item_rate_equip";
    }
    
    // Initialization of npc. No configs past this point.
    if ( gettime(4) > 0 && (gettime(4) < 5 || (gettime(4) == 5 && gettime(3) < 16)) ) set .dynamic, 1;
    else donpc strnpcinfo(3)+"::OnFri1600";
    end;
 
OnMon0000:
    set .dynamic, 1;
    end;
 
OnFri1600: //Restore all battle flags to flat rates
    set .dynamic, 0;
    setbattleflag("base_exp_rate",.flatbase);
    setbattleflag("job_exp_rate",.flatjob);
    for (set .@i,0; .@i < getarraysize(.dropsettings$); set .@i, .@i+1) {
        setbattleflag(.dropsettings$[.@i],.flatdrop);
    }
    end;
 
OnPCLoginEvent:
OnPCLogoutEvent:
    if (!.dynamic || !.dynratetype) end;
    set .@x, getusers(8);
    
    // FIXME: Don't know on a more efficient way of setting this?
    if (.dynratetype & 1) { // Base rate adjustments
        switch(.fashion) {
            case 0: // A + Bx
                set .@rate, .Abase + .Bbase * .@x;
                break;
            case 1: // A + B^x
                set .@rate, .Abase + pow(.Bbase,.@x);
                break;
            case 2: // A + x^B
                set .@rate, .Abase + pow(.@x,.Bbase);
                break;
            default:
                debugmes "Base dynamic rates failed to be setted because of .fashion value set to an invalid value. Setting rates to their flat value or cap value, whichever is lower";
                set .@rate, .flatbase;
        }
        if (.@rate > .capbase) set .@rate, .capbase;
        setbattleflag("base_exp_rate",.@rate);
    }
    if (.dynratetype & 2) { // Job rate adjustments
        switch(.fashion) {
            case 0: // A + Bx
                set .@rate, .Ajob + .Bjob * .@x;
                break;
            case 1: // A + B^x
                set .@rate, .Ajob + pow(.Bjob,.@x);
                break;
            case 2: // A + x^B
                set .@rate, .Ajob + pow(.@x,.Bjob);
                break;
            default:
                debugmes "Job dynamic rates failed to be setted because of .fashion value set to an invalid value. Setting rates to their flat value or cap value, whichever is lower";
                set .@rate, .flatjob;
        }
        if (.@rate > .capjob) set .@rate, .capjob;
        setbattleflag("job_exp_rate",.@rate);   
    }
    if (.dynratetype & 4) { // Drop rate adjustments
        switch(.fashion) {
            case 0: // A + Bx
                set .@rate, .Adrop + .Bdrop * .@x;
                break;
            case 1: // A + B^x
                set .@rate, .Adrop + pow(.Bdrop,.@x);
                break;
            case 2: // A + x^B
                set .@rate, .Adrop + pow(.@x,.Bdrop);
                break;
            default:
                debugmes "Drop dynamic rates failed to be setted because of .fashion value set to an invalid value. Setting rates to their flat value or cap value, whichever is lower";
                set .@rate, .flatdrop;
        }
        if (.@rate > .capdrop) set .@rate, .capdrop;
        for (set .@i,0; .@i < getarraysize(.dropsettings$); set .@i, .@i+1) {
            setbattleflag(.dropsettings$[.@i],.@rate);
        }
    }
    end;
}
Viewed 1401 times, submitted by jaBote.