完善自动死亡逻辑
This commit is contained in:
parent
ac30eff025
commit
c9a6a55ba6
@ -7,7 +7,18 @@
|
||||
|
||||
void Incubator::Init()
|
||||
{
|
||||
|
||||
xtimer_attacher_.xtimer = &room->xtimer;
|
||||
room->xtimer.AddRepeatTimerAndAttach
|
||||
(
|
||||
SERVER_FRAME_RATE * (2 + rand() % 3),
|
||||
a8::XParams()
|
||||
.SetSender(this),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Incubator* incubator = (Incubator*)param.sender.GetUserData();
|
||||
incubator->AutoAllocAndroid();
|
||||
},
|
||||
&xtimer_attacher_.timer_list_);
|
||||
}
|
||||
|
||||
void Incubator::UnInit()
|
||||
@ -134,3 +145,42 @@ bool Incubator::CanSet(Human* hum, Human* exclude_hum)
|
||||
});
|
||||
return can_set;
|
||||
}
|
||||
|
||||
void Incubator::AutoAllocAndroid()
|
||||
{
|
||||
switch (room->GetGasData().gas_mode) {
|
||||
case GasWaiting:
|
||||
case GasMoving:
|
||||
{
|
||||
if (!hold_humans_.empty()){
|
||||
Human* hum = hold_humans_[0];
|
||||
if (room->GetGasData().gas_mode == GasWaiting &&
|
||||
hold_humans_.size() > 1 &&
|
||||
((rand() % 100) > 30)) {
|
||||
Human* killer = nullptr;
|
||||
if (hold_humans_.size() == 2) {
|
||||
killer = hold_humans_[1];
|
||||
} else {
|
||||
killer = hold_humans_[1 + (rand() % (hold_humans_.size() - 1))];
|
||||
}
|
||||
hum->BeKill(killer->GetEntityUniId(),
|
||||
killer->name,
|
||||
killer->GetCurrWeapon()->weapon_id);
|
||||
} else if (room->GetGasData().gas_count > 1) {
|
||||
hum->BeKill(VP_SafeArea,
|
||||
TEXT("battle_server_killer_gas", "毒圈"),
|
||||
VW_SafeArea);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
hold_humans_.erase(hold_humans_.begin());
|
||||
room->xtimer.ModifyTimer(room->xtimer.GetRunningTimer(), SERVER_FRAME_RATE * (3 + rand() % 5));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <a8/xtimer.h>
|
||||
|
||||
class Human;
|
||||
class Room;
|
||||
class Incubator
|
||||
@ -14,7 +16,9 @@ class Incubator
|
||||
|
||||
private:
|
||||
bool CanSet(Human* hum, Human* exclude_hum);
|
||||
void AutoAllocAndroid();
|
||||
|
||||
private:
|
||||
std::vector<Human*> hold_humans_;
|
||||
a8::XTimerAttacher xtimer_attacher_;
|
||||
};
|
||||
|
@ -3722,6 +3722,7 @@ void Room::ForwardGasRing(int n)
|
||||
}
|
||||
gas_data_.rad_old = gas_data_.old_area_meta->i->rad();
|
||||
gas_data_.rad_new = gas_data_.new_area_meta->i->rad();
|
||||
gas_data_.gas_count++;
|
||||
--n;
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ struct GasData
|
||||
MetaData::SafeArea* old_area_meta = nullptr;
|
||||
MetaData::SafeArea* new_area_meta = nullptr;
|
||||
bool is_last_gas = false;
|
||||
int gas_count = 0;
|
||||
};
|
||||
|
||||
struct Weapon
|
||||
|
Loading…
x
Reference in New Issue
Block a user