# HealthPrediction
# Description
The HealthPrediction namespace provides functionality to predict unit health values, which can be used for last-hitting minions, calculating damage, and other scenarios. It helps players predict a unit's health at a future point in time, taking into account various incoming damage factors.
# How to Use
#include "Noble.h"
void OnGameUpdate()
{
// Iterate through enemy minions
for (auto* minion : ObjectManager::GetEnemyMinions())
{
// Predict minion health after 500ms
float healthAfter500ms = HealthPrediction::GetHealthPrediction(minion, 500);
// Get hero auto-attack damage
float myAaDamage = ObjectManager::Player()->GetAutoAttackDamage(minion);
// If predicted health is less than or equal to my auto-attack damage, and the minion won't die naturally (health > 0)
if (healthAfter500ms <= myAaDamage && healthAfter500ms > 0)
{
// This minion can be killed after 500ms, consider attacking it
Console::Add("Can kill minion, current health: %.1f, predicted health: %.1f",
minion->Health(), healthAfter500ms);
}
}
}
# GetHealthPrediction
float HealthPrediction::GetHealthPrediction(AIBaseClient* unit, int time, int delay = 0)
Predicts the health of a specified unit after a given time, considering incoming damage.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | The unit to predict health for |
time | int | Future time (in milliseconds) |
delay | int | Optional additional delay (in milliseconds) |
AIBaseClient* minion = /* Get a minion */;
// Predict health after 400ms
float predictedHealth = HealthPrediction::GetHealthPrediction(minion, 400);
Console::Add("Minion current health: %.1f, predicted health after 400ms: %.1f",
minion->Health(), predictedHealth);
# HasMinionAggro
bool HealthPrediction::HasMinionAggro(AIBaseClient* minion)
Checks if the specified minion is being targeted by other minions.
Parameter Name | Parameter Type | Description |
---|---|---|
minion | AIBaseClient* | The minion to check |
AIBaseClient* minion = /* Get a minion */;
bool hasAggro = HealthPrediction::HasMinionAggro(minion);
Console::Add("Is minion targeted by other minions: %s", hasAggro ? "Yes" : "No");
# HasTurretAggro
bool HealthPrediction::HasTurretAggro(AIBaseClient* minion)
Checks if the specified minion is being targeted by a turret.
Parameter Name | Parameter Type | Description |
---|---|---|
minion | AIBaseClient* | The minion to check |
AIBaseClient* minion = /* Get a minion */;
bool hasTurretAggro = HealthPrediction::HasTurretAggro(minion);
Console::Add("Is minion targeted by a turret: %s", hasTurretAggro ? "Yes" : "No");
# LaneClearHealthPrediction
float HealthPrediction::LaneClearHealthPrediction(AIBaseClient* unit, int time, int delay = 0)
Health prediction designed for lane clearing mode, considering minion-to-minion attacks.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | The unit to predict health for |
time | int | Future time (in milliseconds) |
delay | int | Optional additional delay (in milliseconds) |
AIBaseClient* minion = /* Get a minion */;
// Predict health after 500ms in lane clear mode
float predictedHealth = HealthPrediction::LaneClearHealthPrediction(minion, 500);
if (predictedHealth > 0 && predictedHealth < ObjectManager::Player()->GetAutoAttackDamage(minion))
{
// In lane clear mode, this minion can be killed with an auto-attack
Console::Add("Lane clear mode: Can kill minion, predicted health: %.1f", predictedHealth);
}
# TurretAggroStartTick
int HealthPrediction::TurretAggroStartTick(AIBaseClient* minion)
Gets the game time tick when a turret began targeting the minion.
Parameter Name | Parameter Type | Description |
---|---|---|
minion | AIBaseClient* | The minion to check |
AIBaseClient* minion = /* Get a minion */;
if (HealthPrediction::HasTurretAggro(minion))
{
int aggroStartTick = HealthPrediction::TurretAggroStartTick(minion);
int currentTick = Game::GameTimeTickCount();
int ticksSinceAggro = currentTick - aggroStartTick;
Console::Add("Turret has been targeting minion for %d milliseconds", ticksSinceAggro);
}