From 117ab617b62ce43d37f31bc2fed3585573457e69 Mon Sep 17 00:00:00 2001 From: Sarjuuk Date: Fri, 10 Jun 2022 15:58:09 +0200 Subject: [PATCH] SAI/Teleport (#346) * fixed resolving teleport target for NPCs --- includes/smartAI.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/smartAI.class.php b/includes/smartAI.class.php index 45ceeef2..53ac07f0 100644 --- a/includes/smartAI.class.php +++ b/includes/smartAI.class.php @@ -1271,7 +1271,15 @@ class SmartAI $a['param'][6] = $this->aiTemplate($a['param'][0]); break; case SAI_ACTION_TELEPORT: // 62 -> invoker [resolved coords already stored in areatrigger entry] - $a['param'][6] = $this->miscData['teleportA']; + if (isset($this->miscData['teleportA'])) + $a['param'][6] = $this->miscData['teleportA']; + else if ($pos = Game::worldPosToZonePos($a['param'][0], $this->itr['target']['pos'][0], $this->itr['target']['pos'][1])) + $a['param'][6] = $pos['areaId']; + else if ($areaId = DB::Aowow()->selectCell('SELECT id FROM ?_zones WHERE mapId = ?d LIMIT 1', $a['param'][0])) + $a['param'][6] = $areaId; + else + trigger_error('SmartAI::action - could not resolve teleport target: map:'.$a['param'][0].' x:'.$this->itr['target']['pos'][0].' y:'.$this->itr['target']['pos'][1]); + $this->jsGlobals[Type::ZONE][] = $a['param'][6]; break; case SAI_ACTION_SET_ORIENTATION: // 66 -> any target