Back Stab usage idea.

Wrote new code? Fixed a bug? Want to discuss technical stuff? Feel free to post it here.

Moderator: Moderators

Message
Author
Mortimal
Developers
Developers
Posts: 389
Joined: 01 Nov 2008, 15:31
Noob?: No

Back Stab usage idea.

#1 Post by Mortimal »

I have an idea how to check if we are standing behind the back of the mob.


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;
Please fix my code mistakes because i am realy bad at Perl x)

if $result we are behind the back of the mob...
I can write the explanations if u wish.
I had not tested it yet.
Please use pin function for uploading your file contents!