Lbniese
17-09-09, 02:48 PM
Greetings everyone and welcome to the basic Lua Scripting tutorial for World of Warcraft. With this tutorial I will clearly and step for step learn you about the basics of a boss encounter. Make sure you are reading this tutorial step by step if you are a beginner
Introducion
1. Lua
2. Events
3. Spells
4. Phases
5. Extra additions
LUA
Lua is a great program for much games like World of Warcraft. The main thing to learn Lua is because it's one of the most used languages and one of the easiest to understand in games. With Lua you will get a great rank in developing at servers with a high community.
EVENTS
The Events are the ones who start a script. The most used Events are OnCombat, OnLeaveCombat, OnKilledTarget and OnDeath. I will clearly explain those basic Events to you and how to use them.
2.1. OnCombat
2.2. OnLeaveCombat
2.3. OnKilledTarget
2.4. OnDeath
OnCombat
OnCombat means when the player enters the in-combat range of the boss. When the player enters combat with the boss, then the script basicly starts. Here is an example how an OnCombat phase should look like with no events.
function Boss_OnCombat(pUnit, Event)
end
Let me explain these things to you:
function, the functions tell the script what to do.
Boss, this is the name of my boss, I have called him Boss because there isn't a better name for this tutorial. You can replace this name with your own name, Boss doesn't have anything to deal with what kind of boss it is.
OnCombat, this is the name of the function, at this point, the funcion is the OnCombat Event.
(pUnit, Event), I haven't put these things seperate because they are a must at every function. pUnit means the NPC, this doesn't mean you have to change pUnit into the name of your NPC, another thing about pUnit is that it doesn't have to be pUnit everytime. You can change pUnit in another name too. The only rule about this is that you can't have two names like pUnit and Unit, remind yourself on that. And Event is the Event, meaning with 'Event is the Event' is because the Event is OnCombat.
end, this means the end of the function. You only have to put one end because it ends on one function, will explain later about this at Phases.
Now we all had these explainations, we are going to make some changes in the OnCombat phase.
With these changes I mean that we are going to let the NPC talk when a player enters in-combat range, watch what I'm going to change.
function Boss_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Welcome to my lair!")
end
This will let the NPC yell "Welcome to my lair!" Let me explain this about how I did this.
pUnit, here is pUnit again, pUnit is always used for things like this, and to cast spells, but I'm coming back on that later.
SendChatMessage, this will let the NPC send a chat message which the players can read
(14, 0, "Welcome to my lair!") I haven't put these things separate because they are all together. The number 14 means that he yells the chat message, the number 0 means that it is universial so that everyone can understand it. The text "Welcome to my lair!" is the text the NPC yells in universial, make sure you are putting it between "".
I'm going to show you some other languages and about in what sort of type he can say it:
How he can say it:
12 –- Means that the NPC says something
13 –- Means that the NPC whispers something
14 -- Means that the NPC yells something
In what sort of language he can say it:
0 -- Universal, means everyone can understand it
1 -- Orcish
2 -- Darnassian
3 -- Tauron
6 -- Dwarfs
7 -- Common
8 -- Demonic
9 -- Titan
13 -- Gnomish
14 -- Trolls
33 -- Gutterspeak
35 -- Draenei
Ok, this were the basics of an OnCombat Event, lets go to the other Events.
OnLeaveCombat
This is the OnLeaveCombat Event. The OnLeaveCombat Event is when the boss leaves combat with his opponents. You can have text with this too, but there is something else added to it also.
function Boss_OnLeaveCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "You are to scared for my powers?!")
pUnit:RemoveEvents()
end
As you can see it's the same as OnCombat. But now I've added pUnit:RemoveEvents() add it. The reason why I'm doing this is because when you leave combat with him. It will remove all the current events, like casting spells and other things.
Now we are moving on the the next event.
OnKilledTarget
The OnKilledTarget event is not hard at all. You don't need to have pUnit:RemoveEvents() at this event. The reason why? I'll explain, when the boss kills an enemy, the script continues. If you put RemoveEvents() at is, he will start from the beginning. We don't want that ofcourse.
function Boss_OnKilledTarget(pUnit, Event)
end
Ofcourse, you can add more things to it. Like when he kills an enemy, he gets stronger or something. For that, we will use pUnit:CastSpell(). CastSpell() means that he casts a spell in Area of Effect, or on himself. You can look the spell ID's at Wowhead: Dataz! We need more dataz! (http://www.wowhead.com)., or www.thotbot.com (http://www.thotbot.com). How to get those ID's? I'll explain. I want that my boss gets stronger everytime. I'll try to find the spell "Growth", I'm typing Growth at the search button of wowhead. Going to Uncategorized spells and I click on the spell I wanted. Now I'm at the page: Growth - Spell - World of Warcraft (http://www.wowhead.com/?spell=36300). As you can see the spell ID is on the end. This is how you find spells. Now, back on pUnit:CastSpell(). Now I've got the spellID. I need to copy and paste it into the brackets of CastSpell(), means the (). Lets add the pUnit:CastSpell() now to the event.
function Boss_OnKilledTarget(pUnit, Event)
pUnit:CastSpell(36300)
end
You can have text at it too ofcourse. If he gets stronger everytime, lets think of some text who fits in it.
function Boss_OnKilledTarget(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Your worthless blood feeds me!")
pUnit:CastSpell(36300)
end
So, this was the OnKilledTarget event, not so hard is it?
OnDeath
The OnDeath event is just as easy as the others. You need to have pUnit:RemoveEvents() too and ofcourse, chatmessages are always welcome.
function Boss_OnDeath(pUnit, Event)
pUnit:SendChatMessage(14, 0, "That's impossible! Nooo!")
pUnit:RemoveEvents()
end
I don't have much to explain about only the main thing here, is the put the chatmessage above pUnit:RemoveEvents(). Why? Because otherwise it removes the events before he sends the chat message and it won't say anything then.
Ok! This were the explainations about all the basic Events in a boss encounter. How to put them in a script? I'll show you!
function Boss_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Welcome to my lair!")
end
function Boss_OnLeaveCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "You are to scared for my powers?!")
pUnit:RemoveEvents()
end
function Boss_OnKilledTarget(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Your worthless blood feeds me!")
pUnit:CastSpell(36300)
end
function Boss_OnDeath(pUnit, Event)
pUnit:SendChatMessage(14, 0, "That's impossible! Nooo!")
pUnit:RemoveEvents()
end
It looks nice now, but how are these events activated? Well, really simple, you need to register these events with:
RegisterUnitEvent(EntryID, 1, "Boss_OnCombat")
RegisterUnitEvent(EntryID, 2, "Boss_OnLeaveCombat")
RegisterUnitEvent(EntryID, 3, "Boss_OnKilledTarget")
RegisterUnitEvent(EntryID, 4, "Boss_OnDeath")
This is the registering part of the events, I'm going to explain you step by step how it works.
RegisterUnitEvent, means that it registers the kind of event.
EntryID, here you need to put the EntryID of your NPC.
1, this shows what type of event it is. 1 means that it's the OnCombat event. 2 means OnLeaveCombat, 3, means OnKilledTarget and 4 means OnDeath. Those are basics, do not mess with these numbers, just put them at the right place.
"Boss_OnCombat", this is the name of the event, if you got another name on the OnCombat event, you need to change to name of it in the registering part too.
How do I put the registering part in the script? Simple, I'll show you!
function Boss_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Welcome to my lair!")
end
function Boss_OnLeaveCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "You are to scared for my powers?!")
pUnit:RemoveEvents()
end
function Boss_OnKilledTarget(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Your worthless blood feeds me!")
pUnit:CastSpell(36300)
end
function Boss_OnDeath(pUnit, Event)
pUnit:SendChatMessage(14, 0, "That's impossible! Nooo!")
pUnit:RemoveEvents()
end
RegisterUnitEvent(EntryID, 1, "Boss_OnCombat")
RegisterUnitEvent(EntryID, 2, "Boss_OnLeaveCombat")
RegisterUnitEvent(EntryID, 3, "Boss_OnKilledTarget")
RegisterUnitEvent
Just down the whole script, you don't need to have function, end or whatever to it. This is the whole Registering part of the events.
** Next part SPELLS **
Introducion
1. Lua
2. Events
3. Spells
4. Phases
5. Extra additions
LUA
Lua is a great program for much games like World of Warcraft. The main thing to learn Lua is because it's one of the most used languages and one of the easiest to understand in games. With Lua you will get a great rank in developing at servers with a high community.
EVENTS
The Events are the ones who start a script. The most used Events are OnCombat, OnLeaveCombat, OnKilledTarget and OnDeath. I will clearly explain those basic Events to you and how to use them.
2.1. OnCombat
2.2. OnLeaveCombat
2.3. OnKilledTarget
2.4. OnDeath
OnCombat
OnCombat means when the player enters the in-combat range of the boss. When the player enters combat with the boss, then the script basicly starts. Here is an example how an OnCombat phase should look like with no events.
function Boss_OnCombat(pUnit, Event)
end
Let me explain these things to you:
function, the functions tell the script what to do.
Boss, this is the name of my boss, I have called him Boss because there isn't a better name for this tutorial. You can replace this name with your own name, Boss doesn't have anything to deal with what kind of boss it is.
OnCombat, this is the name of the function, at this point, the funcion is the OnCombat Event.
(pUnit, Event), I haven't put these things seperate because they are a must at every function. pUnit means the NPC, this doesn't mean you have to change pUnit into the name of your NPC, another thing about pUnit is that it doesn't have to be pUnit everytime. You can change pUnit in another name too. The only rule about this is that you can't have two names like pUnit and Unit, remind yourself on that. And Event is the Event, meaning with 'Event is the Event' is because the Event is OnCombat.
end, this means the end of the function. You only have to put one end because it ends on one function, will explain later about this at Phases.
Now we all had these explainations, we are going to make some changes in the OnCombat phase.
With these changes I mean that we are going to let the NPC talk when a player enters in-combat range, watch what I'm going to change.
function Boss_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Welcome to my lair!")
end
This will let the NPC yell "Welcome to my lair!" Let me explain this about how I did this.
pUnit, here is pUnit again, pUnit is always used for things like this, and to cast spells, but I'm coming back on that later.
SendChatMessage, this will let the NPC send a chat message which the players can read
(14, 0, "Welcome to my lair!") I haven't put these things separate because they are all together. The number 14 means that he yells the chat message, the number 0 means that it is universial so that everyone can understand it. The text "Welcome to my lair!" is the text the NPC yells in universial, make sure you are putting it between "".
I'm going to show you some other languages and about in what sort of type he can say it:
How he can say it:
12 –- Means that the NPC says something
13 –- Means that the NPC whispers something
14 -- Means that the NPC yells something
In what sort of language he can say it:
0 -- Universal, means everyone can understand it
1 -- Orcish
2 -- Darnassian
3 -- Tauron
6 -- Dwarfs
7 -- Common
8 -- Demonic
9 -- Titan
13 -- Gnomish
14 -- Trolls
33 -- Gutterspeak
35 -- Draenei
Ok, this were the basics of an OnCombat Event, lets go to the other Events.
OnLeaveCombat
This is the OnLeaveCombat Event. The OnLeaveCombat Event is when the boss leaves combat with his opponents. You can have text with this too, but there is something else added to it also.
function Boss_OnLeaveCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "You are to scared for my powers?!")
pUnit:RemoveEvents()
end
As you can see it's the same as OnCombat. But now I've added pUnit:RemoveEvents() add it. The reason why I'm doing this is because when you leave combat with him. It will remove all the current events, like casting spells and other things.
Now we are moving on the the next event.
OnKilledTarget
The OnKilledTarget event is not hard at all. You don't need to have pUnit:RemoveEvents() at this event. The reason why? I'll explain, when the boss kills an enemy, the script continues. If you put RemoveEvents() at is, he will start from the beginning. We don't want that ofcourse.
function Boss_OnKilledTarget(pUnit, Event)
end
Ofcourse, you can add more things to it. Like when he kills an enemy, he gets stronger or something. For that, we will use pUnit:CastSpell(). CastSpell() means that he casts a spell in Area of Effect, or on himself. You can look the spell ID's at Wowhead: Dataz! We need more dataz! (http://www.wowhead.com)., or www.thotbot.com (http://www.thotbot.com). How to get those ID's? I'll explain. I want that my boss gets stronger everytime. I'll try to find the spell "Growth", I'm typing Growth at the search button of wowhead. Going to Uncategorized spells and I click on the spell I wanted. Now I'm at the page: Growth - Spell - World of Warcraft (http://www.wowhead.com/?spell=36300). As you can see the spell ID is on the end. This is how you find spells. Now, back on pUnit:CastSpell(). Now I've got the spellID. I need to copy and paste it into the brackets of CastSpell(), means the (). Lets add the pUnit:CastSpell() now to the event.
function Boss_OnKilledTarget(pUnit, Event)
pUnit:CastSpell(36300)
end
You can have text at it too ofcourse. If he gets stronger everytime, lets think of some text who fits in it.
function Boss_OnKilledTarget(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Your worthless blood feeds me!")
pUnit:CastSpell(36300)
end
So, this was the OnKilledTarget event, not so hard is it?
OnDeath
The OnDeath event is just as easy as the others. You need to have pUnit:RemoveEvents() too and ofcourse, chatmessages are always welcome.
function Boss_OnDeath(pUnit, Event)
pUnit:SendChatMessage(14, 0, "That's impossible! Nooo!")
pUnit:RemoveEvents()
end
I don't have much to explain about only the main thing here, is the put the chatmessage above pUnit:RemoveEvents(). Why? Because otherwise it removes the events before he sends the chat message and it won't say anything then.
Ok! This were the explainations about all the basic Events in a boss encounter. How to put them in a script? I'll show you!
function Boss_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Welcome to my lair!")
end
function Boss_OnLeaveCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "You are to scared for my powers?!")
pUnit:RemoveEvents()
end
function Boss_OnKilledTarget(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Your worthless blood feeds me!")
pUnit:CastSpell(36300)
end
function Boss_OnDeath(pUnit, Event)
pUnit:SendChatMessage(14, 0, "That's impossible! Nooo!")
pUnit:RemoveEvents()
end
It looks nice now, but how are these events activated? Well, really simple, you need to register these events with:
RegisterUnitEvent(EntryID, 1, "Boss_OnCombat")
RegisterUnitEvent(EntryID, 2, "Boss_OnLeaveCombat")
RegisterUnitEvent(EntryID, 3, "Boss_OnKilledTarget")
RegisterUnitEvent(EntryID, 4, "Boss_OnDeath")
This is the registering part of the events, I'm going to explain you step by step how it works.
RegisterUnitEvent, means that it registers the kind of event.
EntryID, here you need to put the EntryID of your NPC.
1, this shows what type of event it is. 1 means that it's the OnCombat event. 2 means OnLeaveCombat, 3, means OnKilledTarget and 4 means OnDeath. Those are basics, do not mess with these numbers, just put them at the right place.
"Boss_OnCombat", this is the name of the event, if you got another name on the OnCombat event, you need to change to name of it in the registering part too.
How do I put the registering part in the script? Simple, I'll show you!
function Boss_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Welcome to my lair!")
end
function Boss_OnLeaveCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "You are to scared for my powers?!")
pUnit:RemoveEvents()
end
function Boss_OnKilledTarget(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Your worthless blood feeds me!")
pUnit:CastSpell(36300)
end
function Boss_OnDeath(pUnit, Event)
pUnit:SendChatMessage(14, 0, "That's impossible! Nooo!")
pUnit:RemoveEvents()
end
RegisterUnitEvent(EntryID, 1, "Boss_OnCombat")
RegisterUnitEvent(EntryID, 2, "Boss_OnLeaveCombat")
RegisterUnitEvent(EntryID, 3, "Boss_OnKilledTarget")
RegisterUnitEvent
Just down the whole script, you don't need to have function, end or whatever to it. This is the whole Registering part of the events.
** Next part SPELLS **