# Prediction
# Description
The Prediction namespace provides skill prediction functionality, allowing you to predict the positions of enemy heroes for precise skill targeting.
# How to Use
// Basic prediction usage
auto target = TargetSelector::GetTarget(1000.0f, eDamageType::Magical);
if (target) {
PredictionOutput pred = Prediction::GetPrediction(target, 0.25f, 80.0f, 1600.0f);
if (pred.Hitchance >= eHitChance::High) {
// Use the predicted position to cast the skill
Vector castPos = pred.CastPosition();
// Cast the skill...
}
}
// Using custom prediction input
PredictionInput input;
input.Unit = target;
input.Delay = 0.25f;
input.Radius = 80.0f;
input.Speed = 1600.0f;
input.Type = eSkillshotType::SkillshotLine;
input.Collision = true;
input.CollisionObjects = { eCollisionableObjects::Minions, eCollisionableObjects::YasuoWall };
PredictionOutput pred = Prediction::GetPrediction(input);
# GetPrediction
PredictionOutput GetPrediction(AIBaseClient* unit, float delay)
Gets position prediction for the target, considering only delay.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
delay | float | Skill cast delay (seconds) |
auto target = TargetSelector::GetTarget(1000.0f, eDamageType::Magical);
if (target) {
PredictionOutput pred = Prediction::GetPrediction(target, 0.25f);
if (pred.Hitchance >= eHitChance::High) {
// Use the predicted position to cast the skill
}
}
# GetPrediction
PredictionOutput GetPrediction(AIBaseClient* unit, float delay, float radius)
Gets position prediction for the target, considering delay and skill radius.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
delay | float | Skill cast delay (seconds) |
radius | float | Skill radius |
auto target = TargetSelector::GetTarget(1000.0f, eDamageType::Magical);
if (target) {
PredictionOutput pred = Prediction::GetPrediction(target, 0.25f, 80.0f);
if (pred.Hitchance >= eHitChance::High) {
// Use the predicted position to cast the skill
}
}
# GetPrediction
PredictionOutput GetPrediction(AIBaseClient* unit, float delay, float radius, float speed)
Gets position prediction for the target, considering delay, skill radius, and speed.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
delay | float | Skill cast delay (seconds) |
radius | float | Skill radius |
speed | float | Skill travel speed |
auto target = TargetSelector::GetTarget(1000.0f, eDamageType::Magical);
if (target) {
PredictionOutput pred = Prediction::GetPrediction(target, 0.25f, 80.0f, 1600.0f);
if (pred.Hitchance >= eHitChance::High) {
// Use the predicted position to cast the skill
}
}
# GetPrediction
PredictionOutput GetPrediction(AIBaseClient* unit, float delay, float radius, float speed, std::vector<eCollisionableObjects> const& collisionable)
Gets position prediction for the target, considering delay, skill radius, speed, and collision detection.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
delay | float | Skill cast delay (seconds) |
radius | float | Skill radius |
speed | float | Skill travel speed |
collisionable | std::vector<eCollisionableObjects> const& | Collision objects to check |
auto target = TargetSelector::GetTarget(1000.0f, eDamageType::Magical);
if (target) {
std::vector<eCollisionableObjects> collisionObjects = { eCollisionableObjects::Minions, eCollisionableObjects::YasuoWall };
PredictionOutput pred = Prediction::GetPrediction(target, 0.25f, 80.0f, 1600.0f, collisionObjects);
if (pred.Hitchance >= eHitChance::High && pred.CollisionObjects.empty()) {
// Use the predicted position to cast the skill, and there's no collision
}
}
# GetPrediction
PredictionOutput GetPrediction(PredictionInput const& input)
Gets position prediction for the target using custom PredictionInput.
Parameter Name | Parameter Type | Description |
---|---|---|
input | PredictionInput const& | Prediction input parameters |
auto target = TargetSelector::GetTarget(1000.0f, eDamageType::Magical);
if (target) {
PredictionInput input;
input.Unit = target;
input.Delay = 0.25f;
input.Radius = 80.0f;
input.Speed = 1600.0f;
input.Type = eSkillshotType::SkillshotLine;
input.Collision = true;
input.CollisionObjects = { eCollisionableObjects::Minions, eCollisionableObjects::YasuoWall };
PredictionOutput pred = Prediction::GetPrediction(input);
if (pred.Hitchance >= eHitChance::High && pred.CollisionObjects.empty()) {
// Use the predicted position to cast the skill, and there's no collision
}
}
# Class:PredictionInput
Input parameter class for prediction functionality.
// Create prediction input object
PredictionInput input;
input.Unit = target;
input.Delay = 0.25f;
input.Radius = 80.0f;
input.Speed = 1600.0f;
input.Type = eSkillshotType::SkillshotLine;
# PredictionInput.AddHitBox
Whether to consider the target's collision volume.
input.AddHitBox = true; // Consider the target's collision volume
# PredictionInput.Aoe
Whether the prediction is for an area-of-effect skill.
input.Aoe = true; // Set as an area-of-effect skill
# PredictionInput.Collision
Whether prediction needs to perform collision detection.
input.Collision = true; // Enable collision detection
# PredictionInput.CollisionObjects
List of collision objects to check during prediction.
input.CollisionObjects = { eCollisionableObjects::Minions, eCollisionableObjects::YasuoWall };
# PredictionInput.Delay
Skill cast delay (seconds).
input.Delay = 0.25f; // Set skill delay to 0.25 seconds
# PredictionInput.From
Vector From() const
Gets the skill cast position.
Vector castPosition = input.From();
# PredictionInput.From_Set
void From_Set(Vector const& value)
Sets the skill cast position.
Parameter Name | Parameter Type | Description |
---|---|---|
value | Vector const& | Cast position |
Vector myPosition = ObjectManager::Player()->ServerPosition();
input.From_Set(myPosition);
# PredictionInput.Radius
Skill radius.
input.Radius = 80.0f; // Set skill radius to 80 units
# PredictionInput.Range
Maximum skill range.
input.Range = 900.0f; // Set skill range to 900 units
# PredictionInput.RangeCheckFrom
Vector RangeCheckFrom() const
Gets the starting point for skill range checking.
Vector rangeCheckPos = input.RangeCheckFrom();
# PredictionInput.RangeCheckFrom_Set
void RangeCheckFrom_Set(Vector const& value)
Sets the starting point for skill range checking.
Parameter Name | Parameter Type | Description |
---|---|---|
value | Vector const& | Check starting point |
Vector myPosition = ObjectManager::Player()->ServerPosition();
input.RangeCheckFrom_Set(myPosition);
# PredictionInput.RealRadius
float RealRadius() const
Gets the actual skill radius considering the target's collision volume.
float actualRadius = input.RealRadius();
# PredictionInput.Speed
Skill travel speed.
input.Speed = 1600.0f; // Set skill speed to 1600 units/second
# PredictionInput.Type
Skill type.
input.Type = eSkillshotType::SkillshotLine; // Set as a line skillshot
# PredictionInput.Unit
Target unit for prediction.
input.Unit = target; // Set prediction target
# Class:PredictionOutput
Output result class for prediction functionality.
// Get prediction result
PredictionOutput output = Prediction::GetPrediction(input);
// Use prediction result
if (output.Hitchance >= eHitChance::High) {
// Use predicted position
}
# PredictionOutput.AoeTargetsHit
List of targets that may be hit by an area-of-effect skill.
std::vector<AIBaseClient*> hitTargets = output.AoeTargetsHit;
# PredictionOutput.AoeTargetsHitCount
int AoeTargetsHitCount() const
Gets the number of targets that may be hit by an area-of-effect skill.
int hitCount = output.AoeTargetsHitCount();
if (hitCount >= 3) {
// May hit 3 or more targets, worth casting the skill
}
# PredictionOutput.CastPosition
Vector CastPosition() const
Gets the recommended skill cast position.
Vector castPos = output.CastPosition();
# PredictionOutput.CastPosition_Set
void CastPosition_Set(Vector const& value)
Sets the recommended skill cast position.
Parameter Name | Parameter Type | Description |
---|---|---|
value | Vector const& | Cast position |
Vector bestPosition = Vector(1000.0f, 500.0f, 0.0f);
output.CastPosition_Set(bestPosition);
# PredictionOutput.CollisionObjects
List of collision objects along the predicted skill path.
if (output.CollisionObjects.empty()) {
// No collision, can cast the skill
}
# PredictionOutput.Hitchance
Predicted hit chance.
if (output.Hitchance >= eHitChance::High) {
// High hit chance, can cast the skill
}
# PredictionOutput.Input
Input parameters used to generate this prediction result.
PredictionInput originalInput = output.Input;
# PredictionOutput.UnitPosition
Vector UnitPosition() const
Gets the predicted position of the target unit.
Vector predictedPos = output.UnitPosition();
# PredictionOutput.UnitPosition_Set
void UnitPosition_Set(Vector const& value)
Sets the predicted position of the target unit.
Parameter Name | Parameter Type | Description |
---|---|---|
value | Vector const& | Unit position |
Vector predictedPosition = Vector(1000.0f, 500.0f, 0.0f);
output.UnitPosition_Set(predictedPosition);