This commit is contained in:
aozhiwei 2023-03-15 15:30:45 +08:00
parent 959471461c
commit 659a301965
2 changed files with 37 additions and 5 deletions

View File

@ -14,20 +14,20 @@
void HideBuff::Activate()
{
float alert_range = meta->GetBuffParam2(this);
float alert_time = meta->GetBuffParam3(this);
alert_range = meta->GetBuffParam2(this);
alert_time = meta->GetBuffParam3(this);
if (alert_range > 1.0f) {
owner->room->xtimer.SetIntervalWpEx
(
SERVER_FRAME_RATE,
[this, alert_range, alert_time]
[this]
(int event, const a8::Args* args) mutable
{
if (a8::TIMER_EXEC_EVENT == event) {
++step_;
owner->TraverseCreatures
(
[this, alert_range] (Creature* target, bool& stop)
[this] (Creature* target, bool& stop)
{
if (!target->dead && target->team_id != owner->team_id &&
Collision::CheckCC(owner, owner->GetRadius(),
@ -50,10 +50,39 @@ void HideBuff::Deactivate()
void HideBuff::AddInRangeObject(Creature* target)
{
auto itr = alert_buff_hash_.find(target->GetUniId());
if (itr != alert_buff_hash_.end()) {
std::get<2>(itr->second) = step_;
} else {
int buff_uniid = target->TryAddBuff(GetCaster().Get(), meta->_int_buff_param4, skill_meta);
alert_buff_hash_[target->GetUniId()] = std::make_tuple(target->GetWeakPtrRef(),
owner->room->GetFrameNo(),
step_,
buff_uniid);
}
}
void HideBuff::Check()
{
bool timeout = false;
std::vector<int> leave_targets;
for (auto& pair : alert_buff_hash_) {
auto& tuple = pair.second;
if (std::get<2>(tuple) < step_) {
if (Collision::CheckCC(owner,
owner->GetRadius(),
std::get<0>(tuple).Get(),
alert_range)) {
} else {
leave_targets.push_back(pair.first);
}
if (std::get<0>(tuple).Get()) {
} else {
}
}
}
}

View File

@ -17,4 +17,7 @@ class HideBuff : public Buff
int step_ = 1;
std::map<int, std::tuple<CreatureWeakPtr, long long, int, int>> alert_buff_hash_;
float alert_range = 0.0f;
float alert_time = 0.0f;
};