Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3914,3 +3914,13 @@ Added: 'H' shortcut for variables to get the value as hexadecimal.

13-10-2024, Jhobean
- Added: @PetRelease trigger work like @petdesert and return 1 to prevent the pet from being released.

- Added: @DisplayName give possibility to change the name other player see on the paperdoll and on status bar. Could be use on RP server where unknow person don't know your name before presentation.
Since the name is use at many place, this trigger happen on 3 differents place in the source.
src.: The player requesting to view the name on the paperdoll or status
i: The player stalked by the src.
ARGS (R/W): The name to display
ARGN (R): Tell if trigger is launch on 1:Paperdoll 2:Status 3: Tooltip
RETURN 1 : Change the name to the new value of ARGS


1 change: 1 addition & 0 deletions src/game/CObjBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,7 @@ enum CTRIG_TYPE : short
CTRIG_DelMulti, // Delete the given multi to the CMultiStorage of this char (player).
CTRIG_Destroy, // I am nearly destroyed.
CTRIG_Dismount, // I'm dismounting.
CTRIG_DisplayName, // Paperdoll and status is sent and I can change the display name
CTRIG_Drink, // I'm drinking something.
CTRIG_DYE,
CTRIG_Eat, // I'm eating something.
Expand Down
1 change: 1 addition & 0 deletions src/game/chars/CChar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ lpctstr const CChar::sm_szTrigName[CTRIG_QTY+1] = // static
"@DelMulti", // Removing a multi to the MultiStorage,
"@Destroy", //+I am nearly destroyed
"@Dismount", // I am trying to get rid of my ride right now
"@DisplayName", // Name Show on the paperdoll and status bar
"@Drink", // I am drinking something.
"@Dye", // My color has been changed
"@Eat",
Expand Down
27 changes: 23 additions & 4 deletions src/game/clients/CClientMsg_AOSTooltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ bool CClient::addAOSTooltip(CObjBase * pObj, bool fRequested, bool fShop)

if (PacketPropertyList::CanSendTo(GetNetState()) == false)
return false;

// Enhanced and KR clients always need the tooltips (but they can't be enabled without FEATURE_AOS_UPDATE_B, since this has to be sent to the client via the packet 0xB9).
// Shop items use tooltips whether they're disabled or not,
// so we can just send a basic tooltip with the item name
Expand Down Expand Up @@ -68,14 +67,17 @@ bool CClient::addAOSTooltip(CObjBase * pObj, bool fRequested, bool fShop)

PacketPropertyList* propertyList = pObj->GetPropertyList();

if (propertyList == nullptr || propertyList->hasExpired(g_Cfg.m_iTooltipCache))
CItem* pItem = pObj->IsItem() ? static_cast<CItem*>(pObj) : nullptr;
CChar* pChar = pObj->IsChar() ? static_cast<CChar*>(pObj) : nullptr;

