diff --git a/server/gameserver/mt/Param.h b/server/gameserver/mt/Param.h index 835a5380..27a6be1a 100644 --- a/server/gameserver/mt/Param.h +++ b/server/gameserver/mt/Param.h @@ -170,7 +170,7 @@ namespace mt std::vector spd_pun_fac_vec; int battle_hint_interval = 10; - int battle_hint_disappear = 10; + int battle_hint_duration = 10; int battle_hint_view_range = 512; int battle_hint_broadcast_range = 800; diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 1772851c..e2022550 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -2186,13 +2186,37 @@ void Human::SendViewerUiMemberUpdate(std::vector member_ids) void Human::BroadcastBattleHint() { if (room->GetFrameNo() - last_battle_hint_frameno_ >= mt::Param::s().battle_hint_interval) { - last_battle_hint_frameno_ = room->GetFrameNo(); if (last_battle_hint_uniid_ > 0) { - cs::SMDelBattleHint notify_msg; - notify_msg.set_uniid(last_battle_hint_uniid_); - SendNotifyMsg(notify_msg); + if (room->GetFrameNo() - last_battle_hint_frameno_ < + mt::Param::s().battle_hint_duration * SERVER_FRAME_RATE + 8) { + cs::SMDelBattleHint notify_msg; + notify_msg.set_uniid(last_battle_hint_uniid_); + SendNotifyMsg(notify_msg); + } last_battle_hint_uniid_ = 0; } + last_battle_hint_frameno_ = room->GetFrameNo(); + std::shared_ptr notify_msg; + room->TraversePlayerList + ( + [this, ¬ify_msg] (Player* hum) -> bool + { + if (!hum->dead) { + float distance = hum->GetPos().Distance2D2(GetPos()); + if (distance >= mt::Param::s().battle_hint_view_range && + distance <= mt::Param::s().battle_hint_broadcast_range) { + if (!notify_msg) { + last_battle_hint_uniid_ = room->AllocUniid(); + notify_msg = std::make_shared(); + notify_msg->set_uniid(last_battle_hint_uniid_); + notify_msg->set_duration(mt::Param::s().battle_hint_duration); + TypeConvert::ToPb(GetPos(), notify_msg->mutable_pos()); + } + hum->SendNotifyMsg(*notify_msg.get()); + } + } + return true; + }); } }