New processAutoAttack and &Misc::getBestTarget

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

Moderator: Moderators

Message
Author
hakore
Super Moderators
Super Moderators
Posts: 200
Joined: 16 May 2008, 08:28
Noob?: No
Contact:

New processAutoAttack and &Misc::getBestTarget

#1 Post by hakore »

Resurrecting topic.

http://bibian.ath.cx/openkore/viewtopic.php?t=37499

The new attack AI code commited was a bit buggy. I noticed the change when I upgraded my bot (that runs on v.2.0.5) to SVN 6386. While using the old version, my character gains about 900k to 1m exp per hour. With the new attack AI logic, the exp dropped down to 600k - 800k. That's quite a big downgrade.

Here are the issues I found:
  1. attackCheckLOS is originally intended for ranged attackers. Not many melee attackers would want LOS to be checked since they can do fine routing close to the target. However, the proposed attack logic forces ALL characters to check LOS. Also, even when attackCheckLOS is set to 0 in config.txt, LOS is still checked regardless (since the condition has an OR that supersedes the check to attackCheckLOS). I therefore reverted the attackCheckLOS code to the old working one retaining as much as possible pieces of code from the "new logic" that matters and works.
    .
  2. The @cleanMonster array is removed and the clean monsters now are inter-mixed with the @aggressives array. This destroys priority. I had to restore the @cleanMonster array back.
    .
  3. Minor bug, monsters whose mon_control flag is set to 3 are being ignored completely.
    .
  4. attackMaxDistance (originally attackDistance, but was changed by Bibian to attackMaxDistance) is being checked in the new attack logic for picking the best target. In the new logic, all monsters outside attackMaxDistance are immediately removed from the list of possible targets. There is an error of understanding attackMaxDistance here. Please note that the options attackDistance and attackMaxDistance only determines the range of normal attack, not the range of the character's capability to engage monsters. The options attackDistance and attackMaxDistance does not indicate an area within which Kore will be allowed to choose targets.

    This is generally how Kore originally uses attackDistance and attackMaxDistance: after choosing a target, it checks if the monster is outside attackMaxDistance. If it is, then it will move near the target until it reach attackDistance. Then it uses normal attack. Attack skills work the same way, although in this case, Kore uses _dist for both attackDistance and attackMaxDistance. See the scenario? In the old logic, Kore can choose monsters outside attackMaxDistance. It simply moves closer to engage it.

    By restricting Kore to choose targets that are only within the attackMaxDistance range, how would you think Kore will behave for melee characters that have attackMaxDistance set to 2? Obviously, it will ignore most monsters around. Kore would be lucky enough if after a teleport, it lands 2 cells away from a non-aggressive monster. Or while random-walking, it walked near an idling monster. But in most cases, it would just ignore everything else.

    Therefore, I removed that check in getBestTarget().
    .
  5. Lastly, attackAuto_onlyWhenSafe is misplaced. In the new logic, it is checked for all monsters. In the old code, it is only checked for non-aggressive monsters. The old code is more reasonable since you wouldn't want Kore to just stand there and be killed by aggressive monsters when a player happens to walk by. Originally, attackAuto_onlyWhenSafe will only stop you from engaging non-aggressive monsters. You will have to continue killing aggressive ones even if players flock around you or you'll die like a stupid bot. This is reverted back to the old logic.
I believe most people have tested SVN r6386 and experienced a rather non-aggressive attack AI, walking around ignoring monsters. Please compare it again against the latest SVN r6428 to see the issues I described above.

Thank you.
Whatever...

Bibian
Perl Monk
Perl Monk
Posts: 416
Joined: 04 Apr 2008, 03:08

Re: New processAutoAttack and &Misc::getBestTarget

#2 Post by Bibian »

i believe freegoods was doing something with the attack code...

also i experienced this on a sniper, i wrote a plugin for PvP and kore would tell me it didnt have LOS when i called AI::attack() but when i use a skill (with skillTask) it was able to hit the target from where the attack AI would tell it had no LOS... that would prolly qualify as a bug :P (ps: attackDistance was set to 15)

freegoods
Perl Monk
Perl Monk
Posts: 8
Joined: 05 Apr 2008, 02:39
Noob?: Yes
Location: Russia

Re: New processAutoAttack and &Misc::getBestTarget

#3 Post by freegoods »

hakore, thank you for debugging the code! It should have taken a lot of time.
I appretiate the fixes and sorry for the bugs (especially for cases 2 and 5 which were the reason of many deaths of players with updated svn).

------------------------------

Since v6409 attackCheckLOS is slightly broken. It will take time to fix it, not recommended to use for the moment.
OK ignores LOSSubRoute and countinues its main route. In combination with a monster behind the wall causes AI loop.

Post Reply