Need help with Boss Script menu

User Tag List

Results 1 to 4 of 4
  1. #1
    modmassacre's Avatar Private
    Reputation
    1
    Join Date
    Mar 2014
    Posts
    2
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help with Boss Script

    Hey guys, I'm still pretty new to LUA scripting and some things in my server. However I would like to say I know a couple things from practice. I'm currently working on a project for my tech class and I'm scripting a dungeon that the class can play through. So far it's going well but I do have a couple questions with things that I've seen online, but don't work how they should. If you can only answer 1, or don't feel like answering them all, any help would be appreciated! **EDIT** I am using a 2.4.3 Repack, as well as ArcEmu Core

    1. The only targeting function I can get to work for bosses is Unit:GetMainTank(). I would like to randomly target players, but things such as Unit:GetRandomPlayer() give me an error of " calling 'GetRandomPlayer' on bad self (number expected, got no value).

    2. I have a boss spawn a mob that will heal the boss, which works fine by using the command Unit:GetUnitBySqlID( X ). However this is very tedious as I have to re-enter the SQL entry every time I delete or edit my mob. I would also like her to cast heals on all mobs friendly to her. I tried Unit:GetClosestFriend but that failed as well.

    3. I would like my boss to be interacting with the environment while he isn't in combat. Such as moving around and saying different things. However when I make the function Bossname_OnSpawn and register it as RegisterUnitEvent(70011, 6, "Bossname_OnSpawn") it doesn't do anything. I thought 6 was the value for OnSpawn?

    4. I've partially learned how to edit a mob's items through playing around with HeidiSQL. But its very tedious that way, is there any easier way I can edit what weapons/armor a boss wears?

    5. My mobs that do have items equipped, unsheathe them and attack, then sheathe them again, then unsheathe to attack, etc. It looks pretty weird and was wondering if there was a fix to it.

    I know I'm asking a lot of questions, but I really want to improve on my scripting abilities and expand my knowledge of the subject. So far I've figured everything out without any help, but these are the things I can't find on my own. Please be gentle


    Here is my script for my final boss (Subject to change as I am only halfway done with it):
    If you could find any errors I might have it would be very helpful! Thanks again in advance!


    local Name = "Mr. T"
    local NPCID = 70011

    function T_OnCombat(pUnit, event, player)
    pUnit:RegisterEvent("T", 1000, 1)
    pUnit:SendChatMessage(14, 1, "IM DONE POOPIN!")
    pUnit:RegisterEvent("T_Fireball",5000,0)
    end

    function T_OnSpawn(Unit, Event)
    Unit:SendChatMessage(14, 0, "ON SPAWN")
    end

    function T(unit, event, miscunit, misc)
    print "T"
    unit:RegisterEvent("T_90", 1000, 1)
    end

    function T_Fireball(Unit, event, miscunit, misc)
    print "T Fireball"
    Unit:StopMovement(2000)
    Unit:FullCastSpellOnTarget(40598, Unit:GetRandomPlayer(0))
    end

    function T_SpawnTechs(Unit, Event) -- Spawns Random Tech Kids
    local faction = 1813
    Choice=math.random(1,3)
    x = Unit:GetX();
    y = Unit:GetY();
    z = Unit:GetZ();
    o = Unit:GetO();
    if Choice == 1 then
    Unit:SpawnCreature(70015, x+10, y, z, o, faction, 3000000)
    Unit:SendChatMessage(12, 0, "Even the laziest of students can prove useful! Get them BRAM.")
    end
    if Choice == 2 then
    Unit:SpawnCreature(70014, x+10, y, z, o, faction, 3000000)
    Unit:SendChatMessage(14, 0, "Come to my aid Linnea!")
    end
    if Choice == 3 then
    Unit:SpawnCreature(70013, x+10, y, z, o, faction, 3000000)
    Unit:SendChatMessage(14, 0, "ISS Jordan, if you fail to kill these fools!")
    end
    end

    function T_Soul_Flay(Unit, event, miscunit, misc)
    print "T Soul Flay"
    Unit:StopMovement(2000)
    Unit:FullCastSpellOnTarget(45342,Unit:GetMainTank())
    end

    function T_90(pUnit, Event) -- Starting of T's Phases
    if pUnit:GetHealthPct() <= 90 then
    pUnit:RemoveEvents()
    pUnit:RegisterEvent("T_Fireball",5000,0)
    pUnit:RegisterEvent("T_70", 1000, 1)
    else
    pUnit:RegisterEvent("T_90", 1000, 1)
    end
    end

    function T_70(pUnit, Event)
    if pUnit:GetHealthPct() <= 70 then
    pUnit:RemoveEvents()
    pUnit:RegisterEvent("T_SpawnTechs", 30000, 0)
    pUnit:SendChatMessage(14, 1, "Hahaha! Tech 3, Show these fools who are the TRUE Seniors")
    pUnit:RegisterEvent("T_SpawnTechs", 1000, 1)
    pUnit:RegisterEvent("T_30", 1000, 1)
    else
    pUnit:RegisterEvent("T_70", 1000, 1)
    end
    end -- End of T's Phases


    function T_30(pUnit, Event)
    if pUnit:GetHealthPct() <= 30 then
    pUnit:RemoveEvents()
    pUnit:FullCastSpell(45342)
    pUnit:RegisterEvent("T_Soul_Flay",15000,0)
    pUnit:SetScale(.35)
    pUnit:SetModel(23200)
    pUnit:SendChatMessage(14, 1, "ANOTHER ISS FOR JORDAN!")
    else
    pUnit:RegisterEvent("T_30", 1000, 1)
    end
    end

    function T_OnKilledTarget(pUnit, event, player)
    pUnit:SendChatMessage(14, 1, "MORE! I NEED MORE!")
    pUnit:FullCastSpellOnTarget(45866, pUnit:GetMainTank())
    end

    function T_OnLeaveCombat(pUnit, event, player)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(14, 0, "What a JOKE!")
    end

    function T_OnDeath(pUnit, event, player)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(14, 0, "Chaos....and Cookies...")
    end

    RegisterUnitEvent(70011, 1, "T_OnCombat")
    RegisterUnitEvent(70011, 2, "T_OnLeaveCombat")
    RegisterUnitEvent(70011, 3, "T_OnKilledTarget")
    RegisterUnitEvent(70011, 4, "T_OnDeath")
    RegisterUnitEvent(70011, 6, "T_OnSpawn") -- End of T$'s Actual Script


    function L_OnSpawn(Unit, Event)
    Unit:RegisterEvent("L_Healing", 2500, 0)
    Unit:StopMovement(400000)
    end

    function L_Healing(Unit, Event)
    Unit:FullCastSpellOnTarget(29564, Unit:GetUnitBySqlId(200002265)
    end

    RegisterUnitEvent(70014, 1, "L_OnSpawn") -- Linnea's Code, I want her to purely heal, not do damage

    function B_OnSpawn(Unit, Event)
    Unit:RegisterEvent("B_Seal", 30000, 0)
    end

    function B_Seal(Unit, Event)
    Unit:CastSpell(41459)
    end

    RegisterUnitEvent(70015, 1, "B_OnSpawn") -- Bram's Code

    function J_OnSpawn(Unit, Event)
    Unit:CastSpellOnTarget(46459, Unit:GetPrimaryCombatTarget())
    end

    function J_OnDeath(Unit, Event)
    Unit:SendChatMessage(12, 0, "All I wanted.... was.. Laynes..")
    end

    RegisterUnitEvent(70013, 1, "J_OnSpawn") -- Jordan's Code
    RegisterUnitEvent(70013, 4, "J_OnDeath")
    Last edited by modmassacre; 03-03-2014 at 11:39 PM.

    Need help with Boss Script
  2. #2
    newtech's Avatar Active Member
    Reputation
    57
    Join Date
    Aug 2008
    Posts
    308
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What you need to realize is, it is always much better to be referencing units by actual references, as opposed to using GetUnitBySqlId or other fancy stuff like that. So instead of
    Unit:FullCastSpellOnTarget(29564, Unit:GetUnitBySqlId(200002265)

    try
    Unit:FullCastSpellOnTarget(29564, unitMrT)

    And obviously you'd need to declare a global variable in the T script, where you define unitMrT as the T unit, upon spawn.

    Also,
    calling 'GetRandomPlayer' on bad self (number expected, got no value).
    That usually means you're using either a bad source, or target. So either pUnit is null (or something equally bad), or the target does not exist. This will make the core go bai bai (aka the error in the script)

    Thanks
    Newtech
    LuaHypArc Lua scripter - 3.3.5a World Builder.

  3. #3
    stoneharry's Avatar Moderator Harry


    Reputation
    1614
    Join Date
    Sep 2007
    Posts
    4,558
    Thanks G/R
    151/146
    Trade Feedback
    0 (0%)
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    1. The only targeting function I can get to work for bosses is Unit:GetMainTank(). I would like to randomly target players, but things such as Unit:GetRandomPlayer() give me an error of " calling 'GetRandomPlayer' on bad self (number expected, got no value).
    Code:
    -- Probably should do this
    if pUnit:IsCasting() then
       return
    end
    -- Try to cast on a random player
    local plr = pUnit:GetRandomPlayer(0)
    if (plr and plr:GetDistanceYards(pUnit) <= 40) then
       pUnit:FullCastSpellOnTarget(1,plr)
    end
    2. I have a boss spawn a mob that will heal the boss, which works fine by using the command Unit:GetUnitBySqlID( X ). However this is very tedious as I have to re-enter the SQL entry every time I delete or edit my mob. I would also like her to cast heals on all mobs friendly to her. I tried Unit:GetClosestFriend but that failed as well.
    Code:
    if pUnit:IsCasting() then
      return
    end
    -- Quite a costly function
    for _,v in pairs(pUnit:GetInRangeUnits()) do
       if v:GetEntry() == 100 and v:IsAlive() and v:GetDistanceYards(pUnit) <= 40 then
         pUnit:FullCastSpellOnTarget(11, v)
         break
       end
    end
    3. I would like my boss to be interacting with the environment while he isn't in combat. Such as moving around and saying different things. However when I make the function Bossname_OnSpawn and register it as RegisterUnitEvent(70011, 6, "Bossname_OnSpawn") it doesn't do anything. I thought 6 was the value for OnSpawn?
    6 was what it used to be about ~5 years ago. It is 18 now. Look at ArcEmu's wiki. Also note that OnSpawn is fired before the creature has been fully loaded, so you will want to wait a second before doing most things.

    4. I've partially learned how to edit a mob's items through playing around with HeidiSQL. But its very tedious that way, is there any easier way I can edit what weapons/armor a boss wears?
    .npc equipitem1 itemid
    .npc equpitem2 itemid
    .npc equipitem3 itemid

    Commands from the top of my head. Use bytes2 to have weapons unsheathed.

    .mod bytes2 1 <- primary and offhand weapon unsheathed
    .mod bytes2 2 <- this is ranged weapon, I think from memory

    5. My mobs that do have items equipped, unsheathe them and attack, then sheathe them again, then unsheathe to attack, etc. It looks pretty weird and was wondering if there was a fix to it.
    Set bytes2 to 1. .mod bytes2 1.

  4. #4
    modmassacre's Avatar Private
    Reputation
    1
    Join Date
    Mar 2014
    Posts
    2
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet, I'll try these out tomorrow. Thank you so much guys!

Similar Threads

  1. [Lua Script] need help with boss script
    By bellios in forum WoW EMU Questions & Requests
    Replies: 6
    Last Post: 12-09-2010, 03:10 PM
  2. [Lua Script] Need help with 2 Scripts (One Boss, One Gauntlet)
    By controlsx2 in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 07-22-2010, 02:42 AM
  3. Help With Boss Script
    By DragenFear in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 10-10-2008, 11:24 PM
  4. Need help with my script [lua]
    By Satzen in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 05-18-2008, 05:19 PM
  5. [C++]Need help with my Scripted Item
    By freezer1012 in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 01-13-2008, 05:55 PM
All times are GMT -5. The time now is 09:56 AM. 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