diff --git a/server/gameserver/android.ai.cc b/server/gameserver/android.ai.cc index 68b7204..22b0bbf 100644 --- a/server/gameserver/android.ai.cc +++ b/server/gameserver/android.ai.cc @@ -49,26 +49,6 @@ void AndroidNewAI::Update(int delta_time) if (hum->dead) { return; } - #if 1 - { - if (a8::HasBitFlag(hum->status, HS_NewBieGuideAndroid)) { - UpdateNewBieNpc(); - return; - } - if (a8::HasBitFlag(hum->status, HS_LastAndroid)) { - UpdateLastNpc(); - return; - } - if ((hum->room->GetRoomType() == RT_NewBrid || - hum->room->GetRoomType() == RT_MidBrid) && - hum->room->GetGasData().gas_mode != GasInactive && - hum->team_uuid.empty() - ) { - UpdateNewBieRoomLogic(); - return; - } - } - #endif if (hum->room->GetGasData().gas_mode == GasInactive) { DefaultAi(); return; @@ -166,12 +146,6 @@ void AndroidNewAI::DoMoveOldAI() if (owner->UpdatedTimes() % 2 == 0) { Human* hum = (Human*)owner; int speed = std::max(1, (int)hum->GetSpeed()); - if (a8::HasBitFlag(hum->status, HS_NewBieGuideAndroid) && - hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 8) { - a8::Vec2 move_dir = hum->room->GetFirstNewBie()->GetPos() - hum->GetPos(); - move_dir.Normalize(); - hum->SetMoveDir(move_dir); - } for (int i = 0; i < speed; ++i) { a8::Vec2 old_pos = hum->GetPos(); hum->SetPos(hum->GetPos() + hum->GetMoveDir()); @@ -217,207 +191,6 @@ void AndroidNewAI::DoAttackOldAI() } } -void AndroidNewAI::UpdateNewBieNpc() -{ - Human* hum = (Human*)owner; - if (hum->room->GetFrameNo() - hum->enable_frameno < 2) { - if (hum->GetPos().ManhattanDistance(hum->room->GetFirstNewBie()->GetPos()) > 100) { - a8::Vec2 move_dir = hum->room->GetFirstNewBie()->GetPos() - hum->GetPos(); - move_dir.Normalize(); - hum->SetMoveDir(move_dir); - } - hum->SetAttackDir(hum->GetMoveDir()); - if (hum->GetCurrWeapon()->weapon_idx != 0) { - hum->GetCurrWeapon()->ammo = MetaMgr::Instance()->newbie_first_robot_ammo; - } - } else if (hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 1.5) { - int speed = std::max(1, (int)hum->GetSpeed()); - for (int i = 0; i < speed; ++i) { - hum->SetPos(hum->GetPos() + hum->GetMoveDir()); - hum->room->grid_service->MoveCreature(hum); - } - } else if (hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 3) { - Human* enemy = hum->room->GetFirstNewBie(); - Human* sender = hum; - a8::Vec2 shot_dir = enemy->GetPos() - sender->GetPos(); - if (std::abs(shot_dir.x) > FLT_EPSILON || - std::abs(shot_dir.y) > FLT_EPSILON) { - shot_dir.Normalize(); - shot_dir.Rotate((rand() % 10) / 180.0f); - sender->SetAttackDir(shot_dir); - bool shot_ok = false; - sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE); - } - } else { - a8::UnSetBitFlag(hum->status, HS_NewBieGuideAndroid); - } -} - -void AndroidNewAI::UpdateLastNpc() -{ - Human* hum = (Human*)owner; - if (hum->room->GetFrameNo() - hum->enable_frameno < 2) { - if (hum->GetPos().ManhattanDistance(hum->last_human_target->GetPos()) > 100) { - a8::Vec2 move_dir = hum->last_human_target->GetPos() - hum->GetPos(); - move_dir.Normalize(); - hum->SetMoveDir(move_dir); - } - hum->SetAttackDir(hum->GetMoveDir()); - if (hum->GetCurrWeapon()->weapon_idx != 0) { - hum->GetCurrWeapon()->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()); - for (int i = 0; i < speed; ++i) { - a8::Vec2 old_pos = hum->GetPos(); - hum->SetPos(hum->GetPos() + hum->GetMoveDir()); - if (!hum->room->OverBorder(hum->GetPos(), hum->meta->i->radius())) { - hum->room->grid_service->MoveCreature(hum); - } else { - hum->SetPos(old_pos); - break; - } - } - } else if (hum->room->GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 3) { - Human* enemy = hum->last_human_target; - Human* sender = hum; - a8::Vec2 shot_dir = enemy->GetPos() - sender->GetPos(); - if (std::abs(shot_dir.x) > FLT_EPSILON || - std::abs(shot_dir.y) > FLT_EPSILON) { - shot_dir.Normalize(); - shot_dir.Rotate((rand() % 10) / 180.0f); - sender->SetAttackDir(shot_dir); - bool shot_ok = false; - sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE); - } - } else { - a8::UnSetBitFlag(hum->status, HS_LastAndroid); - } -} - -void AndroidNewAI::UpdateNewBieRoomLogic() -{ - Human* hum = (Human*)owner; - Creature* old_last_target = old_ai_data_.last_target.Get(); - Creature* target = old_ai_data_.last_target.Get(); - if ((old_ai_data_.last_target.Get() && old_ai_data_.last_target.Get()->real_dead) || - !old_ai_data_.last_target.Get()) { - if (hum->last_human_target && !hum->last_human_target->dead) { - target = hum->last_human_target; - } else { - if (rand() % 100 < 70) { - hum->room->TraversePlayerList - ( - a8::XParams(), - [hum, &target] (Player* player, a8::XParams& param) - { - if (!player->dead && hum->team_id != player->team_id) { - if (!target) { - target = player; - } else { - if (hum->GetPos().ManhattanDistance(player->GetPos()) < - hum->GetPos().ManhattanDistance(target->GetPos())) { - target = player; - } - } - } - }); - } else { - hum->room->TraverseHumanList - ( - a8::XParams(), - [hum, &target] (Human* huma, a8::XParams& param) - { - if (!huma->dead && - huma->IsAndroid() && - hum->team_id != huma->team_id && - !a8::HasBitFlag(huma->status, HS_Disable)) { - if (!target) { - target = huma; - } else { - if (hum->GetPos().ManhattanDistance(huma->GetPos()) < - hum->GetPos().ManhattanDistance(target->GetPos())) { - target = huma; - } - } - } - return true; - }); - } - } - old_ai_data_.last_target.Attach(target); - } - if (!target) { - return; - } - if (target->IsPlayer()) { - if (hum->room->AliveCount() < 15) { - if (hum->GetPos().ManhattanDistance(target->GetPos()) > 1000) { - a8::Vec2 pos = target->GetPos(); - a8::Vec2 dir = target->GetMoveDir(); - dir = a8::Vec2::UP; - if (rand() % 100 < 1) { - dir.Rotate(a8::RandAngle() / 2.0f); - } else { - dir.Rotate(a8::RandAngle()); - } - pos = pos + dir * SHUA_RANGE; - if (hum->room->OverBorder(pos, hum->GetRadius())) { - pos.x = target->GetPos().x; - if (hum->room->OverBorder(pos, hum->GetRadius())) { - pos = target->GetPos(); - } - } - hum->SetPos(pos); - hum->room->grid_service->MoveCreature(hum); - hum->FindLocation(); - hum->RefreshView(); - } - } - } - if (hum->GetPos().ManhattanDistance(target->GetPos()) > 180) { - if (hum->GetPos().ManhattanDistance(target->GetPos()) > 650 && - hum->room->GetFrameNo() - old_ai_data_.last_findenemy_frameno > SERVER_FRAME_RATE * 3) { - old_ai_data_.last_findenemy_frameno = hum->room->GetFrameNo(); - old_ai_data_.last_target.Reset(); - } else { - int speed = std::max(1, (int)hum->GetSpeed()); - a8::Vec2 move_dir = target->GetPos() - hum->GetPos(); - move_dir.Normalize(); - hum->SetMoveDir(move_dir); - hum->SetAttackDir(hum->GetMoveDir()); - speed *= 0.7; - for (int i = 0; i < speed; ++i) { - hum->SetPos(hum->GetPos() + hum->GetMoveDir()); - hum->room->grid_service->MoveCreature(hum); - } - } - } else { - if (hum->room->GetFrameNo() - old_ai_data_.last_attack_frameno > SERVER_FRAME_RATE + (rand() % 15)) { - old_ai_data_.last_attack_frameno = hum->room->GetFrameNo(); - Human* sender = (Human*)owner; - a8::Vec2 shot_dir = target->GetPos() - sender->GetPos(); - if (std::abs(shot_dir.x) > FLT_EPSILON || - std::abs(shot_dir.y) > FLT_EPSILON) { - shot_dir.Normalize(); - shot_dir.Rotate((rand() % 10) / 180.0f); - sender->SetAttackDir(shot_dir); - bool shot_ok = false; - sender->Shot(shot_dir, shot_ok, DEFAULT_FLY_DISTANCE); - } - } - if (old_last_target && old_ai_data_.last_target.Get() && old_last_target == old_ai_data_.last_target.Get()) { - ++old_ai_data_.series_attack_frames; - } else { - old_ai_data_.series_attack_frames = 0; - } - if (old_ai_data_.series_attack_frames > SERVER_FRAME_RATE * 10 && - old_ai_data_.last_target.Get() && old_ai_data_.last_target.Get()->IsAndroid()) { - old_ai_data_.last_target.Reset(); - } - } -} - void AndroidNewAI::UpdateNewAI() { Human* hum = (Human*)owner; @@ -808,3 +581,4 @@ int AndroidNewAI::GetAttackTimes() return ai_meta->i->attack_times(); } } + diff --git a/server/gameserver/android.ai.h b/server/gameserver/android.ai.h index ea34f7c..7603c18 100644 --- a/server/gameserver/android.ai.h +++ b/server/gameserver/android.ai.h @@ -68,9 +68,6 @@ private: void ChangeToStateOldAI(AndroidState_e to_state); void DoMoveOldAI(); void DoAttackOldAI(); - void UpdateNewBieNpc(); - void UpdateLastNpc(); - void UpdateNewBieRoomLogic(); void UpdateNewAI(); void UpdateIdle(); diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 1fa5a84..cefa9bd 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -2797,38 +2797,6 @@ void Human::CancelRevive() } } -void Human::ProcNewBieLogic() -{ - if (a8::HasBitFlag(status, HS_AlreadyProcNewBieLogic)) { - return; - } - a8::SetBitFlag(status, HS_AlreadyProcNewBieLogic); - //刷一个机器人 - room->xtimer.AddDeadLineTimerAndAttach - (SERVER_FRAME_RATE * MetaMgr::Instance()->newbie_first_robot_appeartime, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Human* hum = (Human*)param.sender.GetUserData(); - hum->room->ShuaGuideAndroid(hum); - }, - &xtimer_attacher.timer_list_ - ); - //6秒后出现空投 - room->xtimer.AddDeadLineTimerAndAttach - (SERVER_FRAME_RATE * MetaMgr::Instance()->newbie_airdrop_appeartime, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Human* hum = (Human*)param.sender.GetUserData(); - hum->room->InitAirDrop(); - }, - &xtimer_attacher.timer_list_ - ); -} - void Human::ClearLordMode() { Buff* buff = GetBuffByEffectId(kBET_LordMode); diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 014d15e..f40cd34 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -17,10 +17,6 @@ enum HumanStatus { HS_AlreadyLordMode = 1, HS_Disable = 2, - HS_NewBieGuideAndroid = 3, - HS_AlreadyEquip = 5, - HS_AlreadyProcNewBieLogic = 6, - HS_LastAndroid = 7, HS_DisableAttack = 8, HS_End }; @@ -235,7 +231,6 @@ class Human : public Creature void AddItem(int item_id, int item_num); void DecItem(int item_id, int item_num); virtual void DropItems(Obstacle* obstacle) override; - void ProcNewBieLogic(); void OnEnable(); void OnDisable(); Entity* GetLastCollisionDoor() { return last_collision_door_; } diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 0132749..b73b19c 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -607,11 +607,6 @@ void Player::LootInteraction(Loot* entity) need_sync_active_player = true; SyncAroundPlayers(__FILE__, __LINE__, __func__); } - if (room->GetRoomType() == RT_NewBrid && - !a8::HasBitFlag(status, HS_AlreadyEquip)) { - a8::SetBitFlag(status, HS_AlreadyEquip); - ProcNewBieLogic(); - } } break; case EQUIP_TYPE_OLDSKIN: diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index e4b8847..9f8387c 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -384,10 +384,6 @@ void Room::CreateAndroid(int robot_num) Human* Room::FindEnemy(Human* hum) { - if (a8::HasBitFlag(hum->status, HS_NewBieGuideAndroid) && - GetFrameNo() - hum->enable_frameno < SERVER_FRAME_RATE * 8) { - return first_newbie_; - } std::vector enemys; enemys.reserve(50); EntitySubType_e sub_type = EST_Player; @@ -2266,14 +2262,6 @@ void Room::SecondRandPoint() hum->born_point = AllocBornPoint(hum); } CombineTeamBornPoint(); - if (room_type_ == RT_NewBrid) { - BornPoint* newbie_point = GetBornPoint(level0room_born_point_uniid_); - if (newbie_point && first_newbie_) { - ForceSetBornPoint(first_newbie_, newbie_point); - } else { - abort(); - } - } if (room_type_ == RT_MidBrid) { BornPoint* newbie_point = GetBornPoint(level1room_born_point_uniid_); for (auto& pair : accountid_hash_) { @@ -2310,7 +2298,6 @@ void Room::SecondRandPoint() 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]->GetUniId()] = tmp_humans[i]; - a8::SetBitFlag(tmp_humans[i]->status, HS_LastAndroid); } } #ifdef DEBUG @@ -2545,7 +2532,6 @@ void Room::ShuaGuideAndroid(Human* target) } hum->SetPos(pos); EnableHuman(hum); - a8::SetBitFlag(hum->status, HS_NewBieGuideAndroid); } } { @@ -2722,7 +2708,6 @@ void Room::ProcDieAndroid(int die_time, int die_num) #endif std::vector alive_humans; alive_humans.reserve(human_hash_.size()); - GetAliveHumansExcludeLastHuman(alive_humans, 16); { Human* first_alive_player = nullptr; for (auto& pair : accountid_hash_) { @@ -2898,7 +2883,6 @@ void Room::ShuaGridRound(Human* target) Human* hum = pair.second; if (hum->IsAndroid() && a8::HasBitFlag(hum->status, HS_Disable) && - !a8::HasBitFlag(hum->status, HS_LastAndroid) && !hum->real_dead && hum->team_uuid.empty() && grid_service->InView(target->GetGridId(), hum->GetPos().x, hum->GetPos().y) @@ -3005,34 +2989,6 @@ void Room::GetAliveHumans(std::vector& alive_humans, size_t num, Human* } } -void Room::GetAliveHumansExcludeLastHuman(std::vector& alive_humans, size_t num) -{ - alive_humans.reserve(num); - { - if (GetFrameNo() % 8 < 5) { - for (auto itr = human_hash_.begin(); itr != human_hash_.end(); ++itr) { - if (a8::HasBitFlag(itr->second->status, HS_LastAndroid)) { - continue; - } - CheckAliveHuman(itr->second, alive_humans); - if (alive_humans.size() > num) { - break; - } - } - } else { - for (auto itr = human_hash_.rbegin(); itr != human_hash_.rend(); ++itr) { - if (a8::HasBitFlag(itr->second->status, HS_LastAndroid)) { - continue; - } - CheckAliveHuman(itr->second, alive_humans); - if (alive_humans.size() > num) { - break; - } - } - } - } -} - void Room::CheckAliveHuman(Human* hum, std::vector& alive_humans) { if (hum->IsAndroid() && @@ -3279,6 +3235,7 @@ BornPoint* Room::ForceTakeBornPoint(Human* hum, BornPoint* reserve_born_point) void Room::NewBieRoomStart() { + #if 0 if (room_type_ == RT_NewBrid) { for (auto& pair : accountid_hash_) { first_newbie_ = pair.second; @@ -3313,6 +3270,7 @@ void Room::NewBieRoomStart() }, &xtimer_attacher_.timer_list_); } + #endif } void Room::ZombieModeStart() @@ -3377,8 +3335,7 @@ void Room::GetCanEnableAndroids(std::vector& humans, size_t num) for (auto& pair : human_hash_) { if (pair.second->IsAndroid() && !pair.second->real_dead && - a8::HasBitFlag(pair.second->status, HS_Disable) && - !a8::HasBitFlag(pair.second->status, HS_LastAndroid) + a8::HasBitFlag(pair.second->status, HS_Disable) ) { if (humans.size() >= num) { break; @@ -3601,7 +3558,6 @@ void Room::ShuaLastGas() Human* hum = pair.second; if (hum->IsAndroid() && a8::HasBitFlag(hum->status, HS_Disable) && - !a8::HasBitFlag(hum->status, HS_LastAndroid) && !hum->real_dead && hum->team_uuid.empty() ) { diff --git a/server/gameserver/room.h b/server/gameserver/room.h index cadfc18..cc51ecc 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -84,7 +84,6 @@ public: Player* GetPlayerByUniId(int uniid); Entity* GetEntityByUniId(int uniid); Human* GetHumanByUniId(int uniid); - Human* GetFirstNewBie() { return first_newbie_; } int GetRealPlayerNum() { return accountid_hash_.size();} Player* NewPlayer(); @@ -232,7 +231,6 @@ private: void ShuaGridRound(Human* target); void GetAliveHumans(std::vector& alive_humans, size_t num, Human* exclude_hum); void CheckAliveHuman(Human* hum, std::vector& alive_humans); - void GetAliveHumansExcludeLastHuman(std::vector& alive_humans, size_t num); a8::Vec2 GetDefaultBornPoint(); void AddToEntityHash(Entity* entity); @@ -286,7 +284,6 @@ private: const std::vector* loots_ = nullptr; const std::vector* buildings_ = nullptr; const std::vector* level0room_spec_things_ = nullptr; - Human* first_newbie_ = nullptr; bool sent_zombie_boss_notify = false; bool waiting_start_ = false;