# waitAIRemaining

<p class="callout info">An eventCall to wait until a certain quantity of specified ai types remain in an idEncounterManager.</p>

## Usage

```
item[0] = {
	eventCall = {
		eventDef = "waitAIRemaining";
		args = {
			num = 3;
			item[0] = {
				eEncounterSpawnType_t = ""; // aiType
			}
			item[1] = {
				int = 0; // desired_remaing_ai_count
			}
			item[2] = {
				string = ""; // group_label
			}
		}
	}
}
```

- `aiType` are the [`eEncounterSpawnType_t`](https://wiki.eternalmods.com/books/entities-custom-encounters/page/eencounterspawntype-t "eEncounterSpawnType_t") that you want to wait on.
- The encounter will wait until the quantity of specified ai types present in the encounter are less than or equal to the value of `desired_remaing_ai_count`
- `group_label` is the label that you want to wait on. This parameter is optional, and can be left blank.

## Example Usage

```
item[0] = {
	eventCall = {
		eventDef = "spawnAI";
		args = {
			num = 4;
			item[0] = {
				eEncounterSpawnType_t = "ENCOUNTER_SPAWN_IMP ENCOUNTER_SPAWN_SHOTGUN_SOLDIER"; // spawnType
			}
			item[1] = {
				int = 4; // spawn_count
			}
			item[2] = {
				entity = "mod_spawngroup_15"; // spawnGroup
			}
			item[3] = {
				string = ""; // group_label
			}
		}
	}
}
item[1] = {
	eventCall = {
		eventDef = "spawnAI";
		args = {
			num = 4;
			item[0] = {
				eEncounterSpawnType_t = "ENCOUNTER_SPAWN_HELL_SOLDIER ENCOUNTER_SPAWN_BEAM_SOLDIER"; // spawnType
			}
			item[1] = {
				int = 4; // spawn_count
			}
			item[2] = {
				entity = "mod_spawngroup_21"; // spawnGroup
			}
			item[3] = {
				string = ""; // group_label
			}
		}
	}
}
item[2] = {
	eventCall = {
		eventDef = "waitAIRemaining";
		args = {
			num = 3;
			item[0] = {
				eEncounterSpawnType_t = "ENCOUNTER_SPAWN_ANY"; // aiType
			}
			item[1] = {
				int = 0; // desired_remaing_ai_count
			}
			item[2] = {
				string = ""; // group_label
			}
		}
	}
}
```

In this example, 4 Imps/Shotgunners are spawned, and 4 Soldiers/Hell Razers. By using `waitAIRemaining` set to `ENCOUNTER_SPAWN_ANY` with a `desired_remaing_ai_count` of 0, this ensures that all enemies will need to be killed first.