[TrinityCore] Enchant NPC menu

User Tag List

Results 1 to 2 of 2
  1. #1
    kaios95's Avatar Member
    Reputation
    9
    Join Date
    Jan 2009
    Posts
    25
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [TrinityCore] Enchant NPC

    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

    [TrinityCore] Enchant NPC
  2. #2
    ~Jagris's Avatar Contributor
    Reputation
    154
    Join Date
    Apr 2007
    Posts
    1,479
    Thanks G/R
    2/2
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have been lurking for too long. This is a great thread man. Pretty good use of an NPC for the right type of server, keep it up.


Similar Threads

  1. [TrinityCore] Buffer NPC 3.3.5a
    By JadaDev in forum WoW EMU General Releases
    Replies: 0
    Last Post: 04-02-2014, 03:24 PM
  2. [C++ Script] Ultimate Enchanting NPC
    By parranoia in forum WoW EMU General Releases
    Replies: 0
    Last Post: 07-20-2013, 07:34 AM
  3. [Lua Script] Enchanter npc!
    By thebigman in forum WoW EMU General Releases
    Replies: 3
    Last Post: 05-26-2012, 03:20 AM
  4. [C++] Enchantment NPC
    By Vision1000 in forum WoW EMU General Releases
    Replies: 43
    Last Post: 02-25-2010, 05:14 AM
  5. LUA enchant npc
    By Shankers in forum WoW EMU Questions & Requests
    Replies: 5
    Last Post: 01-01-2010, 03:54 PM
All times are GMT -5. The time now is 05:48 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search