//If pChar is a client we avoid to use cache because we always generate new tooltip for player.
if ((pChar && pChar->IsClientActive()) || propertyList == nullptr || propertyList->hasExpired(g_Cfg.m_iTooltipCache))
{
pObj->m_TooltipData.clear();
pObj->FreePropertyList();

CClientTooltip* t = nullptr;
CItem *pItem = pObj->IsItem() ? static_cast<CItem *>(pObj) : nullptr;
CChar *pChar = pObj->IsChar() ? static_cast<CChar *>(pObj) : nullptr;


//DEBUG_MSG(("Preparing tooltip for 0%x (%s)\n", (dword)pObj->GetUID(), pObj->GetName()));
if (fNameOnly) // if we only want to display the name
Expand Down Expand Up @@ -246,6 +248,22 @@ void CClient::AOSTooltip_addName(CObjBase* pObj)
}
else if (pChar)
{
CChar* pClient = static_cast<CChar*>(GetChar());
if (IsTrigUsed(TRIGGER_DISPLAYNAME) && pChar->IsClientType() && (pChar != pClient)) //Avoid launch trigger if the target is the same character
{
CScriptTriggerArgs args;
args.m_s1 = pChar->GetName();
args.m_iN1 = 3;//Trigger use on tooltip

if (pChar->OnTrigger(CTRIG_DisplayName, pClient, &args) == TRIGRET_RET_TRUE)
{
/*To make it work correctly TooltipCache must be set to 0 on ini or other player will use wrong tooltip*/
/*Maybe a beter way can be done*/
PUSH_FRONT_TOOLTIP(pChar, new CClientTooltip(1070722, args.m_s1)); // ~1_NOTHING~
return; //Avoid to show the prefix and suffix. Show only the name you want
}
}

lpctstr lpPrefix = pChar->GetKeyStr("NAME.PREFIX");

if (!*lpPrefix)
Expand All @@ -254,6 +272,7 @@ void CClient::AOSTooltip_addName(CObjBase* pObj)
if (!*lpPrefix)
lpPrefix = " ";


tchar * lpSuffix = Str_GetTemp();
Str_CopyLimitNull(lpSuffix, pChar->GetKeyStr("NAME.SUFFIX"), Str_TempLength());

Expand Down
59 changes: 52 additions & 7 deletions src/network/send.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "../game/uo_files/uofiles_enums_creid.h"
#include "../game/CServer.h"
#include "../game/CWorldGameTime.h"
#include "../game/triggers.h"
#include "CNetworkManager.h"
#include "send.h"

Expand Down Expand Up @@ -127,22 +128,45 @@ PacketCombatDamage::PacketCombatDamage(const CClient* target, word damage, CUID
*
*
***************************************************************************/
PacketObjectStatus::PacketObjectStatus(const CClient* target, CObjBase* object) : PacketSend(XCMD_Status, 7, g_Cfg.m_fUsePacketPriorities? PRI_LOW : PRI_NORMAL)
PacketObjectStatus::PacketObjectStatus(CClient* target, CObjBase* object) : PacketSend(XCMD_Status, 7, g_Cfg.m_fUsePacketPriorities? PRI_LOW : PRI_NORMAL)
{
ADDTOCALLSTACK("PacketObjectStatus::PacketObjectStatus");
ASSERT(object);

const CNetState * state = target->GetNetState();
const CChar *character = target->GetChar();
CChar *objectChar = object->IsChar() ? static_cast<CChar *>(object) : nullptr;

CChar *character = target->GetChar();
CChar *objectChar = object->IsChar() ? static_cast<CChar *>(object) : nullptr;

bool fCanRename = false;

byte version = 0;

initLength();

writeInt32(object->GetUID());
writeStringFixedASCII(object->GetName(), 30);

bool bCustomName=0;
CSString sShowName;
if (objectChar != nullptr &&
objectChar->IsClientType() &&
IsTrigUsed(TRIGGER_DISPLAYNAME) &&
(objectChar != character)) //Avoid launch trigger if the target is the same character
{
CScriptTriggerArgs args;
args.m_s1 = object->GetName();
args.m_iN1 =2;//Trigger use on status

if (objectChar->OnTrigger(CTRIG_DisplayName, character, &args) == TRIGRET_RET_TRUE)
{
bCustomName = 1;
sShowName = args.m_s1;
}
}
if (bCustomName)
writeStringFixedASCII(sShowName, 30);
else
writeStringFixedASCII(object->GetName(), 30);

if (state->isClientVersionNumber(MINCLIVER_STATUS_V6))
version = 6;
Expand Down Expand Up @@ -2604,7 +2628,7 @@ PacketCharacterListUpdate::PacketCharacterListUpdate(CClient* target, const CCha
*
*
***************************************************************************/
PacketPaperdoll::PacketPaperdoll(const CClient* target, const CChar* character) : PacketSend(XCMD_PaperDoll, 66, g_Cfg.m_fUsePacketPriorities? PRI_LOW : PRI_NORMAL)
PacketPaperdoll::PacketPaperdoll(const CClient* target, CChar* character) : PacketSend(XCMD_PaperDoll, 66, g_Cfg.m_fUsePacketPriorities? PRI_LOW : PRI_NORMAL)
{
ADDTOCALLSTACK("PacketPaperdoll::PacketPaperdoll");

Expand All @@ -2619,15 +2643,35 @@ PacketPaperdoll::PacketPaperdoll(const CClient* target, const CChar* character)

writeInt32(character->GetUID());

bool bCustomName = 0;
CSString sShowName;


if (IsTrigUsed(TRIGGER_DISPLAYNAME) && (target->GetChar() != character)) //Avoid launch trigger if the target is the same character
{
CScriptTriggerArgs args;
args.m_s1 = character->GetName();
args.m_iN1 = 1;//Trigger use on paperdoll
if (character->OnTrigger(CTRIG_DisplayName, target->GetChar(), &args) == TRIGRET_RET_TRUE)
{
bCustomName = 1;
sShowName = args.m_s1;
}
}

if (character->IsStatFlag(STATF_INCOGNITO))
{
writeStringFixedASCII(character->GetName(), 60);
}
}
else if (bCustomName)
{
writeStringFixedASCII(sShowName, 60);
}
else
{
tchar* text = Str_GetTemp();
int len = 0;

int len = 0;
const CStoneMember* guildMember = character->Guild_FindMember(MEMORY_GUILD);
if (guildMember != nullptr && guildMember->IsAbbrevOn() && guildMember->GetParentStone()->GetAbbrev()[0])
{
Expand All @@ -2651,6 +2695,7 @@ PacketPaperdoll::PacketPaperdoll(const CClient* target, const CChar* character)
}

writeByte((byte)mode);

push(target);
}

Expand Down
4 changes: 2 additions & 2 deletions src/network/send.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class PacketCombatDamage : public PacketSend
class PacketObjectStatus : public PacketSend
{
public:
PacketObjectStatus(const CClient* target, CObjBase* object);
PacketObjectStatus(CClient* target, CObjBase* object);

private:
void WriteVersionSpecific(const CClient* target, CChar* other, byte version);
Expand Down Expand Up @@ -948,7 +948,7 @@ class PacketCharacterListUpdate : public PacketSend
class PacketPaperdoll : public PacketSend
{
public:
PacketPaperdoll(const CClient* target, const CChar* character);
PacketPaperdoll(const CClient* target, CChar* character);
};

/***************************************************************************
Expand Down
1 change: 1 addition & 0 deletions src/tables/triggers.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ ADD(DELREDCANDLE)
ADD(DELWHITECANDLE)
ADD(DESTROY)
ADD(DISMOUNT)
ADD(DISPLAYNAME)
ADD(DRINK)
ADD(DROPON_CHAR)
ADD(DROPON_GROUND)
Expand Down