# Spell
# 说明
Spell类用于管理和预测游戏内技能的释放,提供技能伤害计算、命中预测和技能释放功能。
# 如何使用
// 创建技能实例
Spell qSpell(eSpellSlot::Q, 900, eDamageType::Physical);
// 设置为技能射线
qSpell.SetSkillshot(0.25f, 60.f, 1600.f, true, eSkillshotType::Line);
// 检查技能是否可以释放
if (qSpell.IsReady())
{
// 获取目标
AIBaseClient* target = qSpell.GetTarget();
// 如果有目标且可以命中
if (target != nullptr && qSpell.CanCast(target))
{
// 释放技能
qSpell.Cast(target);
}
}
# CanCast
bool CanCast(AIBaseClient* unit) const
检查技能是否可以对指定单位释放。
参数名 | 参数类型 | 描述 |
---|---|---|
unit | AIBaseClient* | 目标单位 |
if (qSpell.CanCast(target))
{
// 可以对目标释放技能
}
# Cast
eCastStates Cast(AIBaseClient* unit, bool packetCast = false, bool aoe = false)
对指定单位释放技能。
参数名 | 参数类型 | 描述 |
---|---|---|
unit | AIBaseClient* | 目标单位 |
packetCast | bool | 是否使用封包释放(可选) |
aoe | bool | 是否为范围技能(可选) |
eCastStates result = qSpell.Cast(target);
# Cast
bool Cast(bool packetCast = false)
释放技能(自我目标)。
参数名 | 参数类型 | 描述 |
---|---|---|
packetCast | bool | 是否使用封包释放(可选) |
bool success = qSpell.Cast();
# Cast
bool Cast(Vector const& fromPosition, Vector const& toPosition)
从指定位置向指定位置释放技能。
参数名 | 参数类型 | 描述 |
---|---|---|
fromPosition | Vector const& | 起始位置 |
toPosition | Vector const& | 目标位置 |
bool success = qSpell.Cast(myHero->Position, targetPos);
# Cast
bool Cast(Vector const& position, bool packetCast = false)
向指定位置释放技能。
参数名 | 参数类型 | 描述 |
---|---|---|
position | Vector const& | 目标位置 |
packetCast | bool | 是否使用封包释放(可选) |
bool success = qSpell.Cast(targetPos);
# CastIfHitchanceEquals
bool CastIfHitchanceEquals(AIBaseClient* unit, eHitChance hitChance, bool packetCast = false)
当命中率等于指定值时释放技能。
参数名 | 参数类型 | 描述 |
---|---|---|
unit | AIBaseClient* | 目标单位 |
hitChance | eHitChance | 命中率要求 |
packetCast | bool | 是否使用封包释放(可选) |
bool success = qSpell.CastIfHitchanceEquals(target, eHitChance::VeryHigh);
# CastIfWillHit
bool CastIfWillHit(AIBaseClient* unit, int minTargets = 5, bool packetCast = false)
当能命中至少指定数量目标时释放技能。
参数名 | 参数类型 | 描述 |
---|---|---|
unit | AIBaseClient* | 主要目标单位 |
minTargets | int | 最少命中目标数量(可选) |
packetCast | bool | 是否使用封包释放(可选) |
bool success = qSpell.CastIfWillHit(target, 2);
# CastOnBestTarget
eCastStates CastOnBestTarget(float extraRange = 0, bool packetCast = false, bool aoe = false)
对最佳目标释放技能。
参数名 | 参数类型 | 描述 |
---|---|---|
extraRange | float | 额外范围(可选) |
packetCast | bool | 是否使用封包释放(可选) |
aoe | bool | 是否为范围技能(可选) |
eCastStates result = qSpell.CastOnBestTarget(50.f);
# CastOnUnit
bool CastOnUnit(AIBaseClient* unit, bool packetCast = false)
对指定单位释放技能(单位目标技能)。
参数名 | 参数类型 | 描述 |
---|---|---|
unit | AIBaseClient* | 目标单位 |
packetCast | bool | 是否使用封包释放(可选) |
bool success = qSpell.CastOnUnit(target);
# ChargingStartTime
float ChargingStartTime() const
获取蓄力技能开始蓄力的时间。
float chargeTime = qSpell.ChargingStartTime();
# Cooldown
float Cooldown() const
获取技能的当前冷却时间。
float cd = qSpell.Cooldown();
if (cd <= 0)
{
// 技能已冷却完毕
}
# CountHits
int CountHits(std::vector<AIBaseClient*>const& units, Vector const& castPosition) const
计算从指定位置释放技能可以命中的单位数量。
参数名 | 参数类型 | 描述 |
---|---|---|
units | std::vector<AIBaseClient*>const& | 潜在目标列表 |
castPosition | Vector const& | 释放位置 |
std::vector<AIBaseClient*> enemies = ObjectManager::GetEnemyHeroes();
int hitCount = qSpell.CountHits(enemies, castPos);
# CountHits
int CountHits(std::vector<Vector>const& points, Vector const& castPosition) const
计算从指定位置释放技能可以命中的点数量。
参数名 | 参数类型 | 描述 |
---|---|---|
points | std::vector<Vector>const& | 潜在命中点列表 |
castPosition | Vector const& | 释放位置 |
std::vector<Vector> positions;
// 填充positions
int hitCount = qSpell.CountHits(positions, castPos);
# From
Vector From() const
获取技能释放的起始位置。
Vector startPos = qSpell.From();
# From_Set
void From_Set(const Vector& value)
设置技能释放的起始位置。
参数名 | 参数类型 | 描述 |
---|---|---|
value | const Vector& | 起始位置坐标 |
qSpell.From_Set(myHero->Position);
# GetCircularFarmLocation
FarmLocation GetCircularFarmLocation(std::vector<AIBaseClient*>const& minions, float overrideWidth = -1) const
获取圆形技能的最佳清线位置。
参数名 | 参数类型 | 描述 |
---|---|---|
minions | std::vector<AIBaseClient*>const& | 小兵列表 |
overrideWidth | float | 覆盖技能宽度(可选) |
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
获取圆形技能的最佳清线位置(基于点列表)。
参数名 | 参数类型 | 描述 |
---|---|---|
minionPositions | std::vector<Vector>const& | 小兵位置列表 |
overrideWidth | float | 覆盖技能宽度(可选) |
std::vector<Vector> positions;
// 填充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
获取技能路径上的碰撞单位。
参数名 | 参数类型 | 描述 |
---|---|---|
Output | std::vector<AIBaseClient*>& | 输出碰撞单位 |
from | const Vector& | 起始位置 |
to | std::vector<Vector>const& | 目标位置列表 |
delayOverride | float | 覆盖延迟值(可选) |
std::vector<AIBaseClient*> collisionUnits;
std::vector<Vector> endPositions = { targetPos };
qSpell.GetCollision(collisionUnits, myHero->Position, endPositions);
# GetDamage
float GetDamage(AIBaseClient* target, int stage = 0) const
获取技能对目标的伤害值。
参数名 | 参数类型 | 描述 |
---|---|---|
target | AIBaseClient* | 目标单位 |
stage | int | 伤害阶段(可选) |
float damage = qSpell.GetDamage(target);
if (damage >= target->Health)
{
// 技能可击杀目标
}
# GetHealthPrediction
float GetHealthPrediction(AIBaseClient* unit) const
预测单位在技能到达时的生命值。
参数名 | 参数类型 | 描述 |
---|---|---|
unit | AIBaseClient* | 目标单位 |
float predictedHealth = qSpell.GetHealthPrediction(target);
# GetHitCount
int GetHitCount(eHitChance hitChance = eHitChance::High) const
获取满足指定命中率的目标数量。
参数名 | 参数类型 | 描述 |
---|---|---|
hitChance | eHitChance | 命中率要求(可选) |
int count = qSpell.GetHitCount();
# GetLineFarmLocation
FarmLocation GetLineFarmLocation(std::vector<AIBaseClient*>const& minions, float overrideWidth = -1) const
获取线性技能的最佳清线位置。
参数名 | 参数类型 | 描述 |
---|---|---|
minions | std::vector<AIBaseClient*>const& | 小兵列表 |
overrideWidth | float | 覆盖技能宽度(可选) |
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
获取线性技能的最佳清线位置(基于点列表)。
参数名 | 参数类型 | 描述 |
---|---|---|
minionPositions | std::vector<Vector>const& | 小兵位置列表 |
overrideWidth | float | 覆盖技能宽度(可选) |
std::vector<Vector> positions;
// 填充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
获取技能的预测结果。
参数名 | 参数类型 | 描述 |
---|---|---|
unit | AIBaseClient* | 目标单位 |
aoe | bool | 是否为范围技能(可选) |
overrideRange | float | 覆盖范围值(可选) |
collisionable | std::vector<eCollisionableObjects> const& | 可碰撞对象(可选) |
PredictionOutput pred = qSpell.GetPrediction(target);
if (pred.Hitchance >= eHitChance::High)
{
qSpell.Cast(pred.CastPosition);
}
# GetRange
float GetRange(AIBaseClient* target) const
获取对特定目标的技能范围。
参数名 | 参数类型 | 描述 |
---|---|---|
target | AIBaseClient* | 目标单位 |
float range = qSpell.GetRange(target);
# GetRangeSqr
float GetRangeSqr(AIBaseClient* target) const
获取对特定目标的技能范围平方值。
参数名 | 参数类型 | 描述 |
---|---|---|
target | AIBaseClient* | 目标单位 |
float rangeSqr = qSpell.GetRangeSqr(target);
# GetTarget
AIBaseClient* GetTarget(float extraRange = 0, const std::vector<AIBaseClient*>& champsToIgnore = {}) const
获取当前最佳的技能目标。
参数名 | 参数类型 | 描述 |
---|---|---|
extraRange | float | 额外范围(可选) |
champsToIgnore | const std::vector<AIBaseClient*>& | 忽略的目标列表(可选) |
AIBaseClient* target = qSpell.GetTarget(50.f);
if (target != nullptr)
{
qSpell.Cast(target);
}
# Instance
SpellDataInst* Instance() const
获取技能的实例数据。
SpellDataInst* spellData = qSpell.Instance();
# IsCharging
bool IsCharging() const
检查技能是否正在蓄力。
if (qSpell.IsCharging())
{
// 技能正在蓄力
}
# IsInRange
bool IsInRange(AIBaseClient* obj, float range = -1) const
检查目标是否在技能范围内。
参数名 | 参数类型 | 描述 |
---|---|---|
obj | AIBaseClient* | 目标单位 |
range | float | 覆盖范围值(可选) |
if (qSpell.IsInRange(target))
{
// 目标在技能范围内
}
# IsInRange
bool IsInRange(Vector const& point, float range = -1) const
检查位置是否在技能范围内。
参数名 | 参数类型 | 描述 |
---|---|---|
point | Vector const& | 目标位置 |
range | float | 覆盖范围值(可选) |
if (qSpell.IsInRange(targetPos))
{
// 位置在技能范围内
}
# IsKillable
bool IsKillable(AIBaseClient* target, int stage = 0) const
检查目标是否可被技能击杀。
参数名 | 参数类型 | 描述 |
---|---|---|
target | AIBaseClient* | 目标单位 |
stage | int | 伤害阶段(可选) |
if (qSpell.IsKillable(target))
{
// 目标可被技能击杀
qSpell.Cast(target);
}
# IsReady
bool IsReady(int t = 0) const
检查技能是否准备好释放。
参数名 | 参数类型 | 描述 |
---|---|---|
t | int | 额外时间(可选) |
if (qSpell.IsReady())
{
// 技能已准备好
}
# Level
int Level() const
获取技能的当前等级。
int level = qSpell.Level();
# ManaCost
float ManaCost() const
获取技能的法力消耗。
float mana = qSpell.ManaCost();
if (myHero->Mana >= mana)
{
// 法力值足够
}
# Range
float Range() const
获取技能的范围。
float range = qSpell.Range();
# Range_Set
void Range_Set(float value)
设置技能的范围。
参数名 | 参数类型 | 描述 |
---|---|---|
value | float | 技能范围 |
qSpell.Range_Set(1000.f);
# RangeCheckFrom
Vector RangeCheckFrom() const
获取技能范围检查的起始位置。
Vector checkPos = qSpell.RangeCheckFrom();
# RangeCheckFrom_Set
void RangeCheckFrom_Set(const Vector& value)
设置技能范围检查的起始位置。
参数名 | 参数类型 | 描述 |
---|---|---|
value | const Vector& | 范围检查起始位置 |
qSpell.RangeCheckFrom_Set(myHero->Position);
# RangeSqr
float RangeSqr() const
获取技能范围的平方值。
float rangeSqr = qSpell.RangeSqr();
# SetCharged
void SetCharged(float minRange, float maxRange, float deltaT)
设置为蓄力技能。
参数名 | 参数类型 | 描述 |
---|---|---|
minRange | float | 最小范围 |
maxRange | float | 最大范围 |
deltaT | float | 蓄力时间 |
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)
设置为技能射击。
参数名 | 参数类型 | 描述 |
---|---|---|
delay | float | 延迟时间 |
width | float | 宽度 |
speed | float | 速度 |
collision | bool | 是否检测碰撞 |
type | eSkillshotType | 技能射击类型 |
from | Vector const& | 起始位置(可选) |
rangeCheckFrom | Vector const& | 范围检查起始位置(可选) |
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)
设置为指向性技能。
参数名 | 参数类型 | 描述 |
---|---|---|
delay | float | 延迟时间 |
speed | float | 速度 |
from | Vector const& | 起始位置(可选) |
rangeCheckFrom | Vector const& | 范围检查起始位置(可选) |
qSpell.SetTargetted(0.25f, 2000.f);
# StartCharging
void StartCharging()
开始蓄力技能。
qSpell.StartCharging();
# Width
float Width() const
获取技能的宽度。
float width = qSpell.Width();
# Width_Set
void Width_Set(float value)
设置技能的宽度。
参数名 | 参数类型 | 描述 |
---|---|---|
value | float | 技能宽度 |
qSpell.Width_Set(80.f);
# WillHit
bool WillHit(AIBaseClient* unit, Vector const& castPosition, int extraWidth = 0, eHitChance minHitChance = eHitChance::High) const
检查技能是否会命中目标。
参数名 | 参数类型 | 描述 |
---|---|---|
unit | AIBaseClient* | 目标单位 |
castPosition | Vector const& | 释放位置 |
extraWidth | int | 额外宽度(可选) |
minHitChance | eHitChance | 最小命中率(可选) |
if (qSpell.WillHit(target, castPos))
{
// 技能将会命中目标
}
# WillHit
bool WillHit(Vector const& point, Vector const& castPosition, int extraWidth = 0) const
检查技能是否会命中指定位置。
参数名 | 参数类型 | 描述 |
---|---|---|
point | Vector const& | 目标位置 |
castPosition | Vector const& | 释放位置 |
extraWidth | int | 额外宽度(可选) |
if (qSpell.WillHit(targetPos, castPos))
{
// 技能将会命中目标位置
}