> For the complete documentation index, see [llms.txt](https://soulslike-framework.isik.vip/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://soulslike-framework.isik.vip/components-managers/ai-only-components/ai-interaction-manager.md).

# AI Interaction Manager

<div align="left"><figure><img src="/files/Pxb9F1D6r6SRb7Q5t5rd" alt=""><figcaption></figcaption></figure></div>

The **AI Interaction Manager (AC\_AI\_InteractionManager)** is responsible for handling NPC interactions, primarily focusing on **dialogue and vendor** logic. It determines **which dialogue should be displayed based on the player's progress** and displays the associated dialog entry upon interaction. Additionally, it allows NPCs to function as vendors, providing a seamless transition from dialogue into a shop or trade interface.

It is added to the **Soulslike NPC (B\_Soulslike\_NPC)** class by default.

### **How it Works**

* **Dialogue Handling**
  * Upon interaction with an NPC, the `BeginDialog` method is triggered. It ensures that a reference to the player's **Progress Manager** and the NPC’s **Dialog Asset** is valid before proceeding.
  * It fetches the appropriate **Dialog Table** based on the player’s progress and resets the **dialog index** to 0.
  * The dialog index is adjusted accordingly, either moving to the next line or exiting the conversation.
  * If the player **exits mid-dialog**, the system ensures that the dialog index is adjusted appropriately *(so that entries that execute gameplay events cannot be re-triggered).*
* **Executing Gameplay Events**
  * If the current dialog entry has an **event**, it triggers it via[ **AC\_ProgressManager**](/components-managers/player-specific-components/progress-manager.md) **-> ExecuteGameplayEvent()**.
* **Vendor Handling**
  * Upon completing the **last dialog entry**, the system checks if the NPC has an associated **vendor asset**.
  * If a vendor asset is found, the **NPC Window** is set up, transitioning the player into the vendor/shop interface.
  * If no vendor asset is present, the conversation simply ends.

### Example Usage

<figure><img src="/files/FQUeCTu8fbIkHUUqnqqc" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/85ET2b2EbHI7N76fja73" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/W0EdwSusFyEY5Zs2IKpd" alt=""><figcaption></figcaption></figure>
