diff --git a/server/gameserver/human.h b/server/gameserver/human.h index e390922..295f829 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -18,6 +18,7 @@ enum HumanStatus { HS_AlreadyLordMode = 1, HS_Disable = 2, + HS_NewBieNpc = 3, HS_End }; diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 4ec97c9..5afd31b 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1744,7 +1744,7 @@ void Room::DisableHuman(Human* target) void Room::ShuaNewBieAndroid(Human* target) { - #ifdef DEBUG +#ifdef DEBUG a8::UdpLog::Instance()->Debug("ShuaNewBieAndroid %s %s", { target->account_id, @@ -1765,12 +1765,41 @@ void Room::ShuaNewBieAndroid(Human* target) } } hum->SetPos(pos); + a8::SetBitFlag(hum->status, HS_NewBieNpc); EnableHuman(hum); break; } } - ShuaAndroidTimerFunc(); - DieAndroidTimerFunc(); + { + int shua_time = a8::RandEx( + MetaMgr::Instance()->level0room_shua_robot_min_time, + MetaMgr::Instance()->level0room_shua_robot_max_time + ); + xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * (shua_time), + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Room* room = (Room*)param.sender.GetUserData(); + room->ShuaAndroidTimerFunc(); + }, + &xtimer_attacher_.timer_list_); + } + { + int die_time = a8::RandEx( + MetaMgr::Instance()->level0room_die_robot_min_time, + MetaMgr::Instance()->level0room_die_robot_max_time + ); + xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * (die_time), + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Room* room = (Room*)param.sender.GetUserData(); + room->DieAndroidTimerFunc(); + }, + &xtimer_attacher_.timer_list_); + } } void Room::ShuaAndroidTimerFunc() @@ -1876,10 +1905,37 @@ void Room::ProcShuaAndroid(int shua_time, int shua_num) shua_num }); #endif + Human* target = nullptr; + for (auto& pair : accountid_hash_) { + if (!pair.second->real_dead) { + target = pair.second; + break; + } + } + if (!target) { + return; + } + 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(); + pos.x -= MetaMgr::Instance()->newbie_first_robot_distance; + if (grid_service->BroderOverFlow(pos.x, pos.y)) { + a8::Vec2 pos = target->GetPos(); + pos.x += MetaMgr::Instance()->newbie_first_robot_distance; + if (grid_service->BroderOverFlow(pos.x, pos.y)) { + break; + } + } + hum->SetPos(pos); + a8::SetBitFlag(hum->status, HS_NewBieNpc); + EnableHuman(hum); + ++refreshed_num; + if (refreshed_num >= shua_num) { + break; + } } } }