MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides  
Homepage Register FAQ Members Mark Forums Read Advertise Marketplace FPSowned


Go Back   MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides > Programming > Programming section > Misc
Reload this Page LUA mega scripting!!
Misc For other languages that don't fit elsewhere like KuRIoSaN or Lavishscript - PROGRAMMING WISE

Reply
 
LinkBack Thread Tools
LUA mega scripting!!
(#1)
Old
runiker's Avatar
runiker is Offline
Contributor
Rep Power: 2
Reputation: 92
runiker will become famous soon enough
 
Posts: 439
Join Date: Nov 2007
LUA mega scripting!! - 03-10-2008

Hello and welcome to the new and improved guide to lua.
I will split this into parts to make it easier to understand. This
Guide uses color coding on a lot of the text just so you can see
What is what.

1. understanding lua as a whole
2. Registering the events
3. the events themselves
4. registering events inside events
5. Tables
6. Pre-made lua scripts
7. Portal making 101
8. key points of new guide

Understanding LUA as a whole

LUA is much more then just world of warcraft it is the base of many games. For this Instance we will be just looking at Lua on wow because it would just be easier that Way and less time consuming. First off there are two main parts of lua The part that registers the event found at the bottom and the part that IS The event. The part that registers the event MUST be at the bottom of the script And must be the same name as the event itself. The event should always begain With the same name as the register.


Registering the events
The events I have listed are here for your Convenience. All you have to do is change The “Npc spawn ID” to the id that spawns The npc you want this script for As well as The “Name” Needs to be changed to the name of the creature. This part of the LUA Must be placed at the bottom.

☼RegisterUnitEvent (Npc Spawn ID, 1, "Name_Entercombat")
Using this will make the event happen when the player enters combat with the Npc that has this script enabled.

☼RegisterUnitEvent (Npc Spawn ID, 2, "Name_Leavecombat")
Using this will make the event happen when the player leaves combat with the Npc that has this script enabled.

☼RegisterUnitEvent(Npc Spawn ID, 3, "Name_Killtarget")
Using this will make the event happen when the Npc who has this script kills its target

☼RegisterUnitEvent (Npc Spawn ID, 4, "Name_Died")This event will happen when the npc has died

☼RegisterUnitEvent (Npc Spawn ID, 5, "Name_AItick")Not sure yet???

☼RegisterUnitEvent (Npc Spawn ID, 6, "Name_Spawn")This will happen when the npc is spawned

☼RegisterUnitEvent (Npc Spawn ID, 7, "Name_Gossip")Not sure yet??

☼RegisterUnitEvent (Npc Spawn ID, 8, "Name_waypoint")This will happen when player reaches waypoint

☼RegisterUnitEvent (Npc Spawn ID, 9, "Name_leavelimbo")Not sure yet

☼RegisterUnitEvent (Npc Spawn ID, 10, "Name_playerenter")This will happen when player reachs waypoint.

---note you will need at least one per event you would like to do
so if you wanted to make the npc do something on waypoint AND
combat you would need to make two making the bottom look like this


RegisterUnitEvent (Npc Spawn ID, 1, "Name_Entercombat")
RegisterUnitEvent (Npc Spawn ID, 8, "Name_waypoint")

The events themselves

pUnit:SendChatMessage(<type>, <language>, message)
The npc will say the message (look at type and/or language codes to change)

pUnit:MoveTo(x, y, z, o)
This will move the npc to the xyzo location (look at the xyz part of the guide)

pUnit:CastSpell(spellID)
This will make the npc cast the spell with the spell id (look at thottbot for more spell ids)

pUnit:FullCastSpell(spellID)
Makes the npc cast a spell with full casting time (look at thottbot for more spell ids)

pUnit:SpawnGameObject(entryID, x, y, z, o, duration)
This will spawn a game object then despawn it after the time time is in milliseconds. (look at the xyz part of the guide)

pUnit:SpawnCreature(entryID, x, y, z, o, faction, duration)
This will spawn a npc then despawn it after the time, time is in milliseconds. (look at the xyz part of the guide)

pUnit:CastSpell(spellID)
Despawns the npc for a duration in milliseconds after the delay also in milliseconds

pUnit:PlaySoundToSet(soundID)
This will play a sound to the area

pUnit:SetMovementType(movementType)
This will tell the npc how to move (movement types are fly and walk)

pUnit:SetHealthPct(value)
This will make the npcs health at specified percent

pUnit:SetNPCFlags(flags)
This will mark a flag on npc

pUnit:SetModel(modelID)
This will change the display of the npc

pUnit:SetScale(scale)
This will change the scale of npc

pUnit:SetFaction(factionID)
This will change the faction of the npc

pUnit:SetModel(Display id)
This will change the display of the npc


-------This ends the the ones that I know work and work well---------
-------Use the below ones only if you know what you are doing-----

pUnit:SendAreaTriggerMessage(message)

pUnit:KnockBack(dx, dy, affect1, affect2)

pUnit:MarkQuestObjectiveAsComplete(questID, objective)
Marks an objective of a quest as complete.

pUnit:LearnSpell(spellID)
Adds a spell to a unit.

pUnit:UnlearnSpell(spellID)
Removes a spell from a unit.

pUnit:Despawn(delay, respawn)
Despawns a unit after delay milliseconds and respawns it after respawn milliseconds.

pUnit:PlaySoundToSet(soundID)
Plays a sound to the surrounding area.

pUnit:RemoveAura(auraID)
Removes an aura from a unit.

pUnit:StopMovement(time)
Stops a unit from moving for time milliseconds.

pMisc:AddItem(itemID, count)
Adds a quantity of items to a unit.

pUnit:RemoveItem(itemID, count)
Removes a quantity of items from a unit.

pUnit:CreateCustomWaypointMap()
Creates a custom waypoint map.

pUnit:CreateWaypoint(x, y, z, o, waitTime, flags, modelID)
Adds a waypoint to the custom waypoint map.

pUnit:DestroyCustomWaypointMap()
Destroys a created custom waypoint map.

pUnit:MoveToWaypoint(waypointID)
Tells a unit to move to a particular waypoint.

pUnit:SetCombatCapable(value)
If value is 1 the unit cannot attack.

pUnit:SetHealthPct(value)
Sets the unit's health percentage.

pUnit:SetNPCFlags(flags)
Sets the NPC flags of a unit.

pUnit:SetModel(modelID)
Sets the model (display ID) of a unit.

pUnit:SetScale(scale)
Sets the scale (size) of a unit.

pUnit:SetFaction(factionID)
Sets the faction of a unit.

pUnit:SetTauntedBy(unit)
Sets the unit that taunted the current unit.

pUnit:SetSoulLinkedWith(unit)
Sets the unit that is soul linked with this unit.

---------Known to not work on new patch DO NOT use--------
------------Only here in case they do work one day----------------

pUnit:SendBroadcastMessage(message)
This will broadcast the message across the whole server

pUnit:Emote(emoteID)
Tells a unit to perform an emote.

pUnit:FullCastSpellOnTarget(spellID, unitTarget)
Makes npc cast a spell on target. (look at thottbot for more spell ids)

pUnit:CastSpellOnTarget(spellID, unitTarget)
Cast spell on target (look at thottbot for more spell ids)


Changing the red to what you need

Spell-this can be found on thottbot or Wowhead it’s the last numbers of the page of spell
Type-use the premade table I have made below
Language-use the premade table I have made below
Scale-this is how big you want it to get by multiplying it
Modelid-this is the display id of the mob
Flag-this can be found on mmowned
Value-% at wich you would like the npc’s health
Momenttype-you can pick fly or walk
Soundid-you can find on mmowned
Entryid- this is the same as the number used to spawn it
Duration-how long until this is undone
Faction- what faction would you like it
Message-enter your message here
X,Y,Z,O- these are found by typing .gps inside the server itself at the location you want.]
Emoteid- The id of the emote search mmowned for these
Displayid- display id of what you want it to look like
Time- Time is in milliseconds

