This is the minimal solution i could do:
Code: Select all
my $mld = $target->{look}{body};
my $mdf = ("0"=>1,"1"=>2,"2"=>1,"3"=>0,"4"=>-1,"5"=>-2,"6"=>-1,"7"=>0)->($mld);
my $subx = $char->{pos}{x} - $target->{pos_to}{x};
my $suby = $char->{pos}{y} - $target->{pos_to}{y};
if ($subx < 0) $subx = -1 elsif ($subx > 0) $subx = 1 else $subx = 0;
if ($suby < 0) $suby = -1 elsif ($suby > 0) $suby = 1 else $suby = 0;
if ((abs($odf - $mdf) == 1) || ( $odf == $mdf && $subx > $suby && grep(/$mld/,(2..4)) ) || ( $odf == $mdf && !grep(/$mld/,(2..4)) ) ) my $result = 1;
if $result we are behind the back of the mob...
I can write the explanations if u wish.
I had not tested it yet.