mobber plugin

Other plugins for extending OpenKore's functionality. This forum is only for posting new plugins and commenting on existing plugins. For support, use the Support forum.

Moderator: Moderators

fco2783
Plain Yogurt
Plain Yogurt
Posts: 95
Joined: 05 Apr 2008, 05:15
Noob?: Yes
Location: in place where you cant go

mobber plugin

#1 Post by fco2783 »

could someone fix this plugin... the original post said this working fine...
though im having lots of bug encounter... and also if there someone there could make this work on openkore 2.0.0

Code: Select all

#mobber.pl OpenKore mobbing plugin
#Plugin by: [? Fenris? ?], Openkore
#Revision 5.3
#Openkore 2.0.5+
#Fixed, but should be tested

#mob 0
#mobLure_toMaster 0
#mob_keepDistance 5 #NEW on Update 5
#mobDefault_attackAuto
#mobDefault_route_step 10
#mobDefault_small_step 4
#mobAttack_whenDmg 10000
#mobbingStart 6
#mobDefault_attackAuto

package mobber;

use strict;

use Commands;
use Globals;
use Log qw(message error warning);
use Network::Send;
use Settings;
use Plugins;
use Utils;
use Misc;
use AI;
use Match;

Plugins::register('Mobbing Add-On.', 'Make you bot mob-train.', \&unload);

my $ai_mob_attack = Plugins::addHook('AI_pre', \&mobCheck);
my $atk_Active = 0;
my $slow = 0;

sub unload {
        Plugins::delHook('AI_pre', $ai_mob_attack);
}

sub activateMobbing {
	Commands::run("conf attackAuto 1 ".$::config{'mobDefault_attackAuto'});
	Commands::run("conf route_step 1 ".$::config{'mobDefault_route_step'});
	$atk_Active = 1;
}

sub resetToDefault {
	Commands::run("conf attackAuto 1 ".$::config{'mobDefault_attackAuto'}) if ($::config{'attackAuto'} != $::config{'mobDefault_attackAuto'});
	Commands::run("conf route_step 1 ".$::config{'mobDefault_route_step'}) if ($::config{'route_step'} != $::config{'mobDefault_route_step'});
}

sub mobCheck {
	if($::config{'mob'}){
		if ($::field{'name'} eq $::config{'lockMap'}) {
			my $aggros = scalar(main::ai_getAggressives());
			my $totalDmg = 0;
			my $monsterGotDamage = 0;
			
			for (my $i = 0; $i < @monstersID; $i++) {
				my $dmgFromMon = ($monsters{$monstersID[$i]}{'dmgFrom'} ne "")
				? $monsters{$monstersID[$i]}{'dmgFrom'}
				: 0;
				
				my $dmgToMon = ($monsters{$monstersID[$i]}{'dmgTo'} ne "")
				? $monsters{$monstersID[$i]}{'dmgTo'}
				: 0;				

				if($dmgFromMon > 0 || $monsters{$monstersID[$i]}{target} eq $accountID){

					$totalDmg += $dmgFromMon;
					$monsterGotDamage += $dmgToMon;
				}

			}

			if (timeOut($timeout{'ai_mobWait'}) && $aggros == 0) {
				$timeout{'ai_mobWait'}{'time'} = time;
			} elsif ($aggros >= $::config{'mobbingStart'} && 
				$::config{'attackAuto'} != $::config{'mobDefault_attackAuto'} &&
				$atk_Active == 0) {
					message("Activating attack config due to number of monsters.\n", "info");
					activateMobbing();					
			} elsif (timeOut($timeout{'ai_mobWait'}) &&
				$atk_Active == 0) {
					message("Activating attack config due to seeking timeout.\n", "info");
					activateMobbing();
			} elsif ($totalDmg >= $::config{'mobAttack_whenDmg'} &&
				$atk_Active == 0 && $aggros > 0) {
					message("Activating attack config due to monsters' total Damage.\n", "info");	
					activateMobbing();
			} elsif ($monsterGotDamage > 0 &&
				$atk_Active == 0 && $aggros > 0) {
					message("Activating attack config some monster got damage.\n", "info");	
					activateMobbing();
			} elsif ($aggros == 0 && $::config{'attackAuto'} != 0) {
					#We stop attacking monsters when there are no more aggressives around
					Commands::run("conf attackAuto 0");
					#And normalize our walk speed
					Commands::run("conf route_step ".$::config{'mobDefault_route_step'}) if ($::config{'route_step'} != $::config{'mobDefault_route_step'});
					$atk_Active = 0;
					$slow = 0;
			} elsif ($aggros == 1 && $slow == 0) {
					Commands::run("conf route_step ".$::config{'mobDefault_small_step'});
					$timeout{'ai_mobWait'}{'time'} = time;
					$slow = 1;
			} elsif ($slow == 1) {
				#Check average mob distance
				my $distanceSum;
				my $totalMon;
				for (my $i = 0; $i < @monstersID; $i++) {
					#try to detect whether this monster has attacked you or is chasing you.
					my $dist = distance(\%{$chars[$config{'char'}]{'pos_to'}}, 
						\%{$monsters{$monstersID[$i]}{'pos_to'}});

					my $dmgToMonster = ($monsters{$monstersID[$i]}{'dmgTo'} ne "")
					? $monsters{$monstersID[$i]}{'dmgTo'}
					: 0;
					
					my $dmgFromMonster = ($monsters{$monstersID[$i]}{'dmgFrom'} ne "")
					? $monsters{$monstersID[$i]}{'dmgFrom'}
					: 0;

					if($dmgFromMonster > 0 || $monsters{$monstersID[$i]}{target} eq $accountID){
						$totalMon++;
						$distanceSum += $dist;
					}
				}
				
				if ($totalMon > 0) {
					if(($distanceSum / $totalMon) >  
						$::config{'mob_keepDistance'}) {
						Commands::run("conf route_step 0") if ($::config{'route_step'} != 0);
					} else {
						Commands::run("conf route_step ".$::config{'mobDefault_small_step'}) if ($::config{'route_step'} != $::config{'mobDefault_small_step'});
					}
				}
			}
		} else {
			resetToDefault();
		}
	} else {
		resetToDefault();
	}
}

return 1;
Usage
mob 0
mobLure_toMaster 0
mob_keepDistance 5 #NEW on Update 5
mobDefault_attackAuto
mobDefault_route_step 10
mobDefault_small_step 4
mobAttack_whenDmg 10000
mobbingStart 6
mobDefault_attackAuto
c00ld1ds
Noob
Noob
Posts: 6
Joined: 12 Sep 2010, 19:45
Noob?: Yes

Re: mobber plugin

#2 Post by c00ld1ds »

can you explain the usage and everything?
c00ld1ds
Noob
Noob
Posts: 6
Joined: 12 Sep 2010, 19:45
Noob?: Yes

Re: mobber plugin

#3 Post by c00ld1ds »

nvm replied to ancient post