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