The Advanced if commands Use these commands if you want
Whatever is between the then and the end Tags to work
only when it is a yes.

pMisc:GetName()
This will return the units name
[Returns name if true does commands]

pMisc:GetX()
This will return the units X position.
[to be used later in codes]

pMisc:GetY()
This will return the units Y position.
[to be used later in codes]

pMisc:GetZ()
This will return the units Z position.
[to be used in later codes]

pMisc:GetO()
This will return the units orientation.
[used later in code]

pMisc:IsPlayer() then
This will make the commands below it work only If the target is a player
[use this if you want the commands below to work only if target is a player]

pMisc:IsCreature() then
This will make the commands below work if the target is a creature
[use this if you want the commands below to work only if target is a npc]

pMisc:HasFinishedQuest(questID) then
This will work only if the target has finished quest id
[use this if you want the commands below to work only if target has finished quest]

pMisc:GetItemCount(itemID) < # then
This will tell if how many of the items player has
[use the “< #” to tell it to work only when player has x amount of items]

pMisc:GetHealthPct() <% then
This will tell it to only do it if the health is at a percent
[use the “< %” to tell it to work when health is at this]

pMisc:GetUnitBySqlId(sqlID)then
Returns a unit from the sql ID.
[not sure what this is used for yet]

pMisc:GetClosestPlayer() then
This will target the nearest player
[I think this will change target to closest player]

pMisc:GetRandomPlayer(flags)
Returns a random in-range unit that is a player.
[not sure what this is used for yet]

pMisc:GetRandomFriend()
Returns a random in-range unit that is a player and is friendly towards the current player.
[I think it changes target]

pMisc:GetMainTank()
Returns the main tank (most hated).
[I think it changes target]

pMisc:GetAddTank()
Returns the add tank (second most hated).
[I think it changes target]

pMisc:GetTauntedBy()
Returns the player that taunted the unit.
[I think it changes target]

pMisc:GetSoulLinkedWith()
Returns the unit that is set as the soul link for this unit.[not sure what this is used for yet]



Registering events inside events

RegisterUnitEvent(225501, 1, "Vanity_OnCombat")
Is to register the event itself but if you wanted to make
Events inside an event you would use
Unit:RegisterEvent("Vanity_Phase1",1000, 0)
And then for the sub event you would use
function Vanity_Phase1(Unit, event)lets put them all together to show
you what I mean. Hope this helps out people wondering about two part
events.

---code----
function Vanity_Phase1(Unit, event)
if Unit:GetHealthPct() < 95 then
Unit:RemoveEvents()
Unit:SendChatMessage(11, 0, "You think you can beat me")
Unit:RegisterEvent("Vanity_Phase2",1000, 0)
end
end



function Vanity_Phase2(Unit, event)
if Unit:GetHealthPct() < 80 then
Unit:RemoveEvents()
Unit:CastSpell(22436)
end
end


function Vanity_OnCombat(Unit, event)
Unit:SendChatMessage(11, 0, "Do i have to kill you are no equal?")
Unit:RegisterEvent("Vanity_Phase1",1000, 0)
Unit:RegisterEvent("Vanity_Phase2",1000, 0)
end

---end of code-----


Tables and codes
<Language>0 = UNIVERSAL
1 = ORCISH
2 = DARNASSIAN
3 = TAURAHE
6 = DWARVISH
7 = COMMON
8 = DEMONIC
9 = TITAN
10 = THELASSIAN
11 = DRACONIC
12 = KALIMAG
13 = GNOMISH
14 = TROLL
33 = GUTTERSPEAK
35 = DRAENEI<Talk>-1 = ADDON
0 = SAY
1 = PARTY
2 = RAID
3 = GUILD
4 = OFFICER
5 = YELL
6 = WHISPER
7 = WHISPER_INFORM
8 = EMOTE
9 = TEXT_EMOTE
10 = SYSTEM
11 = MONSTER_SAY
12 = MONSTER_YELL
13 = MONSTER_WHISPER
14 = CHANNEL
16 = CHANNEL_JOIN
17 = CHANNEL_LEAVE
18 = CHANNEL_LIST
19 = CHANNEL_NOTICE
20 = CHANNEL_NOTICE_USER
21 = AFK
22 = DND
23 = COMBAT_LOG
24 = IGNORED
25 = SKILL32 = LOOT
83 = BATTLEGROUND_EVENT
87 = RAIDLEADER
88 = RAIDWARNING
Pre made’s

I have made a few pre made’s for you guys to take a look at
All of these are based on using the grubish arena as the home
Of the npc boss or portal just change whats in red to the id of your
Mob you want this on.

Making a portal is not far from
Making npc lua scripts just different commands
You will want to change everything in red to what
You need for yourself. (Note I tell how to make the sorry)
Script for the portal not the portal itself



----code----
function Teleporting_onUse (pUnit, Event, pMisc)
pMisc:Teleport (MAPID, X, Y, Z)
end

RegisterGameObjectEvent (PORTALGUID, 2, "Teleporting_onUse")
----code----

PORTALGUID” is the number used to spawn it
MAPID, X, Y, Z” can be found by typing .gps in gameThis new guide is to help people understand lua and how to use it the
edit notes are as follows

-color coding
-lua for dummys
-Portal script
-registering an event in event
-lots more just look
-removed the scripts becasue too long


---for example codes go to shadowcast.midgard-wow.com that is where all my
work gets put



Last edited by runiker; 03-10-2008 at 03:04 AM..
Reply With Quote

Donate to remove ads.
(#2)
Old
Murlock.'s Avatar
Murlock. is Offline
Contributor
Rep Power: 2
Reputation: 85
Murlock. will become famous soon enough
 
Posts: 251
Join Date: Oct 2007
Location: The Shore
03-10-2008

Zomg, I was just looking for this! when I can! This deserves a bookmark!


Reply With Quote
(#3)
Old
runiker's Avatar
runiker is Offline
Contributor
Rep Power: 2
Reputation: 92
runiker will become famous soon enough
 
Posts: 439
Join Date: Nov 2007
03-10-2008

reposted all my scripting guides here just because its good to have it here as well


Reply With Quote
(#4)
Old
Murlock.'s Avatar
Murlock. is Offline
Contributor
Rep Power: 2
Reputation: 85
Murlock. will become famous soon enough
 
Posts: 251
Join Date: Oct 2007
Location: The Shore
03-10-2008

Btw, is there a place where you get these script commands? And is that your website?

EDIT: Nevermind, it is.


Reply With Quote
(#5)
Old
runiker's Avatar
runiker is Offline
Contributor
Rep Power: 2
Reputation: 92
runiker will become famous soon enough
 
Posts: 439
Join Date: Nov 2007
03-10-2008

um i dont member how i got them all but most of them are from searching thrugh scripts or finding a few new ones here or there i cleared it all up and tossed it into a guide imm edit this one tho instead of the other one


Reply With Quote
(#6)
Old
EcHoEs's Avatar
EcHoEs is Offline
Contributor
Rep Power: 4
Reputation: 243
EcHoEs has a spectacular aura aboutEcHoEs has a spectacular aura aboutEcHoEs has a spectacular aura about
 
Posts: 1,277
Join Date: Sep 2006
Location: in ur cmputer
03-10-2008

GetX, GetY etc are mostly used for spawning mobs when mob, for example, dies. GetX gets X for mob, GetY gets Y, etc, then it spawns the mob at excactly same place as the dying mob.
Fix that ^^




Reply With Quote
(#7)
Old
EcHoEs's Avatar
EcHoEs is Offline
Contributor
Rep Power: 4
Reputation: 243
EcHoEs has a spectacular aura aboutEcHoEs has a spectacular aura aboutEcHoEs has a spectacular aura about
 
Posts: 1,277
Join Date: Sep 2006
Location: in ur cmputer
03-10-2008

pMisc:GetName() will return targets name, so you can for example make this :
Code:
function test(pUnit, Event)
if pUnit:GetName() = Lol then
pUnit:FullCastSpell(ID)
end
end

RegisterUnitEvent(ID, 1, "test")
If players name is Lol, it will cast spell.




Reply With Quote
(#8)
Old
runiker's Avatar
runiker is Offline
Contributor
Rep Power: 2
Reputation: 92
runiker will become famous soon enough
 
Posts: 439
Join Date: Nov 2007
03-10-2008

fixed thank you


Reply With Quote
(#9)
Old
dude891's Avatar
dude891 is Offline
Sergeant Major
Rep Power: 2
Reputation: 26
dude891 is on a distinguished road
 
Posts: 145
Join Date: Nov 2007
Location: Look behind you....
04-12-2008

I have read this and it seemed good at first, but at the end it looked like you were doing something completely different than what you explained at the top. The way you explained that is pretty confusing to me and I don't really get any of this. This has left me extremely frustrated and gave me a head ache. Thanks for trying to contribute though.


Remember, there's no such thing as a stupid question, just stupid people!

Last edited by dude891; 04-12-2008 at 06:56 PM..
Reply With Quote
(#10)
Old
malthi is Offline
Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 2
Reputation: 3
malthi is an unknown quantity at this point
 
Posts: 36
Join Date: Sep 2007
04-13-2008

keep up the good work
Reply With Quote
(#11)
Old
Iceknight001's Avatar
Iceknight001 is Offline
Sergeant
Rep Power: 2
Reputation: 18
Iceknight001 is on a distinguished road
 
Posts: 59
Join Date: Jan 2007
Location: Not really sure...
04-27-2008

wow, man awesome guide, i'm gonna include the link for this in my next one!!


http://www.mmowned.com/forums/image.php?type=sigpic&userid=26334&dateline=1220425020
Reply With Quote
(#12)
Old
controlsx2 is Offline
Sergeant Major
Rep Power: 2
Reputation: 7
controlsx2 is an unknown quantity at this point
 
Posts: 142
Join Date: Jun 2007
05-06-2008

Dont understand the registring bit i mean

Unit:RegisterEvent("Vanity_Phase2",1000, 0)

whats the 1000 and 0 for?
and why is Vanity_Phase2 registerd twice?
Reply With Quote
(#13)
Old
controlsx2 is Offline
Sergeant Major
Rep Power: 2
Reputation: 7
controlsx2 is an unknown quantity at this point
 
Posts: 142
Join Date: Jun 2007
05-06-2008

Whats wrong with this code?

Quote:
function Anzu_HealthCheckA(Unit)
if Unit:GetHealthPct() < 66 and Didthat == 0 then
x = Unit:GetX()
y = Unit:GetY()
z = Unit:GetZ()
Unit:SpawnCreature(519203, x, y, z, 0, 17, 60000);
Unit:SpawnCreature(519203, x, y, z, 0, 17, 60000);
Didthat = 1
else
end
end

function Anzu_HealthCheckB(Unit)
if Unit:GetHealthPct() < 33 and Didthat == 1 then
Unit:FullCastSpell(14204)
x = Unit:GetX()
y = Unit:GetY()
z = Unit:GetZ()
Unit:SpawnCreature(519203, x, y, z, 0, 17, 60000);
Unit:SpawnCreature(519203, x, y, z, 0, 17, 60000);
Didthat = 2
else
end
end


function Anzu(unit, event, miscunit, misc)
print "Anzu"
unit:RegisterEvent("Anzu_HealthCheckA",1000,0)
unit:RegisterEvent("Anzu_HealthCheckB",1000,0)
end

function Speak_OnCombat(Unit, Event)
Unit:SendChatMessage(11, 0, "You Dare Defile Me?!?!")
end

RegisterUnitEvent(150001,1,"Anzu")
RegisterUnitEvent(150001,1,"Speak_OnCombat")


Reply With Quote
Reply

Thread Tools

Posting Rules
You may not