[LUA]NPC Talking menu

User Tag List

Results 1 to 7 of 7
  1. #1
    P1raten's Avatar Banned
    Reputation
    500
    Join Date
    Mar 2008
    Posts
    1,323
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [LUA]NPC Talking

    MAKING a LUA script that makes a mob talk isnt very hard, though many would think so. Heres an example of a script.

    Code:
    local mob = 99999
    
    function NPC_OnCombat(Unit, Event)
    	Unit:SendChatMessage(11, 0, "You shall die a quick death.")
    end
    
    function NPC_OnLeaveCombat(Unit, Event)
            Unit:SendChatMessage(11, 0, "Wise of you to run.")
    end
    
    function NPC_OnKilledTarget(Unit, Event)
            Unit:SendChatMessage(11, 0, "That was easy.")
    end
    
    function NPC_OnDied(Unit, Event)
            Unit:SendChatMessage(11, 0, "How did this happen? No, it cant be. No!")
    end
    
    RegisterUnitEvent(mob, 1, "NPC_OnCombat")
    RegisterUnitEvent(mob, 2, "NPC_OnLeaveCombat")
    RegisterUnitEvent(mob, 3, "NPC_OnKilledTarget")
    RegisterUnitEvent(mob, 4, "NPC_OnDied")
    Lets go through everything.

    "local mob = 99999"

    Code:
    local mob = 99999
    
    function NPC_OnCombat(Unit, Event)
    	Unit:SendChatMessage(11, 0, "You shall die a quick death.")
    end
    
    function NPC_OnLeaveCombat(Unit, Event)
            Unit:SendChatMessage(11, 0, "Wise of you to run.")
    end
    
    function NPC_OnKilledTarget(Unit, Event)
            Unit:SendChatMessage(11, 0, "That was easy.")
    end
    
    function NPC_OnDied(Unit, Event)
            Unit:SendChatMessage(11, 0, "How did this happen? No, it cant be. No!")
    end
    
    RegisterUnitEvent(mob, 1, "NPC_OnCombat")
    RegisterUnitEvent(mob, 2, "NPC_OnLeaveCombat")
    RegisterUnitEvent(mob, 3, "NPC_OnKilledTarget")
    RegisterUnitEvent(mob, 4, "NPC_OnDied")
    is a variable. Which means that if you write mob then arcemu-world will read it as 99999. When you write a variable in LUA then you need to write local mob = x. X being the variable. When you then use the variable you just write mob. Both mob and 99999 are changable to what ever you want them to be. 99999 being the npc id.

    function NPC_OnCombat(Unit, Event)


    Lets go through everything.

    Code:
    local mob = 99999
    
    function NPC_OnCombat(Unit, Event)
    	Unit:SendChatMessage(11, 0, "You shall die a quick death.")
    end
    
    function NPC_OnLeaveCombat(Unit, Event)
            Unit:SendChatMessage(11, 0, "Wise of you to run.")
    end
    
    function NPC_OnKilledTarget(Unit, Event)
            Unit:SendChatMessage(11, 0, "That was easy.")
    end
    
    function NPC_OnDied(Unit, Event)
            Unit:SendChatMessage(11, 0, "How did this happen? No, it cant be. No!")
    end
    
    RegisterUnitEvent(mob, 1, "NPC_OnCombat")
    RegisterUnitEvent(mob, 2, "NPC_OnLeaveCombat")
    RegisterUnitEvent(mob, 3, "NPC_OnKilledTarget")
    RegisterUnitEvent(mob, 4, "NPC_OnDied")

    is a command which explains what is going to happen. Like the following.function NPC_OnCombat(Unit, Event) Function, is of self-explainable. Its a function.
    NPC_OnCombat, now this, this is just a note. So you can change it what ever you like. But you should go by the original template. NpcName_WhatIsHappening. Example: Illidan_OnCombat
    Note that you will have to write the following at the bottom:
    RegisterUnitEvent(mob, 1, "Illidan_OnCombat")
    This will tell arcemu-world what npc the function is supposed to handle. in this case Illidan, which has the npc id 99999. Not in retail WoW. But the script says so. Because of the mob variable.
    RegisterUnitEvent(
    mob, 1, "Illidan_OnCombat")

    Hope you saw that one.

    Moving on.

    Unit:SendChatMessage(11, 0, "You shall die a quick death.")

    Code:
    local mob = 99999
    
    function NPC_OnCombat(Unit, Event)
    	Unit:SendChatMessage(11, 0, "You shall die a quick death.")
    end
    
    function NPC_OnLeaveCombat(Unit, Event)
            Unit:SendChatMessage(11, 0, "Wise of you to run.")
    end
    
    function NPC_OnKilledTarget(Unit, Event)
            Unit:SendChatMessage(11, 0, "That was easy.")
    end
    
    function NPC_OnDied(Unit, Event)
            Unit:SendChatMessage(11, 0, "How did this happen? No, it cant be. No!")
    end
    
    RegisterUnitEvent(mob, 1, "NPC_OnCombat")
    RegisterUnitEvent(mob, 2, "NPC_OnLeaveCombat")
    RegisterUnitEvent(mob, 3, "NPC_OnKilledTarget")
    RegisterUnitEvent(mob, 4, "NPC_OnDied")
    "Unit:" is the same as the npc. Though if you would write NPC: instead it wouldnt work. Note that you can also write player instead of Unit if you want the player to say something.

    SendChatMessage. Dont need to explain that do i?

    (11, 0, "You shall die a quick death.") The message. Just copy n paste it.

    Now your pretty much done. Just make more functions and etc. But make sure if you make more functions like Illidan_OnCombat then you need to write at the bottom.

    RegisterUnitEvent(mob, 1, "Illidan_OnCombat")
    RegisterUnitEvent(mob, 2, "Illidan_Whatever")

    etc. The number one is not hard to understand. Just write:
    mob, 1
    mob, 2
    mob, 3
    mob, 4
    etc. depending on how many functions you have. And make sure taht you put "end" after each function.

    function NPC_OnCombat(Unit, Event)
    Unit:SendChatMessage(11, 0, "You shall die a quick death.")
    end


    I hope this helped you. If you have any question or wonder about something then just reply and ill do my best to help you, and update the post, to make it easier to understand.

    Over and out, P1raten

    [LUA]NPC Talking
  2. #2
    wow4Supplier's Avatar Banned
    Reputation
    145
    Join Date
    Jan 2009
    Posts
    746
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe I would find this good,If I could understand it...Not good with this stuff xD

  3. #3
    P1raten's Avatar Banned
    Reputation
    500
    Join Date
    Mar 2008
    Posts
    1,323
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then tell me what you dont understand and ill help you to understand it.

  4. #4
    slapaf's Avatar Member
    Reputation
    1
    Join Date
    Jun 2008
    Posts
    24
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im gonna use this for my server =D

  5. #5
    P1raten's Avatar Banned
    Reputation
    500
    Join Date
    Mar 2008
    Posts
    1,323
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dont forget to +rep people who helps you.

  6. #6
    Dr. Livingstone's Avatar Member
    Reputation
    113
    Join Date
    Mar 2008
    Posts
    290
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well pretty well written so +Rep, but there are so many guides for Lua scripting now...

  7. #7
    ViV09's Avatar Member
    Reputation
    4
    Join Date
    Mar 2008
    Posts
    19
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool guide mate

Similar Threads

  1. [Help] How to make an NPC Talk with Lua
    By Silentnvd in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 07-26-2008, 08:08 PM
  2. how to make a npc talk/cast Mangos
    By hotandsekc in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 06-11-2008, 09:12 PM
  3. Why doesnt my NPC talk?
    By controlsx2 in forum World of Warcraft Emulator Servers
    Replies: 13
    Last Post: 05-22-2008, 12:39 PM
  4. [GM Scripting] Making a npc Talk at a % of Health Points
    By Illidan1 in forum WoW EMU Guides & Tutorials
    Replies: 10
    Last Post: 11-10-2007, 06:34 PM
  5. Replies: 14
    Last Post: 10-31-2007, 01:17 PM
All times are GMT -5. The time now is 02:46 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