修复机器人视野
This commit is contained in:
parent
e0fb3a679a
commit
12104f57f3
@ -208,7 +208,7 @@ void AndroidAI::UpdateLastNpc()
|
|||||||
hum->move_dir.Normalize();
|
hum->move_dir.Normalize();
|
||||||
hum->attack_dir = hum->move_dir;
|
hum->attack_dir = hum->move_dir;
|
||||||
if (hum->curr_weapon->weapon_idx != 0) {
|
if (hum->curr_weapon->weapon_idx != 0) {
|
||||||
hum->curr_weapon->ammo = MetaMgr::Instance()->newbie_first_robot_ammo;
|
hum->curr_weapon->ammo = MetaMgr::Instance()->newbie_first_robot_ammo * 2;
|
||||||
}
|
}
|
||||||
} else if (hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 1.5) {
|
} else if (hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 1.5) {
|
||||||
int speed = std::max(1, (int)hum->GetSpeed());
|
int speed = std::max(1, (int)hum->GetSpeed());
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#include "perfmonitor.h"
|
#include "perfmonitor.h"
|
||||||
|
|
||||||
const int ROOM_MAX_PLAYER_NUM = 40;
|
const int ROOM_MAX_PLAYER_NUM = 40;
|
||||||
const int SHUA_RANGE = 731;
|
const int SHUA_RANGE = 512;
|
||||||
|
|
||||||
static long long RoomXGetTickCount(void* context)
|
static long long RoomXGetTickCount(void* context)
|
||||||
{
|
{
|
||||||
@ -1588,6 +1588,23 @@ void Room::SecondRandPoint()
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
CheckPartObjects();
|
CheckPartObjects();
|
||||||
#endif
|
#endif
|
||||||
|
if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) {
|
||||||
|
std::vector<Human*> tmp_humans;
|
||||||
|
tmp_humans.reserve(ROOM_MAX_PLAYER_NUM);
|
||||||
|
for (auto& pair : human_hash_) {
|
||||||
|
if (pair.second->IsAndroid() &&
|
||||||
|
a8::HasBitFlag(pair.second->status, HS_Disable) &&
|
||||||
|
pair.second->team_uuid.empty()
|
||||||
|
) {
|
||||||
|
tmp_humans.push_back(pair.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::random_shuffle(tmp_humans.begin(), tmp_humans.end());
|
||||||
|
for (size_t i = 0; i < accountid_hash_.size(); ++i) {
|
||||||
|
last_human_hash_[tmp_humans[i]->GetEntityUniId()] = tmp_humans[i];
|
||||||
|
a8::SetBitFlag(tmp_humans[i]->status, HS_LastAndroid);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::NotifyGameStart()
|
void Room::NotifyGameStart()
|
||||||
@ -2449,18 +2466,6 @@ void Room::NewBieRoomStart()
|
|||||||
},
|
},
|
||||||
&xtimer_attacher_.timer_list_);
|
&xtimer_attacher_.timer_list_);
|
||||||
}
|
}
|
||||||
std::vector<Human*> tmp_humans;
|
|
||||||
tmp_humans.reserve(ROOM_MAX_PLAYER_NUM);
|
|
||||||
for (auto& pair : human_hash_) {
|
|
||||||
if (pair.second->IsAndroid()) {
|
|
||||||
tmp_humans.push_back(pair.second);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::random_shuffle(tmp_humans.begin(), tmp_humans.end());
|
|
||||||
for (size_t i = 0; i < accountid_hash_.size(); ++i) {
|
|
||||||
last_human_hash_[tmp_humans[i]->GetEntityUniId()] = tmp_humans[i];
|
|
||||||
a8::SetBitFlag(tmp_humans[i]->status, HS_LastAndroid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Human* Room::GetOneCanEnableAndroid()
|
Human* Room::GetOneCanEnableAndroid()
|
||||||
@ -2596,8 +2601,53 @@ void Room::SyncFrameData()
|
|||||||
|
|
||||||
void Room::CheckShowHand()
|
void Room::CheckShowHand()
|
||||||
{
|
{
|
||||||
|
if (show_handed_) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) {
|
if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) {
|
||||||
if (alive_count_ <= (int)(accountid_hash_.size() + last_human_hash_.size())) {
|
int real_player_num = accountid_hash_.size();
|
||||||
|
if (room_type_ == RT_MidBrid) {
|
||||||
|
for (auto& pair : accountid_hash_) {
|
||||||
|
Human* player = pair.second;
|
||||||
|
real_player_num = 0;
|
||||||
|
for (Human* hum : *player->team_members) {
|
||||||
|
if (!hum->real_dead) {
|
||||||
|
++real_player_num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (alive_count_ <= (int)(real_player_num + last_human_hash_.size())) {
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::UdpLog::Instance()->Debug
|
||||||
|
(
|
||||||
|
"showHand %d %d %d %d",
|
||||||
|
{
|
||||||
|
alive_count_,
|
||||||
|
accountid_hash_.size(),
|
||||||
|
last_human_hash_.size(),
|
||||||
|
real_player_num
|
||||||
|
}
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
xtimer.AddDeadLineTimerAndAttach
|
||||||
|
(1,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Room* room = (Room*)param.sender.GetUserData();
|
||||||
|
room->ShowHand();
|
||||||
|
},
|
||||||
|
&xtimer_attacher_.timer_list_);
|
||||||
|
show_handed_ = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::ShowHand()
|
||||||
|
{
|
||||||
std::vector<Player*> players;
|
std::vector<Player*> players;
|
||||||
std::vector<Human*> androids;
|
std::vector<Human*> androids;
|
||||||
for (auto& pair : accountid_hash_) {
|
for (auto& pair : accountid_hash_) {
|
||||||
@ -2620,7 +2670,7 @@ void Room::CheckShowHand()
|
|||||||
} else {
|
} else {
|
||||||
dir.Rotate(a8::RandAngle());
|
dir.Rotate(a8::RandAngle());
|
||||||
}
|
}
|
||||||
pos = pos + dir * SHUA_RANGE;
|
pos = pos + dir * VIEW_RANGE;
|
||||||
if (OverBorder(pos, hum->GetRadius())) {
|
if (OverBorder(pos, hum->GetRadius())) {
|
||||||
pos.x = target->GetPos().x;
|
pos.x = target->GetPos().x;
|
||||||
if (OverBorder(pos, hum->GetRadius())) {
|
if (OverBorder(pos, hum->GetRadius())) {
|
||||||
@ -2632,6 +2682,4 @@ void Room::CheckShowHand()
|
|||||||
EnableHuman(hum);
|
EnableHuman(hum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,7 @@ private:
|
|||||||
bool CanAddToScene(Human* hum);
|
bool CanAddToScene(Human* hum);
|
||||||
void SyncFrameData();
|
void SyncFrameData();
|
||||||
void CheckShowHand();
|
void CheckShowHand();
|
||||||
|
void ShowHand();
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void InitDebugInfo();
|
void InitDebugInfo();
|
||||||
@ -223,6 +224,7 @@ private:
|
|||||||
a8::XTimerAttacher xtimer_attacher_;
|
a8::XTimerAttacher xtimer_attacher_;
|
||||||
size_t airdrop_times_ = 0;
|
size_t airdrop_times_ = 0;
|
||||||
int newbie_born_point_uniid_ = 0;
|
int newbie_born_point_uniid_ = 0;
|
||||||
|
bool show_handed_ = false;
|
||||||
|
|
||||||
int current_teamid_ = 0;
|
int current_teamid_ = 0;
|
||||||
int current_uniid_ = FIXED_OBJECT_MAXID;
|
int current_uniid_ = FIXED_OBJECT_MAXID;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user