mirror of
https://github.com/EQEmu/Server.git
synced 2026-08-29 16:58:02 +00:00
[Rules] Add rule to restrict hand in of quest items to quest flagged NPCs. (#3536)
* Add rule to restrict handin of quest items to quest flagged npcs * Minor format tweak * Formatting
This commit is contained in:
+28
-10
@@ -776,24 +776,32 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
|
||||
const EQ::ItemData* item = inst->GetItem();
|
||||
const bool is_pet = _CLIENTPET(tradingWith) && tradingWith->GetPetType()<=petOther;
|
||||
const bool is_quest_npc = tradingWith->CastToNPC()->IsQuestNPC();
|
||||
const bool restrict_quest_items_to_quest_npc = RuleB(NPC, ReturnQuestItemsFromNonQuestNPCs);
|
||||
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() ||
|
||||
(!restrict_quest_items_to_quest_npc || (is_quest_npc && item->IsQuestItem()) || !item->IsQuestItem()) && // If rule is enabled, return any quest items given to non-quest NPCs
|
||||
(((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);
|
||||
const EQ::ItemInstance *baginst = inst->GetItem(bslot);
|
||||
if (baginst) {
|
||||
const EQ::ItemData* bagitem = baginst->GetItem();
|
||||
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)))) {
|
||||
const EQ::ItemData *bagitem = baginst->GetItem();
|
||||
if (bagitem && (GetGM() ||
|
||||
(!restrict_quest_items_to_quest_npc ||
|
||||
(is_quest_npc && bagitem->IsQuestItem()) || !bagitem->IsQuestItem()) &&
|
||||
// If rule is enabled, return any quest items given to non-quest NPCs (inside bags)
|
||||
(bagitem->NoDrop != 0 && !baginst->IsAttuned()) &&
|
||||
((is_pet && (!bagitem->IsQuestItem() || pets_can_take_quest_items) ||
|
||||
!is_pet)))) {
|
||||
|
||||
auto loot_drop_entry = NPC::NewLootDropEntry();
|
||||
loot_drop_entry.equip_item = 1;
|
||||
loot_drop_entry.equip_item = 1;
|
||||
loot_drop_entry.item_charges = static_cast<int8>(baginst->GetCharges());
|
||||
|
||||
tradingWith->CastToNPC()->AddLootDrop(
|
||||
@@ -802,13 +810,17 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
loot_drop_entry,
|
||||
true
|
||||
);
|
||||
}
|
||||
else if (is_pet && bagitem->IsQuestItem()) {
|
||||
// Return quest items being traded to non-quest NPC when the rule is true
|
||||
} else if (restrict_quest_items_to_quest_npc && (!is_quest_npc && bagitem->IsQuestItem())) {
|
||||
tradingWith->SayString(TRADE_BACK, GetCleanName());
|
||||
PushItemOnCursor(*baginst, true);
|
||||
Message(Chat::Red, "You can only trade quest items to quest NPCs.");
|
||||
// Return quest items being traded to player pet when not allowed
|
||||
} else if (is_pet && bagitem->IsQuestItem() && !pets_can_take_quest_items) {
|
||||
tradingWith->SayString(TRADE_BACK, GetCleanName());
|
||||
PushItemOnCursor(*baginst, true);
|
||||
Message(Chat::Red, "You cannot trade quest items with your pet.");
|
||||
}
|
||||
else if (RuleB(NPC, ReturnNonQuestNoDropItems)) {
|
||||
} else if (RuleB(NPC, ReturnNonQuestNoDropItems)) {
|
||||
tradingWith->SayString(TRADE_BACK, GetCleanName());
|
||||
PushItemOnCursor(*baginst, true);
|
||||
}
|
||||
@@ -817,7 +829,7 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
}
|
||||
|
||||
auto new_loot_drop_entry = NPC::NewLootDropEntry();
|
||||
new_loot_drop_entry.equip_item = 1;
|
||||
new_loot_drop_entry.equip_item = 1;
|
||||
new_loot_drop_entry.item_charges = static_cast<int8>(inst->GetCharges());
|
||||
|
||||
tradingWith->CastToNPC()->AddLootDrop(
|
||||
@@ -827,6 +839,12 @@ void Client::FinishTrade(Mob* tradingWith, bool finalizer, void* event_entry, st
|
||||
true
|
||||
);
|
||||
}
|
||||
// Return quest items being traded to non-quest NPC when the rule is true
|
||||
else if (restrict_quest_items_to_quest_npc && (!is_quest_npc && item->IsQuestItem())) {
|
||||
tradingWith->SayString(TRADE_BACK, GetCleanName());
|
||||
PushItemOnCursor(*inst, true);
|
||||
Message(Chat::Red, "You can only trade quest items to quest NPCs.");
|
||||
}
|
||||
// Return quest items being traded to player pet when not allowed
|
||||
else if (is_pet && item->IsQuestItem()) {
|
||||
tradingWith->SayString(TRADE_BACK, GetCleanName());
|
||||
|
||||
Reference in New Issue
Block a user