youhua shua android
This commit is contained in:
parent
a0de81fcf2
commit
5c9028712d
@ -33,7 +33,7 @@ void AndroidAI::Update(int delta_time)
|
|||||||
if (hum->dead) {
|
if (hum->dead) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (a8::HasBitFlag(hum->status, HS_NewBieNpc)) {
|
if (a8::HasBitFlag(hum->status, HS_NewBieGuideAndroid)) {
|
||||||
UpdateNewBieNpc();
|
UpdateNewBieNpc();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ void AndroidAI::DoMove()
|
|||||||
if (owner->UpdatedTimes() % 2 == 0) {
|
if (owner->UpdatedTimes() % 2 == 0) {
|
||||||
Human* hum = (Human*)owner;
|
Human* hum = (Human*)owner;
|
||||||
int speed = std::max(1, (int)hum->GetSpeed());
|
int speed = std::max(1, (int)hum->GetSpeed());
|
||||||
if (a8::HasBitFlag(hum->status, HS_NewBieNpc) &&
|
if (a8::HasBitFlag(hum->status, HS_NewBieGuideAndroid) &&
|
||||||
hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 8) {
|
hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 8) {
|
||||||
hum->move_dir = hum->room->GetFirstNewBie()->GetPos() - hum->GetPos();
|
hum->move_dir = hum->room->GetFirstNewBie()->GetPos() - hum->GetPos();
|
||||||
hum->move_dir.Normalize();
|
hum->move_dir.Normalize();
|
||||||
@ -190,6 +190,6 @@ void AndroidAI::UpdateNewBieNpc()
|
|||||||
sender->Shot(shot_dir);
|
sender->Shot(shot_dir);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
a8::UnSetBitFlag(hum->status, HS_NewBieNpc);
|
a8::UnSetBitFlag(hum->status, HS_NewBieGuideAndroid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3313,7 +3313,7 @@ void Human::ProcNewBieLogic()
|
|||||||
[] (const a8::XParams& param)
|
[] (const a8::XParams& param)
|
||||||
{
|
{
|
||||||
Human* hum = (Human*)param.sender.GetUserData();
|
Human* hum = (Human*)param.sender.GetUserData();
|
||||||
hum->room->ShuaNewBieAndroid(hum);
|
hum->room->ShuaGuideAndroid(hum);
|
||||||
},
|
},
|
||||||
&xtimer_attacher.timer_list_
|
&xtimer_attacher.timer_list_
|
||||||
);
|
);
|
||||||
@ -3367,10 +3367,39 @@ void Human::AdjustDecHp(float old_health, float& new_health)
|
|||||||
|
|
||||||
void Human::OnEnable()
|
void Human::OnEnable()
|
||||||
{
|
{
|
||||||
|
a8::UnSetBitFlag(status, HS_Disable);
|
||||||
|
enable_frameno = room->GetFrameNo();
|
||||||
|
room->grid_service->AddHuman(this);
|
||||||
|
FindLocation();
|
||||||
|
RefreshView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::OnDisable()
|
void Human::OnDisable()
|
||||||
{
|
{
|
||||||
|
a8::SetBitFlag(status, HS_Disable);
|
||||||
|
for (auto& cell : grid_list) {
|
||||||
|
bool has_target = false;
|
||||||
|
for (Human* hum : cell->human_list[room->GetRoomIdx()]) {
|
||||||
|
if (hum == this) {
|
||||||
|
has_target = true;
|
||||||
|
} else {
|
||||||
|
hum->AddOutObjects(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (has_target) {
|
||||||
|
cell->human_list[room->GetRoomIdx()].erase(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
room->TouchHumanList
|
||||||
|
(
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this),
|
||||||
|
[] (Human* hum, a8::XParams& param)
|
||||||
|
{
|
||||||
|
Human* target = (Human*)param.sender.GetUserData();
|
||||||
|
hum->RemovePartObjects(target);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
grid_id = 0;
|
grid_id = 0;
|
||||||
grid_list.clear();
|
grid_list.clear();
|
||||||
last_collision_door = nullptr;
|
last_collision_door = nullptr;
|
||||||
|
@ -18,7 +18,7 @@ enum HumanStatus
|
|||||||
{
|
{
|
||||||
HS_AlreadyLordMode = 1,
|
HS_AlreadyLordMode = 1,
|
||||||
HS_Disable = 2,
|
HS_Disable = 2,
|
||||||
HS_NewBieNpc = 3,
|
HS_NewBieGuideAndroid = 3,
|
||||||
HS_AlreadyEquip = 5,
|
HS_AlreadyEquip = 5,
|
||||||
HS_AlreadyProcNewBieLogic = 6,
|
HS_AlreadyProcNewBieLogic = 6,
|
||||||
HS_End
|
HS_End
|
||||||
|
@ -289,7 +289,7 @@ void Room::CreateAndroid(int robot_num)
|
|||||||
|
|
||||||
Human* Room::FindEnemy(Human* hum)
|
Human* Room::FindEnemy(Human* hum)
|
||||||
{
|
{
|
||||||
if (a8::HasBitFlag(hum->status, HS_NewBieNpc) &&
|
if (a8::HasBitFlag(hum->status, HS_NewBieGuideAndroid) &&
|
||||||
GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 8) {
|
GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 8) {
|
||||||
return first_newbie_;
|
return first_newbie_;
|
||||||
}
|
}
|
||||||
@ -1605,7 +1605,7 @@ void Room::NotifyGameStart()
|
|||||||
},
|
},
|
||||||
&xtimer_attacher_.timer_list_);
|
&xtimer_attacher_.timer_list_);
|
||||||
|
|
||||||
if (room_type == RT_NewBrid || room_type == RT_MidBrid) {
|
if (room_type_ == RT_NewBrid || room_type_ == RT_MidBrid) {
|
||||||
NewBieRoomStart();
|
NewBieRoomStart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1648,13 +1648,8 @@ void Room::EnableHuman(Human* target)
|
|||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
if (a8::HasBitFlag(target->status, HS_Disable)) {
|
if (a8::HasBitFlag(target->status, HS_Disable)) {
|
||||||
a8::UnSetBitFlag(target->status, HS_Disable);
|
|
||||||
target->OnEnable();
|
target->OnEnable();
|
||||||
target->enable_frameno = GetFrameNo();
|
|
||||||
AddToMoveableHash(target);
|
AddToMoveableHash(target);
|
||||||
grid_service->AddHuman(target);
|
|
||||||
target->FindLocation();
|
|
||||||
target->RefreshView();
|
|
||||||
if (!target->real_dead) {
|
if (!target->real_dead) {
|
||||||
AddToAliveHumanHash(target);
|
AddToAliveHumanHash(target);
|
||||||
}
|
}
|
||||||
@ -1678,33 +1673,16 @@ void Room::DisableHuman(Human* target)
|
|||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
if (!a8::HasBitFlag(target->status, HS_Disable)) {
|
if (!a8::HasBitFlag(target->status, HS_Disable)) {
|
||||||
a8::SetBitFlag(target->status, HS_Disable);
|
target->OnDisable();
|
||||||
RemoveFromMoveableHash(target);
|
RemoveFromMoveableHash(target);
|
||||||
RemoveFromAliveHumanHash(target);
|
RemoveFromAliveHumanHash(target);
|
||||||
for (auto& cell : target->grid_list) {
|
|
||||||
bool has_target = false;
|
|
||||||
for (Human* hum : cell->human_list[room_idx_]) {
|
|
||||||
if (hum == target) {
|
|
||||||
has_target = true;
|
|
||||||
} else {
|
|
||||||
hum->AddOutObjects(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (has_target) {
|
|
||||||
cell->human_list[room_idx_].erase(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& pair : human_hash_) {
|
|
||||||
pair.second->RemovePartObjects(target);
|
|
||||||
}
|
|
||||||
target->OnDisable();
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
CheckPartObjects();
|
CheckPartObjects();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::ShuaNewBieAndroid(Human* target)
|
void Room::ShuaGuideAndroid(Human* target)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
a8::UdpLog::Instance()->Debug("room_idx:%d ShuaNewBieAndroid %s %s",
|
a8::UdpLog::Instance()->Debug("room_idx:%d ShuaNewBieAndroid %s %s",
|
||||||
@ -1714,11 +1692,9 @@ void Room::ShuaNewBieAndroid(Human* target)
|
|||||||
target->name
|
target->name
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
for (auto& pair : human_hash_) {
|
{
|
||||||
if (pair.second->entity_subtype == EST_Android &&
|
Human* hum = GetOneCanEnableAndroid();
|
||||||
a8::HasBitFlag(pair.second->status, HS_Disable)
|
if (hum) {
|
||||||
) {
|
|
||||||
Android* hum = (Android*)pair.second;
|
|
||||||
a8::Vec2 pos = target->GetPos();
|
a8::Vec2 pos = target->GetPos();
|
||||||
pos.x -= MetaMgr::Instance()->newbie_first_robot_distance;
|
pos.x -= MetaMgr::Instance()->newbie_first_robot_distance;
|
||||||
if (OverBorder(pos, hum->GetRadius())) {
|
if (OverBorder(pos, hum->GetRadius())) {
|
||||||
@ -1729,9 +1705,8 @@ void Room::ShuaNewBieAndroid(Human* target)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
hum->SetPos(pos);
|
hum->SetPos(pos);
|
||||||
a8::SetBitFlag(hum->status, HS_NewBieNpc);
|
|
||||||
EnableHuman(hum);
|
EnableHuman(hum);
|
||||||
break;
|
a8::SetBitFlag(hum->status, HS_NewBieGuideAndroid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
@ -1852,32 +1827,11 @@ void Room::DieAndroidTimerFunc()
|
|||||||
|
|
||||||
void Room::ProcShuaAndroid(int shua_time, int shua_num)
|
void Room::ProcShuaAndroid(int shua_time, int shua_num)
|
||||||
{
|
{
|
||||||
Human* target = nullptr;
|
Human* target = GetOneAlivePlayer();
|
||||||
for (auto& pair : accountid_hash_) {
|
|
||||||
if (!pair.second->real_dead) {
|
|
||||||
target = pair.second;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!target) {
|
if (!target) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int real_shua_num = shua_num;
|
int real_shua_num = GetCanShuaNum(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) {
|
if (real_shua_num <= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1891,13 +1845,9 @@ void Room::ProcShuaAndroid(int shua_time, int shua_num)
|
|||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int refreshed_num = 0;
|
std::vector<Human*> humans;
|
||||||
for (auto& pair : human_hash_) {
|
GetCanEnableAndroids(humans, real_shua_num);
|
||||||
if (pair.second->entity_subtype == EST_Android &&
|
for (auto& hum : humans) {
|
||||||
!pair.second->real_dead &&
|
|
||||||
a8::HasBitFlag(pair.second->status, HS_Disable)
|
|
||||||
) {
|
|
||||||
Android* hum = (Android*)pair.second;
|
|
||||||
a8::Vec2 pos = target->GetPos();
|
a8::Vec2 pos = target->GetPos();
|
||||||
a8::Vec2 dir = a8::Vec2::UP;
|
a8::Vec2 dir = a8::Vec2::UP;
|
||||||
dir.Rotate(a8::RandAngle());
|
dir.Rotate(a8::RandAngle());
|
||||||
@ -1910,30 +1860,7 @@ void Room::ProcShuaAndroid(int shua_time, int shua_num)
|
|||||||
}
|
}
|
||||||
hum->SetPos(pos);
|
hum->SetPos(pos);
|
||||||
EnableHuman(hum);
|
EnableHuman(hum);
|
||||||
xtimer.AddDeadLineTimerAndAttach
|
InstallCheckAutoDieTimer(hum);
|
||||||
(
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2463,3 +2390,92 @@ void Room::NewBieRoomStart()
|
|||||||
&xtimer_attacher_.timer_list_);
|
&xtimer_attacher_.timer_list_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Human* Room::GetOneCanEnableAndroid()
|
||||||
|
{
|
||||||
|
std::vector<Human*> humans;
|
||||||
|
GetCanEnableAndroids(humans, 1);
|
||||||
|
return !humans.empty() ? humans[0] : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::GetCanEnableAndroids(std::vector<Human*>& humans, int num)
|
||||||
|
{
|
||||||
|
for (auto& pair : human_hash_) {
|
||||||
|
if (pair.second->IsAndroid() &&
|
||||||
|
!pair.second->real_dead &&
|
||||||
|
a8::HasBitFlag(pair.second->status, HS_Disable)
|
||||||
|
) {
|
||||||
|
if (humans.size() >= num) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
humans.push_back(pair.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::InstallCheckAutoDieTimer(Human* hum)
|
||||||
|
{
|
||||||
|
int autodie_time = 10;
|
||||||
|
int autodie_distance = 500;
|
||||||
|
if (room_type_ == RT_NewBrid) {
|
||||||
|
autodie_time = MetaMgr::Instance()->level0room_robot_autodie_time;
|
||||||
|
autodie_distance = MetaMgr::Instance()->level0room_robot_autodie_distance;
|
||||||
|
} else if (room_type_ == RT_MidBrid) {
|
||||||
|
autodie_time = MetaMgr::Instance()->level1room_robot_autodie_time;
|
||||||
|
autodie_distance = MetaMgr::Instance()->level1room_robot_autodie_distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
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_);
|
||||||
|
}
|
||||||
|
|
||||||
|
Player* Room::GetOneAlivePlayer()
|
||||||
|
{
|
||||||
|
std::vector<Player*> humans;
|
||||||
|
GetAlivePlayers(humans, 1);
|
||||||
|
return !humans.empty() ? humans[0] : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Room::GetAlivePlayers(std::vector<Player*>& humans, int num)
|
||||||
|
{
|
||||||
|
for (auto& pair : accountid_hash_) {
|
||||||
|
if (!pair.second->real_dead) {
|
||||||
|
if (humans.size() >= num) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
humans.push_back(pair.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int Room::GetCanShuaNum(int shua_num)
|
||||||
|
{
|
||||||
|
int real_shua_num = shua_num;
|
||||||
|
if (room_type_ == RT_NewBrid) {
|
||||||
|
real_shua_num = std::max(0,
|
||||||
|
MetaMgr::Instance()->level0room_robot_water - RealAliveCount() +
|
||||||
|
(int)accountid_hash_.size());
|
||||||
|
} else if (room_type_ == RT_MidBrid) {
|
||||||
|
real_shua_num = std::max(0,
|
||||||
|
MetaMgr::Instance()->level1room_robot_water - RealAliveCount() +
|
||||||
|
(int)accountid_hash_.size());
|
||||||
|
}
|
||||||
|
return real_shua_num;
|
||||||
|
}
|
||||||
|
@ -109,10 +109,16 @@ public:
|
|||||||
bool HaveMyTeam(const std::string& team_uuid);
|
bool HaveMyTeam(const std::string& team_uuid);
|
||||||
ObstacleData* GetPermanentObstacleData(int entity_uniid);
|
ObstacleData* GetPermanentObstacleData(int entity_uniid);
|
||||||
long long GetGasInactiveTime();
|
long long GetGasInactiveTime();
|
||||||
void ShuaNewBieAndroid(Human* target);
|
void ShuaGuideAndroid(Human* target);
|
||||||
void InitAirDrop();
|
void InitAirDrop();
|
||||||
void CheckPartObjects(Human* testa = nullptr, Human* testb = nullptr);
|
void CheckPartObjects(Human* testa = nullptr, Human* testb = nullptr);
|
||||||
bool RuningInTimer();
|
bool RuningInTimer();
|
||||||
|
Human* GetOneCanEnableAndroid();
|
||||||
|
void GetCanEnableAndroids(std::vector<Human*>& humans, int num);
|
||||||
|
void InstallCheckAutoDieTimer(Human* hum);
|
||||||
|
Player* GetOneAlivePlayer();
|
||||||
|
void GetAlivePlayers(std::vector<Player*>& humans, int num);
|
||||||
|
int GetCanShuaNum(int shua_num);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int AllocUniid();
|
int AllocUniid();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user