From 0d84ede3d62e8a978f608f157145487fe7ab7ef7 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Sun, 26 Apr 2015 13:35:36 -0400 Subject: [PATCH] Allow /pet attack by mob name to work ex. /pet attack a_snake --- common/eq_packet_structs.h | 2 +- common/patches/rof.cpp | 2 +- common/patches/rof2.cpp | 2 +- common/patches/rof2_structs.h | 2 +- common/patches/rof_structs.h | 2 +- common/patches/sod.cpp | 2 +- common/patches/sod_structs.h | 2 +- common/patches/sof.cpp | 2 +- common/patches/sof_structs.h | 2 +- common/patches/titanium.cpp | 16 ++++++++-------- common/patches/titanium_structs.h | 2 +- common/patches/uf.cpp | 6 +++--- common/patches/uf_structs.h | 2 +- zone/client_packet.cpp | 17 +++++++++-------- 14 files changed, 31 insertions(+), 30 deletions(-) diff --git a/common/eq_packet_structs.h b/common/eq_packet_structs.h index 1481fce8c..8aafc0a62 100644 --- a/common/eq_packet_structs.h +++ b/common/eq_packet_structs.h @@ -1160,7 +1160,7 @@ struct TargetReject_Struct { struct PetCommand_Struct { /*000*/ uint32 command; -/*004*/ uint32 unknown; +/*004*/ uint32 target; }; /* diff --git a/common/patches/rof.cpp b/common/patches/rof.cpp index 7bb64735b..ac6301c75 100644 --- a/common/patches/rof.cpp +++ b/common/patches/rof.cpp @@ -4717,7 +4717,7 @@ namespace RoF SETUP_DIRECT_DECODE(PetCommand_Struct, structs::PetCommand_Struct); IN(command); - emu->unknown = eq->unknown04; + IN(target); FINISH_DIRECT_DECODE(); } diff --git a/common/patches/rof2.cpp b/common/patches/rof2.cpp index 06c524053..16115d881 100644 --- a/common/patches/rof2.cpp +++ b/common/patches/rof2.cpp @@ -4864,7 +4864,7 @@ namespace RoF2 SETUP_DIRECT_DECODE(PetCommand_Struct, structs::PetCommand_Struct); IN(command); - emu->unknown = eq->unknown04; + IN(target); FINISH_DIRECT_DECODE(); } diff --git a/common/patches/rof2_structs.h b/common/patches/rof2_structs.h index 21681df5e..4034e359a 100644 --- a/common/patches/rof2_structs.h +++ b/common/patches/rof2_structs.h @@ -1293,7 +1293,7 @@ struct TargetReject_Struct { struct PetCommand_Struct { /*00*/ uint32 command; -/*04*/ uint32 unknown04; +/*04*/ uint32 target; /*08*/ uint32 unknown08; }; diff --git a/common/patches/rof_structs.h b/common/patches/rof_structs.h index 622305833..344d0e386 100644 --- a/common/patches/rof_structs.h +++ b/common/patches/rof_structs.h @@ -1323,7 +1323,7 @@ struct TargetReject_Struct { struct PetCommand_Struct { /*00*/ uint32 command; -/*04*/ uint32 unknown04; +/*04*/ uint32 target; /*08*/ uint32 unknown08; }; diff --git a/common/patches/sod.cpp b/common/patches/sod.cpp index adf4ec06f..88e52a70a 100644 --- a/common/patches/sod.cpp +++ b/common/patches/sod.cpp @@ -3349,7 +3349,7 @@ namespace SoD default: emu->command = eq->command; } - OUT(unknown); + IN(target); FINISH_DIRECT_DECODE(); } diff --git a/common/patches/sod_structs.h b/common/patches/sod_structs.h index 55730423b..8ccb58937 100644 --- a/common/patches/sod_structs.h +++ b/common/patches/sod_structs.h @@ -1091,7 +1091,7 @@ struct TargetReject_Struct { struct PetCommand_Struct { /*000*/ uint32 command; -/*004*/ uint32 unknown; +/*004*/ uint32 target; }; /* diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index a7553e7f9..42ebeb392 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -2687,7 +2687,7 @@ namespace SoF default: emu->command = eq->command; } - OUT(unknown); + IN(target); FINISH_DIRECT_DECODE(); } diff --git a/common/patches/sof_structs.h b/common/patches/sof_structs.h index fff207893..c969c4b56 100644 --- a/common/patches/sof_structs.h +++ b/common/patches/sof_structs.h @@ -1068,7 +1068,7 @@ struct TargetReject_Struct { struct PetCommand_Struct { /*000*/ uint32 command; -/*004*/ uint32 unknown; +/*004*/ uint32 target; }; /* diff --git a/common/patches/titanium.cpp b/common/patches/titanium.cpp index c8eeea36a..beb338431 100644 --- a/common/patches/titanium.cpp +++ b/common/patches/titanium.cpp @@ -122,7 +122,7 @@ namespace Titanium EAT_ENCODE(OP_GuildMemberLevelUpdate); // added ; EAT_ENCODE(OP_ZoneServerReady); // added ; - + ENCODE(OP_Action) { ENCODE_LENGTH_EXACT(Action_Struct); @@ -326,7 +326,7 @@ namespace Titanium { SETUP_VAR_ENCODE(ExpeditionCompass_Struct); ALLOC_VAR_ENCODE(structs::ExpeditionCompass_Struct, sizeof(structs::ExpeditionInfo_Struct) + sizeof(structs::ExpeditionCompassEntry_Struct) * emu->count); - + OUT(count); for (uint32 i = 0; i < emu->count; ++i) @@ -1308,7 +1308,7 @@ namespace Titanium VARSTRUCT_ENCODE_TYPE(uint8, OutBuffer, emu->unknown12[11]); VARSTRUCT_ENCODE_STRING(OutBuffer, new_message.c_str()); - + delete[] __emu_buffer; dest->FastQueuePacket(&in, ack_req); } @@ -1351,7 +1351,7 @@ namespace Titanium InBuffer += strlen(InBuffer) + 1; memcpy(OutBuffer, InBuffer, sizeof(TaskDescriptionTrailer_Struct)); - + delete[] __emu_buffer; dest->FastQueuePacket(&in, ack_req); } @@ -1621,7 +1621,7 @@ namespace Titanium FINISH_DIRECT_DECODE(); } - + DECODE(OP_ApplyPoison) { DECODE_LENGTH_EXACT(structs::ApplyPoison_Struct); @@ -1942,7 +1942,7 @@ namespace Titanium default: emu->command = eq->command; } - OUT(unknown); + IN(target); FINISH_DIRECT_DECODE(); } @@ -2151,7 +2151,7 @@ namespace Titanium return serverSlot; // deprecated } - + static inline int16 ServerToTitaniumCorpseSlot(uint32 serverCorpseSlot) { //int16 TitaniumCorpse; @@ -2166,7 +2166,7 @@ namespace Titanium return titaniumSlot; // deprecated } - + static inline uint32 TitaniumToServerCorpseSlot(int16 titaniumCorpseSlot) { //uint32 ServerCorpse; diff --git a/common/patches/titanium_structs.h b/common/patches/titanium_structs.h index 5ad997d5b..12042ed31 100644 --- a/common/patches/titanium_structs.h +++ b/common/patches/titanium_structs.h @@ -950,7 +950,7 @@ struct TargetReject_Struct { struct PetCommand_Struct { /*000*/ uint32 command; -/*004*/ uint32 unknown; +/*004*/ uint32 target; }; /* diff --git a/common/patches/uf.cpp b/common/patches/uf.cpp index aafef5896..038dcf548 100644 --- a/common/patches/uf.cpp +++ b/common/patches/uf.cpp @@ -2213,7 +2213,7 @@ namespace UF FINISH_ENCODE(); return; } - + unsigned char *emu_ptr = __emu_buffer; emu_ptr += sizeof(CharacterSelect_Struct); CharacterSelectEntry_Struct *emu_cse = (CharacterSelectEntry_Struct *)nullptr; @@ -3599,7 +3599,7 @@ namespace UF SETUP_DIRECT_DECODE(PetCommand_Struct, structs::PetCommand_Struct); IN(command); - IN(unknown); + IN(target); FINISH_DIRECT_DECODE(); } @@ -3861,7 +3861,7 @@ namespace UF UF::structs::ItemSerializationHeaderFinish hdrf; hdrf.ornamentIcon = ornaIcon; - hdrf.unknown060 = 0; //This is Always 0.. or it breaks shit.. + hdrf.unknown060 = 0; //This is Always 0.. or it breaks shit.. hdrf.unknown061 = 0; //possibly ornament / special ornament hdrf.isCopied = 0; //Flag for item to be 'Copied' hdrf.ItemClass = item->ItemClass; diff --git a/common/patches/uf_structs.h b/common/patches/uf_structs.h index a82bfc4e3..b39bc5b19 100644 --- a/common/patches/uf_structs.h +++ b/common/patches/uf_structs.h @@ -1146,7 +1146,7 @@ struct TargetReject_Struct { struct PetCommand_Struct { /*000*/ uint32 command; -/*004*/ uint32 unknown; +/*004*/ uint32 target; }; /* diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 201b0d13e..12b16610e 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -9752,6 +9752,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) char val1[20] = { 0 }; PetCommand_Struct* pet = (PetCommand_Struct*)app->pBuffer; Mob* mypet = this->GetPet(); + Mob *target = entity_list.GetMob(pet->target); if (!mypet || pet->command == PET_LEADER) { @@ -9799,22 +9800,22 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) switch (PetCommand) { case PET_ATTACK: { - if (!GetTarget()) + if (!target) break; - if (GetTarget()->IsMezzed()) { - Message_StringID(10, CANNOT_WAKE, mypet->GetCleanName(), GetTarget()->GetCleanName()); + if (target->IsMezzed()) { + Message_StringID(10, CANNOT_WAKE, mypet->GetCleanName(), target->GetCleanName()); break; } if (mypet->IsFeared()) break; //prevent pet from attacking stuff while feared - if (!mypet->IsAttackAllowed(GetTarget())) { + if (!mypet->IsAttackAllowed(target)) { mypet->Say_StringID(NOT_LEGAL_TARGET); break; } if ((mypet->GetPetType() == petAnimation && GetAA(aaAnimationEmpathy) >= 2) || mypet->GetPetType() != petAnimation) { - if (GetTarget() != this && DistanceSquaredNoZ(mypet->GetPosition(), GetTarget()->GetPosition()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) { + if (target != this && DistanceSquaredNoZ(mypet->GetPosition(), target->GetPosition()) <= (RuleR(Pets, AttackCommandRange)*RuleR(Pets, AttackCommandRange))) { if (mypet->IsHeld()) { if (!mypet->IsFocused()) { mypet->SetHeld(false); //break the hold and guard if we explicitly tell the pet to attack. @@ -9822,12 +9823,12 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app) mypet->SetPetOrder(SPO_Follow); } else { - mypet->SetTarget(GetTarget()); + mypet->SetTarget(target); } } zone->AddAggroMob(); - mypet->AddToHateList(GetTarget(), 1); - Message_StringID(MT_PetResponse, PET_ATTACKING, mypet->GetCleanName(), GetTarget()->GetCleanName()); + mypet->AddToHateList(target, 1); + Message_StringID(MT_PetResponse, PET_ATTACKING, mypet->GetCleanName(), target->GetCleanName()); } } break;