mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
Allow name billboards to be toggled (#1026)
* Allow name billboards to be toggled * Allow name billboards to be toggled * Add comments * Move logic to Character * Use Entity in Character instead
This commit is contained in:
@@ -621,3 +621,21 @@ void Character::SendMuteNotice() const {
|
||||
|
||||
ChatPackets::SendSystemMessage(GetEntity()->GetSystemAddress(), u"You are muted until " + timeStr);
|
||||
}
|
||||
|
||||
void Character::SetBillboardVisible(bool visible) {
|
||||
if (m_BillboardVisible == visible) return;
|
||||
m_BillboardVisible = visible;
|
||||
|
||||
GameMessages::SendSetNamebillboardState(UNASSIGNED_SYSTEM_ADDRESS, m_OurEntity->GetObjectID());
|
||||
|
||||
if (!visible) return;
|
||||
|
||||
// The GameMessage we send for turning the nameplate off just deletes the BillboardSubcomponent from the parent component.
|
||||
// Because that same message does not allow for custom parameters, we need to create the BillboardSubcomponent a different way
|
||||
// This workaround involves sending an unrelated GameMessage that does not apply to player entites,
|
||||
// but forces the client to create the necessary SubComponent that controls the billboard.
|
||||
GameMessages::SendShowBillboardInteractIcon(UNASSIGNED_SYSTEM_ADDRESS, m_OurEntity->GetObjectID());
|
||||
|
||||
// Now turn off the billboard for the owner.
|
||||
GameMessages::SendSetNamebillboardState(m_OurEntity->GetSystemAddress(), m_OurEntity->GetObjectID());
|
||||
}
|
||||
|
@@ -451,6 +451,10 @@ public:
|
||||
*/
|
||||
void SetIsFlying(bool isFlying) { m_IsFlying = isFlying; }
|
||||
|
||||
bool GetBillboardVisible() { return m_BillboardVisible; }
|
||||
|
||||
void SetBillboardVisible(bool visible);
|
||||
|
||||
private:
|
||||
/**
|
||||
* The ID of this character. First 32 bits of the ObjectID.
|
||||
@@ -652,6 +656,11 @@ private:
|
||||
*/
|
||||
bool m_IsFlying = false;
|
||||
|
||||
/**
|
||||
* True if billboard (referred to as nameplate for end users) is visible, false otherwise
|
||||
*/
|
||||
bool m_BillboardVisible = true;
|
||||
|
||||
/**
|
||||
* Queries the character XML and updates all the fields of this object
|
||||
* NOTE: quick as there's no DB lookups
|
||||
|
@@ -6154,3 +6154,32 @@ void GameMessages::SendDeactivateBubbleBuffFromServer(LWOOBJID objectId, const S
|
||||
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST;
|
||||
SEND_PACKET;
|
||||
}
|
||||
|
||||
void GameMessages::SendSetNamebillboardState(const SystemAddress& sysAddr, LWOOBJID objectId) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
bitStream.Write(objectId);
|
||||
bitStream.Write(GAME_MSG::GAME_MSG_SET_NAME_BILLBOARD_STATE);
|
||||
|
||||
// Technically these bits would be written, however the client does not
|
||||
// contain a deserialize method to actually deserialize, so we are leaving it out.
|
||||
// As such this GM only turns the billboard off.
|
||||
|
||||
// bitStream.Write(overrideDefault);
|
||||
// bitStream.Write(state);
|
||||
|
||||
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST
|
||||
else SEND_PACKET
|
||||
}
|
||||
|
||||
void GameMessages::SendShowBillboardInteractIcon(const SystemAddress& sysAddr, LWOOBJID objectId) {
|
||||
CBITSTREAM;
|
||||
CMSGHEADER;
|
||||
|
||||
bitStream.Write(objectId);
|
||||
bitStream.Write(GAME_MSG::GAME_MSG_SHOW_BILLBOARD_INTERACT_ICON);
|
||||
|
||||
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) SEND_PACKET_BROADCAST
|
||||
else SEND_PACKET
|
||||
}
|
||||
|
@@ -574,6 +574,8 @@ namespace GameMessages {
|
||||
void HandleToggleGhostReferenceOverride(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void HandleSetGhostReferencePosition(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
void SendSetNamebillboardState(const SystemAddress& sysAddr, LWOOBJID objectId);
|
||||
void SendShowBillboardInteractIcon(const SystemAddress& sysAddr, LWOOBJID objectId);
|
||||
void HandleBuyFromVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void HandleSellToVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
void HandleBuybackFromVendor(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
@@ -171,6 +171,19 @@ void SlashCommandHandler::HandleChatCommand(const std::u16string& command, Entit
|
||||
}
|
||||
#endif
|
||||
|
||||
if (chatCommand == "togglenameplate" && (Game::config->GetValue("allownameplateoff") == "1" || entity->GetGMLevel() > GAME_MASTER_LEVEL_DEVELOPER)) {
|
||||
auto* character = entity->GetCharacter();
|
||||
|
||||
if (character && character->GetBillboardVisible()) {
|
||||
character->SetBillboardVisible(false);
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Your nameplate has been turned off and is not visible to players currently in this zone.");
|
||||
} else {
|
||||
character->SetBillboardVisible(true);
|
||||
ChatPackets::SendSystemMessage(sysAddr, u"Your nameplate is now on and visible to all players.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//HANDLE ALL NON GM SLASH COMMANDS RIGHT HERE!
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
Reference in New Issue
Block a user