mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-09 01:38:20 +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:
parent
7671cc6865
commit
b967cc57d1
@ -484,6 +484,7 @@ enum GAME_MSG : unsigned short {
|
||||
GAME_MSG_LOCK_NODE_ROTATION = 1260,
|
||||
GAME_MSG_VEHICLE_SET_WHEEL_LOCK_STATE = 1273,
|
||||
GAME_MSG_NOTIFY_VEHICLE_OF_RACING_OBJECT = 1276,
|
||||
GAME_MSG_SET_NAME_BILLBOARD_STATE = 1284,
|
||||
GAME_MSG_PLAYER_REACHED_RESPAWN_CHECKPOINT = 1296,
|
||||
GAME_MSG_HANDLE_UGC_EQUIP_POST_DELETE_BASED_ON_EDIT_MODE = 1300,
|
||||
GAME_MSG_HANDLE_UGC_EQUIP_PRE_CREATE_BASED_ON_EDIT_MODE = 1301,
|
||||
@ -494,6 +495,7 @@ enum GAME_MSG : unsigned short {
|
||||
GAME_MSG_MATCH_UPDATE = 1310,
|
||||
GAME_MSG_MODULE_ASSEMBLY_DB_DATA_FOR_CLIENT = 1131,
|
||||
GAME_MSG_MODULE_ASSEMBLY_QUERY_DATA = 1132,
|
||||
GAME_MSG_SHOW_BILLBOARD_INTERACT_ICON = 1337,
|
||||
GAME_MSG_CHANGE_IDLE_FLAGS = 1338,
|
||||
GAME_MSG_VEHICLE_ADD_PASSIVE_BOOST_ACTION = 1340,
|
||||
GAME_MSG_VEHICLE_REMOVE_PASSIVE_BOOST_ACTION = 1341,
|
||||
|
@ -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!
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
@ -48,6 +48,7 @@ These commands are primarily for development and testing. The usage of many of t
|
||||
|
||||
|Command|Usage|Description|Admin Level Requirement|
|
||||
|--- |--- |--- |--- |
|
||||
|togglenameplate|`/togglenameplate`|Turns the nameplate above your head that is visible to other players off and on.|8 or if `allow_nameplate_off` is set to exactly `1` in the settings|
|
||||
|fix-stats|`/fix-stats`|Resets skills, buffs, and destroyables.||
|
||||
|join|`/join <password>`|Joins a private zone with given password.||
|
||||
|leave-zone|`/leave-zone`|If you are in an instanced zone, transfers you to the closest main world. For example, if you are in an instance of Avant Gardens Survival or the Spider Queen Battle, you are sent to Avant Gardens. If you are in the Battle of Nimbus Station, you are sent to Nimbus Station.||
|
||||
|
@ -58,3 +58,6 @@ hardcore_uscore_enemies_multiplier=2
|
||||
|
||||
# Percentage of u-score to lose on player death
|
||||
hardcore_lose_uscore_on_death_percent=10
|
||||
|
||||
# Allow civilian players the ability to turn the nameplate above their head off. Must be exactly 1 to be enabled for civilians.
|
||||
allow_nameplate_off=0
|
||||
|
Loading…
Reference in New Issue
Block a user