# waitAIHealthLevel

<p class="callout info">An eventCall that tells the idEncounterManager to wait until the specified ai type reaches a certain HP level, before executing the next eventCalls.</p>

## Usage

```
item[0] = {
    eventCall = {
        eventDef = "waitAIHealthLevel";
        args = {
            num = 3;
            item[0] = {
                eEncounterSpawnType_t = "ENCOUNTER_SPAWN_HELL_KNIGHT"; // spawnType
            }
            item[1] = {
                float = 0.5; // target_group_health
            }
            item[2] = {
                string = ""; // group_label
            }
        }
    }
}
```

- `aiType` is the [`eEncounterSpawnType_t`](https://wiki.eternalmods.com/books/entities-custom-encounters/page/eencounterspawntype-t "eEncounterSpawnType_t") whose HP level should be checked.
- `target_group_health` is the HP level, in decimal percentage, that you want to reach before proceeding.
- `group_label` is the label for the specified ai type(s). This parameter is optional, can be left blank if inapplicable.

## Example Usage

```
item[0] = {
    eventCall = {
        eventDef = "spawnSingleAI";
        args = {
            num = 3;
            item[0] = {
                eEncounterSpawnType_t = "ENCOUNTER_SPAWN_CYBER_MANCUBUS"; // spawnType
            }
            item[1] = {
                entity = "game_target_spawn_1312"; // spawnTarget
            }
            item[2] = {
                string = "check health"; // group_label
            } 
        }
    }
}
item[1] = {
    eventCall = {
        eventDef = "waitAIHealthLevel";
        args = {
            num = 3;
            item[0] = {
                eEncounterSpawnType_t = "ENCOUNTER_SPAWN_CYBER_MANCUBUS"; // spawnType
            }
            item[1] = {
				float = 0.6; // target_group_health
            }
            item[2] = {
                string = "check health"; // group_label
            } 
        }
    }
}
item[2] = {
    eventCall = {
        eventDef = "spawnAI";
        args = {
            num = 4;
            item[0] = {
                eEncounterSpawnType_t = "ENCOUNTER_SPAWN_CACODEMON"; // spawnType
            }
            item[1] = {
				int = 2; // spawn_count
            }
            item[2] = {
                entity = "mod_spawngroup_flying_7"; // spawnGroup
            }
            item[3] = {
                string = "heavy"; // group_label
            }
        }
    }
}
```

In this example, we spawn a Cyber-Mancubus with the label `check_health`. Then we call `waitAIHealthLevel` with said `spawnType` and `group_label`, with `target_group_health` set to `0.6`, so that when the Cyber-Mancubus is &lt;= 60% of its HP, the encounter will proceed.