Combat-only enemy nameplates: the server hides the plate of mobs outside your fight
With Enemy Unit Nameplates on and Always Show Nameplates off the client shows a health bar over every hostile mob in range. The client-side CVar switch of the first version could not fix that: once combat started every nearby enemy got a bar, also one that never joined the fight. The server now decides per viewer. A player who asks for it (Player::SetCombatPlateFilter, the ForeverBots add-on's PLATES request) gets UNIT_FLAG3_FORCE_HIDE_NAMEPLATE on every attackable NPC that is in no live fight with him, his pet or a member of his group on the map. It is checked when the NPC comes into view and four times a second after, so a mob that joins the fight gets its bar and the client draws the plate and the plain name itself. Script-forced plates and player- controlled units keep what they have. A UI reload clears it; the add-on asks again on every loading screen and when either setting changes. The add-on drops the CVar switch: the filter is on by default and only asks with those two settings; /fb plates on|off|status.
This commit is contained in:
@@ -1149,6 +1149,24 @@ void HandleAltsReq(uint32 client_seq, WorldSession* sess)
|
||||
SendFields(sess, client_seq, "ALTS_RESP", fields);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// PLATES — combat-only enemy nameplates for the sender's own client (Player::SetCombatPlateFilter): NPCs outside his, his pet's or
|
||||
// his group's fight show their plain name, the ones fighting get their health bar. Any player may ask (no bot needed).
|
||||
//
|
||||
// Wire: PLATES|1 PLATES|0
|
||||
// Reply: PLATES_RESP|<1|0> (what will be in force from the player's next update)
|
||||
// ----------------------------------------------------------------------------
|
||||
void HandlePlatesReq(uint32 client_seq, WorldSession* sess, std::vector<std::string> const& fields)
|
||||
{
|
||||
Player* me = sess ? sess->GetPlayer() : nullptr;
|
||||
if (!me)
|
||||
return;
|
||||
bool const on = !fields.empty() && fields[0] == "1";
|
||||
me->SetCombatPlateFilter(on);
|
||||
TC_LOG_DEBUG("playerbot.v2", "[combat_plates] {} turns combat-only nameplates {}", me->GetName(), on ? "on" : "off");
|
||||
SendFields(sess, client_seq, "PLATES_RESP", { on ? "1" : "0" });
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// SELF — addon counterpart to `.playerbot self on|off|status`. Attaches
|
||||
// or detaches the V2 bot logic to the issuing player's OWN character. Mirrors
|
||||
@@ -1659,6 +1677,10 @@ void DispatchAssembled(WorldSession* sess, uint32 seq,
|
||||
{
|
||||
HandleAltsReq(seq, sess);
|
||||
}
|
||||
else if (mtype == "PLATES")
|
||||
{
|
||||
HandlePlatesReq(seq, sess, fields);
|
||||
}
|
||||
else if (mtype == "SUMMON")
|
||||
{
|
||||
HandleSummon(seq, sess, fields);
|
||||
@@ -1826,6 +1848,7 @@ bool OnAddonWhisper(Player* sender, Player* /*receiver*/,
|
||||
&& mtype != "LOGOUT_REQ"
|
||||
&& mtype != "SELF"
|
||||
&& mtype != "PING"
|
||||
&& mtype != "PLATES"
|
||||
&& mtype != "LFG_REQ"
|
||||
&& mtype != "POP_REQ"
|
||||
&& mtype != "ASSIGN_REQ")
|
||||
|
||||
Reference in New Issue
Block a user