adventureland icon indicating copy to clipboard operation
adventureland copied to clipboard

The new 33 calls per second limit is killing me!

Open kujukuju opened this issue 8 years ago • 5 comments

I keep getting this error: "Disconnected Reason: You've made 100 calls in 3 seconds. That's too much."

What constitutes a call? I keep getting this error despite how I try to change my code.

Is this limit shared between characters on the account?

kujukuju avatar Oct 20 '16 21:10 kujukuju

don't use cicles (while or for), u should be fine

ghost avatar Oct 20 '16 21:10 ghost

I'd still like to know what is considered a call so I can optimize it. I can't really just completely avoid for loops and while loops for the stuff I'm doing.

kujukuju avatar Oct 20 '16 21:10 kujukuju

My targeting/attack loop only runs every 1300ms and it's way faster that way. Ping is also a factor you might need to switch to the Americas I server like I did

jaggedsoft avatar Oct 21 '16 02:10 jaggedsoft

Check out this script, only runs every 1.3 seconds but attacks faster than everything else I tried. Works good for all classes. This attacks anything in range so you take less damage than if you were attacking the closest monster. It efficiently uses potions when you're below 60 hp (you will want to increase min_hp if you're fighting high level monsters) and will buy potions if you run out.

setInterval(function(){
    var min_hp = 60;
    if ( character.hp < min_hp ) {
        parent.use('hp');
        Autobuy("hpot0");
    } else if ( character.mp < character.mp_cost ) {
        parent.use('mp');
        Autobuy("mpot0");
    }
    loot();
    if ( character.moving ) return;
    var target = get_targeted_monster();
    if ( !target ) {
        target = NextTarget();
        if ( target ) change_target(target);
        else {
            set_message("No Monsters");
            return;
        }
    }
    if ( !in_attack_range(target) ) {
        move(
            character.real_x+(target.real_x-character.real_x)/2,
            character.real_y+(target.real_y-character.real_y)/2
            );
    }
    else if ( target && target.hp && !target.dead ) {
        set_message("Attacking");
        parent.socket.emit("click",{type:"monster",id:target.server_id,button:"right"});
    }
},1300);

function Autobuy(name) {
    if ( character.gold > 19 && Qty(name) < 50 ) {
        var maxbuy = character.gold / 20;
        if ( maxbuy > 300 ) maxbuy = 300;
        buy(name,maxbuy);
    }
}
function Qty(name) {
    for ( var i = 0 ; i < character.items.length ; ++i ) {
        if ( character.items[i].name == name ) return character.items[i].q;
    }
    return 0;
}
function NextTarget() {
    var min_xp = 50;
    var max_attack = character.attack;
    for ( id in parent.entities ) {
        var current = parent.entities[id];
        if ( current.type != "monster" || current.dead ) continue;
        if ( current.xp<min_xp || current.attack>=max_attack ) continue;
        var c_dist = parent.distance(character,current);
        if ( c_dist <= character.range ) return current;
    }
}

If you see "Miss" or for low level characters you will want to change the 1300 delay to a 1600 delay. High level characters may be able to increase the 1300 even lower, but if you see a "Miss" you're doing it too fast.

jaggedsoft avatar Oct 21 '16 03:10 jaggedsoft

I'm looking into this issue further by the way

kaansoral avatar Oct 21 '16 05:10 kaansoral