From 60cb263e4d68bd748df9fdf76ec3e608136de15d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 26 May 2020 11:12:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=96=B0=E6=89=8B=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/android.ai.cc | 2 +- server/gameserver/human.cc | 14 +------------- server/gameserver/human.h | 2 ++ server/gameserver/metamgr.cc | 4 ++++ server/gameserver/metamgr.h | 3 +++ server/gameserver/player.cc | 28 ++++++++++++++++++++++++++++ server/gameserver/room.cc | 9 +++++++-- server/gameserver/room.h | 2 +- 8 files changed, 47 insertions(+), 17 deletions(-) diff --git a/server/gameserver/android.ai.cc b/server/gameserver/android.ai.cc index 4b2d9c5..4541b40 100644 --- a/server/gameserver/android.ai.cc +++ b/server/gameserver/android.ai.cc @@ -162,7 +162,7 @@ void AndroidAI::UpdateNewBieNpc() hum->move_dir.Normalize(); hum->attack_dir = hum->move_dir; if (hum->curr_weapon->weapon_idx != 0) { - hum->curr_weapon->ammo = 10; + hum->curr_weapon->ammo = MetaMgr::Instance()->newbie_first_robot_ammo; } } else if (hum->room->frame_no - hum->enable_frameno < SERVER_FRAME_RATE * 1.5) { int speed = std::max(1, (int)hum->GetSpeed()); diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index ea8e5c3..f6157cb 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -2959,18 +2959,6 @@ void Human::DropItems(Obstacle* obstacle) } else { if (normal_drop_times_ < MetaMgr::Instance()->newbie_drop.size()) { if (normal_drop_times_ == 0) { - //刷一个机器人 - room->xtimer.AddDeadLineTimerAndAttach - (0, - a8::XParams() - .SetSender(this), - [] (const a8::XParams& param) - { - Human* hum = (Human*)param.sender.GetUserData(); - hum->room->ShuaNewBieAndroid(hum); - }, - &xtimer_attacher.timer_list_ - ); } drop_id = MetaMgr::Instance()->newbie_drop[normal_drop_times_]; } @@ -3229,7 +3217,7 @@ void Human::AdjustDecHp(float old_health, float& new_health) Buff* buff = GetBuffByEffectId(kBET_NewProtect); if (buff) { if (GetHP() < GetMaxHP() * buff->meta->param1) { - new_health = std::max(GetMaxHP() * buff->meta->param1, GetMaxHP()); + new_health = std::max(GetMaxHP() * buff->meta->param1, (float)0); #ifdef DEBUG a8::UdpLog::Instance()->Debug("触发新手保护buff %d %s %s %f %f", { diff --git a/server/gameserver/human.h b/server/gameserver/human.h index d264a2c..0273359 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -19,6 +19,8 @@ enum HumanStatus HS_AlreadyLordMode = 1, HS_Disable = 2, HS_NewBieNpc = 3, + HS_AlreadyShow = 4, + HS_AlreadyEquip = 5, HS_End }; diff --git a/server/gameserver/metamgr.cc b/server/gameserver/metamgr.cc index 1f29f1e..b17146c 100755 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -184,6 +184,10 @@ public: MetaMgr::Instance()->other_fill_interval = MetaMgr::Instance()->GetSysParamAsInt("other_fill_interval", 2000); MetaMgr::Instance()->map_cell_width = MetaMgr::Instance()->GetSysParamAsInt("map_cell_width", 64 * 8); { + METAMGR_READ(newbie_first_robot_ammo, 3); + METAMGR_READ(newbie_first_robot_appeartime, 8); + METAMGR_READ(newbie_airdrop_appeartime, 6); + METAMGR_READ(level0room_shua_robot_min_time, 5); METAMGR_READ(level0room_shua_robot_max_time, 7); METAMGR_READ(level0room_shua_robot_min_num, 1); diff --git a/server/gameserver/metamgr.h b/server/gameserver/metamgr.h index b03698c..1be2677 100755 --- a/server/gameserver/metamgr.h +++ b/server/gameserver/metamgr.h @@ -71,6 +71,9 @@ class MetaMgr : public a8::Singleton std::vector newbie_drop; std::vector newbie_airdrop; int newbie_first_robot_distance = 0; + int newbie_first_robot_appeartime = 0; + int newbie_first_robot_ammo = 0; + int newbie_airdrop_appeartime = 0; std::vector newbie_buff_list; int level0room_shua_robot_min_time = 0; diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index f07fee1..5e87224 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -572,6 +572,34 @@ void Player::LootInteraction(Loot* entity) need_sync_active_player = true; SyncAroundPlayers(__FILE__, __LINE__, __func__); } + if (room->room_type == RT_NewBrid && + !a8::HasBitFlag(status, HS_AlreadyEquip)) { + a8::SetBitFlag(status, HS_AlreadyEquip); + //刷一个机器人 + 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->ShuaNewBieAndroid(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_ + ); + } } break; case EQUIP_TYPE_OLDSKIN: diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index a83f1b0..cefd0f2 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -265,6 +265,7 @@ void Room::ShowAndroid(Human* target, int num) hum->born_point = target->born_point; IncBornPointHumanNum(hum->born_point, hum); hum->SetPos(hum->born_point->RandPoint()); + a8::SetBitFlag(hum->status, HS_AlreadyShow); EnableHuman(hum); ++i; if (i >= num) { @@ -903,7 +904,9 @@ void Room::UpdateGasInactive() CombineTeam(); NotifyGameStart(); NotifyWxVoip(); - InitAirDrop(); + if (room_type != RT_NewBrid) { + InitAirDrop(); + } RoomMgr::Instance()->ActiveRoom(room_uuid); } } @@ -1761,7 +1764,9 @@ void Room::ShuaNewBieAndroid(Human* target) #endif for (auto& pair : human_hash_) { if (pair.second->entity_subtype == EST_Android && - a8::HasBitFlag(pair.second->status, HS_Disable)) { + a8::HasBitFlag(pair.second->status, HS_Disable) && + !a8::HasBitFlag(pair.second->status, HS_AlreadyShow) + ) { Android* hum = (Android*)pair.second; a8::Vec2 pos = target->GetPos(); pos.x -= MetaMgr::Instance()->newbie_first_robot_distance; diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 5e3d177..92e6729 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -121,6 +121,7 @@ public: ObstacleData* GetPermanentObstacleData(int entity_uniid); long long GetGasInactiveTime(); void ShuaNewBieAndroid(Human* target); + void InitAirDrop(); private: int AllocUniid(); @@ -135,7 +136,6 @@ private: a8::Vec2& out_pos); void MatchTeam(Human* hum); void CombineTeam(); - void InitAirDrop(); void AirDrop(int appear_time, int box_id); void AdjustAirDropPos(MetaData::MapThing* thing_meta, a8::Vec2& box_pos); void ShuaPlane();