Greetings, today i'll share my enchant npc code, i removed my personnal enchant(that's why there is only 1 enchant) but don't worry i did it on purpose, you can easily add your enchant ! you just have to follow my example( look at case 14 )
Code:
/*
* Copyright (C) 1337 - 2012 Dany 'Nethrak' <http://www.axium-wow.com>
* Copyright (C) 2011 - 2012 Nomsoftware <http://www.nomsoftware.com>
*/
#include "ScriptPCH.h"
class npc_enchant : public CreatureScript
{
public: npc_enchant() : CreatureScript("npc_enchant") {}
uint8 slot;
uint32 tw;
uint32 enchant;
uint32 req;
bool OnGossipHello(Player* player, Creature* creature)
{
MainMenu(player, creature);
return true;
}
void MainMenu(Player* player, Creature* creature)
{
slot = 0; enchant = 0; req = 0; tw = 0;
player->ADD_GOSSIP_ITEM(0, "Back", GOSSIP_SENDER_MAIN, 14);
player->SEND_GOSSIP_MENU(20003, creature->GetGUID());
}
void Enchant(Player* player, Creature* creature, Item* item)
{
item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot );
if(!item)
{
creature->MonsterWhisper("You must equip the item.", player->GetGUID());
MainMenu(player, creature);
return;
}
if ((tw == 1) && (item->GetTemplate()->InventoryType == 17))
{
creature->MonsterWhisper("This enchant need a 2H.", player->GetGUID());
MainMenu(player, creature);
return;
}
SpellItemEnchantmentEntry const* enchantid = sSpellItemEnchantmentStore.LookupEntry(enchant);
if (!enchantid)
{
creature->MonsterWhisper("Error, contact the administrator if you got this message", player->GetGUID());
player->CLOSE_GOSSIP_MENU();
return;
}
player->ApplyEnchantment(item, PERM_ENCHANTMENT_SLOT, false);
item->SetEnchantment(PERM_ENCHANTMENT_SLOT, enchant, 0, 0);
player->ApplyEnchantment(item, PERM_ENCHANTMENT_SLOT, true);
MainMenu(player, creature);
}
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 action)
{
player->PlayerTalkClass->ClearMenus();
Item* item;
switch (action)
{
case 100:
MainMenu(player, creature);
break;
case 14:
slotid = 14;
player->ADD_GOSSIP_ITEM(3, "120 armor", GOSSIP_SENDER_MAIN, 1407);
player->SEND_GOSSIP_MENU(20004, creature->GetGUID());
break;
case 1412:
enchant = 1889;
Enchant(player, creature, item);
break;
}
return true;
}
};
void AddSC_npc_enchant()
{
new npc_enchant();
}
Since i removed like 800 lines this code may not compile (because of gossip) so don't worry about it just check the send_gossip_menu