Log in

View Full Version : Changing players name color (like pvp mode)


Nibiuno
02-23-2015, 04:07 PM
Is there a way to permanently change a players name color, like what happens when you enable GM mode or enable PVP from the Priest of Discord?

I can edit the source, and tried to change the PVP function, but not sure how SendAppearancePacket functions.

Kingly_Krab
02-23-2015, 04:34 PM
Client name color is client-sided, so you would have to have a custom .dll or modify the existing .exe to do that.

Nibiuno
02-23-2015, 06:17 PM
I was hoping I could disable PVP but still set them as PVP so the name changed. I guess Ill keep trying at that for right now.

Thanks for the help

Drajor
02-23-2015, 07:19 PM
You could do that but it would require changes to combat/spell code. The red name is purely aesthetic to the client iirc.

rencro
02-24-2015, 11:33 PM
I was hoping I could disable PVP but still set them as PVP so the name changed. I guess Ill keep trying at that for right now.

Thanks for the help

Are you looking to make say all ogres red (example) or more like if this char (any race) completes epic, show name in red?

rencro
02-25-2015, 07:23 PM
Heres a quick patch to make races have a red nameplate (ala PVP mode). This code was all borrowed from a Xachary fork

url = https://github.com/Xackery/Server.git

I just removed all the pvp stuff out, and made compatible with current source.

Credits Xachary (Shin Noir?) and I believe secrets, sorry if I left any one out

Its set to have Ogres and Iksar carry a red nameplate. But other than their name being red, they are clients like any other( can group ect ect). Of course if you want them to be green instead of red its just a matter of setting the first value of SendAppearancePacket to the gm setting
#define AT_PVP 4 // 0 = blue, 1 = pvp (red)
#define AT_GM 20 // 0 = normal, 1 = GM - all odd numbers seem to make it GM

Very basic stuff. If you wanted this to be acquirable (ie, red/green nameplate via a quest), that needs a different solution.


diff --git a/zone/client.cpp b/zone/client.cpp
index 93ef853..cd78644 100644
--- a/zone/client.cpp
+++ b/zone/client.cpp
@@ -436,6 +436,9 @@ void Client::SendZoneInPackets()
if (GetPVP()) //force a PVP update until we fix the spawn struct
SendAppearancePacket(AT_PVP, GetPVP(), true, false);

+ if (IsEvil()) //Evil has a red tag
+ SendAppearancePacket(AT_PVP, IsEvil(), true, false); //rencro via xachary
+
//Send AA Exp packet:
if (GetLevel() >= 51)
SendAAStats();
diff --git a/zone/entity.cpp b/zone/entity.cpp
index b1b1394..6c96eb0 100644
--- a/zone/entity.cpp
+++ b/zone/entity.cpp
@@ -1175,6 +1175,10 @@ void EntityList::SendZonePVPUpdates(Client *to)
Client *c = it->second;
if(c->GetPVP())
c->SendAppearancePacket(AT_PVP, c->GetPVP(), true, false, to);
+
+ if (c->IsEvil()) //Evil people have red tags rencro via xachary @pvp patch
+ c->SendAppearancePacket(AT_PVP, c->IsEvil(), true, false, to);
+
++it;
}
}
diff --git a/zone/mob.cpp b/zone/mob.cpp
index 57d04f3..96e831e 100644
--- a/zone/mob.cpp
+++ b/zone/mob.cpp
@@ -452,6 +452,17 @@ uint32 Mob::GetAppearanceValue(EmuAppearance iAppearance) {
return(ANIM_STAND);
}

