Page 1 of 1

Patch to support backstab positioning

Posted: 11 Mar 2009, 17:21
by fallen
I created this patch that adds the check "fromBehind" to attackSkillSlot, allowing rogues to more effectively backstab monsters.

It's not 100% perfect (even on the client, I cant manage to land backstabs all the time :P), but works all right for me.

Here is the example config:

Code: Select all

attackSkillSlot Back Step {
        lvl 10             
        dist 2.5
        fromBehind 1
        aggressives <= 2
        sp > 30%        
        maxAttempts 3
        timeout 0
        disabled 0
        target_timeout 0
        inLockOnly 1    
        monsters Porcellio, Mummy, Skel Archer, Skel Soldier,Golem, Verit, Dragon Fly, Hunter Fly, Hill Wind, Stem Worm
}
And here is the patch (against latest SVN):

Code: Select all

--- Attack.pm.orig      2009-03-11 19:15:49.000000000 -0300
+++ Attack.pm   2009-03-11 19:15:58.000000000 -0300
@@ -592,8 +590,49 @@
                        my $slot = $args->{attackMethod}{skillSlot};
                        delete $args->{attackMethod};
 
                        ai_setSuspend(0);
+                       my $monsterLooking=$target->{look}{body};
+                       if ($config{'attackSkillSlot_'.$slot.'_fromBehind'} && $monsterLooking ) {
+                               my %behind;
+                               if ($monsterLooking eq 0 || $monsterLooking eq 8) {
+                                       $behind{x}=$target->{pos_to}{x} ; 
+                                       $behind{y}=$target->{pos_to}{y} - 1;
+                               }       
+                               elsif ($monsterLooking eq 1) {
+                                       $behind{x}=$target->{pos_to}{x} + 1 ; 
+                                       $behind{y}=$target->{pos_to}{y} - 1; 
+                               }
+                               elsif ($monsterLooking eq 2) {
+                                       $behind{x}=$target->{pos_to}{x} + 1 ; 
+                                       $behind{y}=$target->{pos_to}{y}; 
+                               }       
+                               elsif ($monsterLooking eq 3) {
+                                       $behind{x}=$target->{pos_to}{x} + 1; 
+                                       $behind{y}=$target->{pos_to}{y} + 1;
+                               }
+                               elsif ($monsterLooking eq 4) {  
+                                       $behind{x}=$target->{pos_to}{x} ; 
+                                       $behind{y}=$target->{pos_to}{y} + 1;
+                               }
+                               elsif ($monsterLooking eq 5) {
+                                       $behind{x}=$target->{pos_to}{x} - 1; 
+                                       $behind{y}=$target->{pos_to}{y} + 1;
+                               }       
+                               elsif ($monsterLooking eq 6) {
+                                       $behind{x}=$target->{pos_to}{x} - 1; 
+                                       $behind{y}=$target->{pos_to}{y} ;
+                               }
+                               elsif ($monsterLooking eq 7) {
+                                       $behind{x}=$target->{pos_to}{x} - 1; 
+                                       $behind{y}=$target->{pos_to}{y} - 1;
+                               }       
+                               
+       
+                               message "Trying to move behind target ($target->{pos_to}{x},$target->{pos_to}{y} looking $directions_lut{$monsterLooking}) - ($
behind{x},$behind{y})\n";
+                               $messageSender->sendMove($behind{x}, $behind{y});
+
+                       }               
                        my $skill = new Skill(name => lc($config{"attackSkillSlot_$slot"}));
                        if (!ai_getSkillUseType($skill->getHandle())) {
                                ai_skillUse(
                                        $skill->getHandle(),
Hope it makes it's way into the mainstream codebase :)

Re: Patch to support backstab positioning

Posted: 11 Mar 2009, 21:29
by h4rry84
it could be more optimized *_*

Re: Patch to support backstab positioning

Posted: 11 Mar 2009, 21:31
by sli
Wow, yeah, a shitload.

Re: Patch to support backstab positioning

Posted: 11 Mar 2009, 22:06
by kali
Beware of premature optimization :)

Let's give this a few days, then have it committed.

Re: Patch to support backstab positioning

Posted: 21 Jun 2009, 12:07
by Contrast
Are you still working on it? Cause I'd love to use BackStab to level :o

Do i simply have to paste this in Attack.pm?

Re: Patch to support backstab positioning

Posted: 27 Jun 2009, 04:25
by idiomm
im really a noob an if its okay could you start the code from the Hiding Skill to Back Stab?? Please... or could you explain further..

Re: Patch to support backstab positioning

Posted: 09 Sep 2009, 20:14
by M4rk1nhu
please, help me, qhere i put this code?
--- Attack.pm.orig 2009-03-11 19:15:49.000000000 -0300
+++ Attack.pm 2009-03-11 19:15:58.000000000 -0300
@@ -592,8 +590,49 @@
my $slot = $args->{attackMethod}{skillSlot};
delete $args->{attackMethod};

ai_setSuspend(0);
+ my $monsterLooking=$target->{look}{body};
+ if ($config{'attackSkillSlot_'.$slot.'_fromBehind'} && $monsterLooking ) {
+ my %behind;
+ if ($monsterLooking eq 0 || $monsterLooking eq 8) {
+ $behind{x}=$target->{pos_to}{x} ;
+ $behind{y}=$target->{pos_to}{y} - 1;
+ }
+ elsif ($monsterLooking eq 1) {
+ $behind{x}=$target->{pos_to}{x} + 1 ;
+ $behind{y}=$target->{pos_to}{y} - 1;
+ }
+ elsif ($monsterLooking eq 2) {
+ $behind{x}=$target->{pos_to}{x} + 1 ;
+ $behind{y}=$target->{pos_to}{y};
+ }
+ elsif ($monsterLooking eq 3) {
+ $behind{x}=$target->{pos_to}{x} + 1;
+ $behind{y}=$target->{pos_to}{y} + 1;
+ }
+ elsif ($monsterLooking eq 4) {
+ $behind{x}=$target->{pos_to}{x} ;
+ $behind{y}=$target->{pos_to}{y} + 1;
+ }
+ elsif ($monsterLooking eq 5) {
+ $behind{x}=$target->{pos_to}{x} - 1;
+ $behind{y}=$target->{pos_to}{y} + 1;
+ }
+ elsif ($monsterLooking eq 6) {
+ $behind{x}=$target->{pos_to}{x} - 1;
+ $behind{y}=$target->{pos_to}{y} ;
+ }
+ elsif ($monsterLooking eq 7) {
+ $behind{x}=$target->{pos_to}{x} - 1;
+ $behind{y}=$target->{pos_to}{y} - 1;
+ }
+
+
+ message "Trying to move behind target ($target->{pos_to}{x},$target->{pos_to}{y} looking $directions_lut{$monsterLooking}) - ($
behind{x},$behind{y})\n";
+ $messageSender->sendMove($behind{x}, $behind{y});
+
+ }
my $skill = new Skill(name => lc($config{"attackSkillSlot_$slot"}));
if (!ai_getSkillUseType($skill->getHandle())) {
ai_skillUse(
$skill->getHandle(),

Re: Patch to support backstab positioning

Posted: 09 Mar 2013, 05:56
by drane
If for some reason the target is standing right up against a wall, just stand inside of them, it works fine.

Re: Patch to support backstab positioning

Posted: 25 Nov 2013, 00:19
by Kornfred
M4rk1nhu wrote:please, help me, qhere i put this code?
--- Attack.pm.orig 2009-03-11 19:15:49.000000000 -0300
+++ Attack.pm 2009-03-11 19:15:58.000000000 -0300
@@ -592,8 +590,49 @@
my $slot = $args->{attackMethod}{skillSlot};
delete $args->{attackMethod};

ai_setSuspend(0);
+ my $monsterLooking=$target->{look}{body};
+ if ($config{'attackSkillSlot_'.$slot.'_fromBehind'} && $monsterLooking ) {
+ my %behind;
+ if ($monsterLooking eq 0 || $monsterLooking eq 8) {
+ $behind{x}=$target->{pos_to}{x} ;
+ $behind{y}=$target->{pos_to}{y} - 1;
+ }
+ elsif ($monsterLooking eq 1) {
+ $behind{x}=$target->{pos_to}{x} + 1 ;
+ $behind{y}=$target->{pos_to}{y} - 1;
+ }
+ elsif ($monsterLooking eq 2) {
+ $behind{x}=$target->{pos_to}{x} + 1 ;
+ $behind{y}=$target->{pos_to}{y};
+ }
+ elsif ($monsterLooking eq 3) {
+ $behind{x}=$target->{pos_to}{x} + 1;
+ $behind{y}=$target->{pos_to}{y} + 1;
+ }
+ elsif ($monsterLooking eq 4) {
+ $behind{x}=$target->{pos_to}{x} ;
+ $behind{y}=$target->{pos_to}{y} + 1;
+ }
+ elsif ($monsterLooking eq 5) {
+ $behind{x}=$target->{pos_to}{x} - 1;
+ $behind{y}=$target->{pos_to}{y} + 1;
+ }
+ elsif ($monsterLooking eq 6) {
+ $behind{x}=$target->{pos_to}{x} - 1;
+ $behind{y}=$target->{pos_to}{y} ;
+ }
+ elsif ($monsterLooking eq 7) {
+ $behind{x}=$target->{pos_to}{x} - 1;
+ $behind{y}=$target->{pos_to}{y} - 1;
+ }
+
+
+ message "Trying to move behind target ($target->{pos_to}{x},$target->{pos_to}{y} looking $directions_lut{$monsterLooking}) - ($
behind{x},$behind{y})\n";
+ $messageSender->sendMove($behind{x}, $behind{y});
+
+ }
my $skill = new Skill(name => lc($config{"attackSkillSlot_$slot"}));
if (!ai_getSkillUseType($skill->getHandle())) {
ai_skillUse(
$skill->getHandle(),
id like to know that too....