1
This commit is contained in:
parent
5dd3938316
commit
0de41be867
@ -193,6 +193,8 @@ public:
|
||||
METAMGR_READ(level0room_die_robot_min_num, 2);
|
||||
METAMGR_READ(level0room_die_robot_max_num, 5);
|
||||
METAMGR_READ(level0room_robot_water, 2);
|
||||
METAMGR_READ(level0room_robot_autodie_time, 10);
|
||||
METAMGR_READ(level0room_robot_autodie_distance, 500);
|
||||
|
||||
METAMGR_READ(level1room_shua_robot_min_time, 5);
|
||||
METAMGR_READ(level1room_shua_robot_max_time, 7);
|
||||
@ -203,6 +205,8 @@ public:
|
||||
METAMGR_READ(level1room_die_robot_min_num, 1);
|
||||
METAMGR_READ(level1room_die_robot_max_num, 5);
|
||||
METAMGR_READ(level1room_robot_water, 8);
|
||||
METAMGR_READ(level1room_robot_autodie_time, 10);
|
||||
METAMGR_READ(level1room_robot_autodie_distance, 500);
|
||||
}
|
||||
if (MetaMgr::Instance()->K < 0.01f) {
|
||||
abort();
|
||||
|
@ -82,6 +82,8 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
int level0room_die_robot_min_num = 0;
|
||||
int level0room_die_robot_max_num = 0;
|
||||
int level0room_robot_water = 0;
|
||||
int level0room_robot_autodie_time = 0;
|
||||
int level0room_robot_autodie_distance = 0;
|
||||
|
||||
int level1room_shua_robot_min_time = 0;
|
||||
int level1room_shua_robot_max_time = 0;
|
||||
@ -92,6 +94,8 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
int level1room_die_robot_min_num = 0;
|
||||
int level1room_die_robot_max_num = 0;
|
||||
int level1room_robot_water = 0;
|
||||
int level1room_robot_autodie_time = 0;
|
||||
int level1room_robot_autodie_distance = 0;
|
||||
|
||||
int other_fill_interval = 0;
|
||||
float android_attack_range = 0;
|
||||
|
@ -1898,13 +1898,6 @@ void Room::DieAndroidTimerFunc()
|
||||
|
||||
void Room::ProcShuaAndroid(int shua_time, int shua_num)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
a8::UdpLog::Instance()->Debug("ProcShuaAndroid shua_time:%d shua_num%d",
|
||||
{
|
||||
shua_time,
|
||||
shua_num
|
||||
});
|
||||
#endif
|
||||
Human* target = nullptr;
|
||||
for (auto& pair : accountid_hash_) {
|
||||
if (!pair.second->real_dead) {
|
||||
@ -1916,24 +1909,50 @@ void Room::ProcShuaAndroid(int shua_time, int shua_num)
|
||||
return;
|
||||
}
|
||||
int real_shua_num = shua_num;
|
||||
int autodie_time = 10;
|
||||
int autodie_distance = 500;
|
||||
if (room_type == RT_NewBrid) {
|
||||
real_shua_num = std::max(0,
|
||||
MetaMgr::Instance()->level0room_robot_water - RealAliveCount() +
|
||||
(int)accountid_hash_.size());
|
||||
autodie_time = MetaMgr::Instance()->level0room_robot_autodie_time;
|
||||
autodie_distance = MetaMgr::Instance()->level0room_robot_autodie_distance;
|
||||
} else if (room_type == RT_MidBrid) {
|
||||
real_shua_num = std::max(0,
|
||||
MetaMgr::Instance()->level1room_robot_water - RealAliveCount() +
|
||||
(int)accountid_hash_.size());
|
||||
autodie_time = MetaMgr::Instance()->level1room_robot_autodie_time;
|
||||
autodie_distance = MetaMgr::Instance()->level1room_robot_autodie_distance;
|
||||
}
|
||||
if (real_shua_num <= 0) {
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
a8::UdpLog::Instance()->Debug("ProcShuaAndroid shua_time:%d shua_num%d real_shua_num:%d",
|
||||
{
|
||||
shua_time,
|
||||
shua_num,
|
||||
real_shua_num
|
||||
});
|
||||
#endif
|
||||
|
||||
int refreshed_num = 0;
|
||||
for (auto& pair : human_hash_) {
|
||||
if (pair.second->entity_subtype == EST_Android &&
|
||||
a8::HasBitFlag(pair.second->status, HS_Disable)) {
|
||||
Android* hum = (Android*)pair.second;
|
||||
a8::Vec2 pos = target->GetPos();
|
||||
#if 1
|
||||
a8::Vec2 dir = a8::Vec2::UP;
|
||||
pos = pos + dir * 400;
|
||||
dir.Rotate(a8::RandAngle());
|
||||
if (grid_service->BroderOverFlow(pos.x, pos.y)) {
|
||||
pos.x = target->GetPos().x;
|
||||
if (grid_service->BroderOverFlow(pos.x, pos.y)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
pos.x -= MetaMgr::Instance()->newbie_first_robot_distance;
|
||||
if (grid_service->BroderOverFlow(pos.x, pos.y)) {
|
||||
a8::Vec2 pos = target->GetPos();
|
||||
@ -1942,9 +1961,29 @@ void Room::ProcShuaAndroid(int shua_time, int shua_num)
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
hum->SetPos(pos);
|
||||
a8::SetBitFlag(hum->status, HS_NewBieNpc);
|
||||
EnableHuman(hum);
|
||||
xtimer.AddDeadLineTimerAndAttach
|
||||
(
|
||||
SERVER_FRAME_RATE * autodie_time,
|
||||
a8::XParams()
|
||||
.SetSender(hum)
|
||||
.SetParam1(autodie_time)
|
||||
.SetParam2(autodie_distance)
|
||||
.SetParam3(0),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
hum->room->CheckAutoDie(
|
||||
hum,
|
||||
param.param1,
|
||||
param.param2,
|
||||
param.param3
|
||||
);
|
||||
},
|
||||
&hum->xtimer_attacher.timer_list_);
|
||||
++refreshed_num;
|
||||
if (refreshed_num >= real_shua_num) {
|
||||
break;
|
||||
@ -1969,3 +2008,85 @@ void Room::ProcDieAndroid(int die_time, int die_num)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::CheckAutoDie(Human* target,
|
||||
int autodie_time,
|
||||
int autodie_distance,
|
||||
int check_times)
|
||||
{
|
||||
bool nodie = false;
|
||||
for (auto& grid : target->grid_list) {
|
||||
for (Human* hum: grid->human_list[room_idx]) {
|
||||
if (!hum->real_dead &&
|
||||
hum->entity_uniid != target->entity_uniid &&
|
||||
hum->IsPlayer()) {
|
||||
if (std::fabs(hum->GetPos().x - target->GetPos().x) <= autodie_distance &&
|
||||
std::fabs(hum->GetPos().y - target->GetPos().y) <= autodie_distance) {
|
||||
nodie = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nodie) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nodie) {
|
||||
xtimer.AddDeadLineTimerAndAttach
|
||||
(
|
||||
SERVER_FRAME_RATE * (2 + rand() % 3),
|
||||
a8::XParams()
|
||||
.SetSender(target)
|
||||
.SetParam1(autodie_time)
|
||||
.SetParam2(autodie_distance)
|
||||
.SetParam3(check_times + 1),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
hum->room->CheckAutoDie(
|
||||
hum,
|
||||
param.param1,
|
||||
param.param2,
|
||||
param.param3
|
||||
);
|
||||
},
|
||||
&target->xtimer_attacher.timer_list_);
|
||||
} else {
|
||||
for (auto& pair : human_hash_) {
|
||||
if (pair.second->entity_uniid != target->entity_uniid &&
|
||||
pair.second->entity_subtype == EST_Android &&
|
||||
a8::HasBitFlag(pair.second->status, HS_Disable)) {
|
||||
Android* hum = (Android*)pair.second;
|
||||
{
|
||||
target->BeKill(hum->entity_uniid,
|
||||
hum->name,
|
||||
hum->curr_weapon->weapon_id);
|
||||
}
|
||||
#if 0
|
||||
hum->SetPos(target->GetPos());
|
||||
EnableHuman(hum);
|
||||
xtimer.AddDeadLineTimerAndAttach
|
||||
(
|
||||
SERVER_FRAME_RATE * autodie_time,
|
||||
a8::XParams()
|
||||
.SetSender(hum)
|
||||
.SetParam1(autodie_time)
|
||||
.SetParam2(autodie_distance)
|
||||
.SetParam3(0),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
hum->room->CheckAutoDie(
|
||||
hum,
|
||||
param.param1,
|
||||
param.param2,
|
||||
param.param3
|
||||
);
|
||||
},
|
||||
&hum->xtimer_attacher.timer_list_);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -162,6 +162,7 @@ private:
|
||||
void DieAndroidTimerFunc();
|
||||
void ProcShuaAndroid(int shua_time, int shua_num);
|
||||
void ProcDieAndroid(int die_time, int die_num);
|
||||
void CheckAutoDie(Human* hum, int autodie_time, int autodie_distance, int check_times);
|
||||
|
||||
private:
|
||||
int elapsed_time_ = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user