Best way to "delay" an action: timeOut, ai_clientSuspend...?

Forum closed. All further discussion to be discussed at https://github.com/OpenKore/

Moderator: Moderators

Message
Author
stw
Noob
Noob
Posts: 9
Joined: 30 Nov 2011, 14:03
Noob?: No

Best way to "delay" an action: timeOut, ai_clientSuspend...?

#1 Post by stw »

Hey there. I'm afraid that this might be a stupid question (and yes, there are stupid questions).
But since I'm not really familiar with Perl nor OpenKore's interior design, I do hope that someone will point me in the right direction with this one.

What I want to do: I'm trying to add a short delay after Kore dropped a target to avoid kill-stealing (or possibly before) in an attempt to make it look more human. Currently, it's like INSTANTLY choosing a new path/target respectively whenever this occurs, rendering it quite suspicious in a somewhat crowded map. Now, there's two ways that I can imagine how this should "look":

a) Kore continues moving towards its former target, probably even starting to attack in case it's been very close, before "recognizing" that the monster has been tagged by another player and dropping target / routing properly.
b) Kore continues moving towards the already dismissed target and continues its pathing without going zig-zag because it's already following the precalculated path again.

Out of those two, the second one is likely to be harder to implement, so I was going with option "a". I figured that I simply needed to delay the execution of the "dropping target/ignoring monster" part for like a second or so before everything could continue as usual.

So what I got is this

Code: Select all

sub dropTargetWhileMoving {
	my $ID = AI::args->{attackID};
	message T("Dropping target - you will not kill steal others\n");
	$char->sendAttackStop;
	$monsters{$ID}{ignore} = 1;

	# Right now, the queue is either
	#   move, route, attack
	# -or-
	#   route, attack
	AI::dequeue;
	AI::dequeue;
	AI::dequeue if (AI::action eq "attack");
	if ($config{teleportAuto_dropTargetKS}) {
		message T("Teleport due to dropping attack target\n");
		useTeleport(1);
	}
}
and this

Code: Select all

# Drop target if it's already attacked by someone else
		message T("Dropping target - you will not kill steal others\n"), "ai_attack";
		$char->sendMove(@{$realMyPos}{qw(x y)});
		AI::dequeue;
		if ($config{teleportAuto_dropTargetKS}) {
			message T("Teleport due to dropping attack target\n"), "teleport";
			useTeleport(1);
		}
in src\AI\Attack.pm.

I was thinking of adding either timeOut(<n>) or perhaps ai_clientSuspend(<n>) into those two subroutines.

However, I figured that the latter would probably look even worse (full AI suspension, oh yeah) when dropping a target, and also I'm not sure whether or not there are better ways to do it than simply adding a timeOut. I couldn't find anything when browsing through the src files.

It's also possible that there's a way to do this already, in which case I'd appreciate a hint. Thanks in advance!
Hi.

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: Best way to "delay" an action: timeOut, ai_clientSuspend...?

#2 Post by EternalHarvest »

You may do "$timeout{ai_attack_auto}{time} = time;" to set a delay for initiating auto attack for a corresponding period specified in timeouts.txt.

ai_attack_waitAfterKill timeout implementation uses ai_clientSuspend. I guess it can be tolerated for small delays, especially if the reason is to be more human-like.

Locked