OpenKore / openkore

A free/open source client and automation tool for Ragnarok Online
http://openkore.com
Other
1.28k stars 1.04k forks source link

[Feature Request] implement monstersCount in checkselfcondition #3693

Closed hubertyang88 closed 1 year ago

hubertyang88 commented 1 year ago

------------------ Openkore Issues Template ------------------

hubertyang88 commented 1 year ago
CoreLogic.pm

processCheckMonsternum();

sub processCheckMonsternum {
    return if !(timeOut($timeout{'ai_check_monster_num'}));
    my $dist = ($config{moncheckdist} || 12);
    my $counter = 0;
    foreach (@monstersID) {
        next unless $_;
        my $mypos = calcPosition($char);
        my $pos = calcPosition($monsters{$_});
        my $rdist = sprintf("%.1f", distance($mypos, $pos));
        if ($rdist <= $dist) {
            $counter++;
        }
        next;
    }
    $char->{monsternum} = $counter;
    $timeout{'ai_check_monster_num'}{'time'} = time;
}

I did it like this , if anyone need it

alisonrag commented 1 year ago

what about add this to Misc.pm?

|| ($config{$prefix."_monstersCountDist"} && !inRange(blockDistance(calcPosition($char), calcPosition($monster)), $config{$prefix."_monstersCountDist"}))

image

hubertyang88 commented 1 year ago

Your idea is right , what I am trying to do is to make bot find a safe enviroment to run a macro may freeze the move in ten seconds , such as send a mail , and if there is too many monster in a given dist then fly.

so , I also changed files in plugin macro Utilities.pm

sub refreshGlobal {
...
    $varStack{".maxweight"} = $char->{weight_max};
    $varStack{".monsternum"} = $char->{monsternum};
...
}

in Data.pm

our %amMulti =(
    ...
    'moncount' => 1,
    'itemnum' => 1,
    ...
    )

in Automacro.pl

sub automacroCheck {
...
foreach my $i (@{$automacro{$am}->{moncount}}){next CHKAM unless checkCond($char->{monsternum} || 0, $i)}
foreach my $i (@{$automacro{$am}->{itemnum}})     {next CHKAM unless checkCond($char->inventory->size() || 0, $i)}
...
}

to make below automacro work

automacro ccm {
moncount < 2
itemnum > 70
timeout 1
call {
do something
}
}   

and there is no condition of total item number in automacro ,so I add it for some usage