1
This commit is contained in:
parent
aa4ff18785
commit
782022e6d6
@ -671,52 +671,52 @@ void Incubator::StartNewBattleMode()
|
|||||||
if (!selected_player) {
|
if (!selected_player) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::vector<Human*> invisable_humans;
|
auto invisable_humans = std::make_shared<std::vector<Human*>>();
|
||||||
std::vector<Human*> invisable_teammates;
|
auto invisable_teammates = std::make_shared<std::vector<Human*>>();
|
||||||
room->xtimer.SetIntervalWpEx
|
room->xtimer.SetIntervalWpEx
|
||||||
(
|
(
|
||||||
SERVER_FRAME_RATE * (3 + rand() % 2),
|
SERVER_FRAME_RATE * (3 + rand() % 2),
|
||||||
[this, selected_player, &invisable_humans, &invisable_teammates] (int event, const a8::Args* args)
|
[this, selected_player, invisable_humans, invisable_teammates] (int event, const a8::Args* args)
|
||||||
{
|
{
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
if (room->IsGameOver()) {
|
if (room->IsGameOver()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
invisable_humans.clear();
|
invisable_humans->clear();
|
||||||
invisable_teammates.clear();
|
invisable_teammates->clear();
|
||||||
room->TraverseAliveHumanList
|
room->TraverseAliveHumanList
|
||||||
(
|
(
|
||||||
[this, selected_player, &invisable_humans, &invisable_teammates] (Human* hum) -> bool
|
[this, selected_player, invisable_humans, invisable_teammates] (Human* hum) -> bool
|
||||||
{
|
{
|
||||||
if (hum == selected_player) {
|
if (hum == selected_player) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (!CanSee(hum, selected_player)) {
|
if (!CanSee(hum, selected_player)) {
|
||||||
if (hum->GetTeam() == selected_player->GetTeam()) {
|
if (hum->GetTeam() == selected_player->GetTeam()) {
|
||||||
invisable_teammates.push_back(hum);
|
invisable_teammates->push_back(hum);
|
||||||
} else {
|
} else {
|
||||||
invisable_humans.push_back(hum);
|
invisable_humans->push_back(hum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
if (invisable_humans.size() > 0) {
|
if (invisable_humans->size() > 0) {
|
||||||
std::shuffle(invisable_humans.begin(),
|
std::shuffle(invisable_humans->begin(),
|
||||||
invisable_humans.end(),
|
invisable_humans->end(),
|
||||||
std::default_random_engine(a8::XGetTickCount()));
|
std::default_random_engine(a8::XGetTickCount()));
|
||||||
Human *killer = nullptr;
|
Human *killer = nullptr;
|
||||||
Human *target = invisable_humans.at(0);
|
Human *target = invisable_humans->at(0);
|
||||||
for (size_t i = 0; i < invisable_humans.size(); ++i) {
|
for (size_t i = 0; i < invisable_humans->size(); ++i) {
|
||||||
if (invisable_humans.at(i)->GetTeam() != target->GetTeam()) {
|
if (invisable_humans->at(i)->GetTeam() != target->GetTeam()) {
|
||||||
killer = invisable_humans.at(i);
|
killer = invisable_humans->at(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!killer && !invisable_teammates.empty()) {
|
if (!killer && !invisable_teammates->empty()) {
|
||||||
std::shuffle(invisable_teammates.begin(),
|
std::shuffle(invisable_teammates->begin(),
|
||||||
invisable_teammates.end(),
|
invisable_teammates->end(),
|
||||||
std::default_random_engine(a8::XGetTickCount()));
|
std::default_random_engine(a8::XGetTickCount()));
|
||||||
killer = invisable_teammates.at(0);
|
killer = invisable_teammates->at(0);
|
||||||
}
|
}
|
||||||
if (killer) {
|
if (killer) {
|
||||||
target->BeKill(killer->GetUniId(),
|
target->BeKill(killer->GetUniId(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user