Stuck after teleport

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

Moderators: Moderators, Developers

Message
Author
zideaddin
Noob
Noob
Posts: 5
Joined: 05 Oct 2010, 22:34
Noob?: Yes

Stuck after teleport

#1 Post by zideaddin »

in Openkore 2.0.7 all version SVN r7541
server twRO
my knight、Priest

This issue when I was attacked from the blood to a low when I use Teleport to escape,
ai will get stuck , I try to use ai print command to record the situation and attack are mostly stuck in skill_use

Image

when i use "tele" , Will return to normal


DrKN
Developers
Developers
Posts: 79
Joined: 06 Oct 2010, 09:22
Noob?: No

Re: AI get stuck in twRO renewal

#3 Post by DrKN »

i cant sure, but i know what is your problem..
tele is not functioning in twRO.
i tested on free server, the command is no more working.

zideaddin
Noob
Noob
Posts: 5
Joined: 05 Oct 2010, 22:34
Noob?: Yes

Re: AI get stuck in twRO renewal

#4 Post by zideaddin »

this problem is teleport after , when confirmation window jump out , my char if try to teleport will be stuck

how to cancel the teleport confirmation window?

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

Re: AI get stuck in twRO renewal

#5 Post by EternalHarvest »

zideaddin wrote:teleport after , when confirmation window jump out , my char if try to teleport will be stuck
That happens in original client too?

DrKN
Developers
Developers
Posts: 79
Joined: 06 Oct 2010, 09:22
Noob?: No

Re: AI get stuck in twRO renewal

#6 Post by DrKN »

i don get stuck after teleporting....
but messy ai queue is appeared.

zideaddin
Noob
Noob
Posts: 5
Joined: 05 Oct 2010, 22:34
Noob?: Yes

Re: AI get stuck in twRO renewal

#7 Post by zideaddin »

EternalHarvest wrote:
zideaddin wrote:teleport after , when confirmation window jump out , my char if try to teleport will be stuck
That happens in original client too?
Yes , i use Xkore can seen

This problem how to happend ?

1. BOT working
2. BOT need use teleport (etc . hp too low 30% )
3. BOT use Teleport skills , jump out confirmation window
4. BOT happens too many aggressives need teleport
5. confirmation windows need Kore to send packet "Enter" confirmation , but previous confirmation windows need to confirmation already
6. BOT teleport , screen stuck in "confirmation windows" , You must type "tele" to solve or wait other Monster attack you to hp 30%↓ ~

wang1337
Noob
Noob
Posts: 12
Joined: 18 May 2011, 21:12
Noob?: No

Re: AI get stuck in twRO renewal (teleport)

#8 Post by wang1337 »

I'm getting this error aswell on iRO.

It only happens when you use the teleport skill. I checked with Xkore 2 what was happening, and it seems it double casts teleport so you appear in the new place with a dialog box still open. Openkore then tries to continue on but is unable to cast any skills because of the box.

Console output looks like:

Code: Select all

You are casting Teleport on yourself (Delay: 0ms)
----------------- Warp Portal --------------------
#  Place                           Map
--------------------------------------------------
You use Teleport on yourself (Lv: 1)
Monster X (2) hit You when your HP is under 25. Teleporting...
[ 17/ 46] Monster X (2) attacks you (Dmg: 187) (Delay: 576ms)
Monster X (3) uses Blooddrain on Player Y (0) (Dmg: 149) (Delay: 576ms)
Teleporting due to insufficient HP/SP or too many aggressives
Map Change: map.gat (264, 51)
----------------- Warp Portal --------------------
#  Place                           Map
--------------------------------------------------
You use Teleport on yourself (Lv: 1)
And the AI gets stuck on skill_use.

To me it seems its being called twice by two different pieces of code.

Once in Corelogic.pm line 2870:

Code: Select all

		message T("Teleporting due to insufficient HP/SP or too many aggressives\n"), "teleport";
		$ai_v{temp}{clear_aiQueue} = 1 if (useTeleport(1));
		$timeout{ai_teleport_hp}{time} = time;
