# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://soulslike-framework.isik.vip/components-managers/ai-only-components/ai-interaction-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
