PDA

View Full Version : [Ultimate]LUA Guide & Tut



enegue
27-10-09, 05:53 AM
If anything is wrong with this guide, or information is incorrect, please post back and I'll correct it, Be aware I'm not an Lua expert, i learned by looking at many Lua guides, and by messing around and testing out stuff in-game. These are the concepts i feel i have a pretty good understanding of so far. If there is anything i'm missing in this guide, also post and i'll add it in. (Also say if any of the examples / sections of this guide are unclear, i'll try my best to fix them Edit: I've been learning C++, and well... if you have the time, its definitely worth learning over lua.)

After reading through all the other guides that are vague and leave out very basic information that you are expected to know,
but do not.
i decided to make a very very thorough one.

[Table of Contents]

[1.0]: General
[1.1]: Functions & Registering Events
[1.2]: Variables
[1.3]: The If Statement
[1.4]: Command List & Usage

[2.0] Creature Events
[2.1]: Most Common Creature Commands & Usage
[2.5]: Combat and General Events
[2.9]: Creature Summary and Tips

[3.0] Gameobject Events.
[3.1] Most Common Gameobject Commands & Usage
[3.5] Gameobject Events
[3.9] Gameobject Summary and Tips

[5.0] Generalized Gossip Events.

[$.#]3x7r4 1Nf0rNm471on


.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.: .:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.: .:.:.:.:.:.:.:.:.:.:.:.:.

[1.0]General


[1.1]Functions & Registering Events


Functions are blocks of code created to be called upon and do a specific task when your script is executed. The only way to initially call on a function is by having a certain Event happen to the scripted Unit(Whether it be a Creature, Gameobject, or Item)
These triggering events are;

-Accepting a Quest
-Completing a Quest
-Canceling a Quest
-Activating a Quest Gameobject
-Killing a Creature Required for a Quest
-Exploring an Area for a quest
-Picking up an Item for a Quest
-Creature Entering Combat
-Creature Leaving Combat
-Creature Killing an Enemy
-Creature Dieing
-Creature being Parried
-Creature being Dodged
-Creature being Blocked
-Creature being Critically Hit
-Creature Parrying
-Creature Dodging
-Creature Blocking??
-Creature Critically Hitting
-Creature Hitting
-Creature Feared
-Creature Flee
-Creature Loading
-Creature Reaching a Waypoint
-Creature having loot taken from it
-Creature Emoting
-Gameobject being Created
-Gameobject Spawning
-Gameobject having loot taken from it
-Gameobject being clicked/used
-Gameobject Despawning
-Talking to a Gossip Unit
-Selecting an option from a Gossip Unit
-Closing a Gossip Window / Ending it

The Skeleton if you will, of a function must always look like this;

function FunctionName(Unit, Event)

end

When this function is called it will execute what is between the Skeleton. As stated above, it can only be initially called by a trigger event. To have a function called when a specific event happens
you must register that function to do so. Below is the syntax used to register different types of Events.


RegisterUnitEvent(NPCID, FLAG, "FunctionName")
RegisterUnitGossipEvent(NPCID, FLAG, "FunctionName")
RegisterItemGossipEvent(ItemID, FLAG, "Item_Trigger")
RegisterGameObjectEvent(GoID, FLAG, "FunctionName")


Replacing the NPC/item/Go Id's with the ones you will spawn in the world and use. the 'FLAG' is a number that indicates the event that the registered function will trigger on. Here is a breakdown of how to register an event.

[NOTE]When Registering Events, you type it at the bottom or top of the script.
Please remember that no function has to have any particular name. Not having "OnCombat" in the function name, won't affect if it gets triggered on combat, as long as its function name matches the name your registering, and you have the correct flag.



function Creature_OnCombat(Unit, Event)

end

RegisterUnitEvent(6, 1,"Creature_OnCombat")

6: Is the NPCID of a Kobold Vermin, Change it to the NPCID you want to script.
1: Is the Flag of the type of event you want this registered function to get triggered on.
"Creature_OnCombat": Is the name of the function your registering to be executed when the Kobold enters combat.
RegisterUnitEvent: Is used to Register a Unit/Creature Event.

NPCID was 6 (For Kobold Vermin)
EventFlag was 1 (To Register the function Creature_OnCombat when the kobold vermin enters combat
FunctionName "Creature_OnCombat"


Below is a Complete List of EventFlags you can use when registering an event.



[QUEST EVENTS]
QUEST_EVENT_ON_ACCEPT = 1,
QUEST_EVENT_ON_COMPLETE = 2,
QUEST_EVENT_ON_CANCEL = 3,
QUEST_EVENT_GAMEOBJECT_ACTIVATE = 4,
QUEST_EVENT_ON_CREATURE_KILL = 5,
QUEST_EVENT_ON_EXPLORE_AREA = 6,
QUEST_EVENT_ON_PLAYER_ITEMPICKUP = 7,
QUEST_EVENT_COUNT,
[CREATURE EVENTS]
CREATURE_EVENT_ON_ENTER_COMBAT = 1,
CREATURE_EVENT_ON_LEAVE_COMBAT = 2,
CREATURE_EVENT_ON_TARGET_DIED = 3,
CREATURE_EVENT_ON_DIED = 4,
CREATURE_EVENT_ON_TARGET_PARRIED = 5,
CREATURE_EVENT_ON_TARGET_DODGED = 6,
CREATURE_EVENT_ON_TARGET_BLOCKED = 7,
CREATURE_EVENT_ON_TARGET_CRIT_HIT = 8,
CREATURE_EVENT_ON_PARRY = 9,
CREATURE_EVENT_ON_DODGED = 10,
CREATURE_EVENT_ON_BLOCKED = 11,
CREATURE_EVENT_ON_CRIT_HIT = 12,
CREATURE_EVENT_ON_HIT = 13,
CREATURE_EVENT_ON_ASSIST_TARGET_DIED = 14,
CREATURE_EVENT_ON_FEAR = 15,
CREATURE_EVENT_ON_FLEE = 16,
CREATURE_EVENT_ON_CALL_FOR_HELP = 17,
CREATURE_EVENT_ON_LOAD = 18,
CREATURE_EVENT_ON_REACH_WP = 19,
CREATURE_EVENT_ON_LOOT_TAKEN = 20,
CREATURE_EVENT_ON_AIUPDATE = 21,
CREATURE_EVENT_ON_EMOTE = 22,
CREATURE_EVENT_COUNT,
[GAMEOBJECT EVENTS]
GAMEOBJECT_EVENT_ON_CREATE = 1,
GAMEOBJECT_EVENT_ON_SPAWN = 2,
GAMEOBJECT_EVENT_ON_LOOT_TAKEN = 3,
GAMEOBJECT_EVENT_ON_USE = 4,
GAMEOBJECT_EVENT_AIUPDATE = 5,
GAMEOBJECT_EVENT_ON_DESPAWN = 6,
GAMEOBJECT_EVENT_COUNT,
[GOSSIP EVENTS]
GOSSIP_EVENT_ON_TALK = 1,
GOSSIP_EVENT_ON_SELECT_OPTION = 2,
GOSSIP_EVENT_ON_END = 3,
GOSSIP_EVENT_COUNT,
[RANDOM FLAGS]
RANDOM_ANY = 0,
RANDOM_IN_SHORTRANGE = 1,
RANDOM_IN_MIDRANGE = 2,
RANDOM_IN_LONGRANGE = 3,
RANDOM_WITH_MANA = 4,
RANDOM_WITH_RAGE = 5,
RANDOM_WITH_ENERGY = 6,
RANDOM_NOT_MAINTANK = 7,
RANDOM_COUNT,


[NOTE]: 'RandomFlags' are generally used for creature targeting. hers an example.


Unit:GetRandomPlayer(7)

That will get a random player that is not the main tank. (Replacing the the 7 with a different flag when changing it of course).


When creating the meat of a function, every Lua command must have a prefix before the command that tells what will be executing the command(Gameobject/Creature/Item)

For example, when you want a Creature to cast a spell on a random target. it would need a prefix telling who is casting the spell;


function Creature_OnCombat(Unit, Event)
Unit:CastSpellOnTarget(11, Unit:GetRandomPlayer(7))
end

RegisterUnitEvent(NPCID, 1, "Creature_OnCombat")


Above, tells the Unit, To cast spell 11 (Frost bolt of the Ages) on a random player that isn't the main tank. Since it was registed "OnCombat", it will only cast this spell once as the unit enters combat, To make it cast periodically, you Register an event from inside a function.



function Creature_OnCombat(Unit, Event)
Unit:RegisterEvent("FunctionName", Interval, IntervalCount)
end

function Frostbolt(Unit, Event)
Unit:CastSpellOnTarget(11, Unit:GetRandomPlayer(7)
end


FunctionName is the name of the function your calling/registering (the name must match the name of the function you are calling), the interval is the amount of time it will take for the event to get registered, and the IntervalCount is the amount of times the function will be registered (Leave it at 0 for infinite)
Now if you make the interval 1000, and the invervalcount 0. It will cast Frostbolt at a random target that isn't the main tank every second, But say your group wipes. He will still register the event when not in combat, and when he enters combat again he will cast frostbolt twice a second. Which is why you need to use the command
Unit:RemoveEvents() which clears all events from the unit. You do this by creating a new function and registering it with the flag "2" for 'CREATURE_EVENT_ON_LEAVE_COMBAT' and "4" for "CREATURE_EVENT_ON_DIED", Then inserting Unit:RemoveEvents(), clearing all events when the NPC Leaves combat / your group wipes.



function Creature_OnCombat(Unit, Event)
Unit:RegisterEvent("FrostboltSpam", 1000, 0)
end

function FrostboltSpam(Unit, Event)
Unit:FullCastSpellOnTarget(11, Unit:GetClosestPlayer())
end

function Creature_OnLeaveCombat(Unit, Event)
Unit:RemoveEvents()
end

function Creature_OnDied(Unit, Event)
Unit:RemoveEvents()
end

RegisterUnitEvent(NPCID, 1, "Creature_OnCombat")
RegisterUnitEvent(NPCID, 2, "Creature_OnLeaveCombat")
RegisterUnitEvent(NPCID, 4, "Creature_OnDied")



You can only Register events with Creatures/NPC's. From inside Combat Events / Gossip Events, gameobjects and items cannot register events..

[1.2]Variables


Variables are a value stored in memory that can be called upon or modified at a later point in your script. Just like in grade 1 where you have to find out what goes in the box with a equation like so 1 + 2 = [ ]. The Box being the variable, would end up being 3. However we don't use boxes, It is easiest to name your variable after what the variable will be used for, especially when making large scripts. Now there are 2 types of Variables. Global variables, and local variables. Global variables are variables used throughout your entire script. Local variables are variables used within a function. When creating local variables, they need to be declared (Making the Lua engine realize they are local variables). they are declared by using the term 'local' behind the variable your declaring.

function Creature_OnCombat(Unit, Event)
local intVariable = 0
end
Global variables do not need declaration and can be created the same way as local variables, except without the usage of the term 'local'

function Creature_OnCombat(Unit, Event)
intVariable = 0
end

[NOTE]You can have the same local and global variable names as long as you do not use both of them inside the same function.
[NOTE]I'm Not sure about this haven't ever tried it, But i believe Global variables, can be used throughout all your scripts in the scripts folder. So if you want a variable to be relative to just one of your scripts, declare the variable as a local variable at the top of the script:



local intEnteredCombat = 0

function Creature_OnCombat(Unit, Event)
intEnteredCombat = intEnteredCombat + 1
end

RegisterUnitEvent(NPCID, 1, "Creature_OnCombat")




[1.3]The If Statement


When scripting with Lua, One of the most handy things to understand is an If statement. How it works is, IF <this happens / is true> then <this will happen>. Example below:



local intVariable = 0
function Creature_OnCombat(Unit, Event)
intVariable = 0
if (intVariable == 0) then -- If intVariable is equal to something other than 0, nothing will happen when the creature enters combat.
Unit:CastSpellOnTarget(11, Unit:GetRandomPlayer(7)) -- Otherwise it will cast spell 11 (frostbolt of the ages, on a random target that isn't the tank)
end

end


An if statement must always start with If, and end with end. when checking the variables value in a statement, you must use two equals signs, as opposed to one. This indicates you are checking the variables value, rather than modifying/setting it. Within an If statement you can have a few basic substatements (which are not limited to); Elseif, and Else. These statements do what they say.

function Creature_OnCombat(Unit, Event)

if (intVariable == 0) then
Unit:CastSpellOnTarget(11, Unit:GetRandomPlayer(0))
intVariable = 1
elseif (intVariable == 1) then
Unit:CastSpellOnTarget(5, Unit:GetRandomplayer(0))
else
Unit:SendChatMessage(14, 0, "intVariable has no value!)
intVariable = 0
end
end


Whats happening in the function above, is when the NPC enters combat for the first time, since intVariable was not given a value at any other point in the script, it is 'null' (nothing, no value). Which is not 0 or 1, thus executing what is in the 'else' statement, setting intVariable to 0, and sending a chat message. The 2nd time the creautre enters combat, they will cast frostbolt, and the third time and all times after that, they will cast death touch.
A good trick you can use with If statements, when timing scripts. is the use of a variable that equals itself + 1, take a look;


local intVariable = 0
function Creature_OnCombat(Unit, Event)
intVariable = 0 -- Setting a value so it isn't null.
Unit:RegisterEvent("Timer", 1000, 1)
end

function Timer(Unit, Event)
intVariable = intVariable + 1

if (intVariable == 1) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 1")
elseif (intVariable == 2) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 2")
elseif (intVariable == 3) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 3")
elseif (intVariable == 4) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 4")
elseif (intVariable == 5) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 5")
else
Unit:SendChatMessage(14, 0, "intVariable is another value aside from 1, 2, 3, 4, 5")
end
end


Now with the script above, since it's only getting registered once, (IntervalCount is 1) the function Timer, will only be executed once. we need to either set the intervalcount to 0, or create a Stop Variabe while looping the function.


local intVariable = 0
function Creature_OnCombat(Unit, Event)
intVariable = 0
intStop = 0 -- New Stop Variable
Unit:RegisterEvent("Timer", 1000, 1)
end

function Timer(Unit, Event)
intVariable = intVariable + 1

if (intVariable == 1) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 1")
elseif (intVariable == 2) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 2")
elseif (intVariable == 3) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 3")
elseif (intVariable == 4) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 4")
elseif (intVariable == 5) then
Unit:SendChatMessage(14, 0, "intVariable is equal to 5")
else
Unit:SendChatMessage(14, 0, "intVariable is another value aside from 1, 2, 3, 4, 5")
end

if (intStop == 1) then
-- nothing
elseif (intStop == 0) then
Unit:RegisterEvent("Timer", 1000, 1) -- Loops the Timer function unless intStop == 1, in which case it stops.
end
end


creating a stop variable can be useful for when you want to have a certain NPC's death trigger an event to temporarily stop, or prevent an NPC from spawning if one already spawned. And it is a lot safer as when you have intervalcount set to 0, if you spawn more than 1 NPC, you can have an event registered more often than you want.


[1.4]Command List & Usage


[NOTE]:Some of these Commands may not work with some Lua Engines



math.random(min, max) -- returns a random number between min and max. Best used as a variable
Ex.______________________
Choice=math.random(1,5)
if (choice == 5) then
player:SendAreaTriggerMessage("You just won the lottery")
end
_________________________

Gossip Commands
Item:GossipCreateMenu(textid, player, 0)
Item:GossipMenuAddItem(iconid, "name", intid, type);
Item:GossipSendMenu(player);
Item:GossipComplete(player);
Item:GossipSendPOI(player, Xcoord, Ycoord, icon, flags, data, nameofPOI);
Unit:GossipCreateMenu(textid, player, 0);
Unit:GossipMenuAddItem(iconid, "name" intid, type);
Unit:GossipSendMenu(player);
Unit:GossipComplete(player);
Unit:GossipSendPOI(player, Xcoord, Ycoord, icon, flags, data, nameofPOI);
GameObject:GossipCreateMenu(textid, player, 0);
GameObject:GossipMenuAddItem(iconid, "name", intid, type);
GameObject:GossipSendMenu(player);
GameObject:GossipComplete(player);
GameObject:GossipSendPOI(player, Xcoord, Ycoord, icon, flags, data, nameofPOI);

[NOTE] for GossipCreateMenu: textid, is the same id used in npc_textid, however you cannot have the same textid for 2 different menus.
[NOTE] iconid = Icon next to the text in the menu list ingame. intid is a variable used in GossipSubMenu, type - 0 is regular, 1 = code(A prompt box pops up and you have to enter a new value for the variable 'code', doesn't work that good.)

GET COMMANDS

Unit:GetPlayerRace(); -- returns number based on race. [1=Human][2=Orc][3=Dwarf][4=NightElf][5=Undead][6=Tauren][7=Gnome][8=Troll][10=BloodElf][11=Draenei]
Unit:GetCurrentSpellId(); -- Returns spell ID the target is currently casting
Unit:GetStanding(lua_State * L, Unit * ptr);
Unit:GetMainTank(lua_State * L, Unit * ptr);
Unit:GetAddTank(lua_State * L, Unit * ptr);
Unit:GetX(); -- Returns X Coordinate
Unit:GetY(); -- Returns Y Coordinate
Unit:GetZ(); -- Returns Z Coordinate
Unit:GetO(); -- Returns Orientation
Unit:GetTauntedBy(); -- returns player who taunted
Unit:GetSoulLinkedWith(lua_State * L, Unit * ptr);
Unit:GetItemCount(itemid); -- returns amount
Unit:GetName(); -- returns Unit Name
Unit:GetHealthPct(); -- Returns Units health betweeen 1 and 100
Unit:GetManaPct(); -- Returns Units Mana between 1 and 100
Unit:GetInstanceID(); -- returns instance id
Unit:GetClosestPlayer(RandomFlag); -- Gets closest player; use Random Flags.
Unit:GetRandomPlayer(RandomFlag); -- Gets random player; use Random Flags.
Unit:GetRandomFriend(); -- Gets Random friend / player; use Random flags?.
Unit:GetUnitBySqlId(); -- Gets another NPC by their SQLID
Unit:GetPlayerClass(); -- Returns number based on class. [Warrior=1][Paladin=2][Hunter=3][Rogue=4][Priest=5][Deathknight=6][Shaman=7][Mage=8][Warlock=9][Druid=11]
Unit:GetHealth(); -- Returns Units Current health
Unit:GetMaxHealth(); -- Returns units Max health
Unit:GetCreatureNearestCoords(x, y, z, NPCID);
Unit:GetGameObjectNearestCoords(x, y, z, GOID);
Unit:GetDistance(); -- Returns Distance. .debug rangecheck (Uses distance2dsq, 2 distance only.)
Unit:GetGUID(); -- Returns GUID
Unit:GetZoneId(); -- Returns GUID
Unit:GetMaxMana(Value); -- Sets Max Mana
Unit:GetMana(); -- Returns Current Mana
Unit:GetCurrentSpell(); -- returns current spell id?
Unit:GetSpawnO(); -- Returns Orientation of original Spawn
Unit:GetSpawnZ(); -- Returns Z Coordinate of original Spawn
Unit:GetSpawnY(); -- Returns Y Coordinate of original Spawn
Unit:GetSpawnX(); -- Returns X coordinate of Original Spanw
Unit:GetInRangePlayersCount(); -- Returns number based on amount of in range players.
Unit:GetUInt32Value(lua_State * L, Unit * ptr);
Unit:GetUInt64Value(lua_State * L, Unit * ptr);
Unit:GetFloatValue(lua_State * L, Unit * ptr);
Unit:GetAIState(lua_State * L, Unit * ptr);
Unit:GetCurrentSpell(); -- same as others?
Unit:GetInRangeGameObjects(); -- Returns Gameobjects in range in a Table (Cannot be used as a target)--\_____ Will get error "Unit Expected, got Nil"
Unit:GetInRangePlayers(); -- Returns In range Players in a Table (Cannot be used as a target)----------/
Unit:GetAITargets(lua_State * L, Unit * ptr);
Unit:GetUnitByGUID(); -- Returns Unit by their Guid
Unit:GetInRangeObjectsCount(); -- Returns a number based on amount of in range gameobjects
Unit:GetAITargetsCount(lua_State * L, Unit * ptr);
Unit:GetUnitToFollow(lua_State * L, Unit * ptr);
Unit:GetNextTarget(); -- Gets next highest threat target.
Unit:GetPetOwner(lua_State * L, Unit * ptr);
Unit:GetEntry(); -- Returns npc entryid?
Unit:GetFaction(); -- Returns NPC's faction
Unit:GetThreatByPtr(lua_State * L, Unit * ptr);
Unit:GetInRangeFriends(lua_State * L, Unit * ptr);
Unit:GetPowerType(lua_State * L, Unit * ptr);
Unit:GetMapId(); -- Returns Mapid
Unit:GetFactionStanding(lua_State * L, Unit * ptr);
Unit:GetPlayerLevel(); -- Returns playerlevel

IS COMMANDS -- Will returns '1' or 'true' if true. Not sure what one.

Unit:IsPlayerAttacking();
Unit:IsPlayerMoving();
Unit:IsPlayerAtWar(factionID);
Unit:IsPlayer();
Unit:IsCreature();
Unit:IsInCombat();
Unit:IsAlive();
Unit:IsDead(l);
Unit:IsInWorld();
Unit:IsCreatureMoving();
Unit:IsFlying();
Unit:IsInFront();
Unit:IsInBack();
Unit:IsPacified();
Unit:IsFeared();
Unit:IsStunned();
Unit:HasInRangeObjects();
Unit:IsInWater();
Unit:IsInArc();
Unit:IsPet();
Unit:MoveFly();
Unit:NoRespawn();
Unit:HasItem();
Unit:FlyCheat();

OTHER COMMANDS

Unit:AdvanceSkill(skillid, amount);
Unit:AddSkill(skillid);
Unit:RemoveSkill(skillid);
Unit:PlaySpellVisual(lua_State * L, Unit * ptr);
Unit:RemoveThreatByPtr(lua_State * L, Unit * ptr);
Unit:EventCastSpell(lua_State * L, Unit * ptr);
Unit:AttackReaction(lua_State * L, Unit * ptr);
Unit:DismissPet(lua_State * L, Unit * ptr);
Unit:HandleEvent(lua_State * L, Unit * ptr);
Unit:SetMoveRunFlag(lua_State * L, Unit * ptr);
Unit:SendChatMessage(Language, Type, "Message"); -- Langage; what language message is in, type = what form message is in (say/yell/whisper), "message" = duh
Unit:MoveTo(x, y, z, o); -- Once NPC gets to position i reccomend using Unit:SetFacing(Orientation) if O coordinate doesn't work.
Unit:SetMovementType(lua_State * L, Unit * ptr);
Unit:CastSpell(SpellID); -- Casts spell on Itself
Unit:CastSpellOnTarget(spellID, target); -- Casts spell ID on a target with no casttime, mights till be bugged and cast on itself
Unit:FullCastSpell(spellid); -- Fully casts a spell on itself / aoe spell
Unit:FullCastSpellOnTarget(spellid, target); -- Full casts a spell on a target.
Unit:SpawnGameObject(GOID, x, y, z, o, duration); -- self explanitory (set duration to 0 to keep gameobject spawned until server restart/shutdown
Unit:SpawnCreature(NPCID, x, y, z, o, faction, duration); -- self explanitory (set duration to 0 to keep creatued spawned forever until server restart/shutdown)
Unit:RegisterEvent("Event", Interval, IntervalCount); -- "Event"; event name, Interval; amount of time between registering the event again, IntervalCount; Amount of times to register the event.
Unit:RemoveEvents(); -- Removes all events from the Unit
Unit:SendBroadcastMessage("Text"); -- player only command, sends to chat box (player:SendBroadcastMessage("BroadcastMessageAppearsInTextBox"))
Unit:SendAreaTriggerMessage(lua_State * L, Unit * ptr); -- player only command, sends across screen (player:SendAreaTriggerMessage("AreaTriggerMessageAppearsAcrossScreen"))
Unit:KnockBack(dx, dy, affect1, affect2); -- Not sure, distancex, distancey, affects might be spell ID's?
Unit:MarkQuestObjectiveAsComplete(lua_State * L, Unit * ptr); -- no clue
Unit:LearnSpell(SpelLID); -- learns spellid, may be player only command
Unit:UnlearnSpell(SpellID); -- Unlearns spellid, may be player only command
Unit:HasFinishedQuest(QuestID); -- Returns true / 1 if true
Unit:ClearThreatList(); -- Drops all agro, may even leave combat
Unit:ChangeTarget(lua_State * L, Unit * ptr);
Unit:Emote(emoteid, time);
Unit:Despawn(despawntime, respawntime); -- despawntime = despawns in x miliseconds, respawntime = respawns in x miliseconds. (To Permanantly remove a creature spawned by another creature with no SQLID, use :RemoveFromWorld()
Unit:PlaySoundToSet(SoundID);
Unit:RemoveAura(SpellID);
Unit:StopMovement(Time); -- time = Time in miliseconds
Unit:AddItem(itemid, itemcount); -- playeronly command
Unit:RemoveItem(itemid, itemcount); -- playeronly command
Unit:CreateCustomWaypointMap(lua_State * L, Unit * ptr);
Unit:CreateWaypoint(lua_State * L, Unit * ptr);
Unit:DestroyCustomWaypointMap(lua_State * L, Unit * ptr);
Unit:MoveToWaypoint(lua_State * L, Unit * ptr);
Unit:TeleportUnit(map, x, y, z); -- Teleports player that clicked to location, not sure~ might teleport the Unit.
Unit:ClearHateList(); -- Resets threat list, gets random target
Unit:WipeHateList(); -- clears hate list, might leave combat
Unit:WipeTargetList(lua_State * L, Unit * ptr);
Unit:WipeCurrentTarget(lua_State * L, Unit * ptr);
Unit:CastSpellAoF x, y, z, spellid); -- self explanitory
Unit:RemoveAllAuras(); -- removes all auras, hostile and friendly
Unit:StopChannel(); -- stops channeling
Unit:ChannelSpell(spellid, target); -- channels spell on target?
Unit:ReturnToSpawnPoint(); -- returns to spawn point
Unit:HasAura(spellid); -- returns true or 1 if true.
Unit:Land(); -- Unit removes 1024 flag of flying.
Unit:CancelSpell(spellid); -- stops casting spell?
Unit:Root(target); -- self
Unit:Unroot(target); -- explanitory?
Unit:CalcDistance(target); -- returns value based in yards?
Unit:ModUInt32Value(lua_State * L, Unit * ptr);
Unit:ModFloatValue(lua_State * L, Unit * ptr);
Unit:SendData(lua_State * L, Unit * ptr);
Unit:InitPacket(lua_State * L, Unit * ptr);
Unit:AddDataToPacket(lua_State * L, Unit * ptr);
Unit:AddGuidDataToPacket(lua_State * L, Unit * ptr);
Unit:AdvanceQuestObjective(lua_State * L, Unit * ptr);
Unit:Heal(lua_State * L, Unit * ptr);
Unit:Energize(lua_State * L, Unit * ptr);
Unit:SendChatMessageAlternateEntry(lua_State * L, Unit * ptr);
Unit:SendChatMessageToPlayer(lua_State * L, Unit * ptr);
Unit:Strike(lua_State * L, Unit * ptr);
Unit:Kill(target);
Unit:DealDamage(lua_State * L, Unit * ptr);
Unit:CreateGuardian(lua_State * L, Unit * ptr);
Unit:CalcToDistance(lua_State * L, Unit * ptr);
Unit:CalcAngle(lua_State * L, Unit * ptr);
Unit:CalcRadAngle(lua_State * L, Unit * ptr);
Unit:IsInvisible(lua_State * L, Unit * ptr);
Unit:IsInvincible(lua_State * L, Unit * ptr);
Unit:ResurrectPlayer(player); -- player only command
Unit:KickPlayer(lua_State * L, Unit * ptr);
Unit:CanCallForHelp(lua_State * L, Unit * ptr);
Unit:CallForHelpHp(lua_State * L, Unit * ptr);
Unit:RemoveFromWorld(); -- Removes Unit From World (useful for npcs not saved to the Db {NPC spawned by other NPCS with no GUID})
Unit:SpellNonMeleeDamageLog(lua_State * L, Unit * ptr);
Unit:ModThreat(lua_State * L, Unit * ptr);
Unit:AddAssistTargets(lua_State * L, Unit * ptr);
Unit:RemoveAurasByMechanic(lua_State * L, Unit * ptr);
Unit:RemoveAurasType(lua_State * L, Unit * ptr);
Unit:AddAuraVisual(lua_State * L, Unit * ptr);

SET COMMANDS

Unit:SetPlayerStanding(lua_State * L, Unit * ptr);
Unit:SetPlayerLevel(level); -- might not work
Unit:SetPlayerAtWar(lua_State * L, Unit * ptr);
Unit:SetCreatureName(lua_State * L, Unit * ptr);
Unit:SetDeathState(lua_State * L, Unit * ptr);
Unit:SetPowerType(lua_State * L, Unit * ptr);
Unit:SetAttackTimer(time, duration);
Unit:SetMana(Value); -- sets currnet mana
Unit:SetMaxMana(Value);
Unit:SetHealth(Value); -- sets current health
Unit:SetMaxHealth(Value);
Unit:SetFlying(); -- Sets NPC to fly.
Unit:SetCombatCapable(1); --------\
Unit:SetCombatMeleeCapable(1); ----\
Unit:SetCombatRangedCapable(1); ----\_________ Set to 1 for Disableing Capableness, set to 0 to enable it again.
Unit:SetCombatSpellCapable(1); -----/
Unit:SetCombatTargetingCapable(1);-/
Unit:SetNPCFlags(NPCFLAGS); -- sets npc flags
Unit:SetModel(displayid); -- displayid
Unit:SetScale(Scale); -- size
Unit:SetFaction(faction); -- faction id
Unit:SetStandState(lua_State * L, Unit * ptr);
Unit:SetTauntedBy(lua_State * L, Unit * ptr);
Unit:SetSoulLinkedWith(lua_State * L, Unit * ptr);
Unit:SetInFront(lua_State * L, Unit * ptr);
Unit:SetHealthPct(%); -- sets health Percent
Unit:SetOutOfCombatRange(lua_State * L, Unit * ptr);
Unit:ModifyRunSpeed(lua_State * L, Unit * ptr);
Unit:ModifyWalkSpeed(lua_State * L, Unit * ptr);
Unit:ModifyFlySpeed(lua_State * L, Unit * ptr);
Unit:SetRotation(Orientation);
Unit:SetOrientation(Orientation);
Unit:SetUInt32Value(lua_State * L, Unit * ptr);
Unit:SetUInt64Value(lua_State * L, Unit * ptr);
Unit:SetFloatValue(lua_State * L, Unit * ptr);
Unit:SetUnitToFollow(lua_State * L, Unit * ptr);
Unit:SetNextTarget(lua_State * L, Unit * ptr);
Unit:SetPetOwner(lua_State * L, Unit * ptr);
Unit:SetFacing(lua_State * L, Unit * ptr);

GAMEOBJECT LIST

GET COMMANDS
GameObject:GetName(lua_State * L, GameObject * ptr);
GameObject:GetMapId(lua_State * L, GameObject * ptr);
GameObject:GetCreatureNearestCoords(lua_State * L, GameObject * ptr);
GameObject:GetGameObjectNearestCoords(lua_State *L, GameObject * ptr);
GameObject:GetAreaID(lua_State * L, GameObject * ptr);
GameObject:GetClosestPlayer(lua_State * L, GameObject * ptr);
GameObject:GetZoneId(lua_State *L, GameObject * ptr);
GameObject:GetItemCount(lua_State * L, GameObject * ptr);
GameObject:GetSpawnX(lua_State * L, GameObject * ptr);
GameObject:GetSpawnY(lua_State * L, GameObject * ptr);
GameObject:GetSpawnZ(lua_State * L, GameObject * ptr);
GameObject:GetSpawnO(lua_State * L, GameObject * ptr);
GameObject:GetInRangePlayersCount(lua_State * L, GameObject * ptr);
GameObject:GetEntry(lua_State * L, GameObject * ptr);
GameObject:GetX(lua_State * L, GameObject * ptr);
GameObject:GetY(lua_State * L, GameObject * ptr);
GameObject:GetZ(lua_State * L, GameObject * ptr);
GameObject:GetO(lua_State * L, GameObject * ptr);
GameObject:GetInRangePlayers(lua_State * L, GameObject * ptr);
GameObject:GetInRangeGameObjects(lua_State * L, GameObject * ptr);
GameObject:GetInstanceID(lua_State * L, GameObject * ptr);
GameObject:GetUInt64Value(lua_State * L, GameObject * ptr);
GameObject:GetUInt32Value(lua_State * L, GameObject * ptr);
GameObject:GetFloatValue(lua_State * L, GameObject * ptr);
GameObject:GetGUID(lua_State * L, GameObject* ptr);

OTHER COMMANDS
GameObject:Teleport(lua_State * L, GameObject * ptr); -- player command, player:Teleport(map, x, y, z)
GameObject:AddItem(lua_State * L, GameObject * ptr); -- player command, player:AddItem(itemid, itemcount)
GameObject:Despawn(lua_State * L, GameObject * ptr);
GameObject:IsInWorld(lua_State * L, GameObject * ptr);
GameObject:IsInBack(lua_State * L, GameObject * ptr);
GameObject:IsInFront(lua_State * L, GameObject * ptr);
GameObject:PlaySoundToSet(lua_State * L, GameObject * ptr);
GameObject:SpawnCreature(lua_State * L, GameObject * ptr);
GameObject:SpawnGameObject(lua_State * L, GameObject * ptr);
GameObject:CalcDistance(lua_State * L, GameObject * ptr);
GameObject:SetOrientation(lua_State * L, GameObject * ptr);
GameObject:RemoveFromWorld(lua_State * L, GameObject * ptr);
GameObject:CalcRadAngle(lua_State * L, GameObject * ptr);
GameObject:SetUInt32Value(lua_State * L, GameObject * ptr);
GameObject:SetUInt64Value(lua_State * L, GameObject * ptr);
GameObject:SetFloatValue(lua_State * L, GameObject * ptr);
GameObject:ModUInt32Value(lua_State * L, GameObject * ptr);
GameObject:CastSpell(lua_State * L, GameObject * ptr);
GameObject:FullCastSpell(lua_State * L, GameObject * ptr);
GameObject:CastSpellOnTarget(lua_State * L, GameObject * ptr);
GameObject:FullCastSpellOnTarget(lua_State * L, GameObject * ptr);
GameObjectvEventCastSpell(lua_State * L, GameObject * ptr);
GameObject:GossipObjectCreateMenu(lua_State * L, GameObject * ptr);
GameObject:GossipObjectMenuAddItem(lua_State * L, GameObject * ptr);
GameObject:GossipObjectSendMenu(lua_State * L, GameObject * ptr);
GameObject:GossipObjectComplete(lua_State * L, GameObject * ptr);
GameObject:GossipObjectSendPOI(lua_State * L, GameObject * ptr);
GameObject:ModUInt32Value(lua_State * L, GameObject * ptr);
GameObject:ModFloatValue(lua_State * L, GameObject * ptr);
GameObject:GetFloatValue(lua_State * L, GameObject * ptr);
GameObject:InitPacket(lua_State * L, GameObject * ptr);
GameObject:AddDataToPacket(lua_State * L, GameObject * ptr);
GameObject:AddGuidDataToPacket(lua_State * L, GameObject * ptr);
GameObject:SendData(lua_State * L, GameObject * ptr);


[1.5]Commenting


Thought i'd add this in here real quick. Commenting code is done by using two '-' followed by a space and text of your choice for reminders or tags for certain lines of code. heres an example;

function Creature_OnLoad(Unit, Event)
Unit:RegisterEvent("Timer", 1000, 1)
end

function Timer(Unit, Event)
Unit:FullCastSpellOnTarget(35853, Unit:GetRandomPlayer(7)) -- [SPELLID:35853 = Chain Fireball]
end


another example is encasing a large paragraph of text using --[[ & -- ]. Heres an example



-- [[
################################################## #############
# #
# #
# #
# Dumb Header For scripting Teams? #
# #
# #
# #
################################################## ############# -- ]]

function Creature_OnLoad(Unit, Event)
Unit:RegisterEvent("SendChatMessage", 1000, 0)
end

function SendChatMessage(Unit, Event)
Unit:SendChatMessage(12, 0, "Im an annoying spammer NPC...")
Unit:SetFaction(14)
Unit:CastSpell(5) -- Deathtouches himself
end



[2.0] Creature Events


Most Common Creature Commands & Usage[2.1]


The most common commands when scripting a boss fight of creature are;



Unit:RegisterEvent("EventName", Interval, IntervalCount)
Unit:CastSpell(Spellid)
Unit:CastSpellOnTarget(SpellId, target)
Unit:FullCastSpellOnTarget(SpellId, target)
Unit:FullCastSpell(SpellID)
Unit:GetHealthPct()
Unit:SetModel(DisplayID)
Unit:GetRandomPlayer(FLAG)
[RANDOM FLAGS]
RANDOM_ANY = 0,
RANDOM_IN_SHORTRANGE = 1,
RANDOM_IN_MIDRANGE = 2,
RANDOM_IN_LONGRANGE = 3,
RANDOM_WITH_MANA = 4,
RANDOM_WITH_RAGE = 5,
RANDOM_WITH_ENERGY = 6,
RANDOM_NOT_MAINTANK = 7,
Unit:GetClosestPlayer()
Unit:SpawnCreature(creatureID, x, y, z, o, faction, duration) -- duration = 0 for infinite.
Unit:SendChatMessage(language, channeltype, "Message")
Unit:RemoveEvents()




function Creature_OnCombat(Unit, Event)
Unit:RegisterEvent("WatchHealth", 1000, 1)
end

function WatchHealth(Unit, Event)
if Unit:GetHealthPct() <= 80 then
Unit:RemoveEvents() -- Removes constant Registering event from OnCombat
Unit:RegisterEvent("Phase2", 1000, 1) -- Registers Phase2.
Unit:FullCastSpellOnTarget(11, Unit:GetRandomPlayer(7))
Unit:SendChatMessage(41, 0, "Creature begins to transform!, and his minion appears!")
Unit:SetModel(28090)
Unit:SpawnCreature(6, 1234, 432, 42, 0, 14, 10000) -- Spawns creature 6(Kobold vermin), at x1234, y 432, z 42, and its orientation facing north. its faction is 14, and it will despawn 10 seconds after it is spawned.
else
Unit:RegisterEvent("WatchHealth", 5000, 1)
end
end



Languages and Channeltypes for SendChatMessage



[Language ID
0 = Universal
1 = Orcish
2 = Darnassian
3 = Tauron
6 = Dwarfs
7 = Common
8 = Demonic
9 = Titans
13 = Gnomish
14 = Troll language
33 = Gutterspeak
35 = Draenei

[ChannelTypes
12 = Say
14 = Yell
13 = Whisper
16 = Emote
41 = Area Broadcast with sound \__________ ex: "The lava around sarthiron begins to churn" then the bell noise.
42 = Area Broadcast with sound /



[2.3]Combat and General Events


Bosses are where you can really let your imagination run wild. A Boss must be fun. But no matter how simple it is, you must make sure it is a unique and entertaining fight, Otherwiset, The fight will get boring, no one will attempt the boss as much, everyone will have the same loot. So i'm here to hopefully show you how to make a good fun boss fight. However, your scripts are only as good as your imagination.

But before i start, any new Commands i use in the examples below will be explained and they will also have an example for them. Also, i will be using Kobold Vermins entry ID for the boss, rawr.

To start, I will show you how to create phases, There is a few different ways;


1). This takes a bit more work, but is generally easier to handle.


function Creature_OnCombat(Unit, Event)
Unit:SendChatMessage(14, 0, "rawr its my first phase")
Unit:RegisterEvent("Creature_FirstPhase", 1000, 1)
end

function Creature_FirstPhase(Unit, Event)
if Unit:GetHealthPct() <= 80 then
Unit:RegisterEvent("Creature_SecondPhase", 1000, 1) -- The boss is below 80% hp, registering 2nd phase.
Unit:SendChatMessage(14, 0, "Rawr entering second phase") -- This is where you will input any spells or chat messages you only want to be said ONCE when your npc enters their next phase.
else
Unit:RegisterEvent("Creature_FirstPhase", 1000, 1) -- If the boss isn't below 80% hp, it will register the event and check again every 1 second.
end
end

function Creature_SecondPhase(Unit, Event)
-- Second phase code.
end

RegisterUnitEvent(6, 1, "Creature_OnCombat")



2). This requires the least work, but sometimes can cause problems



function Creature_OnCombat(Unit, Event)
Unit:SendChatMessage(14, 0, "rawr its my first phase")
Unit:RegisterEvent("Creature_FirstPhase", 1000, 0)
end

function Creature_FirstPhase(Unit, Event)
if Unit:GetHealthPct() <= 80 then
Unit:RemoveEvents() -- Removing this event , so it stops registering since its interval count is set to infinite.
Unit:RegisterEvent("Creature_SecondPhase", 1000, 0)
end
end

function Creature_SecondPhase(Unit, Event)
-- Second phase code.
end


[NOTE]: Unit:RemoveEvents() must be before Unit:RegisterEvent("Creature_SecondPhase", 1000,0) otherwise, Creature_SecondPhase event, will be removed.

3). This way, is similar to the first one, except your phases aren't based on the bosses health, there based on if, for example - There add dies, and we have a stoptrigger get set to 1. I added in another variable to count how many seconds goesby so you can time spells or events you want to happen at certain points in phase one.



local intCreatureAddDeadTrigger = 0
local intPhaseOneCount = 0

function Creature_OnCombat(Unit, Event)
Unit:SendChatMessage(41, 0, "The creature awakens.")
Unit:RegisterEvent("Creature_PhaseOne", 1000, 1)
Unit:SpawnCreature(NPCID, x, y, z, o, 14, 0)
end

function Creature_PhaseOne(Unit, Event)
intPhaseOneCount = intPhaseOneCount + 1

if (intPhaseOneCount == 15) then
-- After 15 seconds he'll do this and so on...
elseif (intPhaseOneCount == 30) then
-- and so on...
elseif (intPhaseOneCount == 35) then
-- ... and so on...
elseif (intPhaseOneCount == 50) then
-- On your last event you want to happen, set intPhaseOneCount back to 0 so it will continue to loop the events above.
end


if (intCreatureAddDeadTrigger == 1) then
Unit:RegisterEvent("Creature_PhaseTwo", 1000, 1)
else
Unit:RegisterEvent("Creature_PhaseOne", 1000, 1)
end
end

function Creature_PhaseTwo(Unit, Event)
-- awmahgawd phase 2.
end

function CreatureAdd_OnDied(Unit, Event)
intCreatureAddDeadTrigger = 1
end

RegisterUnitEvent(NPCID, 4, "CreatureAdd_OnDied")
RegisterUnitEvent(NPCID, 1, "Creature_OnCombat")



At first, i was surprised about how short this section was, but then i realized, After you know about what you can do with variables and if statements, and then how to make phases, you can do whatever you want.

[2.9]Creature Summary and Tips


There is a few things i know to make your life much much easier. The first thing is making an NPC as a whole, a variable, Meaning NPCs can cast spells on each other, Say things, all in the same function.. (Thanks Stoneharry)



function Creature_OnLoad(Unit, Event)
-- Say the bosses name is Fresca (Courtesy of the leaning tower of pop cans on my desk)
Fresca = Unit -- What this does, is makes the "Unit" from this function into the variable of "Fresca"
end

RegisterUnitEvent(NPCID, 18, "Creature_OnLoad")



The reason this is insanely useful is due to being able to have two different creatures being able to do something in the same function. And when your timing an even where two different npcs talk to eachother, ect ect. You can do that without making a parralell function line and trying to get the timing right. heres an example.




local TalkStartCount = 0

function CreatureOne_OnLoad(Unit, Event)
COne = Unit
end

function CreatureTwo_OnLoad(Unit, Event)
CTwo = Unit
end

function CreatureOne_OnCombat(Unit, Event)
COne:RegisterEvent("Talk_Start", 1000, 15)
COne:SetCombatMeleeCapable(1) -- All this just makes them friendly, and stand still / not attackable
CTwo:SetCombatMeleeCapable(1) -- Whlie there talking to each other before
COne:SetFaction(35) -- the actual event happens and
CTwo:SetFaction(35) -- you have to fight them
end

function Talk_Start(Unit, Event)
TalkStartCount = TalkStartCount + 1

if (TalkStartCount == 1) then
COne:SendChatMessage(14, 0, "Hey, how are you doing")
elseif (TalkStartCount == 5) then
CTwo:SendChatMessage(14, 0, "Good... and yourself")
elseif (TalkStartCount == 10) then
COne:SendChatMessage(14, 0, "I'm going to kill you")
elseif (TalkStartCount == 15) then
CTwo:SendChatMessage(14, 0, "gasp.")
CTwo:SetFaction(84)
COne:SetFaction(106)
CTwo:SetCombatMeleeCapable(0)
COne:SetCombatMeleeCapable(0)
end
end

RegisterUnitEvent(NPCID, 18, "CreatureTwo_OnLoad")
RegisterUnitEvent(NPCID, 18, "CreatureOne_OnLoad")
RegisterUnitEvent(NPCID, 1, "CreatureOne_OnCombat")



This instead of...



local TalkStartCountTwo = 0
local TalkStartCountOne = 0

function CreatureTwo_OnCombat(Unit, Event)
Unit:RegisterEvent("TalkTwo_Start", 1000, 15)
Unit:SetCombatMeleeCapable(1)
Unit:SetFaction(35)
end

function TalkTwo_Start(Unit, Event)
TalkStartCountTwo = TalkStartCountTwo + 1

if (TalkStartCountTwo == 1) then
COne:SendChatMessage(14, 0, "Hey, how are you doing")
elseif (TalkStartCountTwo == 10) then
COne:SendChatMessage(14, 0, "I'm going to kill you")
Unit:SetFaction(84)
Unit:SetCombatMeleeCapable(0)
end
end

function CreatureOne_OnCombat(Unit, Event)
Unit:RegisterEvent("TalkOne_Start", 1000, 15)
Unit:SetCombatMeleeCapable(1)
Unit:SetFaction(35)
end

function TalkOne_Start(Unit, Event)
TalkStartCountOne = TalkStartCountOne + 1

if (TalkStartCountOne == 5) then
CTwo:SendChatMessage(14, 0, "Good... and yourself")
elseif (TalkStartCountOne == 15) then
Unit:SendChatMessage(14, 0, "Gasp")
Unit:SetFaction(106)
Unit:SetCombatMeleeCapable(0)
end
end

RegisterUnitEvent(NPCID, 18, "CreatureTwo_OnLoad")
RegisterUnitEvent(NPCID, 18, "CreatureOne_OnLoad")
RegisterUnitEvent(NPCID, 1, "CreatureOne_OnCombat")
RegisterUnitEvent(NPCID, 1, "CraetureTwo_OnCombat")


Red highlights indicate what doesn't need to be there if we used the first method.

You can probably imagine how much more usefull this will become once your scripts get larger, and you have more than 2 NPC's.

Another tip is keeping you code clean, there is proper coding edicate i believe, but if its your own script. using Tabs instead of 5 spaces isn't going to hurt anything. Space your codes lines out appropriately so its easy to read through the code, or if you realase you scripts its easy for people to re-read them and modify them to their liking.
Sometimes you'll see code with no spaces, and some with plenty of spaces, heres an example.

No Spaces


local intCount = 0

function Creature_OnCombat(Unit, Event)
Unit:RegisterEvent("OmgWhatAMess", 1000, 1)
Unit:SendChatMessage(14, 0, "Hello everyone")
end

function OmgWhatAMess(Unit, Event)
intCount = intCount + 1
if (intCount == 1) then
Unit:SendChatMessage(12, 0, "intcount is equal to 1)
elseif (intCount == 2) then
UnitSendChatMessage(12, 0, "intCount is equal to 2
Unit:FullCastSpellOnTarget(11, Unit:GetClosestPlayer())
else
Unit:SendChatMessage(14, 0, "whats going on")
intCount = 0
end
if Unit:GetHealthPct() <= 80 then
Unit:RegisterEvent("phasetwo", 1000, 1)
else
Unit:RegisterEvent(OmgWhatAMess", 1000, 1)
end
end
RegisterUnitEvent(NPCID, 1, "Creature_OnCombat")



With Spaces



local intCount = 0

function Creature_OnCombat(Unit, Event)
Unit:RegisterEvent("OmgWhatAMess", 1000, 1)
Unit:SendChatMessage(14, 0, "Hello everyone")
end


function OmgWhatAMess(Unit, Event)
intCount = intCount + 1

if (intCount == 1) then
Unit:SendChatMessage(12, 0, "intcount is equal to 1)
elseif (intCount == 2) then
UnitSendChatMessage(12, 0, "intCount is equal to 2
Unit:FullCastSpellOnTarget(11, Unit:GetClosestPlayer())
else
Unit:SendChatMessage(14, 0, "whats going on")
intCount = 0
end

if Unit:GetHealthPct() <= 80 then
Unit:RegisterEvent("phasetwo", 1000, 1)
else
Unit:RegisterEvent(OmgWhatAMess", 1000, 1)
end

end

RegisterUnitEvent(NPCID, 1, "Creature_OnCombat")



With spaces, it becomes much clearer where If statements start and end, and in general whats actually happening in the script.



==============================================\/ Continued \/=============================================

enegue
27-10-09, 05:54 AM
[3.0]Gameobject Events

[3.1] Most Common Gameobject Commands Usage & Events.
You can't do too much with Gameobjects, some people may argue with me but at least on my lua engine, Gameobjects are relatively limited to teleporting.

To make a simple teleport portal. All do you is use the player:teleport command in the registered event.

[NOTE]: Most of these examples are going to be copied and pasted from my server, sorry if some of the coords are messed up



function Gameobject_OnUse(Unit, Event, player)
player:Teleport(mapid, x, y, z)
end

RegisterGameObjectEvent(GOID, 4, "Gameobject_OnUse")


Now, thats not that interesting. However you can add in a few more things, If the player is in combat, you can make the portal un-usable to them;



function Gameobject_OnUse(Unit, Event, player)
if (player:IsInCombat() == true) then
player:SendAreaTriggerMessage("You are in combat!")
else
player:Teleport(mapid, x, y , z)
end
end

RegisterGameObjectEvent(GOID, 4, "Gameobject_OnUse")


Some other things you can do, Is for instance, to avoid people camping where people get ported in in gurubashi, you can write the script with math.random command (I'll add that command in the command list above :X) Ex.



function GurubashiPortal_OnUse(Unit, Event, player)
local Choice=math.random(1, 5) -- Chooses a random number between 1 and 5, That value is stored as the local variable 'choice'
if (player:IsInCombat() == true) then
player:SendBroadcastMessage("You are in combat!")
else
if (Choice == 1) then -- Depending on what number came out of the math.random command, Choice's value can be equal to any of the below values in the if statements. Teleporting a player randomly to 1 of 5 spots in gurubashi arena.
player:Teleport(0, -13217, 184, 100)
elseif (Choice == 2) then
player:Teleport(0, -13269, 212, 100)
elseif (Choice == 3) then
player:Teleport(0, -13294.5, 279, 100)
elseif (Choice == 4) then
player:Teleport(0, -13171, 337, 100)
elseif (Choice == 5) then
player:Teleport(0, -13148, 226, 100)
end
end
end

RegisterGameObjectEvent(98815, 4, "GurubashiPortal_OnUse")


[Note]: SQL Below if you're interested. Arcemu structure


INSERT INTO `gameobject_names` VALUES ('98815', '22', '7849', 'Armory Portal to Gurubashi', '', '', '', '', '', '', '9438', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0');


Something i've done is made certain portals only interactable with GM's / donars. And no i didn't find out a way to check if a player is a GM.

Assuming you don't have over nine thousand Game masters (maybe donars), this shouldn't be too much of a hassle.




function PortalToThinkBox_OnUse(Unit, Event, player)
local Name = player:GetName()

if (Name == nil) then
player:SendAreaTriggerMessage("You cannot enter through here!")
elseif (Name == "GM name one") then
player:Teleport(1, 16227.4, 16403.8, -64)
elseif (Name == "GM name two") then
player:Teleport(1, 16227.4, 16403.8, -64)
elseif (Name == "GM name three") then
player:Teleport(1, 16227.4, 16403.8, -64)
elseif (Name == "GM name four") then
player:Teleport(1, 16227.4, 16403.8, -64)
elseif (Name == "GM name five") then
player:Teleport(1, 16227.4, 16403.8, -64)
else
player:SendBroadcastMessage("You are not a Game Master.")
player:Teleport(mapid, x, y, z) -- Mall Location is what i use.
end
end

-- Or of course, you can set GM/Donar names as variables..

RegisterGameObjectEvent(98814, 4, "PortalToThinkBox_OnUse")


Remember in the example above, The names must be in string form... (Wrapped in quotations) otherwise it will think GMnamefour is a variable with a nil value!

[3.3] Gameobject Summary and Tips

Gameobjects can not register events. But they can still play a good role in a bossfight, and a big part in your server if you aren't a fan of pocket teleporters (People teleport in combat / bleh) Traditional ports are the way to go IMO =).

/facepalm at this pathetic section =)


[5.0] Generalized Gossip Events


Gossip commands and usage are generally all the same for Gameobjects, NPC's and items.

A gossip script has 2 events that need to be registered. (OnGossip, and OnSelectOption / OnSubMenu)



RegisterUnitGossipEvent(NPCID, 1, "OnGossip")
RegisterUnitGossipEvent(NPCID, 2, "OnSubMenu")
RegisterGOGossipEvent(GOID, 2, "OnSubMenu")
RegisterGoGossipEvent(GOID, 1, "OnGossip")
RegisterItemGossipEvent(ITEMID, 1, "Item_OnClick")
RegisterItemGossipEvent(ITEMID, 2, "OnSubMenu")



The basics of a Lua Gossip script are as follows:



function Npc_OnGossip(Unit, Event, player)

end

function Npc_OnSubMenu(Unit, Event, player, id, intid, code)

end

[Note]intid, code, will all be explained later
"player" is the player who clicked the npc.
Not sure what id is for



The Gossip commands and usage all go inside, they are as follows;



function Npc_OnGossip(Unit, Event, player)
Unit:GossipCreateMenu(100, player, 0)
Unit:GossipMenuAddItem(0, "Name", 1, 50)
Unit:GossipSendMenu(player)
end


Those are the three basic commands to create the actual gossip interface. What they do is;



function Npc_OnGossip(Unit, Event, player)
Unit:GossipCreateMenu(textid, player, 0)
end

textid: Insert the entryid of the text you want to be displayed before your options: Ex. "Hey there, $N. How can I help you?". You can find the correct entryid in `npc_text` table.

player: Who you are creating this menu for.

0: No clue. i just know when its set to anything other than 0, the npc generally doesn't respond with any action.





function Npc_OnGossip(Unit, Event, player)
Unit:GossipMenuAddItem(symbolid, "Name of Option", intid, codeflag)
end

symbolid: Sets the ID of the symbol beside the Option Name.
Name of Option: Sets the name of the Option
intid: This is what intid will be set to if this option is selected.
codeflag: Flags triggering this option to open a input box. (1 and 3 are the flags that work.)
[Note]: please remember intid is a variable.




function Npc_OnGossip(Unit, Event, player)
Unit:GossipSendMenu(player)
end

player: who you are sending the menu too.


Ok, now that you understand what the commands are, lets get started creating an actual gossip script. I will make 3 examples. One of them will be a teleporter, Another one a guessing game.

Teleporter


function Creature_OnGossip(Unit, Event, player)
Unit:GossipCreateMenu(100, player, 0) -- Sends a menu to the player with the npc_text entryid of 100.
Unit:GossipMenuAddItem(0, "Outlands Locations", 1, 0) -- SETS intid to 1!!! And registers Creature_OnSubMenu(If its easier to remember, "OnSelectOption", same thing)
Unit:GossipSendMenu(player) -- Sends menu to the player.
end

function Creature_OnSubMenu(Unit, Event, player, id, intid, code)

if (intid == 1) then -- This is what will happen if you click outlands locations
Unit:GossipCreateMenu(100, player, 0)
Unit:GossipMenuAddItem(0, "Hellfire Penninsula", 2, 0)
Unit:GossipSendMenu(player)
end

if (intid == 2) then -- When you click on Hellfire Penninsula you get teleported since intID gets set to 2.
player:Teleport(530, x, y, z) -- usage = (mapid, x, y, z) full list of player commands with usage will be posted later.
end
end

RegisterUnitGossipEvent(NPCID, 1, "Creature_OnGossip")
RegisterUnitGossipEvent(NPCID, 2, "Creature_OnSubMenu")

NOTE: "Unit:GossipMenuAddItem(0, player, 0, 0)", Just becuase it is in an OnGossip function. (id, intid, code) still apply to their fields. For this reason, 0 sets intid to 0.


Whats happening in the script above, is when you click Outlands Locations, intid gets set to 1, At the point in time you've selected an option, which registers ("Creature_OnSubMenu"), If it doesn't make sense, think of Creature_OnSubMenu as Creature_OnSelectOption. So then that function gets registered. and your send a new menu with outland locations. Upon clicking hellfire penninsula, you clicked an option, which registers Creature_OnSubMenu yet again, and changing intid to 2, Executing the code withing the corresponding If statement.

Now below, i will make a Number guessing gossip script hopefully explaining what almost no Lua Tutorials contain... (Unit, Event, id, intid, code)




function Creature_OnGossip(Unit, Event, player)
Unit:GossipCreateMenu(100, player, 0)
Unit:GossipMenuAddItem(0, "Guess a number between 1 and 10!", 0, 3) -- 3 Flags this menu item to open an input box where a player can enter data (Like you do when redeeming a wow trading card game code for a rocket mount on retail ect ect)
Unit:GossipSendMenu(player)
end

function Creature_OnSubMenu(Unit, Event, player, id, intid, code)
if (intid == 0) then
if (code == "5") then -- code is a variable returned as whatever the player entered in the input box. Remember it is returned as a string (in word form) so whatever is it equal to must be in quotations. Having [if (code == 1) then] it will always return false and execute whats inside the 'else', this being due to anything the player types in the box will return as "<what player typed>".
player:AddItem(29434, 1) -- Adds an item to the player who clicked. player:AddItem(itemid, quantity)
else
player:SendAreaTriggerMessage("You Guessed wrong.") -- inserts a message into the players chat box in yellow.
end
end
end

RegisterUnitGossipEvent(NPCID, 1, "Creature_OnGossip")
RegisterUnitGossipEvent(NPCID, 2, "Creature_OnSubMenu")

"5" Is that value that IF what the player entered in the box is equal to, the statement will add an item to the player.


There wasn't much to explain, so i just threw in what there was to know in comments.

Its been a while since I've updated this, but i thought I'd add this small tip in for gossip scripts;

When creating a gossip scripts, It gets annoying always having to close and re-open the gossip after you've selected a certain option. For example, Say one of your gossip scripts is to give players food, The player does not want to have to re-open the gossip menu everytime he wants to get a new stack of food! So to keep the same menu active after an option has been selected, check out the example below.



function Unit_OnGossip(Unit, Event, player)
Unit:GossipCreateMenu(100, player, 0)
Unit:GossipMenuAddItem(0, "Item Selection", 1, 0)
Unit:GossipSendMenu(player)
end

function Unit_OnSelect(Unit, Event, player, id, intid, code)
if (intid == 1) then
Unit:GossipCreateMenu(101, player, 0)
Unit:GossipMenuAddItem(0, "Add Food!", 2, 0)
Unit:GossipMenuAddItem(0, "Add Water!", 3, 0)
Unit:GossipSendMenu(player)
end

if (intid == 2) then
player:AddItem(FoodItemID, amount)
intid = 1
Unit:GossipSendMenu(player)
end

if (intid == 3) then
player:AddItem(WaterItemID, amount)
intid = 1
Unit:GossipSendMenu(player)
end


end


What this does is adds an item to the players inventory, then sets intid to 1, and sends the menu associated to 1 to the player again. Keep in mind the menu being sent must be the one the player was currently on, otherwise it won't work(There is logic behind this but its late and i forget :S). To have properly working back buttons, i believe you still have to make a replica of the menu you want it to go back to.

Item Gossip

Theres not much difference between regular gossip events, and ones you'd use with an item.



function Item_OnClick(Item, Event, player)
Item:GossipCreateMenu(100, player, 0)
Item:GossipMenuAddItem(0, "hello lets telepert", 0, 0)
Item:GossipMenuAddItem(0, "hello want an item?", 2, 0)
Item:GossipSendMenu(player)
end

function OnSubMenu(Item, Event, player, id, intid, code)
if (intid == 0) then
player:Teleports(mapid, x, y, z)
end

if (intid == 1) then
player:AddItem(itemid, 1)
end
end

RegisterItemGossipEvent(ITEMID, 1, "Item_OnClick")
RegisterItemGossipEvent(ITEMID, 2, "OnSelect")


Above, is an example of an item gossip script. You script the exact same as you would with a Npcs gossip. There is almost no difference.


Below is a list of player commands usefull when creating gossip scripts.


player:AddItem(itemid, quantity) -- Adds item to the players inventory
player:Teleport(mapid, xcoord, ycoord, zcoord) -- Teleports the player to the selected coordinates.
player:SendAreaTriggerMessage("Message") -- Enters a message in the players chat box.
player:SendBroadcastMessage("Message") -- Enters a message across the players screen, where error messsages are shown
player:GossipSendPOI(player, Xcoord, Ycoord, icon, flags, data, nameofPOI); -- Flags a coordinate on your main map, and mini map, as a Point of Interest, with the assigned name, icon and coordinates. Leave data as 0. (I almost never use this command, so im not the best person to be explaining it)


Aside from those, i don't believe you use many More.

[$.#]3x7r4 1Nf0rNm471on

String Concatenation

Had to add this in here right now. Concatenation is just joining two strings together. Say if you wanted your boss to cast a spell on a certain person, and call out their name. You'd use string Concatenation.

Heres an example of having a boss call out a players name.



function Creature_OnCombat(Unit, Event)
Unit:RegisterEvent("Creature_CastSpell", 30000, 0)
end

function Creature_CastSpell(Unit, Event)
local name = Unit:GetRandomPlayer(7)
Unit:FullCastSpellOnTarget(
Unit:SendChatMessage(14, 0, "Enjoy sum frostbewltz"..name) -- "Enjoy sum frostbewltz" is the first part of the string, and 'name' is the variable your joining together.
end -- The two dots are what is joining them together.

RegisterUnitEvent(NPCID, 1, "Creature_OnCombat")

Creature yells: Enjoy sum frostbewltz VisionOneThousand


two periods and two alone, are what you use to join two strings together when you want to do something like above. Or when your debugging a stupid script that won't work, and you can't figure out why a certain value even though set, will never be equal to another value.



local number = 5

function Creature_OnCombat(Unit, Event)
Unit:RegisterEvent("Creature_OnCastSpell", 1000, 1)
end

function Creature_OnCastSpell(Unit, Event)
local plr = Unit:GetRandomPlayer(0) -- Gets a random player
local name = plr:GetName()
Unit:CastSpellOnTarget(11, name) -- Using CastSpellOnTarget, it was bugged at one point and would ALWAYS cast the spell on itself.
Unit:SendChatMessage(14, 0, "name is equal to"..name.."Is that who the spell was cast on?") -- If the spell casts on himself, the command is bugged, if it casts on 'name' (Whoever was said ingame) then it works.
end

RegisterUnitEvent(NPCID, 1, "Creature_OnCombat")


Debugging.

When making a Lua script for your first time. You are going to get a LOT of errors. Most errors are caught by the lua Engine on startup. But some get printed on the console while your script is running ingame (If your trying to add 1 to a variable with a nil value).
Heres a screenshot of what the errors can look like on startup.

http://img36.imageshack.us/img36/3947/debugscreen1.png
[NOTE]: No i don't use a repack, i just still use the Ac-web folder from when i used to =P
It will tell you what line the error is on, which is usually enough to go find whats wrong, but it also tells you whats wrong. even though sometimes it feels like its always saying the same thing.

Heres a list(that i can remember) of debugging errors i've ran into;



Forgetting a Left Parethisis to close a Function/Command.
Unit:SendChatMessage(41, 0, "The Lava Around Sarthiron Begins to Churn"

Forgetting a comma inside the Parameters of a Command.
Unit:SendChatMessage(41, 0 "The Lava Around Sarthiron Begins to Churn")

Concatenating a string with a nil value.
function Creature_OnCombat(Unit, Event)
local name -- Nil value, forgot to put player:GetName()
Unit:SendChatMessage(14, 0, "how come you be agroing me "..name)
end

Adding an integer with a nil value.
function Creature_OnCombat(Unit, Event)
count = count + 1 -- When the creature enters combat, count was never previously given a value, so it is nil, and it is being added to 1. To fix this you'd write 'local count = 0' at the top of the script.
end

Adding an integer to a string.
function Npc_OnGossip(Unit, Event, player)
Unit:GossipCreateMenu(100, player, 0)
Unit:GossipMenuAddItem(1, "Guessing Game", 0, 3)
Unit:GossipSendMenu(player)
end

function Npc_OnSubMenu(Unit, Event, player, id, intid, code)
codeplusone = code + 1 -- Code (Whatever the player wrote in the text box) will always return as a string, trying to add it to 1 will give you an error.
if (code == codeplusone) then
player:AddItem(29434, 20)
end
end

Forgetting or adding an extra 'end' to a function / if statement.
function Creature_OnCombat(Unit, Event)
if (Unit = nil) then
print"awmah gawd this creature doesn't exist and its attacking me!"
elseif
if (Unit ~= nil) then
print"phew this creature exists"
-- Should be an End here.
end
end

Using lowercase letters.
function Creature_OnCOmbat(Unit, Event)
unit:SendChatMessage(14, 0, "Why is this not working?") -- Lowercase unit at the start of the command.
end



As you can see most of these errors are from spelling mistakes (Where the Lua Engine also tells you what line the error is on), However when a certain phase isn't registering and you can't figure out why or where to look. Use of the print command can come in handy, To give you an idea of where to look.

The usage of the print command is as follors



print"insert debug message here"

print("Insert Message here")


Below is how it could be used when you're having a problem with your script



local count = 0

function Creature_OnCombat(Unit, Event)
Unit:RegisterEvent("Creature_PhaseOne", 1000, 1)
end

function Creature_PhaseOne(Unit, Event)
count = count + 1
if (count == 1) then
Unit:SendChatMessage(14, 0, "Im gonna cast a spell on you.")
elseif (count == 4) then
Unit:SendChatMessage(14, 0, "Im gonna send a chat message!")
elseif (count == 5) then
Unit:SendChatMessage(14, 0, "Watchout this script is about to break")
end

if Unit:GetHealthPct <= 80 then
-- register a new event.
else
Unit:RegisterEvent("Creature_PhaseOne", 1000, 1)
print("count is equal to"..count) -- This will print in the console every second what count is equal to. And then you can figure out why it isn't looping like you want it to.
-- The reason is, count was never reset back to 0 when it was equal to 5. so you would've found count would'v continuously went up.
end
end



If you find you're events are accelerating faster and faster casting a spell inside a function until the server crashes check the interval count on the end of when you register an event; I've done once.



function Creature_OnCombat(Unit, Event)
local name = player:GetName()
Unit:SendChatMessage(14, 0, "Why are you agroing me"..name)
Unit:RegisterEvent("Creature_CastSpell", 1000, 0) -- Put it as infinite, which registered the event when the event was registered.
end

function Creature_CastSpell(Unit, Event)
Unit:CastSpell(insertIDhere)

if Unit:GetHealthPct() <= 80 then
-- register new event
else
Unit:RegisterEvent("Creature_CastSpell", 1000, 1) -- You can guess where this led too
end
end


If you get an error about Unknown symbol near 'insert line of code here' Just rewrite that line, not really sure what causes it.

================================================== ==================

That brings us to the end of this tutorial, Hopefully you've learned something or had any questions you had answered. And remember, Sometimes just doing the boring work of 15 extra If statements / functions is worth having a move fun boss fight for.

Hopefully you can use what you've learned to be innovative and creative in your scripts.

This tutorial is finished, but i will still be adding things to it. PM me if you are curious how to do certain things or use certain commands. I will PM you back and then add an example and Explanation to this guide! Its win win.

enegue
27-10-09, 05:55 AM
Credits
Vision1000 of *******

Disclaimer
I take absolutely no credit for this guide. Any +rep to me will be considered a bonus.

Dimman
27-10-09, 08:26 AM
Thanks for contributing! :p


I will +rep you both :D




// <<Dimman>>

enegue
28-10-09, 01:39 AM
Haha, thanks man!

enegue
03-11-09, 05:24 AM
Bump!

XploDcs
09-11-09, 02:41 PM
Hello, everyone...I am very tired; I'm trying to add some lines to my teleporter...Please tell me where I did wrong, please.
My LUA teleporter (Ultimate NPC.lua) looks like this:


function On_Gossip_Talk(unit, event, player)
unit:GossipCreateMenu(3544, player, 0)
local race=player:GetPlayerRace()
if race==1 or race==3 or race==4 or race==7 or race==11 then
unit:GossipMenuAddItem(6, "|cff0000ffMain Cities", 600, 0)
end
local race=player:GetPlayerRace()
if race==2 or race==5 or race==6 or race==8 or race==10 then
unit:GossipMenuAddItem(4, "|cff0000ffMain Cities", 601, 0)
end
unit:GossipMenuAddItem(2, "|cFF008080Azeroth Locations", 610, 0)
unit:GossipMenuAddItem(2, "|cFF008080Azeroth Instances", 611, 0)
unit:GossipMenuAddItem(2, "|cFF0000FFOutland Locations", 612, 0)
unit:GossipMenuAddItem(2, "|cFF0000FFOutland Instances", 613, 0)
unit:GossipMenuAddItem(2, "|cffffff00Northrend Locations", 97, 0)
unit:GossipMenuAddItem(2, "|cffffff00Northrend Instances", 777, 0)
unit:GossipMenuAddItem(5, "|cff0000ffShattrath City", 614, 0)
unit:GossipMenuAddItem(5, "|cff0000ffDalaran (Mall)", 1001, 0)
unit:GossipMenuAddItem(9, "|cFF000000Gurubashi Arena", 45, 0);
unit:GossipSendMenu(player)
end
function On_Gossip_Select (unit, event, player, id, intid, code)
if(intid == 601) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Orgrimmar", 602, 0)
unit:GossipMenuAddItem(2, "|cFF008000Undercity", 603, 0)
unit:GossipMenuAddItem(2, "|cFF008000Thunder Bluff", 604, 0)
unit:GossipMenuAddItem(2, "|cFF008000Silvermoon", 605, 0)
unit:GossipSendMenu(player)
end
if(intid == 600) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Stormwind", 606, 0)
unit:GossipMenuAddItem(2, "|cFF008000Ironforge", 607, 0)
unit:GossipMenuAddItem(2, "|cFF008000Darnassus", 608, 0)
unit:GossipMenuAddItem(2, "|cFF008000Exodar", 609, 0)
unit:GossipSendMenu(player)
end
if(intid == 610) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Eastern Kingdoms", 40, 0)
unit:GossipMenuAddItem(2, "|cFF008000Kalimdor", 41, 0)
unit:GossipSendMenu(player)
end
if(intid == 40) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Alterac Mountains", 208, 0)
unit:GossipMenuAddItem(2, "|cFF008000Badlands", 214, 0)
unit:GossipMenuAddItem(2, "|cFF008000Blasted Lands", 222, 0)
unit:GossipMenuAddItem(2, "|cFF008000Burning Steppes", 216, 0)
unit:GossipMenuAddItem(2, "|cFF008000Deadwind Pass", 221, 0)
unit:GossipMenuAddItem(2, "|cFF008000Dun Morogh", 212, 0)
unit:GossipMenuAddItem(2, "|cFF008000Duskwood", 220, 0)
unit:GossipMenuAddItem(2, "|cFF008000Eastern Plaguelands", 206, 0)
unit:GossipMenuAddItem(2, "|cFF008000Elwynn Forest", 217, 0)
unit:GossipMenuAddItem(2, "|cFF008000Eversong Woods", 201, 0)
unit:GossipMenuAddItem(2, "|cFF008000Ghostlands", 202, 0)
unit:GossipMenuAddItem(0, "-->Second Page-->", 42, 0)
unit:GossipSendMenu(player)
end
if(intid == 41) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Ashenvale", 109, 0)
unit:GossipMenuAddItem(2, "|cFF008000Azuremyst Isle", 103, 0)
unit:GossipMenuAddItem(2, "|cFF008000Bloodmyst Isle", 102, 0)
unit:GossipMenuAddItem(2, "|cFF008000Darkshore", 105, 0)
unit:GossipMenuAddItem(2, "|cFF008000Desolace", 113, 0)
unit:GossipMenuAddItem(2, "|cFF008000Durotar", 111, 0)
unit:GossipMenuAddItem(2, "|cFF008000Dustwallow Marsh", 117, 0)
unit:GossipMenuAddItem(2, "|cFF008000Felwood", 107, 0)
unit:GossipMenuAddItem(2, "|cFF008000Feralas", 116, 0)
unit:GossipMenuAddItem(2, "|cFF008000Moonglade", 106, 0)
unit:GossipMenuAddItem(2, "|cFF008000Mulgore", 115, 0)
unit:GossipMenuAddItem(2, "|cFF008000Silithus", 120, 0)
unit:GossipMenuAddItem(0, "-->Second Page-->", 43, 0)
unit:GossipSendMenu(player)
end
if(intid == 42) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Hillsbrad Foothills", 210, 0)
unit:GossipMenuAddItem(2, "|cFF008000Loch Modan", 213, 0)
unit:GossipMenuAddItem(2, "|cFF008000Redridge Mountains", 218, 0)
unit:GossipMenuAddItem(2, "|cFF008000Searing Gorge", 215, 0)
unit:GossipMenuAddItem(2, "|cFF008000Silverpine Forest", 207, 0)
unit:GossipMenuAddItem(2, "|cFF008000Strangethorn Vale", 223, 0)
unit:GossipMenuAddItem(2, "|cFF008000Swamp Of Sorrows", 219, 0)
unit:GossipMenuAddItem(2, "|cFF008000Trisfal Glades", 205, 0)
unit:GossipMenuAddItem(2, "|cFF008000Western Plaguelands", 203, 0)
unit:GossipMenuAddItem(2, "|cFF008000Wetlands", 211, 0)
unit:GossipSendMenu(player)
end
if(intid == 43) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Stonetalon Mountains", 112, 0)
unit:GossipMenuAddItem(2, "|cFF008000Tanaris", 121, 0)
unit:GossipMenuAddItem(2, "|cFF008000Teldrassil", 100, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Barrens", 114, 0)
unit:GossipMenuAddItem(2, "|cFF008000Thousand Needles", 118, 0)
unit:GossipMenuAddItem(2, "|cFF008000Un'Goro Crater", 119, 0)
unit:GossipMenuAddItem(2, "|cFF008000Winterspring", 108, 0)
unit:GossipSendMenu(player)
end
if(intid == 611) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Shadowfang Keep", 615, 0)
unit:GossipMenuAddItem(2, "|cFF008000Zul'Gurub", 616, 0)
unit:GossipMenuAddItem(2, "|cFF008000Scarlet Monastery", 617, 0)
unit:GossipMenuAddItem(2, "|cFF008000Stratholme", 22, 0)
unit:GossipMenuAddItem(2, "|cFF008000Scholomance", 23, 0)
unit:GossipMenuAddItem(2, "|cFF008000Blackrock", 24, 0)
unit:GossipMenuAddItem(2, "|cFF008000Onyxia's Lair", 25, 0)
unit:GossipMenuAddItem(2, "|cFF008000Molten Core", 26, 0)
unit:GossipMenuAddItem(2, "|cFF008000Karazhan", 27, 0)
unit:GossipMenuAddItem(2, "|cFF008000Caverns Of Time", 29, 0)
unit:GossipSendMenu(player)
end
if(intid == 612) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Hellfire", 30, 0)
unit:GossipMenuAddItem(2, "|cFF008000Zangremarsh", 31, 0)
unit:GossipMenuAddItem(2, "|cFF008000Nagrand", 32, 0)
unit:GossipMenuAddItem(2, "|cFF008000Blades Edge", 33, 0)
unit:GossipMenuAddItem(2, "|cFF008000Netherstorm", 34, 0)
unit:GossipMenuAddItem(2, "|cFF008000Terokkar Forest", 35, 0)
unit:GossipMenuAddItem(2, "|cFF008000Shadowmoon Valley", 36, 0)
unit:GossipMenuAddItem(2, "|cFF008000Shattrath", 37, 0)
unit:GossipSendMenu(player)
end
if(intid == 613) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF800080Outland Raids", 47, 0)
unit:GossipMenuAddItem(2, "|cFF008000Hellfire Ramparts", 618, 0)
unit:GossipMenuAddItem(2, "|cFF008000The BloodFurnace", 619, 0)
unit:GossipMenuAddItem(2, "|cFF008000Shattered Halls", 620, 0)
unit:GossipMenuAddItem(2, "|cFF008000Mana-Tombs", 621, 0)
unit:GossipMenuAddItem(2, "|cFF008000Sethekk Halls", 622, 0)
unit:GossipMenuAddItem(2, "|cFF008000Auchenai Crypts", 623, 0)
unit:GossipMenuAddItem(2, "|cFF008000Shadow Labyrinth",624, 0)
unit:GossipMenuAddItem(2, "|cFF008000Caverns of Time", 625, 0)
unit:GossipMenuAddItem(2, "|cFF008000Magisters Terrace", 445, 0)
unit:GossipMenuAddItem(0, "-->Second Page-->", 48, 0)
unit:GossipSendMenu(player)
end
if(intid == 47) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Gruul's Lair", 446, 0)
unit:GossipMenuAddItem(2, "|cFF008000Magtheridon's Lair", 447, 0)
unit:GossipMenuAddItem(2, "|cFF008000Zul'Aman", 448, 0)
unit:GossipMenuAddItem(2, "|cFF008000Serpentshrine Cavern", 449, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Eye", 450, 0)
unit:GossipMenuAddItem(2, "|cFF008000Black Temple", 451, 0)
unit:GossipMenuAddItem(2, "|cFF008000Sunwell Plateau", 452, 0)
unit:GossipSendMenu(player)
end
if(intid == 48) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Mechanar", 627, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Botanica", 628, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Arcatraz", 629, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Steamvault", 630, 0)
unit:GossipMenuAddItem(2, "|cFF008000Slave Pens", 631, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Underbog", 632, 0)
unit:GossipSendMenu(player)
end
if(intid == 614) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Terrace of Light", 38, 0)
unit:GossipSendMenu(player)
end
if(intid == 97) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Borean Tundra", 501, 0)
unit:GossipMenuAddItem(2, "|cFF008000Crystalsong Forest", 502, 0)
unit:GossipMenuAddItem(2, "|cFF008000Dalaran (City)", 503, 0)
unit:GossipMenuAddItem(2, "|cFF008000Dragonblight", 504, 0)
unit:GossipMenuAddItem(2, "|cFF008000Grizzly Hills", 505, 0)
unit:GossipMenuAddItem(2, "|cFF008000Howling Fjord", 506, 0)
unit:GossipMenuAddItem(2, "|cFF008000Icecrown", 507, 0)
unit:GossipMenuAddItem(2, "|cFF008000Sholazar Basin", 508, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Storm Peaks", 509, 0)
unit:GossipMenuAddItem(2, "|cFF008000Zul'Dark", 510, 0)
unit:GossipMenuAddItem(2, "|cFF008000DK Start Zone", 511, 0)
unit:GossipMenuAddItem(2, "|cFF008000Angrathar the Wrathgate", 802, 0)
unit:GossipSendMenu(player)
end
if(intid == 777) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Utgarde Keep", 779, 0)
unit:GossipMenuAddItem(2, "|cFF008000Utgard Pinnacle", 778, 0)
unit:GossipMenuAddItem(2, "|cFF008000Draktharon Keep", 780, 0)
unit:GossipMenuAddItem(2, "|cFF008000Halls of Stone", 781, 0)
unit:GossipMenuAddItem(2, "|cFF008000Halls of Lighting", 782, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Nexus", 785, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Oculus", 786, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Old Kingdom", 787, 0)
unit:GossipMenuAddItem(2, "|cFF008000Azjol-nerub", 788, 0)
unit:GossipMenuAddItem(2, "|cFF800080Northrend Raids--->", 888, 0)
unit:GossipSendMenu(player)
end
if(intid == 888) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Naxxramas", 783, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Eye of Eternity", 784, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Siege of Ulduar", 800, 0)
unit:GossipMenuAddItem(2, "|cFF008000The Antechamber of Ulduar", 801, 0)
unit:GossipSendMenu(player)
end
if (intid == 5) then
unit:GossipMenuAddItem(3, "Professions", 813, 0)
unit:GossipMenuAddItem(5, "set my profession skills to 450", 50,0);
unit:GossipSendMenu(player)
end
if(intid == 813) then
unit:GossipCreateMenu(50, player, 0)
unit:GossipMenuAddItem(0, "|cff0000ffAlchemy", 400, 0)
unit:GossipMenuAddItem(0, "|cff0000ffBlacksmithing", 401, 0)
unit:GossipMenuAddItem(0, "|cff0000ffEnchanting", 402, 0)
unit:GossipMenuAddItem(0, "|cff0000ffEngineering", 403, 0)
unit:GossipMenuAddItem(0, "|cff0000ffHerbalism", 404, 0)
unit:GossipMenuAddItem(0, "|cff0000ffInscription", 405, 0)
unit:GossipMenuAddItem(0, "|cff0000ffJewelcrafting", 406, 0)
unit:GossipMenuAddItem(0, "|cff0000ffLeatherworking", 407, 0)
unit:GossipMenuAddItem(0, "|cff0000ffMining", 408, 0)
unit:GossipMenuAddItem(0, "|cff0000ffSkinning", 409, 0)
unit:GossipMenuAddItem(0, "|cff0000ffCooking", 410, 0)
unit:GossipMenuAddItem(0, "|cff0000ffFirst Aid", 411, 0)
unit:GossipMenuAddItem(0, "|cff0000ffFishing", 412, 0)
unit:GossipMenuAddItem(0, "|cff0000ffTailoring", 413, 0)
unit:GossipSendMenu(player)
end
if(intid == 99) then
unit:GossipCreateMenu(3543, player, 0)
unit:FullCastSpellOnTarget(48100, player)
unit:FullCastSpellOnTarget(48102, player)
unit:FullCastSpellOnTarget(48104, player)
unit:FullCastSpellOnTarget(58449, player)
unit:FullCastSpellOnTarget(58451, player)
unit:FullCastSpellOnTarget(58452, player)
unit:GossipSendMenu(player)
end
if(intid == 98) then
unit:GossipCreateMenu(3543, player, 0)
unit:FullCastSpellOnTarget(26565, player)
unit:GossipSendMenu(player)
end
if(intid == 900) then
unit:GossipCreateMenu(62, player, 0)
player:LearnSpell(15007)
player:UnlearnSpell(15007)
unit:GossipMenuAddItem(0, "[Main Menu]", 75, 0)
unit:GossipSendMenu(player)
end
if(intid == 400) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Alchemy", 415, 0)
unit:GossipMenuAddItem(3, "Grand Master Alchemy", 416, 0)
unit:GossipMenuAddItem(0, "", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 401) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Blacksmithing", 417, 0)
unit:GossipMenuAddItem(3, "Grand Master Blacksmithing", 418, 0)
unit:GossipMenuAddItem(0, "", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 402) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "UnlearnGrand Master Enchanting", 419, 0)
unit:GossipMenuAddItem(3, "Grand Master Enchanting", 420, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 403) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Engineering", 421, 0)
unit:GossipMenuAddItem(3, "Grand Master Engineering", 422, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 404) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Herbalism", 423, 0)
unit:GossipMenuAddItem(3, "Grand Master Herbalism", 424, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 405) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Inscription", 425, 0)
unit:GossipMenuAddItem(3, "Grand Master Inscription", 426, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 406) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Jewelcrafting", 427, 0)
unit:GossipMenuAddItem(3, "Grand Master Jewelcrafting", 428, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 407) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Leatherworking", 429, 0)
unit:GossipMenuAddItem(3, "Grand Master Leatherworking", 430, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 408) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Mining", 431, 0)
unit:GossipMenuAddItem(3, "Grand Master Mining", 432, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 409) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Skinning", 433, 0)
unit:GossipMenuAddItem(3, "Grand Master Skinning", 434, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 410) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Cooking", 435, 0)
unit:GossipMenuAddItem(3, "Grand Master Cooking", 436, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 411) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master First Aid", 437, 0)
unit:GossipMenuAddItem(3, "Grand Master First Aid", 438, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 412) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Fishing", 439, 0)
unit:GossipMenuAddItem(3, "Grand Master Fishing", 440, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 413) then
unit:GossipCreateMenu(3543, player, 0)
unit:GossipMenuAddItem(3, "Unlearn Grand Master Tailor", 441, 0)
unit:GossipMenuAddItem(3, "Grand Master Tailor", 442, 0)
unit:GossipMenuAddItem(0, "[Back]", 813, 0)
unit:GossipSendMenu(player)
end
if(intid == 889) then
player:Teleport(1, 4613.19, -3861.61, 944.178)
end
if(intid == 602) then
player:Teleport(1, 1484, -4417, 25)
end
if(intid == 603) then
player:Teleport(0, 1831, 238, 60)
end
if(intid == 604) then
player:Teleport(1, -1277, 118, 131)
end
if(intid == 605) then
player:Teleport(530, 9413, -7277, 14)
end
if(intid == 606) then
player:Teleport(0, -8913.23, 554.633, 94.7944)
end
if(intid == 607) then
player:Teleport(0, -4981.25, -881.542, 502.66)
end
if(intid == 608) then
player:Teleport(1, 9948, 2413, 1327)
end
if(intid == 609) then
player:Teleport(530, -4014.080078, -11895.799805, -1.990842)
end
if(intid == 615) then
player:Teleport(0, -234.495087, 1561.946411, 76.892143)
end
if(intid == 616) then
player:Teleport(0, -11919.073242, -1202.459374, 92.298744)
end
if(intid == 617) then
player:Teleport(0, 2870.442627, -819.985229, 160.331085)
end
if(intid == 22) then
player:Teleport(0, 3359.111572, -3380.8444238, 144.781860)
end
if(intid == 23) then
player:Teleport(0, 1267.468628, -2556.651367, 94.127983)
end
if(intid == 24) then
player:Teleport(0, -7527.129883, -1224.997437, 285.733002)
end
if(intid == 25) then
player:Teleport(1, -4708.491699, -3727.672363, 54.535076)
end
if(intid == 26) then
player:Teleport(0, -7515.409668, -1045.369629, 182.301208)
end
if(intid == 27) then
player:Teleport(0, -11122.913086, -2014.498779, 47.079350)
end
if(intid == 28) then
player:Teleport(0, 3132.915283, -3731.012939, 138.658371)
end
if(intid == 29) then
player:Teleport(1, -8519.718750, -4297.542480, -208.441376)
end
if(intid == 30) then
player:Teleport(530, -247.9672, 948.5709, 84.3798)
end
if(intid == 31) then
player:Teleport(530, -1045.0179, 5380.0288, 22.1216)
end
if (intid == 32) then
player:Teleport(530, -468, 8418, 28)
end
if(intid == 33) then
player:Teleport(530, 1552.2236, 6813.3798, 125.1364)
end
if(intid == 34) then
player:Teleport(530, 3396, 4185, 137)
end
if(intid == 35) then
player:Teleport(530, -2276.82, 5132.03, -8.62994)
end
if(intid == 36) then
player:Teleport(530, -3004.3488, 2968.4343, 81.8821)
end
if(intid == 37) then
player:Teleport(530, -1849.4200, 5401.4599, -12.4279)
end
if(intid == 38) then
player:Teleport(530, -1849.4200, 5401.4599, -12.4279)
end
if(intid == 45) then
player:Teleport(0, -13243.240234, 197.949799, 32.112690)
end
if(intid == 46) then
player:Teleport(530, 12956.072266, -6943.814453, 9.968110)
end
if(intid == 100) then
player:Teleport(1, 9874.646484, 595.742432, 1303.874023)
end
if(intid == 102) then
player:Teleport(530, -2721.68, -12208.9, 10.0882)
end
if(intid == 103) then
player:Teleport(530, -4020.48, -13783.3, 74.9001)
end
if(intid == 105) then
player:Teleport(1, 6207.5, -152.833, 80.8185)
end
if(intid == 106) then
player:Teleport(1, 7504.171387, -2195.534668, 479.813629)
end
if(intid == 107) then
player:Teleport(1, 5483.9, -749.881, 335.621)
end
if(intid == 108) then
player:Teleport(1, 6107.62, -4181.6, 853.322)
end
if(intid == 109) then
player:Teleport(1, 3469.816162, 842.109, 6.364)
end
if(intid == 111) then
player:Teleport(1, 341.42, -4684.7, 31.9493)
end
if(intid == 112) then
player:Teleport(1, 1145.85, 664.812, 143)
end
if(intid == 113) then
player:Teleport(1, -93.1614, 1691.15, 90.0649)
end
if(intid == 114) then
player:Teleport(1, -90.19003, -1943.44, 95.4727)
end
if(intid == 115) then
player:Teleport(1, -2370.044434, -906.534607, -8.42)
end
if(intid == 116) then
player:Teleport(1, -4458.93, 243.415, 42.6136)
end
if(intid == 117) then
player:Teleport(1, -3463.26, -4123.13, 18.1043)
end
if(intid == 118) then
player:Teleport(1, -4968.558, -1596.792, -41.9857)
end
if(intid == 119) then
player:Teleport(1, -7932.61, -2139.61, -229.728)
end
if(intid == 120) then
player:Teleport(1, -7373.69, -2950.2, 12.3298)
end
if(intid == 121) then
player:Teleport(1, -7167.86, -3807.46, 11.7068)
end
if(intid == 201) then
player:Teleport(530, 9449.15, -6782.61, 16.6167)
end
if(intid == 202) then
player:Teleport(530, 7880, -6193, 22)
end
if(intid == 203) then
player:Teleport(0, 1224.36, -1151.97, 61.7327)
end
if(intid == 205) then
player:Teleport(0, 2019.35, 1904.36, 106.144)
end
if(intid == 206) then
player:Teleport(0, 1919.44, -4306.23, 77.838)
end
if(intid == 207) then
player:Teleport(0, 511.536, 1638.63, 121.417)
end
if(intid == 208) then
player:Teleport(0, 272.704, -654.514, 129.609)
end
if(intid == 209) then
player:Teleport(0, 139.375, -1982.79, 134.043)
end
if(intid == 210) then
player:Teleport(0, -852.854, -576.712, 21.0293)
end
if(intid == 211) then
player:Teleport(0, -4086.36, -2610.95, 47.0143)
end
if(intid == 212) then
player:Teleport(0, -5425.924316, -224.271957, 404.984344)
end
if(intid == 213) then
player:Teleport(0, -4939.1, -3423.74, 306.595)
end
if(intid == 214) then
player:Teleport(0, -6018.138184, -3311.517822, 261.744324)
end
if(intid == 215) then
player:Teleport(0, -7176.63, -937.667, 171.206)
end
if(intid == 216) then
player:Teleport(0, -7907.41, -1128.66, 192.056)
end
if(intid == 217) then
player:Teleport(0, -9621.383789, -371.068207, 57.471478)
end
if(intid == 218) then
player:Teleport(0, -9219.37, -2149.94, 71.606)
end
if(intid == 219) then
player:Teleport(0, -10264.6, -3059.9, 19.9356)
end
if(intid == 220) then
player:Teleport(0, -11224.254883, -378.471802, 52.764240)
end
if(intid == 221) then
player:Teleport(0, -10435.4, -1809.28, 101)
end
if(intid == 222) then
player:Teleport(0, -11170.81, -2718.3918, 20.9472)
end
if(intid == 223) then
player:Teleport(0, -11634.8, -54.0697, 14.4439)
end
if(intid == 618) then
player:Teleport(530, -360.671, 3071.9, -15.0977)
end
if(intid == 619) then
player:Teleport(542, -3.9967, 14.6363, -44.8009)
end
if(intid == 631) then
player:Teleport(530, 721.926, 7012.24, -73.065)
end
if(intid == 632) then
player:Teleport(530, 779.802, 6769.33, -71.4282)
end
if(intid == 621) then
player:Teleport(530, -3101.47, 4947.11, -101.177)
end
if(intid == 623) then
player:Teleport(530, -3357.32, 5216.77, -101.049)
end
if(intid == 625) then
player:Teleport(1, -8195.94, -4500.13, 9.60819)
end
if(intid == 622) then
player:Teleport(530, -3360.13, 4667.85, -101.047)
end
if(intid == 630) then
player:Teleport(0, -11634.8, -54.0697, 14.4439)
end
if(intid == 624) then
player:Teleport(530, -3635.76, 4931.82, -100.034)
end
if(intid == 620) then
player:Teleport(530, -309.83, 3080.08, -3.63538)
end
if(intid == 627) then
player:Teleport(530, 2885.2, 1564.73, 248.874)
end
if(intid == 628) then
player:Teleport(530, 3405.48, 1489.14, 183.838)
end
if(intid == 629) then
player:Teleport(530, 2872, 1555.29, 253.159)
end
if(intid == 445) then
player:Teleport(585, 2.19347, -0.123698, -2.8025)
end
if(intid == 446) then
player:Teleport(530, 3606.85, 5260.49, 4.1724)
end
if(intid == 447) then
player:Teleport(530, -319.635, 3102.03, -113.937)
end
if(intid == 448) then
player:Teleport(530, 6850, -7950, 170)
end
if(intid == 449) then
player:Teleport(530, 742.883, 6867.19, -68.8289)
end
if(intid == 450) then
player:Teleport(530, 3087.22, 1380.7, 184.883)
end
if(intid == 451) then
player:Teleport(530, -3604.74, 328.252, 38.3077)
end
if(intid == 452) then
player:Teleport(580, 1791.17, 926.31, 15.1135)
end
if(intid == 501) then
player:Teleport(571, 2087.0109, 6508.6171, 1.4727)
end
if(intid == 502) then
player:Teleport(571, 5434.8281, -1022.4812, 175.0125)
end
if(intid == 503) then
player:Teleport(571, 5811.4067, 647.7883, 647.4152)
end
if(intid == 504) then
player:Teleport(571, 3511.6850, 2841.8454, 36.7473)
end
if(intid == 505) then
player:Teleport(571, 3346.2551, -4486.8173, 259.2319)
end
if(intid == 506) then
player:Teleport(571, 2195.3654, -4526.7729, 216.7943)
end
if(intid == 507) then
player:Teleport(571, 6729.2387, 2510.4931, 427.7868)
end
if(intid == 508) then
player:Teleport(570, 4913.3090, 5536.0737, -76.4190)
end
if(intid == 509) then
player:Teleport(571, 6196.4174, -776.7462, 402.3688)
end
if(intid == 510) then
player:Teleport(571, 5443.4326, -1259.7487, 248.7494)
end
if(intid == 511) then
player:Teleport(609, 2355.7048, -5662.7075, 426.0274)
end
if(intid == 521) then
player:Teleport(574, 149, -88, 13)
end
if(intid == 522) then
player:Teleport(575, 570, -327, 111)
end
if(intid == 523) then
player:Teleport(576, 146, -10, -16)
end
if(intid == 524) then
player:Teleport(578, 1129, 1052, 70)
end
if(intid == 525) then
player:Teleport(599, 1153, 811, 196)
end
if(intid == 526) then
player:Teleport(602, 1333, -237, 41)
end
if(intid == 527) then
player:Teleport(603, 1739, 310, 119)
end
if(intid == 528) then
player:Teleport(600, -518, -488, 11)
end
if(intid == 529) then
player:Teleport(604, 2031, 805, 246)
end
if(intid == 530) then
player:Teleport(1, -8638, -4382, -207)
end
if(intid == 531) then
player:Teleport(595, 1967, 1287, 146)
end
if(intid == 532) then
player:Teleport(595, 2300, 1495, 129)
end
if(intid == 533) then
player:Teleport(595, 2258.3, 1153.6, 139)
end
if(intid == 534) then
player:Teleport(595, 1560.4, 603.3, 100)
end
if(intid == 535) then
player:Teleport(595, 1654.3, 1611.9, 117)
end
if(intid == 536) then
player:Teleport(607, 1605, 32, 23)
end
if(intid == 778) then
player:Teleport(571, 1248.92, -4853.94, 219.231)
end
if(intid == 779) then
player:Teleport(571, 1215.37, -4866.46, 47.8483)
end
if(intid == 780) then
player:Teleport(571, 4775.11, -2035.08, 229.387)
end
if(intid == 781) then
player:Teleport(571, 9174.49, -1377.79, 1102.41)
end
if(intid == 782) then
player:Teleport(571, 8923.74, -986.607, 1039.35)
end
if(intid == 783) then
player:Teleport(571, 3674, -1270, 244)
end
if(intid == 784) then
player:Teleport(571, 3879.34, 6979.7, 152.042)
end
if(intid == 785) then
player:Teleport(571, 3881.67, 6984.54, 73.7606)
end
if(intid == 786) then
player:Teleport(571, 3879.99, 6984.38, 106.321)
end
if(intid == 787) then
player:Teleport(571, 3717.18, 2154.97, 36.4342)
end
if(intid == 788) then
player:Teleport(571, 3717.18, 2154.97, 36.4342)
end
if(intid == 800) then
player:Teleport(603, -863.575, -149.027, 458.885)
end
if(intid == 801) then
player:Teleport(603, 1497.971, -24.3288, 420.966)
end
if(intid == 802) then
player:Teleport(571, 4687.669922, 1245.670044, 142.494995)
end


if(intid == 1001) then
player:Teleport(571, 5830.084, 484.196, 658.143921)
end
if(intid == 415) then
player:UnlearnSpell(51303)
end
if(intid == 416) then
player:LearnSpell(51303)
end
if(intid == 417) then
player:UnlearnSpell(51298)
end
if(intid == 418) then
player:LearnSpell(51298)
end
if(intid == 419) then
player:UnlearnSpell(51312)
end
if(intid == 420) then
player:LearnSpell(51312)
end
if(intid == 421) then
player:UnlearnSpell(51305)
end
if(intid == 422) then
player:LearnSpell(51305)
end
if(intid == 423) then
player:UnlearnSpell(50301)
end
if(intid == 424) then
player:LearnSpell(50301)
end
if(intid == 425) then
player:UnlearnSpell(45380)
end
if(intid == 426) then
player:LearnSpell(45380)
end
if(intid == 427) then
player:UnlearnSpell(51310)
end
if(intid == 428) then
player:LearnSpell(51310)
end
if(intid == 429) then
player:UnlearnSpell(51301)
end
if(intid == 430) then
player:LearnSpell(51301)
end
if(intid == 431) then
player:UnlearnSpell(50309)
end
if(intid == 432) then
player:LearnSpell(50309)
end
if(intid == 433) then
player:UnlearnSpell(50307)
end
if(intid == 434) then
player:LearnSpell(50307)
end
if(intid == 435) then
player:UnlearnSpell(51295)
end
if(intid == 436) then
player:LearnSpell(51295)
end
if(intid == 437) then
player:UnlearnSpell(50299)
end
if(intid == 438) then
player:LearnSpell(50299)
end
if(intid == 439) then
player:UnlearnSpell(51293)
end
if(intid == 440) then
player:LearnSpell(51293)
end
if(intid == 441) then
player:UnlearnSpell(51308)
end
if(intid == 442) then
player:LearnSpell(51308)
end
if (intid == 50) then
player:AdvanceSkill(333, 450);
player:AdvanceSkill(197, 450);
player:AdvanceSkill(202, 450);
player:AdvanceSkill(755, 450);
player:AdvanceSkill(171, 450);
player:AdvanceSkill(164, 450);
player:AdvanceSkill(182, 450);
player:AdvanceSkill(165, 450);
player:AdvanceSkill(186, 450);
player:AdvanceSkill(393, 450);
player:AdvanceSkill(185, 450);
player:AdvanceSkill(129, 450);
player:AdvanceSkill(356, 450);
player:AdvanceSkill(773, 450);
player:AdvanceSkill(633, 1000);
unit:GossipComplete(player)
unit:SendChatMessage(12,0,"All Skills At Max")
unit:GossipMenuAddItem(0, "[Back]", 5, 0)
end
end
RegisterUnitGossipEvent(400035, 1, "On_Gossip_Talk")
RegisterUnitGossipEvent(400035, 2, "On_Gossip_Select")

I just want to add some leveling zones in this lua script.
The coordonates I want to add in here are:

Map 1, zone 0, area 616, X: 4617.256348, Y: -3865.134277, Z: 944.782227, Orientation: 1.030601, Area Name: Hyjal(for leveling 100-170)

Map 0, Zone 0, Area 85, X: 2508.905029, Y: 2139.439941, Z: 34.060631, Orientation: 3.275555, Area Name: Tirisfal (for leveling 60-100) and another 2...
Here is my work, I know that it isn't good, but I really wanna know where I did wrong, so please-please-please help me, I wanna learn this things.
unit:GossipMenuAddItem(4, "|cff0000ffLeveling Area", 616, 0)
end


if (intid == [B]616) then
unit:GossipCreateMenu([B]3543, player, 0)
unit:GossipMenuAddItem(2, "|cFF008000Hyjal 100-170", 616, 0)
unit:GossipMenuAddItem(2, "|cFF008000Tirisfal Prime 60-100", 85, 0)
unit:GossipMenuAddItem(2, "|cFF008000Hrothgar's Landing 220-255", 4742, 0)
unit:GossipMenuAddItem(2, "|cFF008000Dun Morogh 170-220", 1, 0)
unit:GossipSendMenu(player)


if(intid == 1) then
player:Teleport(0, -4748.650391, 556.198608, 409.938446)
end
if(intid == 4742) then
player:Teleport(571, 9926.966797, 1032.371094, 18.732323)
end
if(intid == 616) then
player:Teleport(1, 4617.256348, -3865.134277, 944.782227)
end
if(intid == 85) then
player:Teleport(0, 2508.905029, 2139.439941, 34.060631)

The blue numbers - I don't know which numbers should I wrote there; I know these are wrong, but I wanted to try, at least.
After adding these lines to the Lua teleporter, when I click on my npc teleporter, it says only something like "Hello, XploD, how can I help you?" - all my instances dissapears.
Thanks a lot.
+rep
offtopic: Please excuse me for my bad english.

XploDcs
09-11-09, 02:44 PM
Omg, I thought that my quote will have scroll...what a long post...sorry, I don't know how to do with scroll.

enegue
10-11-09, 08:57 AM
Nah, it's ok. Are those blue numbers the original or those you changed?

XploDcs
10-11-09, 04:45 PM
I solved this problem...It seems that I wrote 2 times the same number (616) and I didn't put those lines in the right places.
Thank you, anyway.

XploDcs
10-11-09, 11:51 PM
Could someone tell me how to create restrictions for level? For example, in Hyjal, to allow only players with level beetween 100 and 170.
Thank you very much.

enegue
12-11-09, 03:18 AM
I don't think that's possible.. You could always make the last monster a level 159.

XploDcs
13-11-09, 06:54 AM
How to add items for drop, on a npc ( on a boss, for example)?
Maybe you know.
Thanks.

P1raten
20-11-09, 06:57 AM
How to add items for drop, on a npc ( on a boss, for example)?
Maybe you know.
Thanks.
That's DB releated. Has nothing to do with Lua.