Loading...   


sub EVENT_ENTERZONE{
	%enter_zone_options = ("timer_interval" => 5);
	BotDetectionHandler_EVENT_ENTERZONE(\%enter_zone_options);
}

sub EVENT_TIMER{
	%event_timer_options = ("check_for_afk" => 1, "common_shift_threshold_count" => 2);
	BotDetectionHandler_EVENT_TIMER(\%event_timer_options);
}

sub BotDetectionHandler_EVENT_ENTERZONE{
	quest::settimer("start_bot_detection", $_[0]{"timer_interval"});
}

sub BotDetectionHandler_EVENT_TIMER{
	my $Debug = 1;
	if($timer eq "start_bot_detection"){
		#::: Location counters
		#:::  We start recording rounded counters, if we have excessive amounts of counters for common locs, we can probably suspect that this person is botting
		if(is_loc_different()){ record_coord_shifts(); check_for_common_shifts(); debug_coord_shift() if $Debug; set_last_coord_shift_time(); } #::: Record Coordinate Shifts
		record_cur_loc(); #::: Record current coords for shifts
		plugin::SEV($client, "total_tics", (plugin::REV($client, "total_tics") + 1)); #::: Record Total Tics
		increment_coord_pair_count(); #::: Incremenet Coordinate Pair Count
	}
}

sub check_for_common_shifts{
	if(get_coord_pair_count() > $_[0]{"common_shift_threshold_count"}){
		debug_common_shifts if $Debug;
	}
}
sub debug_common_shifts{ $client->Message(15, "Common shift point detected X (" . get_x_round() . ") Y (" . get_y_round() . ") Shift Count " . get_coord_pair_count()); }
sub debug_coord_shift{ $client->Message(15, "Coordinate shift detected, Total Shifts " . get_coord_shifts() . " Last Shift Time " . (time() - get_last_coord_shift_time()) . " seconds ago"); }
sub set_last_coord_shift_time{ return plugin::SEV($client, "coord_shift_time", time());  }
sub get_last_coord_shift_time{ return plugin::REV($client, "coord_shift_time");  }
sub get_coord_shifts{ return plugin::REV($client, "total_coord_shifts");  }
sub record_coord_shifts{ plugin::SEV($client, "total_coord_shifts", (plugin::REV($client, "total_coord_shifts") + 1));  }
sub is_loc_different{ if(plugin::REV($client, "cur_loc") != (get_x_round() + get_y_round() + 10000)){ return 1; } else{ return; }  }
sub record_cur_loc{ plugin::SEV($client, "cur_loc", (get_x_round() + get_y_round() + 10000));  }
sub get_x_round{ return round_up($x, 10); }
sub get_y_round{ return round_up($y, 10); }
sub increment_coord_pair_count{ plugin::SEV($client, "coord_pair_" . get_x_round() . "_" . get_y_round(), (plugin::REV($client, "coord_pair_" . get_x_round() . "_" . get_y_round()) + 1)); }
sub get_coord_pair_count{ plugin::REV($client, "coord_pair_" . get_x_round() . "_" . get_y_round()); }

#::: Roundup, First argument is the actual number, the second is the place you want to round up to 10 = tens, 1 = ones, 100 = hundreds etc.
sub round_up{
	my $number = shift;
	my $round = shift;
	if ($number % $round) { return (1 + int($number/$round)) * $round; } else { return $number; }
}

Raw Paste Data