diff --git a/data/sql/db-world/base/recycleditems_0000_00_00_00.sql b/data/sql/db-world/base/recycleditems_0000_00_00_00.sql index bac6e99..bd94bb4 100644 --- a/data/sql/db-world/base/recycleditems_0000_00_00_00.sql +++ b/data/sql/db-world/base/recycleditems_0000_00_00_00.sql @@ -7,3 +7,9 @@ INSERT INTO `npc_text` (`ID`, `text0_0`, `text0_1`, `BroadcastTextID0`, `lang0`, DELETE FROM `item_template` WHERE `entry`=999888; INSERT INTO `item_template` (`entry`, `class`, `subclass`, `SoundOverrideSubclass`, `name`, `displayid`, `Quality`, `Flags`, `FlagsExtra`, `BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace`, `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell`, `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank`, `maxcount`, `stackable`, `ContainerSlots`, `StatsCount`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`, `stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`, `stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`, `ScalingStatDistribution`, `ScalingStatValue`, `dmg_min1`, `dmg_max1`, `dmg_type1`, `dmg_min2`, `dmg_max2`, `dmg_type2`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial`, `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `block`, `itemset`, `MaxDurability`, `area`, `Map`, `BagFamily`, `TotemCategory`, `socketColor_1`, `socketContent_1`, `socketColor_2`, `socketContent_2`, `socketColor_3`, `socketContent_3`, `socketBonus`, `GemProperties`, `RequiredDisenchantSkill`, `ArmorDamageModifier`, `duration`, `ItemLimitCategory`, `HolidayId`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`, `flagsCustom`, `VerifiedBuild`) VALUES (999888, 15, 4, -1, 'Recycler', 0, 1, 0, 0, 1, 0, 0, 0, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 'The recycler allows players to recycle unwanted items for increased money which incentivizes a player driven economy.|n|nYou can find the recycler throughout the world to make it easy to recycle.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, '', 0, 0, 0, 0, 0, NULL); + +DELETE FROM `item_template` WHERE `entry`=41178; +INSERT INTO `item_template` (`entry`, `class`, `subclass`, `SoundOverrideSubclass`, `name`, `displayid`, `Quality`, `Flags`, `FlagsExtra`, `BuyCount`, `BuyPrice`, `SellPrice`, `InventoryType`, `AllowableClass`, `AllowableRace`, `ItemLevel`, `RequiredLevel`, `RequiredSkill`, `RequiredSkillRank`, `requiredspell`, `requiredhonorrank`, `RequiredCityRank`, `RequiredReputationFaction`, `RequiredReputationRank`, `maxcount`, `stackable`, `ContainerSlots`, `StatsCount`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`, `stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`, `stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`, `ScalingStatDistribution`, `ScalingStatValue`, `dmg_min1`, `dmg_max1`, `dmg_type1`, `dmg_min2`, `dmg_max2`, `dmg_type2`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `RangedModRange`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellppmRate_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellppmRate_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellppmRate_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellppmRate_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellppmRate_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `description`, `PageText`, `LanguageID`, `PageMaterial`, `startquest`, `lockid`, `Material`, `sheath`, `RandomProperty`, `RandomSuffix`, `block`, `itemset`, `MaxDurability`, `area`, `Map`, `BagFamily`, `TotemCategory`, `socketColor_1`, `socketContent_1`, `socketColor_2`, `socketContent_2`, `socketColor_3`, `socketContent_3`, `socketBonus`, `GemProperties`, `RequiredDisenchantSkill`, `ArmorDamageModifier`, `duration`, `ItemLimitCategory`, `HolidayId`, `ScriptName`, `DisenchantID`, `FoodType`, `minMoneyLoot`, `maxMoneyLoot`, `flagsCustom`, `VerifiedBuild`) VALUES (41178, 0, 8, -1, 'Remote Recycler', 52918, 1, 0, 0, 1, 100, 0, 0, -1, -1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10694, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 0, 0, 0, 0, -1, 0, -1, 1, '|cff00ff00Use: Send an item to the recycler and benefit from the rewards remotely.|r', 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0, '', 0, 0, 0, 0, 0, 15595); + +DELETE FROM `npc_vendor` WHERE `entry`=888999 AND `item`=41178 AND `ExtendedCost`=0; +INSERT INTO `npc_vendor` (`entry`, `slot`, `item`, `maxcount`, `incrtime`, `ExtendedCost`, `VerifiedBuild`) VALUES (888999, 0, 41178, 0, 0, 0, 0); diff --git a/src/RecycledItems.cpp b/src/RecycledItems.cpp index 0f1bc27..fab11c4 100644 --- a/src/RecycledItems.cpp +++ b/src/RecycledItems.cpp @@ -5,6 +5,7 @@ #include #include #include +#include std::string GetCurrencyStringFromCopper(uint32 copper) { @@ -171,7 +172,9 @@ bool IsItemRecylable(Item* item) if (sConfigMgr->GetOption("RecycledItems.Filter.OnlyTradable", true)) { - if (itemProto->Bonding != BIND_WHEN_EQUIPED && itemProto->Bonding != NO_BIND) + if (itemProto->Bonding != BIND_WHEN_EQUIPED && + itemProto->Bonding != NO_BIND && + itemProto->Bonding != BIND_WHEN_USE) { return false; } @@ -237,6 +240,69 @@ bool RecycledItemsPlayerScript::CanSellItem(Player* player, Item* item, Creature return false; } +bool RecycledItemsPlayerScript::CanCastItemUseSpell(Player* player, Item* item, SpellCastTargets const& targets, uint8 /*cast_count*/, uint32 /*glyphIndex*/) +{ + if (!item) + { + return true; + } + + auto itemProto = item->GetTemplate(); + if (!itemProto) + { + return true; + } + + if (itemProto->ItemId != 41178) + { + return true; + } + + if (!sConfigMgr->GetOption("RecycledItems.Enable", false)) + { + player->SendSystemMessage("This item is disabled."); + return true; + } + + auto targetItem = targets.GetItemTarget(); + if (!targetItem) + { + return false; + } + + if (targetItem->GetOwner()->GetGUID() != player->GetGUID()) + { + player->SendSystemMessage("You do not own that item."); + return false; + } + + if (!IsItemRecylable(targetItem)) + { + player->SendSystemMessage("You cannot recycle that item."); + return false; + } + + RecycleItem(targetItem, player); + + player->DestroyItemCount(itemProto->ItemId, 1, true); // Remote Recycler Item + player->RemoveItem(targetItem->GetBagSlot(), targetItem->GetSlot(), true); + + auto targetItemProto = targetItem->GetTemplate(); + + uint32 bonusMultiplier = sConfigMgr->GetOption("RecycledItems.Vendor.CashMultiplier", 2); + uint32 sellPrice = targetItemProto->SellPrice * targetItem->GetCount(); + uint32 money = sellPrice * bonusMultiplier; + player->ModifyMoney(money); + + std::string msg = Acore::StringFormatFmt("|cffFFFFFFGained {} |cffFFFFFFfor recycling.|r", GetCurrencyStringFromCopper(money)); + WorldPacket notifyPacket(SMSG_NOTIFICATION, msg.size() + 1); + notifyPacket << msg; + player->SendDirectMessage(¬ifyPacket); + + + return false; +} + bool RecycledItemsCreatureScript::OnGossipHello(Player* player, Creature* creature) { if (!sConfigMgr->GetOption("RecycledItems.Enable", false)) diff --git a/src/RecycledItems.h b/src/RecycledItems.h index 0ad4054..d0336f9 100644 --- a/src/RecycledItems.h +++ b/src/RecycledItems.h @@ -43,6 +43,8 @@ class RecycledItemsPlayerScript : public PlayerScript private: bool CanSellItem(Player* /*player*/, Item* /*item*/, Creature* /*creature*/) override; + bool CanCastItemUseSpell(Player* /*player*/, Item* /*item*/, SpellCastTargets const& /*targets*/, uint8 /*cast_count*/, uint32 /*glyphIndex*/) override; + Language GetLanguageForTarget(Player* /*player*/); };