+
+//Returns whether mob is evil or not (Based on race) rencro via xachary @pvp patch
+bool Mob::IsEvil()
+{
+ return (
+ base_race == OGRE ||
+ base_race == IKSAR
+ );
+}
+
+
void Mob::SetInvisible(uint8 state)
{
invisible = state;
diff --git a/zone/mob.h b/zone/mob.h
index fb81487..4e824f5 100644
--- a/zone/mob.h
+++ b/zone/mob.h
@@ -429,6 +429,8 @@ public:
//Faction
virtual inline int32 GetPrimaryFaction() const { return 0; }

+ bool IsEvil(); //rencro via xachary @pvp patch
+
//Movement
void Warp(const glm::vec3& location);
inline bool IsMoving() const { return moving; }

rencro
02-25-2015, 10:04 PM
This is a sample of using perl to manipulate the nameplates, I know you wanted "permanent" but just to get an idea on the appearance packet usage.

This could be used for temporary short term changes to a players nameplate, ie, maybe they got mind controlled, diseased, whatever.

This will send an appearance packet but only people currently in the zone would see it, so if a client zones in after another client has this special appearance, they would see their "normal" appearance (green if gm, red if pvp enabled, blue else). Also, when the affected client zones, they would resume their normal appearance.


diff --git a/zone/perl_client.cpp b/zone/perl_client.cpp
index d399d76..4d96198 100644
--- a/zone/perl_client.cpp
+++ b/zone/perl_client.cpp
@@ -6110,6 +6110,47 @@ XS(XS_Client_SendSpellAnim)
XSRETURN_EMPTY;
}

+//rencro color nameplate
+XS(XS_Client_NamePlate);
+XS(XS_Client_NamePlate)
+{
+ dXSARGS;
+ if (items != 2)
+ Perl_croak(aTHX_ "Usage: Client:NamePlate(THIS, red-green-blue)");
+ {
+ Client * THIS;
+ uint8 colorX = (uint8)SvUV(ST(1)); //
+ uint32 colorY = 0; //this will be the type of appearance
+ uint32 colorZ = 0; //this will be the value
+
+ if (sv_derived_from(ST(0), "Client")) {
+ IV tmp = SvIV((SV*)SvRV(ST(0)));
+ THIS = INT2PTR(Client *,tmp);
+ }
+ else
+ Perl_croak(aTHX_ "THIS is not of type Client");
+ if(THIS == nullptr)
+ Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
+
+ if (colorX == 1) {
+ colorY = 4; //pvp
+ colorZ = 0; //blue
+ }
+ else if (colorX == 2) {
+ colorY = 4; //pvp
+ colorZ = 1; //red
+ }
+ else if (colorX == 3) {
+ colorY = 20; //gm mode
+ colorZ = 1; //green
+ }
+
+ THIS->SendAppearancePacket(colorY, colorZ, true, false);
+ }
+ XSRETURN_EMPTY;
+}
+
+
#ifdef __cplusplus
extern "C"
#endif
@@ -6351,6 +6392,7 @@ XS(boot_Client)
newXSproto(strcpy(buf, "SendMarqueeMessage"), XS_Client_SendMarqueeMessage, file, "$$$$$$$");
newXSproto(strcpy(buf, "SendColoredText"), XS_Client_SendColoredText, file, "$$$");
newXSproto(strcpy(buf, "SendSpellAnim"), XS_Client_SendSpellAnim, file, "$$$");
+ newXSproto(strcpy(buf, "NamePlate"), XS_Client_NamePlate, file, "$$");

XSRETURN_YES;
}


And the perl would be something like this


sub EVENT_SAY {
if ($text=~/hail/i) {
quest::say("Hello, to change you nameplate colors use one, two, or three.");
}
elsif ($text=~/one/i) {
quest::say("One...is Blue");
$client->NamePlate(1);
}
elsif ($text=~/two/i) {
quest::say("two...is Red");
$client->NamePlate(2);
}
elsif ($text=~/three/i) {
quest::say("Three...is Green");
$client->NamePlate(3);
}
}


Also, once you go green, it wont change back unless you zone, or you have the #gm off command done on you, even if you are not a gm, but not going to pursue it as this is just for examples, blue and red are completely interchangeable