完善死亡逻辑
This commit is contained in:
parent
80a229baa0
commit
c4e742f90d
@ -1862,23 +1862,7 @@ void Room::ProcDieAndroid(int die_time, int die_num)
|
||||
#endif
|
||||
std::vector<Human*> alive_humans;
|
||||
alive_humans.reserve(human_hash_.size());
|
||||
{
|
||||
if (GetFrameNo() % 8 < 5) {
|
||||
for (auto itr = human_hash_.begin(); itr != human_hash_.end(); ++itr) {
|
||||
CheckAliveHuman(itr->second, alive_humans);
|
||||
if (alive_humans.size() > 16) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (auto itr = human_hash_.rbegin(); itr != human_hash_.rend(); ++itr) {
|
||||
CheckAliveHuman(itr->second, alive_humans);
|
||||
if (alive_humans.size() > 16) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GetAliveHumans(alive_humans, 16, nullptr);
|
||||
{
|
||||
Human* first_alive_player = nullptr;
|
||||
for (auto& pair : accountid_hash_) {
|
||||
@ -1983,23 +1967,15 @@ void Room::CheckAutoDie(Human* target,
|
||||
},
|
||||
&target->xtimer_attacher.timer_list_);
|
||||
} else {
|
||||
bool killed = false;
|
||||
for (auto& pair : human_hash_) {
|
||||
if (pair.second->GetEntityUniId() != target->GetEntityUniId() &&
|
||||
pair.second->IsAndroid() &&
|
||||
!pair.second->real_dead &&
|
||||
a8::HasBitFlag(pair.second->status, HS_Disable)) {
|
||||
Android* hum = (Android*)pair.second;
|
||||
{
|
||||
target->BeKill(hum->GetEntityUniId(),
|
||||
hum->name,
|
||||
hum->curr_weapon->weapon_id);
|
||||
}
|
||||
killed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!killed) {
|
||||
std::vector<Human*> alive_humans;
|
||||
GetAliveHumans(alive_humans, 5, target);
|
||||
if (!alive_humans.empty()) {
|
||||
Human* killer = alive_humans[rand() % alive_humans.size()];
|
||||
a8::UnSetBitFlag(target->status, HS_Disable);
|
||||
target->BeKill(killer->GetEntityUniId(),
|
||||
killer->name,
|
||||
killer->curr_weapon->weapon_id);
|
||||
} else {
|
||||
a8::UnSetBitFlag(target->status, HS_Disable);
|
||||
target->BeKill(VP_SafeArea,
|
||||
"毒圈",
|
||||
@ -2139,6 +2115,34 @@ void Room::CheckPartObjects(Human* testa, Human* testb)
|
||||
}
|
||||
}
|
||||
|
||||
void Room::GetAliveHumans(std::vector<Human*>& alive_humans, int num, Human* exclude_hum)
|
||||
{
|
||||
alive_humans.reserve(num);
|
||||
{
|
||||
if (GetFrameNo() % 8 < 5) {
|
||||
for (auto itr = human_hash_.begin(); itr != human_hash_.end(); ++itr) {
|
||||
if (itr->second == exclude_hum) {
|
||||
continue;
|
||||
}
|
||||
CheckAliveHuman(itr->second, alive_humans);
|
||||
if (alive_humans.size() > num) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (auto itr = human_hash_.rbegin(); itr != human_hash_.rend(); ++itr) {
|
||||
if (itr->second == exclude_hum) {
|
||||
continue;
|
||||
}
|
||||
CheckAliveHuman(itr->second, alive_humans);
|
||||
if (alive_humans.size() > num) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans)
|
||||
{
|
||||
if (hum->IsAndroid() &&
|
||||
|
@ -166,6 +166,7 @@ private:
|
||||
void ProcDisableHuman();
|
||||
void OnHumanGridChg(Human* target);
|
||||
void ShuaGridRound(Human* target);
|
||||
void GetAliveHumans(std::vector<Human*>& alive_humans, int num, Human* exclude_hum);
|
||||
void CheckAliveHuman(Human* hum, std::vector<Human*>& alive_humans);
|
||||
a8::Vec2 GetDefaultBornPoint();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user