NPC lua spell commands [GUIDE] menu

User Tag List

Results 1 to 1 of 1
  1. #1
    thebigman's Avatar Contributor Reliable Trader
    CoreCoins Purchaser
    Reputation
    89
    Join Date
    Dec 2008
    Posts
    605
    Thanks G/R
    2/0
    Trade Feedback
    26 (96%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    NPC lua spell commands [GUIDE]

    Ill give ya the basic blueprint and you can fill in the details of what you want. I will also describe what each one does


    Code:
    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(3544, player, 0)
    unit:GossipMenuAddItem(2, "Remove Rezz Sickness", 1, 3)
    unit:GossipMenuAddItem(2, "Remove Deserter", 3, 3)
    unit:GossipMenuAddItem(2, "Add spell", 4, 3)
    unit:GossipMenuAddItem(2, "Add spell", 5, 3)
    unit:GossipMenuAddItem(2, "Add spell", 6, 3)
    unit:GossipMenuAddItem(2, "Add spell", 7, 3)
    unit:GossipMenuAddItem(2, "Add spell", 8,3 )
    unit:GossipSendMenu(player)
    end
    
    function Gossip_Submenus(unit, event, player, id, intid, code)
    
    if(intid == 3544) then
    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(3544, player, 0)
    unit:GossipMenuAddItem(2, "Remove Rezz Sickness", 1, 3)
    unit:GossipMenuAddItem(2, "Remove Deserter", 3, 3)
    unit:GossipMenuAddItem(2, "Add spell", 4, 3)
    unit:GossipMenuAddItem(2, "Add spell", 5, 3)
    unit:GossipMenuAddItem(2, "Add spell", 6, 3)
    unit:GossipMenuAddItem(2, "Add spell", 7, 3)
    unit:GossipMenuAddItem(2, "Add spell", 8, 3)
    unit:GossipSendMenu(player)
    end
    
    if(intid == 1) then
    player:LearnSpell(15007)
    player:UnlearnSpell(15007)
    end
    
    if(intid == 3) then
    player:LearnSpell(26013)
    player:UnlearnSpell(26013)
    end
    
    if(intid == 4) then
    player:LearnSpell(17040)
    end
    
    if(intid == 5) then
    player:LearnSpell(17039)
    end
    
    if(intid == 6) then
    player:LearnSpell(17041)
    end
    
    if(intid == 7) then
    player:LearnSpell(20221)
    end
    
    if(intid == 8) then
    player:LearnSpell(20220)
    end
    end
    
    RegisterUnitGossipEvent(npcid, 1, "On_Gossip")
    RegisterUnitGossipEvent(npcid, 2, "Gossip_Submenus")

    The first 2 lines are standard in any npc using lua. No need to explain it, except the second line is to exstablish a menu ID for the menu.

    Next we have a bunch of lines that add that option to the menu, the title is add spell for each, replace that with the spell you want to add. if you add more lines make sure the second digit like here, unit:GossipMenuAddItem(2, "Remove Deserter", 3, 3) is not the same as any other option, that is the options ID, the first number, unit:GossipMenuAddItem(2, "Remove Deserter", 3, 3)
    is what icon is displayed next to that option, the range is 1-9, theres a list you can look up somewhere here in mmowned.


    now for the unit:GossipSendMenu(player) this makes it where it targets the player.

    End is self explainitory, it ends the sequence. you always need to put end after every sequence, like I have.


    function Gossip_Submenus(unit, event, player, id, intid, code)
    this ones adds a submenu to the first one.

    if(intid == 3544) then
    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(3544, player, 0)
    unit:GossipMenuAddItem(2, "Remove Rezz Sickness", 1, 3)
    unit:GossipMenuAddItem(2, "Remove Deserter", 3, 3)
    unit:GossipMenuAddItem(2, "Add spell", 4, 3)
    unit:GossipMenuAddItem(2, "Add spell", 5, 3)
    unit:GossipMenuAddItem(2, "Add spell", 6, 3)
    unit:GossipMenuAddItem(2, "Add spell", 7, 3)
    unit:GossipMenuAddItem(2, "Add spell", 8, 3)
    unit:GossipSendMenu(player)
    end

    I added this to make sure it loops back to the starting page.

    unit:GossipSendMenu(player)
    end

    use that to end the second one.

    Now for the submenus!


    if(intid == 1) then
    player:LearnSpell(15007)
    player:UnlearnSpell(15007)
    end

    this targets the first menuid, which was assigned to 1, and add the spell "rezz sickness" then removes it to dispel the debuff. If you want the player to perm learn the spell, remove the unlearn part. The spell ID is in the brackets (ID) replace with the spell you want learned and unlearned, you can also learn 1 thing and have the player unlearn another, like if you wanted custom classes for example, you could have the player learn all mage spells, and remove all warlock spells, and if you knew alot more about lua, add a line taking off all warlock profiencies and adding mage ones.

    you can have more then one submenu ofc, so it looks like this:

    if(intid == 1) then
    player:LearnSpell(15007)
    player:UnlearnSpell(15007)
    end

    if(intid == 3) then
    player:LearnSpell(26013)
    player:UnlearnSpell(26013)
    end

    if(intid == 4) then
    player:LearnSpell(17040)
    end

    if(intid == 5) then
    player:LearnSpell(17039)
    end

    if(intid == 6) then
    player:LearnSpell(17041)
    end

    if(intid == 7) then
    player:LearnSpell(20221)
    end

    if(intid == then
    player:LearnSpell(20220)
    end

    Now, simply add end again to complete it.

    if(intid == 1) then
    player:LearnSpell(15007)
    player:UnlearnSpell(15007)
    end

    if(intid == 3) then
    player:LearnSpell(26013)
    player:UnlearnSpell(26013)
    end

    if(intid == 4) then
    player:LearnSpell(17040)
    end

    if(intid == 5) then
    player:LearnSpell(17039)
    end

    if(intid == 6) then
    player:LearnSpell(17041)
    end

    if(intid == 7) then
    player:LearnSpell(20221)
    end

    if(intid == then
    player:LearnSpell(20220)
    end
    end




    RegisterUnitGossipEvent(npcid, 1, "On_Gossip")
    RegisterUnitGossipEvent(npcid, 2, "Gossip_Submenus")

    This final line registers the menu and submenus to the NPC, replace npcid with the npcs id (DERP)

    now it should look like the above, this:


    Code:
    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(3544, player, 0)
    unit:GossipMenuAddItem(2, "Remove Rezz Sickness", 1, 3)
    unit:GossipMenuAddItem(2, "Remove Deserter", 3, 3)
    unit:GossipMenuAddItem(2, "Add spell", 4, 3)
    unit:GossipMenuAddItem(2, "Add spell", 5, 3)
    unit:GossipMenuAddItem(2, "Add spell", 6, 3)
    unit:GossipMenuAddItem(2, "Add spell", 7, 3)
    unit:GossipMenuAddItem(2, "Add spell", 8,3 )
    unit:GossipSendMenu(player)
    end
    
    function Gossip_Submenus(unit, event, player, id, intid, code)
    
    if(intid == 3544) then
    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(3544, player, 0)
    unit:GossipMenuAddItem(2, "Remove Rezz Sickness", 1, 3)
    unit:GossipMenuAddItem(2, "Remove Deserter", 3, 3)
    unit:GossipMenuAddItem(2, "Add spell", 4, 3)
    unit:GossipMenuAddItem(2, "Add spell", 5, 3)
    unit:GossipMenuAddItem(2, "Add spell", 6, 3)
    unit:GossipMenuAddItem(2, "Add spell", 7, 3)
    unit:GossipMenuAddItem(2, "Add spell", 8, 3)
    unit:GossipSendMenu(player)
    end
    
    if(intid == 1) then
    player:LearnSpell(15007)
    player:UnlearnSpell(15007)
    end
    
    if(intid == 3) then
    player:LearnSpell(26013)
    player:UnlearnSpell(26013)
    end
    
    if(intid == 4) then
    player:LearnSpell(17040)
    end
    
    if(intid == 5) then
    player:LearnSpell(17039)
    end
    
    if(intid == 6) then
    player:LearnSpell(17041)
    end
    
    if(intid == 7) then
    player:LearnSpell(20221)
    end
    
    if(intid == 8) then
    player:LearnSpell(20220)
    end
    end
    
    RegisterUnitGossipEvent(npcid, 1, "On_Gossip")
    RegisterUnitGossipEvent(npcid, 2, "Gossip_Submenus")

    NPC lua spell commands [GUIDE]

Similar Threads

  1. [Guide] How to make a NPC cast spells. NO LUA!
    By Power of Illuminati in forum WoW EMU Guides & Tutorials
    Replies: 52
    Last Post: 05-06-2011, 07:13 AM
  2. [Guide]How to make NPC casting spells(LUA)
    By paulbechtold in forum WoW EMU Guides & Tutorials
    Replies: 2
    Last Post: 12-30-2009, 07:44 PM
  3. [Release] Super Spell Teacher NPC LUA & SQL
    By Zellcorp in forum WoW EMU General Releases
    Replies: 2
    Last Post: 08-01-2009, 04:31 AM
  4. SetSoulLinkedwith LUA Command Guide
    By mager1794 in forum WoW EMU Guides & Tutorials
    Replies: 9
    Last Post: 07-02-2008, 04:16 PM
  5. [Guide] NPC factions and commands
    By Denelly in forum WoW EMU Guides & Tutorials
    Replies: 4
    Last Post: 11-02-2007, 09:03 PM
All times are GMT -5. The time now is 09:36 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search