[Tutorial] How to Script a Phased Boss With LUA. menu

User Tag List

Results 1 to 4 of 4
  1. #1
    Dimarxx's Avatar Private
    Reputation
    10
    Join Date
    Apr 2010
    Posts
    5
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Tutorial] How to Script a Phased Boss With LUA.

    Hello Mmowned Members.

    Today I want to show all the members of Mmowned How I script my Bosses. Okay When I script I take my time I don't rush, the is nothing worse then a script that has 45+ Errors. It's better to spend 4hours making a Lua Script and it work On the first try, then spend 40minutes Making a Lua Script it not working at all

    You will need a few requirements in order to start Scripting Lua. Remember Lua Scripting is like everything else, hard to start with but after 20minutes or so you'll Understand. Well Not all the time.

    • Notepad ++
    • Basic Knowledge of Lua Functions
    • Some time on you're hands
    • Some Sort of Testing Server

    •1.1 - Beginning the Script
    -------------------------
    There are many ways to script Bosses everyone has that unique way of making there scripts. Some say my Lua Style is the hardest, Some say the easiest. I don't care as long as they work that's all I'm worried about.


    So we will start out with a few things.
    Code:
    local NAME = "Elite Boss" - This is the local NPC name of the boss you are scripting.
    local NPCID = 1000001 - This is the local NPC ID of the Boss you are Scripting.
    Next You will want to start the On_Combat, when you script this, this is telling the Boss or Mob what it will do when it comes in contact or In Combat with a Player.

    Code:
    function Elite_OnCombat(pUnit, event, player) ---- Tell The Boss or Mob what they will do on_combat
     Elite=pUnit ----- This is a replacement for pUnit, So instead of saying pUnit every time you can Say Elite.
     pUnit:SendChatMessage(12, 0, "Hello") ---- This Is what the Npc Will Say when He comes in combat with a player.
    end --- This Is ending the Function. So Basically completing it.
    So Let's do a review of what we have learned so far. If you followed the Tutorial the right way you should of came up with something that looks like this.
    Code:
    local NAME = "Elite Boss"
    local NPCID = 1000001
    
    function Elite_OnCombat(pUnit, event, player)
     Elite=pUnit
     pUnit:SendChatMessage(12, 0, "Hello")
    end
    Congratulations, You have just scripted you're very first function. So Now We are gonna Add this after your On_Combat Function. You can use On_KilledTarget, But I find it useless and a way to spam your server. Your Choice.
    Code:
    RegisterUnitEvent(1000001, 1, "Elite_OnCombat") --- This is Registering the Function_OnCombat and will trigger when the boss comes in combat.
    Okay So Now We are going to add 2 more functions to your script. So Make a space right after your end in Function_OnCombat, and start this.
    Code:
    function Elite_OnLeaveCombat(pUnit, event, player) --- This is making it so when the boss leaves combat he will say something or cast something. We will learn how to cast something later in this Tutorial. pUnit:RemoveEvents() ---- This Removes any events that are left on the boss after he/she leaves combat(Such as Spells, Buffs, etc...)
     pUnit:SendChatMessage(14, 0, "Bye") ---- This Is what the Npc Will Say when He comes in combat with a player.
    end ---- Ends the Function

    Next We Will start this.

    Code:
    function Elite_OnDeath(pUnit, event, player) ---- What Will happen when the boss is killed.
    pUnit:RemoveEvents()---- This Removes any events that are left on the boss after he/she leaves combat(Such as Spells, Buffs, etc...)
    end ---- Ends the Function
    Okay So We will review our Script One more time before we start the next step and this is what you should have, or something close to this.
    Code:
    local NAME = "Elite Boss"
    local NPCID = 1000001
    
    function Elite_OnCombat(pUnit, event, player)
     Elite=pUnit
     pUnit:SendChatMessage(12, 0, "Hello")
    end
    
    function Elite_OnLeaveCombat(pUnit, event, player)
     pUnit:RemoveEvents() 
     pUnit:SendChatMessage(14, 0, "Bye")
    end
    
    function Elite_OnDeath(pUnit, event, player)
     pUnit:RemoveEvents()
    end
    
    RegisterUnitEvent(1000001, 1, "Elite_OnCombat")
    Now We Put Our Very last RegisterUnitEvents In to Complete the first Part of our Scirpt.

    Code:
    RegisterUnitEvent(1000001, 1, "Elite_OnCombat") ---- Registers OnCombat Function
    RegisterUnitEvent(1000001, 2, "Elite_OnLeaveCombat") ---- Registers OnLeaveCombat Function
    RegisterUnitEvent(1000001, 4, "Elite_OnDeath") ---- Registers OnDeath Function
    •1.2 - Creating Phases
    -------------------------------
    Okay Step 1.2 In this step I will be teaching you all how to create phases. Phases are kinda like functions but they are can be triggered after the "function Elite_OnCombat" Is Made

    So Lets Start Making Our very First phases. If you look in the Script below I added the Phase right before I did end.

    Code:
    local NAME = "Elite Boss"
    local NPCID = 1000001
    
    function Elite_OnCombat(pUnit, event, player)
     Elite=pUnit
     pUnit:SendChatMessage(12, 0, "Hello")
     pUnit:RegisterEvent("Elite_Phase1", 1000, 1) ----- Here is the Very First Phase.
    end
    
    function Elite_OnLeaveCombat(pUnit, event, player)
     pUnit:RemoveEvents() 
     pUnit:SendChatMessage(14, 0, "Bye")
    end
    
    function Elite_OnDeath(pUnit, event, player)
     pUnit:RemoveEvents()
    end
    
    RegisterUnitEvent(1000001, 1, "Elite_OnCombat")
    RegisterUnitEvent(1000001, 2, "Elite_OnLeaveCombat")
    RegisterUnitEvent(1000001, 4, "Elite_OnDeath")
    Now let me explain the phase. The number "1000" is the time in milliseconds you want the phase to trigger after he is in combat. The Number "1" is telling the script that you want that phase to only trigger once in the entire script.

    So Lets Start making our Phase1 function. This is really easy all you are doing is the same thing as the First functions but just a few more things to. (Remember add you're own spells and etc Mine is just a example. Some of the ID's aren't spells.)
    Code:
    function Elite_Phase1(pUnit, event, player)
     if Elite:GetHealthPct() == 85 then --- This Means that when the boss reaches 85% Health this Phase will be triggered.
     Elite:SendChatMessage(12, 0, "I see that you want a true battle")
     Elite:CastSpell(52262) --- This Means That the boss will cast this spell on itself.
     Elite:RegisterEvent("Elite_Phase2", 1000, 1)
    end ---- End The Function
    end ---- This Is Important because you have to put 2 ends because one end, ends the function the other one ends the"if Elite:GetHealthPct() == 85 then"
    So Far you should have this, If you don't try to reread the Tutorial to see if you missed something.
    Code:
    local NAME = "Elite Boss"
    local NPCID = 1000001
    
    function Elite_OnCombat(pUnit, event, player)
     Elite=pUnit
     pUnit:SendChatMessage(12, 0, "Hello")
     pUnit:RegisterEvent("Elite_Phase1", 1000, 1) ----- Here is the Very First Phase.
    end
    
    function Elite_OnLeaveCombat(pUnit, event, player)
     pUnit:RemoveEvents() 
     pUnit:SendChatMessage(14, 0, "Bye")
    end
    
    function Elite_OnDeath(pUnit, event, player)
     pUnit:RemoveEvents()
    end
    
    function Elite_Phase1(pUnit, event, player)
     if Elite:GetHealthPct() == 85 then 
     Elite:SendChatMessage(12, 0, "I see that you want a true battle")
     Elite:CastSpell(52262)
     Elite:RegisterEvent("Elite_Phase2", 1000, 1)
    end 
    end
    
    RegisterUnitEvent(1000001, 1, "Elite_OnCombat")
    RegisterUnitEvent(1000001, 2, "Elite_OnLeaveCombat")
    RegisterUnitEvent(1000001, 4, "Elite_OnDeath")

    So Now that we have our very first phase I am going to start making our Second phase. If you look in the first phase before I did "end" I put "Elite:RegisterEvent("Elite_Phase2", 1000, 1)". That Made it so I can start my second phase. Remember when you want have another phase you always have to Register it in the phase before.

    So Here is my second phase.

    Code:
    function Elite_Phase2(pUnit, event, player)
     if Elite:GetHealthPct() == 65 then 
     Elite:SendChatMessage(14, 0, "This Is Impossible I am Not Killable, NOW DIE!")
     Elite:SetScale(2) --- This is Setting the scale from 1 to 2
     Elite:SetModel(24345) --- This is Changing the Display of the Boss to another.
     Elite:CastSpell(52262)
     Elite:CastSpell(24705)
     Elite:CastSpell(20230)
    end 
    end
    Congratulations, You made your first Script with Phases. Now I know this Tutorial isn't Long but I tried to Make it easy but then again explained what I knew. So If this guide Helped you then Please leave a thanks or something. I Hope you future scripts are a success.

    Sincerely
    Dimarxx

    [Tutorial] How to Script a Phased Boss With LUA.
  2. #2
    Found's Avatar Banned
    Reputation
    239
    Join Date
    Mar 2009
    Posts
    642
    Thanks G/R
    1/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This was very very helpful +3Rep

  3. #3
    Endbringer's Avatar Knight-Lieutenant
    Reputation
    31
    Join Date
    Jul 2007
    Posts
    258
    Thanks G/R
    1/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    only 1 replay till now?

    nice guide here, a cookie

  4. #4
    Trle94's Avatar Contributor
    Reputation
    167
    Join Date
    May 2009
    Posts
    329
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well there are some errors... If you already added that Elite=pUnit then you dont need anymore pUnit in script... and if local NPCID is 1000001 then change at Registers 1000001 with NPCID ^^


Similar Threads

  1. [Tutorial] How to have colors on your menu (LUA)
    By [pwn]age in forum WoW EMU Guides & Tutorials
    Replies: 11
    Last Post: 07-18-2009, 06:20 PM
  2. Replies: 13
    Last Post: 10-27-2008, 11:42 PM
  3. [Help!] Scripting a GO object with LUA???
    By pioneer1337 in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 07-31-2008, 11:55 PM
  4. [Help] How to make an NPC Talk with Lua
    By Silentnvd in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 07-26-2008, 08:08 PM
  5. How to make game objects teleport with LUA!
    By Le Froid in forum WoW EMU Guides & Tutorials
    Replies: 4
    Last Post: 01-02-2008, 06:59 PM
All times are GMT -5. The time now is 08:40 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search