# BuffInstance
# 说明
BuffInstance 类用于表示和操作游戏中的 buff 实例,包括获取 buff 的各种属性如名称、施法者、类型等,以及检查 buff 的状态。
# 如何使用
auto hero = ObjectManager::GetLocalPlayer();
for (auto buff : hero->GetBuffs()) {
if (buff && buff->IsActive() && buff->Type() == eBuffType::Stun) {
Console::Add("玩家被眩晕,持续时间: %.1f秒", buff->EndTime() - buff->StartTime());
}
}
# Hash
std::uint32_t Hash()
获取 buff 的哈希值。
std::uint32_t hash = buff->Hash();
# Name
const char* Name()
获取 buff 的名称。
const char* buffName = buff->Name();
Console::Add("Buff名称: %s", buffName);
# Caster
AIBaseClient* Caster()
获取施放 buff 的单位。
auto caster = buff->Caster();
if (caster && caster->IsValid()) {
Console::Add("Buff施放者: %s", caster->Name());
}
# Type
eBuffType Type()
获取 buff 的类型。
if (buff->Type() == eBuffType::Slow) {
Console::Add("这是一个减速效果");
}
# IsActive
bool IsActive()
检查 buff 是否处于活动状态。
if (buff->IsActive()) {
// Buff 处于活动状态
}
# Count
int Count()
获取 buff 的层数。
int stacks = buff->Count();
Console::Add("Buff层数: %d", stacks);
# CountAlt
int CountAlt()
获取 buff 的替代层数计数。
int altStacks = buff->CountAlt();
# StartTime
float StartTime()
获取 buff 的开始时间。
float startTime = buff->StartTime();
# EndTime
float EndTime()
获取 buff 的结束时间。
float endTime = buff->EndTime();
float remainingTime = endTime - Game::Time();
Console::Add("Buff剩余时间: %.1f秒", remainingTime);