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