From f64cda608d28208f5a81ea042e86efb24e10f06b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 30 Aug 2024 11:50:51 +0800 Subject: [PATCH] 1 --- server/gameserver/incubator.cc | 51 ++++++++++++++++++++++++++++++---- server/gameserver/player.cc | 2 +- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/server/gameserver/incubator.cc b/server/gameserver/incubator.cc index 5e947822..e6ae6811 100644 --- a/server/gameserver/incubator.cc +++ b/server/gameserver/incubator.cc @@ -54,7 +54,7 @@ void Incubator::Init() if (room->IsNewBieBattle()) { room->xtimer.SetTimeoutEx ( - SERVER_FRAME_RATE * (50), + SERVER_FRAME_RATE * (60), [this] (int event, const a8::Args* args) { if (a8::TIMER_EXEC_EVENT == event) { @@ -152,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)) { @@ -281,7 +282,7 @@ void Incubator::AutoAllocAndroid() if (!hold_humans_.empty() && hold_humans_.size() > 0) { int rnd_space = 70; if (room->IsNewBieBattle()) { - rnd_space = 0; + rnd_space = 20; } Human* hum = hold_humans_[0]; if (room->GetGasData().GetGasMode() == GasWaiting && @@ -308,7 +309,9 @@ void Incubator::AutoAllocAndroid() return; } hold_humans_.erase(hold_humans_.begin()); - if (!room->IsNewBieBattle()) { + 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)); } } @@ -671,12 +674,15 @@ void Incubator::StartNewBattleMode() 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 * (4 + rand() % 3), - [this, selected_player, invisable_humans, invisable_teammates] (int event, const a8::Args* args) + 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()) { @@ -686,7 +692,8 @@ void Incubator::StartNewBattleMode() invisable_teammates->clear(); room->TraverseAliveHumanList ( - [this, selected_player, invisable_humans, invisable_teammates] (Human* hum) -> bool + [this, selected_player, invisable_humans, invisable_teammates, startno] + (Human* hum) -> bool { if (hum == selected_player) { return true; @@ -700,6 +707,38 @@ void Incubator::StartNewBattleMode() } 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(), diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index a1aefaaf..c2a417a0 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -172,7 +172,7 @@ void Player::Initialize() if (room->IsNewBieBattle()) { GetAbility()->AddAttr(kHAT_vAttackRateSe, 5.0f); GetAbility()->AddAttr(kHAT_pDefendRateSe, 2.0f); - GetAbility()->AddAttr(kHAT_vHealthRateSe, 2.0f); + GetAbility()->AddAttr(kHAT_vHealthRateSe, 3.0f); } }