# Creating Custom AI - entities

<p class="callout info">See [Creating Custom AI - decls](https://wiki.eternalmods.com/books/advanced-guide-custom-assets/page/creating-custom-ai-decls) before proceeding</p>

### idAI2 - [Reference](https://wiki.eternalmods.com/books/entities-custom-encounters/page/idai2)

Reference the original **idAI2** file for the vanilla AI and copy it into a separate text file. Like the the **entitydef** decl file, this links all the decls together in a usable format. You will need to copy all of the decl references in this entity, just like for the **entitydef** file.

<p class="callout warning">Make sure to inherit from the added **entitydef** decl.</p>

**materialRemap** is used to apply the custom textures to the new demon. Under **renderModelInfo**, a **materialRemap** parameter can be added (if it does not already exist). The following is an example.

```
renderModelInfo = {
	model = "md6def/characters/monsters/gargoyle/base/gargoyle.md6"; // base gargoyle model to use
	materialRemap = {
		num = 2;
		item[0] = {
			from = "models/monsters/gargoyle/gargoyle"; // replace existing texture
			to = "models/customization/monsters/mancubus/set12/mancubus_guns_set12"; // to this
		}
		item[1] = {
			from = "models/monsters/gargoyle/gargoyle_body";
			to = "models/customization/monsters/mancubus/set12/mancubus_body_set12";
		}
	}
}
```

<p class="callout info">**materialRemaps** should also be done in the entityDef decl.</p>

Notice that the **set12** skin for the the Mancubus is used. See [Creating Custom AI - textures](https://wiki.eternalmods.com/books/6-custom-assets/page/creating-custom-ai-textures) for more information.

### idTarget\_Spawn - [Reference](https://wiki.eternalmods.com/link/64#bkmrk-eternal)

The **idTarget\_Spawn** entity is used to spawn the custom AI. You will need more per custom AI that you want to spawn. Make sure to change the spawn positions for each. Always reference the idAI2 entity when spawning the custom AI, so you would not accidentally spawn the vanilla AI.

#### Troubleshooting

The process of getting custom AI working is a rather challenging task. You are bound to encounter some issues. Double check all of your **modified** decls and reference them with their **vanilla** counterparts. Same applies to **entities**. Ask yourself the following:

- Are you spawning your AI correctly?

If not, check the **idAI2** and **idTarget\_Spawn** for typos. The [encounter manager](https://wiki.eternalmods.com/books/5-level-modding/page/idencountermanager) can also have syntax errors.

- Are the textures loading consistently?

If not, check the **materialRemaps** or **TGA** files for typos. Also, check if the textures are added correctly in the assetsinfo JSON file.

- Does your AI function as intended?

If not, check the **decls** for typos or mislinks. The **entitydef** file might be the root of your problems if there is a mislink.

<p class="callout info">Double check BOTH assetsinfo JSON files for typos. Most crashes occur from syntax errors.</p>

### See Also

- ##### [Entities](https://wiki.eternalmods.com/books/entities-custom-encounters/chapter/entities)