diff --git a/server/gameserver/custom_battle.cc b/server/gameserver/custom_battle.cc index 470d2297..54ca48aa 100644 --- a/server/gameserver/custom_battle.cc +++ b/server/gameserver/custom_battle.cc @@ -51,6 +51,7 @@ void CustomBattle::ParseResult(a8::XObject& obj) map_id_ = obj.Get("map_id"); match_mode_ = obj.Get("match_mode"); start_time_ = obj.Get("start_time"); + is_newbie_battle_ = obj.Get("is_newbie_battle"); sign_ = obj.Get("sign").GetString(); const mt::Map* map_meta = mt::Map::GetById(map_id_); if (!map_meta || !map_meta->IsOpen()) { @@ -402,6 +403,9 @@ void CustomBattle::GameStart() nullptr); } } + if (IsNewBieBattle()) { + room->SetNewBieBattle(1); + } SetRoom(room.get()); room->JoinWithCustomBattle(shared_from_this()); } else { diff --git a/server/gameserver/custom_battle.h b/server/gameserver/custom_battle.h index 8e6355a4..fc9e22e2 100644 --- a/server/gameserver/custom_battle.h +++ b/server/gameserver/custom_battle.h @@ -49,6 +49,7 @@ class CustomBattle : public std::enable_shared_from_this bool IsCustomMode() { return custom_room_type_ == CUSTOM_ROOM_CUSTOM; } bool IsPvp() { return !is_moba_; } bool IsMoba() { return is_moba_; } + int IsNewBieBattle() { return is_newbie_battle_; } void OnEnter(std::shared_ptr join_msg, long ip_saddr, int socket_handle, std::weak_ptr sd_handler); void OnMemberReady(CustomMember* member); @@ -75,6 +76,7 @@ private: int map_id_ = 0; int start_time_ = 0; int team1_average_hero_lv_ = 0; + int is_newbie_battle_ = 0; const mt::MapMode* map_mode_meta_ = nullptr; std::string sign_; std::shared_ptr raw_data_; diff --git a/server/gameserver/hero_agent.cc b/server/gameserver/hero_agent.cc index 65370312..7b5b1859 100644 --- a/server/gameserver/hero_agent.cc +++ b/server/gameserver/hero_agent.cc @@ -418,6 +418,12 @@ behaviac::EBTStatus HeroAgent::SearchEnemy(float range) c->team_id != myself->team_id && !c->IsCar() && !myself->IsIgnoreTarget(c->GetUniId())) { + if (myself->room->IsNewBieBattle() && + myself->GetTeam() && + !myself->GetTeam()->HasPlayer() && + !c->IsPlayer()) { + return true; + } if (a8::HasBitFlag(myself->status, CS_DisableAttackAndroid) && c->IsAndroid()) { } else { @@ -1401,6 +1407,9 @@ int HeroAgent::SearchPickupObj() }); if (nearest_obj && nearest_obj->GetPos().ManhattanDistance2D(owner_->GetPos()) < 200) { + if (GetRoom()->IsNewBieBattle() && nearest_obj->IsCar()) { + return 0; + } int obj_type = 0; if (nearest_obj->IsCar()) { obj_type = 1; diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index d6c1d079..106b157d 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -217,6 +217,11 @@ void Human::DecHP(float dec_hp, int killer_id, const std::string killer_name, in int dmg_type, int dmg_bp) { + if (IsPlayer() && room->IsNewBieBattle()) { + if (dec_hp > 10) { + dec_hp = 10; + } + } real_dmg_out = 0.0f; if (!room->BattleStarted()) { return; @@ -3646,6 +3651,7 @@ void Human::SendPersonalBattleReport() params->SetVal("session_id", session_id); params->SetVal("version", 2023030201); + params->SetVal("is_newbie_battle", a8::XValue(room->IsNewBieBattle())); params->SetVal("battle_uuid", a8::XValue(GetTeam()->GetBattleUuid())); params->SetVal("room_uuid", a8::XValue(room->GetRoomUuid())); params->SetVal("room_mode", room->GetReportRoomMode()); diff --git a/server/gameserver/incubator.cc b/server/gameserver/incubator.cc index 6650b181..e6ae6811 100644 --- a/server/gameserver/incubator.cc +++ b/server/gameserver/incubator.cc @@ -1,5 +1,7 @@ #include "precompile.h" +#include + #include "incubator.h" #include "room.h" #include "human.h" @@ -22,6 +24,8 @@ #include "mt/SafeArea.h" #include "mt/SafeAreaSafePoint.h" +static const int CHIJI_HIDE_HUMANS = 6; + void Incubator::Init() { #if 1 @@ -47,6 +51,18 @@ void Incubator::Init() } }, &xtimer_attacher_); + if (room->IsNewBieBattle()) { + room->xtimer.SetTimeoutEx + ( + SERVER_FRAME_RATE * (60), + [this] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + StartNewBattleMode(); + } + }, + &xtimer_attacher_); + } } }, &xtimer_attacher_); @@ -85,6 +101,9 @@ void Incubator::UnInit() void Incubator::AllocAndroid(Human* target, int num, std::vector* androids) { + if (room->IsNewBieBattle() && target->IsAndroid()) { + return; + } if (!room->xtimer.IsRunning()) { A8_ABORT(); } @@ -98,11 +117,13 @@ void Incubator::AllocAndroid(Human* target, int num, std::vector* androi if (hold_humans_.size() < 1) { return; } - if (hold_humans_.size() <= 6) { - if (room->GetGasData().new_area_meta->GetSmallRingCount() < 4) { - ShowHand(); + if (!room->IsNewBieBattle()) { + if (hold_humans_.size() <= CHIJI_HIDE_HUMANS) { + if (room->GetGasData().new_area_meta->GetSmallRingCount() < 4) { + ShowHand(); + } + return; } - return; } #ifdef MYDEBUG a8::XPrintf("SmallRingCount:%d \n", {room->GetGasData().new_area_meta->GetSmallRingCount()}); @@ -131,6 +152,7 @@ void Incubator::AllocAndroid(Human* target, int num, std::vector* androi App::Instance()->verify_set_pos = 0; if (!CanSee(hum, target)) { room->EnableHuman(hum); + room->grid_service->MoveCreature(hum); #ifdef MYDEBUG #if 0 if (!target->InNewObjects(hum)) { @@ -248,19 +270,24 @@ bool Incubator::CanSee(Human* hum, Human* exclude_hum) void Incubator::AutoAllocAndroid() { +#ifdef MYDEBUG + { + a8::XPrintf("AutoAllocAndroid hold_humans.size:%d\n", {hold_humans_.size()}); + } +#endif switch (room->GetGasData().GetGasMode()) { case GasWaiting: case GasMoving: { -#if 1 if (!hold_humans_.empty() && hold_humans_.size() > 0) { -#else - if (!hold_humans_.empty() && hold_humans_.size() > 6) { -#endif + int rnd_space = 70; + if (room->IsNewBieBattle()) { + rnd_space = 20; + } Human* hum = hold_humans_[0]; if (room->GetGasData().GetGasMode() == GasWaiting && hold_humans_.size() > 1 && - ((rand() % 100) > 70)) { + ((rand() % 100) > rnd_space)) { Human* killer = nullptr; if (hold_humans_.size() == 2) { killer = hold_humans_[1]; @@ -282,7 +309,11 @@ void Incubator::AutoAllocAndroid() return; } hold_humans_.erase(hold_humans_.begin()); - room->xtimer.ModifyTime(alloc_timer_, SERVER_FRAME_RATE * (30 + rand() % 5)); + if (room->IsNewBieBattle()) { + room->xtimer.ModifyTime(alloc_timer_, SERVER_FRAME_RATE * (6 + rand() % 4)); + } else { + room->xtimer.ModifyTime(alloc_timer_, SERVER_FRAME_RATE * (30 + rand() % 5)); + } } } break; @@ -563,7 +594,7 @@ void Incubator::Clear(int save_num) void Incubator::Rearrangement() { - if (hold_humans_.size() < 6) { + if (hold_humans_.size() < CHIJI_HIDE_HUMANS) { return; } std::vector teams2; @@ -629,3 +660,112 @@ void Incubator::Rearrangement() } #endif } + +void Incubator::StartNewBattleMode() +{ + Player* selected_player = nullptr; + room->TraversePlayerList + ( + [&selected_player] (Player* hum) -> bool + { + selected_player = hum; + return false; + }); + if (!selected_player) { + return; + } + auto startno = std::make_shared(); + *startno = room->GetFrameNo(); + auto invisable_humans = std::make_shared>(); + auto invisable_teammates = std::make_shared>(); + room->xtimer.SetIntervalWpEx + ( + SERVER_FRAME_RATE * (5 + rand() % 3), + [this, selected_player, invisable_humans, invisable_teammates, startno] + (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + if (room->IsGameOver()) { + return; + } + invisable_humans->clear(); + invisable_teammates->clear(); + room->TraverseAliveHumanList + ( + [this, selected_player, invisable_humans, invisable_teammates, startno] + (Human* hum) -> bool + { + if (hum == selected_player) { + return true; + } + if (!CanSee(hum, selected_player)) { + if (hum->GetTeam() == selected_player->GetTeam()) { + invisable_teammates->push_back(hum); + } else { + invisable_humans->push_back(hum); + } + } + return true; + }); + if (invisable_humans->size() == 1) { + if (room->GetFrameNo() - *startno < SERVER_FRAME_RATE * 30) { + Human *target = invisable_humans->at(0); + glm::vec3 dir = GlmHelper::UP; + GlmHelper::RotateY(dir, a8::RandAngle()); + int rand_len = rand() % mt::Param::s().incubator_rand_length; + glm::vec3 center = selected_player->GetPos().ToGlmVec3() + dir * (float)(mt::Param::s().incubator_base_length + rand_len); + room->map_instance->Scale(center); + glm::vec3 point; + if (room->map_instance->FindRandomPointAroundCircle + ( + center, + 10 * room->GetMapMeta()->scale(), + point + )) { + room->map_instance->UnScale(point); + + glm::vec3 old_pos = target->GetPos().ToGlmVec3(); + App::Instance()->verify_set_pos = 1; + target->GetMutablePos().FromGlmVec3(point); + App::Instance()->verify_set_pos = 0; + if (CanSee(target, selected_player)) { + App::Instance()->verify_set_pos = 1; + target->GetMutablePos().FromGlmVec3(old_pos); + App::Instance()->verify_set_pos = 0; + } else { + room->grid_service->MoveCreature(target); + } + } + return; + } + } + if (invisable_humans->size() > 0) { + std::shuffle(invisable_humans->begin(), + invisable_humans->end(), + std::default_random_engine(a8::XGetTickCount())); + Human *killer = nullptr; + Human *target = invisable_humans->at(0); + for (size_t i = 0; i < invisable_humans->size(); ++i) { + if (invisable_humans->at(i)->GetTeam() != target->GetTeam()) { + killer = invisable_humans->at(i); + break; + } + } + if (!killer && !invisable_teammates->empty()) { + std::shuffle(invisable_teammates->begin(), + invisable_teammates->end(), + std::default_random_engine(a8::XGetTickCount())); + killer = invisable_teammates->at(0); + } + if (killer) { + target->BeKill(killer->GetUniId(), + killer->name, + killer->GetCurrWeapon()->weapon_id, + killer->GetUniId(), + killer->name); + } + } + } + }, + &xtimer_attacher_); +} diff --git a/server/gameserver/incubator.h b/server/gameserver/incubator.h index 76faa197..ddd2b6b8 100644 --- a/server/gameserver/incubator.h +++ b/server/gameserver/incubator.h @@ -20,6 +20,7 @@ class Incubator void NextWave(); void ShowHand(); void Clear(int save_num); + void StartNewBattleMode(); private: bool CanSee(Human* hum, Human* exclude_hum); diff --git a/server/gameserver/netdata.cc b/server/gameserver/netdata.cc index 961993a8..48d54161 100644 --- a/server/gameserver/netdata.cc +++ b/server/gameserver/netdata.cc @@ -162,6 +162,9 @@ public: hp_ = (hero_meta->GetBasicMeta()->vOrigHealth() * (1 + pHealth / hero_meta->GetBasicMeta()->pBaseHealth()) + vHealthAm) * (1 + vHealthRateSe) * (1 + vHealthRateIn); + if (owner_.Get()->room->IsNewBieBattle() && !owner_.Get()->IsPlayer()) { + hp_ = 50; + } } void RecalcAttack() @@ -1367,6 +1370,9 @@ void BattleDataContext::RecalcCrit() bool BattleDataContext::HasWing() { +#ifdef MYDEBUG + return true; +#endif if (hero_dto) { long long token_id = hero_dto->Get("token_id", ""); if (token_id > 6240603010001668 && token_id <= 6240603010002168) { diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 56d660da..2d5de392 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -169,6 +169,13 @@ void Player::Initialize() }, &xtimer_attacher); } + if (room->IsNewBieBattle()) { + #if 0 + GetAbility()->AddAttr(kHAT_vAttackRateSe, 5.0f); + GetAbility()->AddAttr(kHAT_pDefendRateSe, 2.0f); + GetAbility()->AddAttr(kHAT_vHealthRateSe, 1.0f); + #endif + } } void Player::Update(int delta_time) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index dca4ef34..fa4a0af1 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -625,7 +625,7 @@ void Room::FillSMJoinedNotify(Human* self_hum, cs::SMJoinedNotify& msg) { msg.set_team_mode(msg.team_mode()); msg.set_adjust_bullet(1); - msg.set_is_newbie_room(0); + msg.set_is_newbie_room(IsNewBieBattle()); } void Room::ScatterDrop(const glm::vec3& center, int drop_id, bool no_adjust, std::vector* items) @@ -2641,6 +2641,9 @@ long long Room::GetGasInactiveTime() if (IsNewerMap()) { inactive_time = 10; } + if (IsNewBieBattle()) { + inactive_time = 10; + } return inactive_time; } @@ -4018,6 +4021,7 @@ int Room::GetReportMapMode() void Room::GenBattleRoomReportData(a8::MutableXObject* params) { params->SetVal("version", 2023030201); + params->SetVal("is_newbie_battle", a8::XValue(IsNewBieBattle())); params->SetVal("room_uuid", a8::XValue(GetRoomUuid())); params->SetVal("room_mode", GetReportRoomMode()); params->SetVal("map_mode", GetReportMapMode()); @@ -4039,6 +4043,7 @@ void Room::GenBattleRoomReportData(a8::MutableXObject* params) void Room::GenBattleMobaReportData(a8::MutableXObject* params) { params->SetVal("version", 2023030201); + params->SetVal("is_newbie_battle", a8::XValue(IsNewBieBattle())); params->SetVal("room_uuid", a8::XValue(GetRoomUuid())); params->SetVal("room_mode", GetReportRoomMode()); params->SetVal("map_mode", GetReportMapMode()); @@ -4325,3 +4330,8 @@ void Room::MobaOver() OnGameOver(); } } + +void Room::SetNewBieBattle(int is_newbie_battle) +{ + is_newbie_battle_ = is_newbie_battle; +} diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 2b250a60..7c2b407f 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -308,7 +308,8 @@ public: long long GetMobaOvertimeRaceFrameNo () { return moba_overtime_race_frameno_; } void MobaOver(); std::shared_ptr GetBoxDrop() { return box_drop_; } - + int IsNewBieBattle() { return is_newbie_battle_; } + void SetNewBieBattle(int is_newbie_battle); std::shared_ptr GetInGameVoice() { return ingame_voice_; } private: @@ -476,6 +477,7 @@ private: std::shared_ptr ingame_voice_; std::shared_ptr box_drop_; + int is_newbie_battle_ = 0; friend class Incubator; friend class Team; diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 7d4ef5e2..27eea6b8 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -181,6 +181,9 @@ int RoomMgr::OverRoomNum() std::shared_ptr RoomMgr::GetJoinableRoom(std::shared_ptr p) { + if (p->IsNewBieBattle()) { + return nullptr; + } if (p->IsMoba()) { return nullptr; } diff --git a/server/gameserver/team.cc b/server/gameserver/team.cc index 993e5ee0..ddd25aa0 100644 --- a/server/gameserver/team.cc +++ b/server/gameserver/team.cc @@ -274,6 +274,7 @@ void Team::SendTeamBattleReport(Human* sender) void Team::GenBattleReportData(a8::MutableXObject* params) { params->SetVal("version", 2023030201); + params->SetVal("is_newbie_battle", a8::XValue(room->IsNewBieBattle())); params->SetVal("battle_uuid", a8::XValue(battle_uuid_)); params->SetVal("room_uuid", a8::XValue(room->GetRoomUuid())); params->SetVal("room_mode", room->GetReportRoomMode());