[Rules] Add rule to toggle pets accepting quest items (#3533)

* Add rule to disable handing quests items to pets

* Logic tweak

* Tweaks

Updated formatting and minor logic change

* Minor tweaks
This commit is contained in:
Vayle 2023-08-06 15:32:25 -04:00 committed by GitHub
parent aa6421afdf
commit 3a46bf7383
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 9 deletions

View File

@ -230,6 +230,10 @@ bool EQ::ItemData::IsTypeShield() const
return (ItemType == item::ItemTypeShield);
}
bool EQ::ItemData::IsQuestItem() const {
return QuestItemFlag;
}
bool EQ::ItemData::CheckLoreConflict(const ItemData* l_item, const ItemData* r_item)
{
if (!l_item || !r_item)

View File

@ -546,6 +546,7 @@ namespace EQ
bool IsType1HWeapon() const;
bool IsType2HWeapon() const;
bool IsTypeShield() const;
bool IsQuestItem() const;
static bool CheckLoreConflict(const ItemData* l_item, const ItemData* r_item);
bool CheckLoreConflict(const ItemData* item) const { return CheckLoreConflict(this, item); }

View File

@ -256,6 +256,7 @@ RULE_REAL(Pets, AttackCommandRange, 150, "Range at which a pet will respond to a
RULE_BOOL(Pets, UnTargetableSwarmPet, false, "Setting whether swarm pets should be targetable")
RULE_REAL(Pets, PetPowerLevelCap, 10, "Maximum number of levels a player pet can go up with pet power")
RULE_BOOL(Pets, CanTakeNoDrop, false, "Setting whether anyone can give no-drop items to pets")
RULE_BOOL(Pets, CanTakeQuestItems, true, "Setting whether anyone can give quest items to pets")
RULE_BOOL(Pets, LivelikeBreakCharmOnInvis, true, "Default: true will break charm on any type of invis (hide/ivu/iva/etc) false will only break if the pet can not see you (ex. you have an undead pet and cast IVU")
RULE_BOOL(Pets, ClientPetsUseOwnerNameInLastName, true, "Disable this to keep client pet's last names from being owner_name's pet")
RULE_CATEGORY_END()

View File

@ -72,10 +72,11 @@ void Trade::Start(uint32 mob_id, bool initiate_with)
// Autostart on other mob?
if (initiate_with) {
Mob *with = With();
if (with)
if (with) {
with->trade->Start(owner->GetID(), false);
}
}
}
// Add item from a given slot to trade bucket (automatically does bag data too)
void Trade::AddEntity(uint16 trade_slot_id, uint32 stack_size) {
@ -774,20 +775,22 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
}
const EQ::ItemData* item = inst->GetItem();
bool isPetAndCanHaveNoDrop = (RuleB(Pets, CanTakeNoDrop) &&
_CLIENTPET(tradingWith) &&
tradingWith->GetPetType()<=petOther);
const bool is_pet = _CLIENTPET(tradingWith) && tradingWith->GetPetType()<=petOther;
const bool pets_can_take_quest_items = RuleB(Pets, CanTakeQuestItems);
const bool is_pet_and_can_have_nodrop_items = (RuleB(Pets, CanTakeNoDrop) && is_pet);
const bool is_pet_and_can_have_quest_items = (pets_can_take_quest_items && is_pet);
// if it was not a NO DROP or Attuned item (or if a GM is trading), let the NPC have it
if(GetGM() || (inst->IsAttuned() == false &&
(item->NoDrop != 0 || isPetAndCanHaveNoDrop))) {
if (GetGM() ||
(((item->NoDrop != 0 && !inst->IsAttuned()) || is_pet_and_can_have_nodrop_items) &&
((!item->IsQuestItem() || is_pet_and_can_have_quest_items || !is_pet)))) {
// pets need to look inside bags and try to equip items found there
if (item->IsClassBag() && item->BagSlots > 0) {
for (int16 bslot = EQ::invbag::SLOT_BEGIN; bslot < item->BagSlots; bslot++) {
const EQ::ItemInstance* baginst = inst->GetItem(bslot);
if (baginst) {
const EQ::ItemData* bagitem = baginst->GetItem();
if (bagitem && (GetGM() || (bagitem->NoDrop != 0 && baginst->IsAttuned() == false))) {
if (bagitem && (GetGM() || ((bagitem->NoDrop != 0 && !baginst->IsAttuned()) || is_pet_and_can_have_nodrop_items) &&
((!bagitem->IsQuestItem()|| is_pet_and_can_have_quest_items || !is_pet)))) {
auto loot_drop_entry = NPC::NewLootDropEntry();
loot_drop_entry.equip_item = 1;
@ -800,6 +803,11 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
true
);
}
else if (is_pet && bagitem->IsQuestItem()) {
tradingWith->SayString(TRADE_BACK, GetCleanName());
PushItemOnCursor(*baginst, true);
Message(Chat::Red, "You cannot trade quest items with your pet.");
}
else if (RuleB(NPC, ReturnNonQuestNoDropItems)) {
tradingWith->SayString(TRADE_BACK, GetCleanName());
PushItemOnCursor(*baginst, true);
@ -819,6 +827,12 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
true
);
}
// Return quest items being traded to player pet when not allowed
else if (is_pet && item->IsQuestItem()) {
tradingWith->SayString(TRADE_BACK, GetCleanName());
PushItemOnCursor(*inst, true);
Message(Chat::Red, "You cannot trade quest items with your pet.");
}
// Return NO DROP and Attuned items being handed into a non-quest NPC if the rule is true
else if (RuleB(NPC, ReturnNonQuestNoDropItems)) {
tradingWith->SayString(TRADE_BACK, GetCleanName());