# spawnPossessedAI

<p class="callout info">An eventCall to spawn an ai that is already possessed by a spirit in an idEncounterManager.</p>

## Usage

```
item[0] = {
	eventCall = {
		eventDef = "spawnPossessedAI";
		args = {
			num = 7;
			item[0] = {
				eEncounterSpawnType_t = ""; // ai_spawnType
			}
			item[1] = {
				entity = ""; // ai_spawnTarget
			}
			item[2] = {
				string = ""; // ai_groupLabel
			}
			item[3] = {
				entity = ""; // spirit_spawnTarget
			}
			item[4] = {
				eEncounterSpawnType_t = ""; // spirit_allowedAITypes
			}
			item[5] = {
				string = ""; // spirit_allowedGroupLabel
			}
			item[6] = {
				bool = true; // aiTypeExplicitFiltering
			}
		}
	}
}
```

- `ai_spawnType` is the [`eEncounterSpawnType_t`](https://wiki.eternalmods.com/books/entities-custom-encounters/page/eencounterspawntype-t "eEncounterSpawnType_t") for the ai to be spawned.
- `ai_spawnTarget` is the spawn target to be used for the ai to be spawned.
- `ai_groupLabel` is the label to be given to the spawned ai.
- `spirit_spawnTarget` is the spawn target to be used for the spirit.
- `spirit_allowedAITypes` are the [`eEncounterSpawnType_t`](https://wiki.eternalmods.com/books/entities-custom-encounters/page/eencounterspawntype-t "eEncounterSpawnType_t") that the spirit is allowed to possess.
- `spirit_allowedGroupLabel` is the label that the spirit is allowed to possess.
- `aiTypeExplicitFiltering` is whether the spirit will possess ai based on the specified restrictions.

## Example Usage

```
item[0] = {
	eventCall = {
		eventDef = "spawnSingleAI";
		args = {
			num = 3;
			item[0] = {
				eEncounterSpawnType_t = "ENCOUNTER_SPAWN_PINKY";
			}
			item[1] = {
				entity = "ai_target_spawn_13";
			}
			item[2] = {
				string = "heavy";
			}
		}
	}
}
item[1] = {
	eventCall = {
		eventDef = "spawnPossessedAI";
		args = {
			num = 7;
			item[0] = {
				eEncounterSpawnType_t = "ENCOUNTER_SPAWN_REVENANT"; // ai_spawnType
			}
			item[1] = {
				entity = "ai_target_spawn_21"; // ai_spawnTarget
			}
			item[2] = {
				string = "beamer"; // ai_groupLabel
			}
			item[3] = {
				entity = "ai_target_spawn_17"; // spirit_spawnTarget
			}
			item[4] = {
				eEncounterSpawnType_t = "ENCOUNTER_SPAWN_ANY"; // spirit_allowedAITypes
			}
			item[5] = {
				string = "beamer"; // spirit_allowedGroupLabel
			}
			item[6] = {
				bool = true; // aiTypeExplicitFiltering
			}
		}
	}
}
```

In this example, we spawn a Pinky with the `heavy` label. Then we use `spawnPossessedAI` to spawn a Revenant with the `beamer` label, and the spirit with the ability to possess any ai type with the `beamer` label. This way, once the possessed Revenant is dead, there are no other ai that use the `beamer` label, so the spirit will be unable to possess anyone else, and will despawn.

## See Also

- [spawnSpirit](https://wiki.eternalmods.com/books/entities-custom-encounters/page/spawnspirit)