修复机器人视野
This commit is contained in:
parent
e0fb3a679a
commit
12104f57f3
@ -208,7 +208,7 @@ void AndroidAI::UpdateLastNpc()
|
||||
hum->move_dir.Normalize();
|
||||
hum->attack_dir = hum->move_dir;
|
||||
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) {
|
||||
int speed = std::max(1, (int)hum->GetSpeed());
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "perfmonitor.h"
|
||||
|
||||
const int ROOM_MAX_PLAYER_NUM = 40;
|
||||
const int SHUA_RANGE = 731;
|
||||
const int SHUA_RANGE = 512;
|
||||
|
||||
static long long RoomXGetTickCount(void* context)
|
||||
{
|
||||
@ -1588,6 +1588,23 @@ void Room::SecondRandPoint()
|
||||
#ifdef DEBUG
|
||||
CheckPartObjects();
|
||||
#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()
|
||||
@ -2449,18 +2466,6 @@ void Room::NewBieRoomStart()
|
||||
},
|
||||
&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()
|
||||
@ -2596,42 +2601,85 @@ void Room::SyncFrameData()
|
||||
|
||||
void Room::CheckShowHand()
|
||||
{
|
||||
if (show_handed_) {
|
||||
return;
|
||||
}
|
||||
if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) {
|
||||
if (alive_count_ <= (int)(accountid_hash_.size() + last_human_hash_.size())) {
|
||||
std::vector<Player*> players;
|
||||
std::vector<Human*> androids;
|
||||
int real_player_num = accountid_hash_.size();
|
||||
if (room_type_ == RT_MidBrid) {
|
||||
for (auto& pair : accountid_hash_) {
|
||||
players.push_back(pair.second);
|
||||
}
|
||||
for (auto& pair : last_human_hash_) {
|
||||
androids.push_back(pair.second);
|
||||
}
|
||||
for (size_t i = 0; i < players.size(); ++i) {
|
||||
if (i >= androids.size()) {
|
||||
break;
|
||||
}
|
||||
Player* target = players[i];
|
||||
Human* hum = androids[i];
|
||||
{
|
||||
a8::Vec2 pos = target->GetPos();
|
||||
a8::Vec2 dir = target->move_dir;
|
||||
if (rand() % 100 < 80) {
|
||||
dir.Rotate(a8::RandAngle() / 2.0f);
|
||||
} else {
|
||||
dir.Rotate(a8::RandAngle());
|
||||
Human* player = pair.second;
|
||||
real_player_num = 0;
|
||||
for (Human* hum : *player->team_members) {
|
||||
if (!hum->real_dead) {
|
||||
++real_player_num;
|
||||
}
|
||||
pos = pos + dir * SHUA_RANGE;
|
||||
if (OverBorder(pos, hum->GetRadius())) {
|
||||
pos.x = target->GetPos().x;
|
||||
if (OverBorder(pos, hum->GetRadius())) {
|
||||
pos = target->GetPos(); //!!!
|
||||
}
|
||||
}
|
||||
hum->last_human_target = target;
|
||||
hum->SetPos(pos);
|
||||
EnableHuman(hum);
|
||||
}
|
||||
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<Human*> androids;
|
||||
for (auto& pair : accountid_hash_) {
|
||||
players.push_back(pair.second);
|
||||
}
|
||||
for (auto& pair : last_human_hash_) {
|
||||
androids.push_back(pair.second);
|
||||
}
|
||||
for (size_t i = 0; i < players.size(); ++i) {
|
||||
if (i >= androids.size()) {
|
||||
break;
|
||||
}
|
||||
Player* target = players[i];
|
||||
Human* hum = androids[i];
|
||||
{
|
||||
a8::Vec2 pos = target->GetPos();
|
||||
a8::Vec2 dir = target->move_dir;
|
||||
if (rand() % 100 < 80) {
|
||||
dir.Rotate(a8::RandAngle() / 2.0f);
|
||||
} else {
|
||||
dir.Rotate(a8::RandAngle());
|
||||
}
|
||||
pos = pos + dir * VIEW_RANGE;
|
||||
if (OverBorder(pos, hum->GetRadius())) {
|
||||
pos.x = target->GetPos().x;
|
||||
if (OverBorder(pos, hum->GetRadius())) {
|
||||
pos = target->GetPos(); //!!!
|
||||
}
|
||||
}
|
||||
hum->last_human_target = target;
|
||||
hum->SetPos(pos);
|
||||
EnableHuman(hum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,6 +192,7 @@ private:
|
||||
bool CanAddToScene(Human* hum);
|
||||
void SyncFrameData();
|
||||
void CheckShowHand();
|
||||
void ShowHand();
|
||||
|
||||
#ifdef DEBUG
|
||||
void InitDebugInfo();
|
||||
@ -223,6 +224,7 @@ private:
|
||||
a8::XTimerAttacher xtimer_attacher_;
|
||||
size_t airdrop_times_ = 0;
|
||||
int newbie_born_point_uniid_ = 0;
|
||||
bool show_handed_ = false;
|
||||
|
||||
int current_teamid_ = 0;
|
||||
int current_uniid_ = FIXED_OBJECT_MAXID;
|
||||
|
Loading…
x
Reference in New Issue
Block a user