diff --git a/zone/npc.cpp b/zone/npc.cpp index 5d180e994..c69b6499a 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -2394,6 +2394,29 @@ void NPC::DoQuestPause(Mob *other) { } +void NPC::ChangeLastName(const char* in_lastname) +{ + + EQApplicationPacket* outapp = new EQApplicationPacket(OP_GMLastName, sizeof(GMLastName_Struct)); + GMLastName_Struct* gmn = (GMLastName_Struct*)outapp->pBuffer; + strcpy(gmn->name, GetName()); + strcpy(gmn->gmname, GetName()); + strcpy(gmn->lastname, in_lastname); + gmn->unknown[0]=1; + gmn->unknown[1]=1; + gmn->unknown[2]=1; + gmn->unknown[3]=1; + entity_list.QueueClients(this, outapp, false); + safe_delete(outapp); +} + +void NPC::ClearLastName() +{ + std::string WT; + WT = '\0'; //Clear Last Name + ChangeLastName( WT.c_str()); +} + void NPC::DepopSwarmPets() { if (GetSwarmInfo()) { diff --git a/zone/npc.h b/zone/npc.h index ee3dedf62..8fb80e2a2 100644 --- a/zone/npc.h +++ b/zone/npc.h @@ -361,6 +361,9 @@ public: const bool IsUnderwaterOnly() const { return NPCTypedata->underwater; } const char* GetRawNPCTypeName() const { return NPCTypedata->name; } + void ChangeLastName(const char* in_lastname); + void ClearLastName(); + bool GetDepop() { return p_depop; } void NPCSlotTexture(uint8 slot, uint16 texture); // Sets new material values for slots diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index e2d3fcdd9..a2943d035 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -2409,6 +2409,55 @@ XS(XS_NPC_AddDefensiveProc) { XSRETURN_EMPTY; } +XS(XS_NPC_ChangeLastName); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NPC_ChangeLastName) +{ + dXSARGS; + if (items < 1 || items > 2) + Perl_croak(aTHX_ "Usage: Mob::ChangeLastName(THIS, name)"); + { + NPC * THIS; + char * name = nullptr; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(NPC *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + if (items > 1) { name = (char *)SvPV_nolen(ST(1)); } + + THIS->ChangeLastName(name); + } + XSRETURN_EMPTY; +} + +XS(XS_NPC_ClearLastName); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NPC_ClearLastName) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: Mob::ClearLastName(THIS)"); + { + NPC * THIS; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(NPC *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + THIS->ClearLastName(); + } + XSRETURN_EMPTY; +} + #ifdef __cplusplus extern "C" #endif @@ -2517,6 +2566,8 @@ XS(boot_NPC) newXSproto(strcpy(buf, "AddMeleeProc"), XS_NPC_AddMeleeProc, file, "$$$"); newXSproto(strcpy(buf, "AddRangedProc"), XS_NPC_AddRangedProc, file, "$$$"); newXSproto(strcpy(buf, "AddDefensiveProc"), XS_NPC_AddDefensiveProc, file, "$$$"); + newXSproto(strcpy(buf, "ChangeLastName"), XS_NPC_ChangeLastName, file, "$:$"); + newXSproto(strcpy(buf, "ClearLastName"), XS_NPC_ClearLastName, file, "$"); XSRETURN_YES; }