Attack Logic Improvement

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

Moderator: Moderators

Message
Author
Historm
Human
Human
Posts: 27
Joined: 01 Jun 2011, 01:59
Noob?: No

Attack Logic Improvement

#1 Post by Historm »

CoreLogic.pm line 2691, added check for monsters that have been cast on by party members

Code: Select all

				if ($config{attackAuto_party} && $attackOnRoute && !AI::is("take", "items_take")
				 && !$ai_v{sitAuto_forcedBySitCommand}
				 && ((($monster->{dmgFromParty} || $monster->{castOnByParty}) && $config{attackAuto_party} != 2) ||
				     $monster->{dmgToParty} || $monster->{missedToParty})
				 && timeOut($monster->{attack_failed}, $timeout{ai_attack_unfail}{timeout})) {
					push @partyMonsters, $_;
					next;
				}
CoreLogic.pm line 2699, added check for monsters that have been cast on by followtarget

Code: Select all

				if ($following && $config{'attackAuto_followTarget'} && $attackOnRoute && !AI::is("take", "items_take")
				 && ($monster->{dmgToPlayer}{$followID} || $monster->{dmgFromPlayer}{$followID} || $monster->{missedToPlayer}{$followID} || $monster->{castOnByPlayer}{$followID})
				 && timeOut($monster->{attack_failed}, $timeout{ai_attack_unfail}{timeout})) {
					push @partyMonsters, $_;
					next;
				}

misc.pm line 1347, added check for monsters that have been cast on by party members

Code: Select all

	if ($monster->{dmgFromParty} > 0 || $monster->{missedFromParty} > 0 || $monster->{dmgToParty} > 0 || $monster->{missedToParty} > 0 || $monster->{castOnByParty} > 0) {
		return 1;
	}
misc.pm line 1377, added check for monsters that have been cast on by followtarget

Code: Select all

	if (defined(my $followIndex = AI::findAction("follow"))) {
		my $following = AI::args($followIndex)->{following};
		my $followID = AI::args($followIndex)->{ID};

		if ($following) {
			# And master attacked monster, or the monster attacked/missed master
			if ($monster->{dmgToPlayer}{$followID} > 0
			 || $monster->{missedToPlayer}{$followID} > 0
			 || $monster->{dmgFromPlayer}{$followID} > 0
			 || $monster->{castOnByPlayer}{$followID} > 0) {
				return 1;
			}
		}
	}
misc.pm line 2496, added logic to increment a new hash, $actor->{castOnToParty}
misc.pm line 2510, added logic to increment a new hash, $actor->{castOnByParty}

Code: Select all

sub countCastOn {
	my ($sourceID, $targetID, $skillID, $x, $y) = @_;
	return unless defined $targetID;
	my $source = Actor::get($sourceID);
	my $target = Actor::get($targetID);
	assert(UNIVERSAL::isa($source, 'Actor')) if DEBUG;
	assert(UNIVERSAL::isa($target, 'Actor')) if DEBUG;

	if ($targetID eq $accountID) {
		$source->{castOnToYou}++;
	} elsif ($target->isa('Actor::Player')) {
		$source->{castOnToPlayer}{$targetID}++;
		if (existsInList($config{tankersList}, $target->{name}) ||
			($char->{slaves} && %{$char->{slaves}} && $char->{slaves}{$targetID} && %{$char->{slaves}{$targetID}}) ||
			($char->{party} && %{$char->{party}} && $char->{party}{users}{$targetID} && %{$char->{party}{users}{$targetID}})) {
			$source->{castOnToParty}++;
		}
	} elsif ($target->isa('Actor::Monster')) {
		$source->{castOnToMonster}{$targetID}++;
	}
	

	if ($sourceID eq $accountID) {
		$target->{castOnByYou}++;
	} elsif ($source->isa('Actor::Player')) {
		$target->{castOnByPlayer}{$sourceID}++;
		if (existsInList($config{tankersList}, $source->{name}) || ($char->{slaves} && $char->{slaves}{$sourceID}) ||
			($char->{party} && %{$char->{party}} && $char->{party}{users}{$sourceID} && %{$char->{party}{users}{$sourceID}})) {
			#cast on by party
			$target->{castOnByParty}++;
		}
	} elsif ($source->isa('Actor::Monster')) {
		$target->{castOnByMonster}{$sourceID}++;
	}
}

Code: Select all

	if ($monster->{dmgFromParty} > 0 || $monster->{missedFromParty} > 0 || $monster->{dmgToParty} > 0 || $monster->{missedToParty} > 0 || $monster->{castOnByParty} > 0) {
		return 1;
	}

WARNING! This revision can drastically alter how kore operates! Using attackautoparty 1 as opposed to attackautoparty 2 can result in a kore in tankee mode (archer, mage) going aggro against any mob that the followtarget or party member casts ANY skill on!

In order to avoid unwanted effects of this revision, examine carefully how your attackauto, attackautoparty, attackautoonlywhensafe, and attackautofollowtarget are set!

Regardless of the inconvenience of that, I think this is an important and needed change. It drastically improves the functionality of kore because it enables the detection of non damaging skills, such as lex aetera or provoke, to will trigger aggression. This is extremely useful for using kore in a tank - tankee combination.
Last edited by Historm on 12 Oct 2013, 12:57, edited 1 time in total.

Historm
Human
Human
Posts: 27
Joined: 01 Jun 2011, 01:59
Noob?: No

Re: Attack Logic Improvement

#2 Post by Historm »

BUGFIX:

Code: Select all

if ($config{attackAuto_party} && $attackOnRoute && !AI::is("take", "items_take")
&& !$ai_v{sitAuto_forcedBySitCommand}
&& ((($monster->{dmgFromParty} || $monster->{castOnByParty}) && $config{attackAuto_party} != 2) ||
$monster->{dmgToParty} || $monster->{missedToParty})
&& timeOut($monster->{attack_failed}, $timeout{ai_attack_unfail}{timeout})) {
push @partyMonsters, $_;
next;
}
Logic problem with detecting cast on party, would trigger aggro onto the cast target regardless if attackAuto_party was set to 2 or not.

Fixed by moving the check for (cast by party) into an OR statement with detecting (damage from party), AND attackAuto_party NOT 2.

Historm
Human
Human
Posts: 27
Joined: 01 Jun 2011, 01:59
Noob?: No

Re: Attack Logic Improvement

#3 Post by Historm »

Has any developer taken a look at this and included it yet?

Post Reply