And is overlapping with line 2706 in Misc.pm:

Code: Select all

			} elsif ($config{$player->{configPrefix}.'teleportAuto_hp'} && percent_hp($player) <= $config{$player->{configPrefix}.'teleportAuto_hp'}) {
					message TF("%s hit %s when %s HP is under %d. Teleporting...\n",
						$monster, $player, $player->verb(T('your'), T('its')), $config{$player->{configPrefix}.'teleportAuto_hp'}), "teleport";
					$teleport = 1;
...
useTeleport(1, undef, 1) if ($teleport);
Then to useTeleport() again in Misc.pm line 2894:

Code: Select all

		if ($use_lvl == 1) {
			Plugins::callHook('teleport_sent', \%args);
			$messageSender->sendWarpTele(26, "Random");
			return 1;
Then to ServerType0.pm line 1456:

Code: Select all

sub sendWarpTele { # type: 26=tele, 27=warp
	my ($self, $skillID, $map) = @_;
	my $msg = pack('v2 Z16', 0x011B, $skillID, stringToBytes($map));
	$self->sendToServer($msg);
	debug "Sent ". ($skillID == 26 ? "Teleport" : "Open Warp") . "\n", "sendPacket", 2
}

With a lot of testing I found if i set ai_teleport_hp to a high number like 5, it pretty much eliminates the problem. So I think the offending code is Corelogic.pm line 2870. Although I'm not sure of how to change the code to solve the error from happening without a high timeout.

kLabMouse
Administrator
Administrator
Posts: 1301
Joined: 24 Apr 2008, 12:02

Re: AI get stuck in twRO renewal (teleport)

#9 Post by kLabMouse »

Hmm. Seems to be the race condition.

wang1337
Noob
Noob
Posts: 12
Joined: 18 May 2011, 21:12
Noob?: No

Re: AI get stuck in twRO renewal (teleport)

#10 Post by wang1337 »

Did some more testing with eharvest's help. Tried to add timeouts to the low HP teleport call in Misc.pm but it didn't help. I think that part of the code wasn't the problem since I can reproduce the error without calling that part. I think the problem code is in CoreLogic.pm:

Code: Select all

message T("Teleporting due to insufficient HP/SP or too many aggressives\n"), "teleport";
      $ai_v{temp}{clear_aiQueue} = 1 if (useTeleport(1));
      $timeout{ai_teleport_hp}{time} = time;
which ends up calling in Misc.pm:

Code: Select all

			if (!$emergency && $use_lvl == 1) {
				Plugins::callHook('teleport_sent', \%args);
				$timeout{ai_teleport_retry}{time} = time;
				AI::queue('teleport');
				return 1;
			}
I can easily reproduce the problem, set a low ai_teleport_hp (0.1->1) and set a low teleportAuto_minAggressives to get it to trigger easily using teleportAuto_useSkill 1. Nine times out of 10 the problem will happen for me. Not sure if its due to latency or postdelays. It seems easy to fix conceptually, just check to make sure the dialog box is closed after a certain short delay, hitting 'Cancel' on the box. Sadly I'm not sure how to do that, theres a bunch of other similar calls in CoreLogic.pm but they all use other timeouts that are uses less frequently and/or have a higher default timeout.

If I set a high ai_teleport_retry and a low ai_teleport_hp teleport seems to not work in time (at least with my small hp pool) and I die most of the time, but if I do the reverse (high HP, low retry) it seems to work well and I haven't seen it bug so far.

Edit: After testing over night, it still does bug with a high ai_teleport_hp, but much less frequently just due to it not spamming teleport as much. It helps the problem but won't solve it. I tried a bunch of things to try and fix it but I'm not familiar enough with the code to make it happen. It seems to me we need to confirm skill use (You use Teleport on yourself (Lv: 1)) and wait for mapChanged in the AI (map_change Recieve/ServerType0.pm) before casting again. It needs to spam like it does now however because of lag and postdelay, but not actually send the skill twice.

Locked