[LUA]Just a question or two menu

User Tag List

Results 1 to 3 of 3
  1. #1
    aseroth's Avatar Member
    Reputation
    2
    Join Date
    Dec 2007
    Posts
    22
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [LUA]Just a question or two

    Heya,

    I've got a few questions regarding certain scripts I use on my server for npcs and bosses

    So, I've made several bosses, each with unique spells to them that only those bosses should use, but it seems that my other bosses use those spells as well (i.e. one boss is supposed to fire chaos bolt while another only uses frostfirebolt, but the first boss fires frostfire bolt as well) even though the spell I.D. is not in their script. Is there some sort of overlapping going on that interferes with the script some how? Is there any way to fix this?

    Also, the scripts I use for each is the random casting boss script that was posted on this site:

    HTML Code:
    --Written by Maven (AKA Deathdude or Maven01)
    
    --[[  REMEMBER THIS FOR EDITING
    pUnit:GetRandomPlayer(0) =  Targets Random Player
    pUnit:GetRandomPlayer(1) = Targets Player in Shortrange
    pUnit:GetRandomPlayer( 2)  = Targets Player in Midrange
    pUnit:GetRandomPlayer(4) = Targets Player in Longrange
    pUnit:GetRandomPlayer(4) = Targets Player with Mana
    pUnit:GetRandomPlayer( 5) = Targets Player with Rage
    pUnit:GetRandomPlayer(6) = Targets Player with Energy
    pUnit:GetRandomPlayer(7) = Targets any player that is not Main Tank
    pUnit:GetMainTank = Targets Main Tank
    pUnit:GetAddTank = Targets Offtank
    ]]
    
    
    local NPCID = NPCIDHERE
    
    local Spell_1 = SpellIDHere --For Boss_1
    local BuffSelf = SpellIDHere --For Boss_2
    local Spell_2 = SpellIDHere --For Boss_3
    
    local MessageBegin = "Enter Text Here"
    
    function Boss_OnCombat(pUnit, Event)
    Phase = math.random(1,3)
    if Phase == 1 then
    pUnit:SendChatMessage(12, 0, MessageBegin)
    pUnit:RemoveEvents();
    pUnit:RegisterEvent("Boss_1", math.random(1000, 30000), 0)
    end
    if Phase == 2 then
    pUnit:SendChatMessage(12, 0, MessageBegin)
    pUnit:RemoveEvents();
    pUnit:RegisterEvent("Boss_2", math.random(1000, 30000), 0)
    end
    if Phase == 3 then
    pUnit:SendChatMessage(12, 0, MessageBegin)
    pUnit:RemoveEvents();
    pUnit:RegisterEvent("Boss_3", math.random(1000, 30000), 0)
    end
    end
    
    function Boss_1(pUnit, Event)
    local plr = pUnit:GetMainTank()
    if (plr ~= nil) then
    pUnit:FullCastSpellOnTarget(Spell_1, plr) 
    pUnit:RemoveEvents();
    pUnit:RegisterEvent("Restart_Over", 1000, 0)
    end
    end
    
    function Boss_2(pUnit, Event) --Makes Boss Buffself
    pUnit:CastSpell(BuffSelf) 
    pUnit:RemoveEvents();
    pUnit:RegisterEvent("Restart_Over", 1000, 0)
    end
    
    function Boss_3(pUnit, Event)
    local plr = pUnit:GetMainTank()
    if (plr ~= nil) then
    pUnit:CastSpellOnTarget(Spell_2, plr)
    pUnit:RemoveEvents();
    pUnit:RegisterEvent("Restart_Over", 1000, 0)
    end
    end
    
    function Restart_Over(pUnit, Event)
    local Phase = math.random(1,3)
    if Phase == 1 then
    pUnit:RegisterEvent("Boss_1", math.random(1000, 45000), 0)
    end
    if Phase == 2 then
    pUnit:RegisterEvent("Boss_2", math.random(1000, 45000), 0)
    end
    if Phase == 3 then
    pUnit:RegisterEvent("Boss_3", math.random(1000, 45000), 0)
    end
    end
    
    local MessageEndCombat = "Enter Text Here"
    local MessageOnDied = "Enter Text Here"
    function Boss_OnLeaveCombat(pUnit, Event)
    pUnit:SendChatMessage(12, 0, MessageEndCombat)
    pUnit:RemoveEvents()
    end
    function Boss_OnDied(pUnit, Event)
    pUnit:SendChatMessage(12, 0, MessageOnDied)
    pUnit:RemoveEvents()
    end
    RegisterUnitEvent(NPCID, 1, "Boss_OnCombat")
    RegisterUnitEvent(NPCID, 2, "Boss_OnLeaveCombat")
    RegisterUnitEvent(NPCID, 3, "Boss_OnDied")
    All credit goes to the creator of the script, for without it my bosses would not be possible.

    [LUA]Just a question or two
  2. #2
    Pretzal's Avatar Member
    Reputation
    8
    Join Date
    Aug 2008
    Posts
    57
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay it sounds like this is happening --
    In your LUA Script you register the events/functions like...
    RegisterUnitEvent(NPCID, 1, "Boss_OnCombat")
    RegisterUnitEvent(NPCID, 2, "Boss_OnLeaveCombat")
    RegisterUnitEvent(NPCID, 3, "Boss_OnDied")

    You see the Boss_OnCombat part, on the first line of that for example.
    That is a name of a function, and somewhere else in your script is the same name.

    How to fix it:
    For every boss, change the function name (Boss_OnCombat or whatever) to something unique. it could be My_CustomBoss or CustomBossEvent or Jibberish_Lord. But, if you change one Boss_OnCombat to Jibberish_Lord, make sure you change the rest of the calls for Boss_OnCombat to Jibberish_Lord, or else your script wont register the functions properly (AKA wont work)
    So, For example, replace all the Boss_OnCombat register events & functions in script #1 to BossA_OnCombat, all the Boss_OnLeaveCombat to BossA_OnLeaveCombat etc. dont forget the functions you have in there like Boss_3 (there are obviously a few functions in there. Just look for RegisterEvent and similar things, then replace them.)
    In two seperate scripts, MAKE SURE that you have DIFFERENT names for all of the functions/register events.

    What is happening -
    The LUA scripts are all loaded as one (Not really, but for simplicity sake) And when one script calls for Boss_OnCombat, it looks for the first one it can find (Only expecting one) however there are multiple so it doesant take note of the others, and just uses one. This happens every time.

    Absolute simplest way of putting it -
    The functions need to be named differently in each script.

    Sorry for the big wall of weird, technical, badly constructed text, but i think ive repeated myself enough times to make it clear what im trying to say.

    And for anyone that wants to flame me for bad terminology, idc. Really.

    Best of luck.

  3. #3
    aseroth's Avatar Member
    Reputation
    2
    Join Date
    Dec 2007
    Posts
    22
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply, I'll try renaming each one seperately. I knew it would be something obvious =/

Similar Threads

  1. [Question] Combining two related model edits
    By TheRoo$ter in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 07-13-2008, 07:05 PM
  2. Lua Scripting, a question on mob targeting
    By adarant_dru in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 06-08-2008, 07:28 PM
  3. not asking for a handout, just a question
    By xreiverx in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 12-30-2007, 03:21 PM
  4. Just a Question to the Admin of this website!
    By kimmern in forum World of Warcraft General
    Replies: 4
    Last Post: 12-11-2007, 10:05 AM
  5. Just a Question?
    By Doomhammer in forum World of Warcraft General
    Replies: 1
    Last Post: 07-03-2007, 11:08 PM
All times are GMT -5. The time now is 11:22 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search