Bug with equipAuto and monsters setting

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

Moderator: Moderators

i4ybrid
Noob
Noob
Posts: 6
Joined: 02 Oct 2009, 07:21
Noob?: No

Bug with equipAuto and monsters setting

#1 Post by i4ybrid »

Hey guys,

There's some code in AI.pm which is breaking my equipAuto configuration. The reason is because the monster is not considered "aggressive" unless it has attacked me, and thus doesn't show up on my monsters list when i do:

equipAuto {
rightHand someWeapon
monsters Red Plant
}

This block will never be executed because the Red Plant never hits back. The way I found out this problem is because my hunter won't switch weapons when attacking a slow moving target, he always kills the target before it even reaches him, partly because of attack speed and party because of the distance he begins attacking. The reason this is because of the following code within sub ai_getAggressives:

Code: Select all

			# Remove monsters that are considered forced agressive (when set to 2 on Mon_Control)
			# but has not yet been damaged or attacked by party AND currently has no LOS
			# if this is not done, Kore will keep trying infinitely attack targets set to aggro but who
			# has no Line of Sight (ex.: GH Cemitery when on a higher position seeing an aggro monster in lower levels).
			# The other parameters are re-checked along, so you can continue to attack a monster who has
			# already been hit but lost the line for some reason.
			# Also, check if the forced aggressive is a clean target when it has not marked as "yours".
			my $myPos = calcPosition($char);
			my $pos = calcPosition($monster);

			next if (($type && $control->{attack_auto} == 2)
				&& (($config{'attackCanSnipe'}) ? !Misc::checkLineSnipable($myPos, $pos) : (!Misc::checkLineWalkable($myPos, $pos) || !Misc::checkLineSnipable($myPos, $pos)))
				&& !$monster->{dmgToYou} && !$monster->{missedYou}
				&& ($party && (!$monster->{dmgToParty} && !$monster->{missedToParty} && !$monster->{dmgFromParty}))
				);
&& !$monster->{dmgToYou} && !$monster->{missedYou}
I believe this line should be commented out to resolve this issue. What do you guys think?


EDIT: Another solution that's more complicated would be to create a function to see if the player or party members are actively attacking the monster in question. I don't really know perl, but I know programming languages, so here's the pseudocode:

Code: Select all

function isMonAggressive($monster) {
   if ($monster -> {dmgToYou} || $monster -> {missedYou})
       return true
   if $party {
      if ($monster -> {dmgToParty} || $monster->{missedToParty} || $monster->{dmgFromParty})
          return true
   }
   if ($monster -> {dmgFromYouRecently})
       return true

   return false
}

function dmgFromYouRecently($monster) {
   return ($monster -> {lastAttackTo} within <timeout> seconds)
}
EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Bug with equipAuto and monsters setting

#2 Post by EternalHarvest »

What about using "target", not "monsters"?