This commit is contained in:
aozhiwei 2023-08-17 14:03:57 +08:00
parent 35d3ae5343
commit a4f826ec22
2 changed files with 48 additions and 5 deletions

View File

@ -206,6 +206,7 @@ void Incubator::RecycleAndroid(Human* hum)
hum->RemoveBuffByEffectId(kBET_BeRecycle); hum->RemoveBuffByEffectId(kBET_BeRecycle);
hold_humans_.push_back(hum); hold_humans_.push_back(hum);
room->DisableHuman(hum); room->DisableHuman(hum);
Rearrangement();
#ifdef DEBUG #ifdef DEBUG
room->BroadcastDebugMsg(a8::Format("回收机器人 %d:%s:%d 添加到回收列表", room->BroadcastDebugMsg(a8::Format("回收机器人 %d:%s:%d 添加到回收列表",
{hum->GetUniId(), {hum->GetUniId(),
@ -516,14 +517,11 @@ void Incubator::ShowHand()
room->EnableHuman(hum); room->EnableHuman(hum);
hum->MustBeAddBuff(hum, kTraceBuffId); hum->MustBeAddBuff(hum, kTraceBuffId);
a8::SetBitFlag(hum->status, CS_CrazeMode); a8::SetBitFlag(hum->status, CS_CrazeMode);
#if 0
a8::SetBitFlag(hum->status, CS_DisableAttackAndroid); a8::SetBitFlag(hum->status, CS_DisableAttackAndroid);
#endif
} }
#if 0
room->xtimer.SetIntervalEx room->xtimer.SetIntervalEx
( (
SERVER_FRAME_RATE, SERVER_FRAME_RATE * 40,
[room = room] (int event, const a8::Args* args) mutable [room = room] (int event, const a8::Args* args) mutable
{ {
if (a8::TIMER_EXEC_EVENT == event) { if (a8::TIMER_EXEC_EVENT == event) {
@ -540,7 +538,6 @@ void Incubator::ShowHand()
} }
}, },
&room->xtimer_attacher_); &room->xtimer_attacher_);
#endif
hold_humans_.clear(); hold_humans_.clear();
} }
@ -556,3 +553,48 @@ void Incubator::Clear(int save_num)
hold_humans_.erase(hold_humans_.begin()); hold_humans_.erase(hold_humans_.begin());
} }
} }
void Incubator::Rearrangement()
{
if (hold_humans_.size() < 6) {
return;
}
std::vector<int> teams2;
std::vector<int> teams3;
std::vector<int> teams4;
{
std::map<int, int> team_num_hash;
for (auto hum : hold_humans_) {
if (team_num_hash.find(hum->team_id) != team_num_hash.end()) {
++team_num_hash[hum->team_id];
} else {
team_num_hash[hum->team_id];
}
}
for (auto& pair : team_num_hash) {
if (pair.second > 1) {
teams2.push_back(pair.first);
}
if (pair.second > 2) {
teams3.push_back(pair.first);
}
if (pair.second > 3) {
teams4.push_back(pair.first);
}
}
}
int team_id = 0;
if (!teams3.empty() || !teams4.empty()) {
if (a8::RandEx(1, 99) < 10 && !teams4.empty()) {
team_id = teams4.at(rand() % teams4.size());
} else {
if (!teams3.empty()) {
team_id = teams3.at(rand() % teams3.size());
} else if (!teams4.empty()) {
team_id = teams4.at(rand() % teams4.size());
}
}
} else if (!teams2.empty()) {
team_id = teams2.at(rand() % teams2.size());
}
}

View File

@ -26,6 +26,7 @@ private:
void AutoAllocAndroid(); void AutoAllocAndroid();
void OnEnterNewWave(int wave); void OnEnterNewWave(int wave);
void SpawnWaveMon(int wave); void SpawnWaveMon(int wave);
void Rearrangement();
private: private:
int wait_alloc_time_ = 0; int wait_alloc_time_ = 0;