# Spell
# Description
The Spell class is used to manage and predict skill casting in the game, providing functionality for skill damage calculation, hit prediction, and skill casting.
# How to Use
// Create a skill instance
Spell qSpell(eSpellSlot::Q, 900, eDamageType::Physical);
// Set as a skillshot
qSpell.SetSkillshot(0.25f, 60.f, 1600.f, true, eSkillshotType::Line);
// Check if the skill is ready to cast
if (qSpell.IsReady())
{
// Get the target
AIBaseClient* target = qSpell.GetTarget();
// If there is a target and it can be hit
if (target != nullptr && qSpell.CanCast(target))
{
// Cast the skill
qSpell.Cast(target);
}
}
# CanCast
bool CanCast(AIBaseClient* unit) const
Checks if the skill can be cast on the specified unit.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
if (qSpell.CanCast(target))
{
// Can cast the skill on the target
}
# Cast
eCastStates Cast(AIBaseClient* unit, bool packetCast = false, bool aoe = false)
Casts the skill on the specified unit.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
packetCast | bool | Whether to use packet casting (optional) |
aoe | bool | Whether it's an area skill (optional) |
eCastStates result = qSpell.Cast(target);
# Cast
bool Cast(bool packetCast = false)
Casts the skill (self-targeted).
Parameter Name | Parameter Type | Description |
---|---|---|
packetCast | bool | Whether to use packet casting (optional) |
bool success = qSpell.Cast();
# Cast
bool Cast(Vector const& fromPosition, Vector const& toPosition)
Casts the skill from a specified position to a specified position.
Parameter Name | Parameter Type | Description |
---|---|---|
fromPosition | Vector const& | Start position |
toPosition | Vector const& | Target position |
bool success = qSpell.Cast(myHero->Position, targetPos);
# Cast
bool Cast(Vector const& position, bool packetCast = false)
Casts the skill to a specified position.
Parameter Name | Parameter Type | Description |
---|---|---|
position | Vector const& | Target position |
packetCast | bool | Whether to use packet casting (optional) |
bool success = qSpell.Cast(targetPos);
# CastIfHitchanceEquals
bool CastIfHitchanceEquals(AIBaseClient* unit, eHitChance hitChance, bool packetCast = false)
Casts the skill when the hit chance equals the specified value.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
hitChance | eHitChance | Hit chance requirement |
packetCast | bool | Whether to use packet casting (optional) |
bool success = qSpell.CastIfHitchanceEquals(target, eHitChance::VeryHigh);
# CastIfWillHit
bool CastIfWillHit(AIBaseClient* unit, int minTargets = 5, bool packetCast = false)
Casts the skill when it can hit at least the specified number of targets.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Primary target unit |
minTargets | int | Minimum number of targets to hit (optional) |
packetCast | bool | Whether to use packet casting (optional) |
bool success = qSpell.CastIfWillHit(target, 2);
# CastOnBestTarget
eCastStates CastOnBestTarget(float extraRange = 0, bool packetCast = false, bool aoe = false)
Casts the skill on the best target.
Parameter Name | Parameter Type | Description |
---|---|---|
extraRange | float | Extra range (optional) |
packetCast | bool | Whether to use packet casting (optional) |
aoe | bool | Whether it's an area skill (optional) |
eCastStates result = qSpell.CastOnBestTarget(50.f);
# CastOnUnit
bool CastOnUnit(AIBaseClient* unit, bool packetCast = false)
Casts the skill on the specified unit (unit-targeted skill).
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
packetCast | bool | Whether to use packet casting (optional) |
bool success = qSpell.CastOnUnit(target);
# ChargingStartTime
float ChargingStartTime() const
Gets the time when a charging skill started charging.
float chargeTime = qSpell.ChargingStartTime();
# Cooldown
float Cooldown() const
Gets the current cooldown time of the skill.
float cd = qSpell.Cooldown();
if (cd <= 0)
{
// Skill has finished cooling down
}
# CountHits
int CountHits(std::vector<AIBaseClient*>const& units, Vector const& castPosition) const
Counts the number of units that can be hit by casting the skill from the specified position.
Parameter Name | Parameter Type | Description |
---|---|---|
units | std::vector<AIBaseClient*>const& | List of potential targets |
castPosition | Vector const& | Cast position |
std::vector<AIBaseClient*> enemies = ObjectManager::GetEnemyHeroes();
int hitCount = qSpell.CountHits(enemies, castPos);
# CountHits
int CountHits(std::vector<Vector>const& points, Vector const& castPosition) const
Counts the number of points that can be hit by casting the skill from the specified position.
Parameter Name | Parameter Type | Description |
---|---|---|
points | std::vector<Vector>const& | List of potential hit points |
castPosition | Vector const& | Cast position |
std::vector<Vector> positions;
// Fill positions
int hitCount = qSpell.CountHits(positions, castPos);
# From
Vector From() const
Gets the starting position for the skill cast.
Vector startPos = qSpell.From();
# From_Set
void From_Set(const Vector& value)
Sets the starting position for the skill cast.
Parameter Name | Parameter Type | Description |
---|---|---|
value | const Vector& | Start position coordinates |
qSpell.From_Set(myHero->Position);
# GetCircularFarmLocation
FarmLocation GetCircularFarmLocation(std::vector<AIBaseClient*>const& minions, float overrideWidth = -1) const
Gets the best location for a circular skill to farm minions.
Parameter Name | Parameter Type | Description |
---|---|---|
minions | std::vector<AIBaseClient*>const& | List of minions |
overrideWidth | float | Override skill width (optional) |
std::vector<AIBaseClient*> minions = ObjectManager::GetEnemyMinions();
FarmLocation farmLoc = qSpell.GetCircularFarmLocation(minions);
if (farmLoc.Position.IsValid() && farmLoc.MinionsHit > 2)
{
qSpell.Cast(farmLoc.Position);
}
# GetCircularFarmLocation
FarmLocation GetCircularFarmLocation(std::vector<Vector>const& minionPositions, float overrideWidth = -1) const
Gets the best location for a circular skill to farm minions (based on a list of points).
Parameter Name | Parameter Type | Description |
---|---|---|
minionPositions | std::vector<Vector>const& | List of minion positions |
overrideWidth | float | Override skill width (optional) |
std::vector<Vector> positions;
// Fill positions
FarmLocation farmLoc = qSpell.GetCircularFarmLocation(positions);
# GetCollision
void GetCollision(std::vector<AIBaseClient*>& Output, const Vector& from, std::vector<Vector>const& to, float delayOverride = -1) const
Gets collision units along the skill path.
Parameter Name | Parameter Type | Description |
---|---|---|
Output | std::vector<AIBaseClient*>& | Output collision units |
from | const Vector& | Start position |
to | std::vector<Vector>const& | List of target positions |
delayOverride | float | Override delay value (optional) |
std::vector<AIBaseClient*> collisionUnits;
std::vector<Vector> endPositions = { targetPos };
qSpell.GetCollision(collisionUnits, myHero->Position, endPositions);
# GetDamage
float GetDamage(AIBaseClient* target, int stage = 0) const
Gets the damage value of the skill against the target.
Parameter Name | Parameter Type | Description |
---|---|---|
target | AIBaseClient* | Target unit |
stage | int | Damage stage (optional) |
float damage = qSpell.GetDamage(target);
if (damage >= target->Health)
{
// Skill can kill the target
}
# GetHealthPrediction
float GetHealthPrediction(AIBaseClient* unit) const
Predicts the unit's health when the skill reaches it.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
float predictedHealth = qSpell.GetHealthPrediction(target);
# GetHitCount
int GetHitCount(eHitChance hitChance = eHitChance::High) const
Gets the number of targets that meet the specified hit chance.
Parameter Name | Parameter Type | Description |
---|---|---|
hitChance | eHitChance | Hit chance requirement (optional) |
int count = qSpell.GetHitCount();
# GetLineFarmLocation
FarmLocation GetLineFarmLocation(std::vector<AIBaseClient*>const& minions, float overrideWidth = -1) const
Gets the best location for a linear skill to farm minions.
Parameter Name | Parameter Type | Description |
---|---|---|
minions | std::vector<AIBaseClient*>const& | List of minions |
overrideWidth | float | Override skill width (optional) |
std::vector<AIBaseClient*> minions = ObjectManager::GetEnemyMinions();
FarmLocation farmLoc = qSpell.GetLineFarmLocation(minions);
if (farmLoc.Position.IsValid() && farmLoc.MinionsHit > 2)
{
qSpell.Cast(farmLoc.Position);
}
# GetLineFarmLocation
FarmLocation GetLineFarmLocation(std::vector<Vector>const& minionPositions, float overrideWidth = -1) const
Gets the best location for a linear skill to farm minions (based on a list of points).
Parameter Name | Parameter Type | Description |
---|---|---|
minionPositions | std::vector<Vector>const& | List of minion positions |
overrideWidth | float | Override skill width (optional) |
std::vector<Vector> positions;
// Fill positions
FarmLocation farmLoc = qSpell.GetLineFarmLocation(positions);
# GetPrediction
PredictionOutput GetPrediction(AIBaseClient* unit, bool aoe = false, float overrideRange = -1, std::vector<eCollisionableObjects> const& collisionable = { eCollisionableObjects::Heroes ,eCollisionableObjects::Minions }) const
Gets the prediction result for the skill.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
aoe | bool | Whether it's an area skill (optional) |
overrideRange | float | Override range value (optional) |
collisionable | std::vector<eCollisionableObjects> const& | Collisionable objects (optional) |
PredictionOutput pred = qSpell.GetPrediction(target);
if (pred.Hitchance >= eHitChance::High)
{
qSpell.Cast(pred.CastPosition);
}
# GetRange
float GetRange(AIBaseClient* target) const
Gets the skill range for a specific target.
Parameter Name | Parameter Type | Description |
---|---|---|
target | AIBaseClient* | Target unit |
float range = qSpell.GetRange(target);
# GetRangeSqr
float GetRangeSqr(AIBaseClient* target) const
Gets the squared value of the skill range for a specific target.
Parameter Name | Parameter Type | Description |
---|---|---|
target | AIBaseClient* | Target unit |
float rangeSqr = qSpell.GetRangeSqr(target);
# GetTarget
AIBaseClient* GetTarget(float extraRange = 0, const std::vector<AIBaseClient*>& champsToIgnore = {}) const
Gets the current best target for the skill.
Parameter Name | Parameter Type | Description |
---|---|---|
extraRange | float | Extra range (optional) |
champsToIgnore | const std::vector<AIBaseClient*>& | List of targets to ignore (optional) |
AIBaseClient* target = qSpell.GetTarget(50.f);
if (target != nullptr)
{
qSpell.Cast(target);
}
# Instance
SpellDataInst* Instance() const
Gets the instance data of the skill.
SpellDataInst* spellData = qSpell.Instance();
# IsCharging
bool IsCharging() const
Checks if the skill is currently charging.
if (qSpell.IsCharging())
{
// Skill is charging
}
# IsInRange
bool IsInRange(AIBaseClient* obj, float range = -1) const
Checks if the target is within the skill range.
Parameter Name | Parameter Type | Description |
---|---|---|
obj | AIBaseClient* | Target unit |
range | float | Override range value (optional) |
if (qSpell.IsInRange(target))
{
// Target is within skill range
}
# IsInRange
bool IsInRange(Vector const& point, float range = -1) const
Checks if the position is within the skill range.
Parameter Name | Parameter Type | Description |
---|---|---|
point | Vector const& | Target position |
range | float | Override range value (optional) |
if (qSpell.IsInRange(targetPos))
{
// Position is within skill range
}
# IsKillable
bool IsKillable(AIBaseClient* target, int stage = 0) const
Checks if the target can be killed by the skill.
Parameter Name | Parameter Type | Description |
---|---|---|
target | AIBaseClient* | Target unit |
stage | int | Damage stage (optional) |
if (qSpell.IsKillable(target))
{
// Target can be killed by the skill
qSpell.Cast(target);
}
# IsReady
bool IsReady(int t = 0) const
Checks if the skill is ready to cast.
Parameter Name | Parameter Type | Description |
---|---|---|
t | int | Extra time (optional) |
if (qSpell.IsReady())
{
// Skill is ready
}
# Level
int Level() const
Gets the current level of the skill.
int level = qSpell.Level();
# ManaCost
float ManaCost() const
Gets the mana cost of the skill.
float mana = qSpell.ManaCost();
if (myHero->Mana >= mana)
{
// Mana is sufficient
}
# Range
float Range() const
Gets the range of the skill.
float range = qSpell.Range();
# Range_Set
void Range_Set(float value)
Sets the range of the skill.
Parameter Name | Parameter Type | Description |
---|---|---|
value | float | Skill range |
qSpell.Range_Set(1000.f);
# RangeCheckFrom
Vector RangeCheckFrom() const
Gets the starting position for range checking of the skill.
Vector checkPos = qSpell.RangeCheckFrom();
# RangeCheckFrom_Set
void RangeCheckFrom_Set(const Vector& value)
Sets the starting position for range checking of the skill.
Parameter Name | Parameter Type | Description |
---|---|---|
value | const Vector& | Range check start position |
qSpell.RangeCheckFrom_Set(myHero->Position);
# RangeSqr
float RangeSqr() const
Gets the squared value of the skill range.
float rangeSqr = qSpell.RangeSqr();
# SetCharged
void SetCharged(float minRange, float maxRange, float deltaT)
Sets as a charging skill.
Parameter Name | Parameter Type | Description |
---|---|---|
minRange | float | Minimum range |
maxRange | float | Maximum range |
deltaT | float | Charging time |
qSpell.SetCharged(400.f, 1200.f, 1.5f);
# SetSkillshot
void SetSkillshot(float delay, float width, float speed, bool collision, eSkillshotType type, Vector const& from = Vector::Zero, Vector const& rangeCheckFrom = Vector::Zero)
Sets as a skillshot.
Parameter Name | Parameter Type | Description |
---|---|---|
delay | float | Delay time |
width | float | Width |
speed | float | Speed |
collision | bool | Whether to check collision |
type | eSkillshotType | Skillshot type |
from | Vector const& | Start position (optional) |
rangeCheckFrom | Vector const& | Range check start position (optional) |
qSpell.SetSkillshot(0.25f, 60.f, 1600.f, true, eSkillshotType::Line);
# SetTargetted
void SetTargetted(float delay, float speed, Vector const& from = Vector::Zero, Vector const& rangeCheckFrom = Vector::Zero)
Sets as a targeted skill.
Parameter Name | Parameter Type | Description |
---|---|---|
delay | float | Delay time |
speed | float | Speed |
from | Vector const& | Start position (optional) |
rangeCheckFrom | Vector const& | Range check start position (optional) |
qSpell.SetTargetted(0.25f, 2000.f);
# StartCharging
void StartCharging()
Starts charging the skill.
qSpell.StartCharging();
# Width
float Width() const
Gets the width of the skill.
float width = qSpell.Width();
# Width_Set
void Width_Set(float value)
Sets the width of the skill.
Parameter Name | Parameter Type | Description |
---|---|---|
value | float | Skill width |
qSpell.Width_Set(80.f);
# WillHit
bool WillHit(AIBaseClient* unit, Vector const& castPosition, int extraWidth = 0, eHitChance minHitChance = eHitChance::High) const
Checks if the skill will hit the target.
Parameter Name | Parameter Type | Description |
---|---|---|
unit | AIBaseClient* | Target unit |
castPosition | Vector const& | Cast position |
extraWidth | int | Extra width (optional) |
minHitChance | eHitChance | Minimum hit chance (optional) |
if (qSpell.WillHit(target, castPos))
{
// Skill will hit the target
}
# WillHit
bool WillHit(Vector const& point, Vector const& castPosition, int extraWidth = 0) const
Checks if the skill will hit the specified position.
Parameter Name | Parameter Type | Description |
---|---|---|
point | Vector const& | Target position |
castPosition | Vector const& | Cast position |
extraWidth | int | Extra width (optional) |
if (qSpell.WillHit(targetPos, castPos))
{
// Skill will hit the target position
}