Custom Lua Scripted Boss (Not working!) menu

User Tag List

Results 1 to 8 of 8
  1. #1
    shtriga's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    8
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Custom Lua Scripted Boss (Not working!)

    Ok so I made a custom NPC and made a script for him to use some spells and say some dialogue. When I spawn the mob in game and attack it, he does not cast the spells OR say the dialogue that I want him to. I do not understand what I've done wrong? I will link the script and you can tell me what you think. Thanks in advanced:



    local name = "Argatros"
    local npcid = 50000

    function Argatros_OnCombat(pUnit, Event,)
    pUnit:SendChatMessage(12, 0, "More fools to challenge me?")
    pUnit:RegisterEvent(Argatros_accelerate, 20000, 0)
    pUnit:RegisterEvent(Argatros_burst, 1000, 0)
    pUnit:RegisterEvent(Argatros_kick, 30000, 0)
    pUnit:RegisterEvent(Argatros_steal, 35000, 0)
    pUnit:RegisterEvent(Argatros_nova, 60000, 0)
    pUnit:RegisterEvent(Argatros_aegis, 62000, 0)
    pUnit:RegisterEvent(Argatros_cc, 64000, 0)
    pUnit:RegisterEvent(Argatros_static, 75000, 0)
    pUnit:RegisterEvent(Argatros_attenuation, 77000, 0)
    end

    function Argatros_OnLeaveCombat(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(14, 0, "See you In Hell")
    end

    function Argatros_KilledTarget
    pUnit:SendChatMessage(14, 0, "Any one else?")
    end

    function Argatros_OnDied(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(14, 0, "I..Will...Return!")
    end

    RegisterUnitEvent(50000, 1, "Argatros_OnCombat")
    RegisterUnitEvent(50000, 2, "Argatros_OnLeaveCombat")
    RegisterUnitEvent(50000, 3, "Argatros_KilledTarget")
    RegisterUnitEvent(50000, 4, "Argatros_OnDied")

    function Argatros_accelerate(pUnit, Event)
    pUnit:CastSpell(52635)
    end

    function Argatros_burst(pUnit, Event)
    pUnit:CastSpell(7201
    end

    function Argatros_kick(pUnit, Event)
    pUnit:FullCastSpellOnTarget(24671, pUnit:GetRandomPlayer(0))
    end

    function Argatros_steal(pUnit, Event)
    pUnit:FullCastSpellOnTarget(71839, pUnit:GetMainTank())
    end

    function Argatros_nova(pUnit, Event)
    pUnit:CastSpell(59363)
    end

    function Argatros_cc(pUnit, Event)
    pUnit:FullCastSpellOnTarget(64156, pUnit:GetRandomPlayer(0))
    end

    function Argatros_acid(pUnit, Event)
    pUnit:FullCastSpellOnTarget(59419, pUnit(GetMainTank())
    end

    function Argatros_aegis(pUnit, Event)
    pUnit:CastSpell(20620)
    end

    function Argatros_static(pUnit, Event)
    pUnit:FullCastSpellOnTarget(59795, pUnit:GetRandomPlayer(0))
    pUnit:SendChatMessage(14, 0, "Yes! Feel the pain run through your soul!")
    end

    function Argatros_attenuation(pUnit, Event)
    pUnit:CastSpell(50627)
    end




    The boss attacks me and I attack him like normal but nothing happens other than that. And by the way that emoticon is "8" + ")" . quite annoying that
    Last edited by shtriga; 11-27-2013 at 03:14 PM.

    Custom Lua Scripted Boss (Not working!)
  2. #2
    minupii's Avatar Master Sergeant
    Reputation
    25
    Join Date
    Sep 2012
    Posts
    84
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please use code tags next time, it was hard to read and I think it would remove the emoticon too :-)
    Does world.exe give you any error when you attack him or when loading the scripts?
    As it seems the script is not run at all.
    I will test it on my own server tomorrow.

    Regards, Minupi.

  3. #3
    shtriga's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    8
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by minupii View Post
    Please use code tags next time, it was hard to read and I think it would remove the emoticon too :-)
    Does world.exe give you any error when you attack him or when loading the scripts?
    As it seems the script is not run at all.
    I will test it on my own server tomorrow.

    Regards, Minupi.
    Ok so I tidied up the coding a little. I also changed one spell. After testing and checking the world.exe I found no errors.
    It's almost as if there isn't even an attempt at executing this script upon attacking. He didn't even say the dialogue within OnCombat.
    I compare closely to scripts that do work and there is little difference. :S

    Code:
    local NPC_ID = 50000
    
    function Argatros_OnCombat(pUnit, Event,)
    pUnit:SendChatMessage(12, 0, "More fools to challenge me?")
    pUnit:RegisterEvent(Argatros_accelerate, 20000, 5)
    pUnit:RegisterEvent(Argatros_burst, 20000, 10) 
    pUnit:RegisterEvent(Argatros_kick, 30000, 5)
    pUnit:RegisterEvent(Argatros_steal, 10000, 20)
    pUnit:RegisterEvent(Argatros_nova, 25000, 5)
    pUnit:RegisterEvent(Argatros_aegis, 40000, 20)
    pUnit:RegisterEvent(Argatros_cc, 60000, 4)
    pUnit:RegisterEvent(Argatros_static, 65000, 4)
    pUnit:RegisterEvent(Argatros_attenuation, 77000, 2)
    end
    
    function Argatros_accelerate(pUnit, Event)
    pUnit:CastSpell(52635)
    end
    
    function Argatros_burst(pUnit, Event)
    pUnit:CastSpell(62415)
    end
    
    function Argatros_kick(pUnit, Event)
    pUnit:FullCastSpellOnTarget(24671, pUnit:GetRandomPlayer(0))
    end
    
    function Argatros_steal(pUnit, Event)
    pUnit:FullCastSpellOnTarget(71839, pUnit:GetMainTank())
    end
    
    function Argatros_nova(pUnit, Event)
    pUnit:CastSpell(59363)
    end
    
    function Argatros_cc(pUnit, Event)
    pUnit:FullCastSpellOnTarget(64156, pUnit:GetRandomPlayer(0))
    end
    
    function Argatros_acid(pUnit, Event)
    pUnit:FullCastSpellOnTarget(59419, pUnit(GetMainTank())
    end
    
    function Argatros_aegis(pUnit, Event)
    pUnit:CastSpell(20620)
    end
    
    function Argatros_static(pUnit, Event)
    pUnit:FullCastSpellOnTarget(59795, pUnit:GetRandomPlayer(0))
    end
    
    function Argatros_attenuation(pUnit, Event)
    pUnit:CastSpell(50627)
    end
    
    function Argatros_OnLeaveCombat(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(14, 0, "See you In Hell")
    end
    
    function Argatros_OnKilledTarget
    pUnit:SendChatMessage(14, 0, "Any one else?")
    end
    
    function Argatros_OnDied(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(14, 0, "I..Will...Return!")
    end
    
    RegisterUnitEvent(50000, 1, "Argatros_OnCombat")
    RegisterUnitEvent(50000, 2, "Argatros_OnLeaveCombat")
    RegisterUnitEvent(50000, 3, "Argatros_OnKilledTarget")
    RegisterUnitEvent(50000, 4, "Argatros_OnDied")

  4. #4
    shtriga's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    8
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by minupii View Post
    Please use code tags next time, it was hard to read and I think it would remove the emoticon too :-)
    Does world.exe give you any error when you attack him or when loading the scripts?
    As it seems the script is not run at all.
    I will test it on my own server tomorrow.

    Regards, Minupi.
    Ok, I spotted some silly mistakes, like one ':' was accidentally a '('.
    So after correcting errors - IT WORKS
    One spell didn't work but thanks to you pointing out i can check the world.exe for these things too, i spotted it.

    No need for any further help. Thank you.

    For those who wish to see the final working script:

    Code:
    local NPC_ID = 50000
    
    function Argatros_OnCombat(pUnit, Event)
    pUnit:SendChatMessage(12, 0, "More fools to challenge me?")
    pUnit:RegisterEvent(Argatros_accelerate, 20000, 5)
    pUnit:RegisterEvent(Argatros_burst, 10000, 40) 
    pUnit:RegisterEvent(Argatros_kick, 30000, 5)
    pUnit:RegisterEvent(Argatros_steal, 13000, 20)
    pUnit:RegisterEvent(Argatros_nova, 25000, 5)
    pUnit:RegisterEvent(Argatros_aegis, 40000, 20)
    pUnit:RegisterEvent(Argatros_cc, 60000, 4)
    pUnit:RegisterEvent(Argatros_static, 65000, 4)
    pUnit:RegisterEvent(Argatros_attenuation, 77000, 2)
    end
    
    function Argatros_accelerate(pUnit, Event)
    pUnit:CastSpell(52635)
    end
    
    function Argatros_burst(pUnit, Event)
    pUnit:CastSpell(38539)
    end
    
    function Argatros_kick(pUnit, Event)
    pUnit:FullCastSpellOnTarget(24671, pUnit:GetRandomPlayer(0))
    end
    
    function Argatros_steal(pUnit, Event)
    pUnit:FullCastSpellOnTarget(71839, pUnit:GetMainTank())
    end
    
    function Argatros_nova(pUnit, Event)
    pUnit:CastSpell(59363)
    end
    
    function Argatros_cc(pUnit, Event)
    pUnit:FullCastSpellOnTarget(64156, pUnit:GetRandomPlayer(0))
    end
    
    function Argatros_acid(pUnit, Event)
    pUnit:FullCastSpellOnTarget(59419, pUnit:GetMainTank())
    end
    
    function Argatros_aegis(pUnit, Event)
    pUnit:CastSpell(20620)
    end
    
    function Argatros_static(pUnit, Event)
    pUnit:FullCastSpellOnTarget(59795, pUnit:GetRandomPlayer(0))
    end
    
    function Argatros_attenuation(pUnit, Event)
    pUnit:CastSpell(50627)
    end
    
    function Argatros_OnLeaveCombat(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(14, 0, "See you In Hell")
    end
    
    function Argatros_OnKilledTarget(pUnit, Event)
    pUnit:SendChatMessage(14, 0, "Any one else?")
    end
    
    function Argatros_OnDied(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(14, 0, "I..Will...Return!")
    end
    
    RegisterUnitEvent(50000, 1, "Argatros_OnCombat")
    RegisterUnitEvent(50000, 2, "Argatros_OnLeaveCombat")
    RegisterUnitEvent(50000, 3, "Argatros_OnKilledTarget")
    RegisterUnitEvent(50000, 4, "Argatros_OnDied")
    Last edited by shtriga; 11-27-2013 at 08:28 PM.

  5. #5
    minupii's Avatar Master Sergeant
    Reputation
    25
    Join Date
    Sep 2012
    Posts
    84
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great that it works :-)

  6. #6
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    This is how you should be programming bosses in Lua:

    Code:
    local NPC_ID = 50000
    
    A = {}
    A.V = {}
    
    local AVmessages = {
    	{12, "More fools to challenge me?"},
    	{14, "See you In Hell"},
    	{14, "Any one else?"},
    	{14, "I... will... return!"}
    }
    
    function A.V.Arg_Events(pUnit, Event)
    	--[[
    	-- Use code below if we want to store variables accross functions
    	local id = pUnit:GetInstanceID() or 1
    	A[id] = A[id] or {V={}}
            A[id].V.unitReference = pUnit
    	]]
    	pUnit:SendChatMessage(AVmessages[Event][1], 0, AVmessages[Event][2])
    	if Event == 1 then
    		pUnit:RegisterEvent("A.V.Argatros_accelerate", 20000, 5)
    		pUnit:RegisterEvent("A.V.Argatros_burst", 10000, 40) 
    		pUnit:RegisterEvent("A.V.Argatros_kick", 30000, 5)
    		pUnit:RegisterEvent("A.V.Argatros_steal", 13000, 20)
    		pUnit:RegisterEvent("A.V.Argatros_nova", 25000, 5)
    		pUnit:RegisterEvent("A.V.Argatros_aegis", 40000, 20)
    		pUnit:RegisterEvent("A.V.Argatros_cc", 60000, 4)
    		pUnit:RegisterEvent("A.V.Argatros_static", 65000, 4)
    		pUnit:RegisterEvent("A.V.Argatros_attenuation", 77000, 2)
    	elseif Event == 2 or Event == 4 then
    		pUnit:RemoveEvents()
    	end
    end
    
    function A.V.Argatros_accelerate(pUnit)
    	pUnit:CastSpell(52635)
    end
    
    function A.V.Argatros_burst(pUnit)
    	pUnit:CastSpell(38539)
    end
    
    function A.V.Argatros_kick(pUnit)
    	castOnPlayerTarget(24671, pUnit)
    end
    
    function A.V.Argatros_steal(pUnit)
    	castOnPlayerTarget(71839, pUnit)
    end
    
    function A.V.Argatros_nova(pUnit)
    	pUnit:CastSpell(59363)
    end
    
    function A.V.Argatros_cc(pUnit)
    	castOnPlayerTarget(64156, pUnit)
    end
    
    function A.V.Argatros_acid(pUnit)
    	castOnPlayerTarget(59419, pUnit)
    end
    
    function A.V.Argatros_aegis(pUnit)
    	pUnit:CastSpell(20620)
    end
    
    function A.V.Argatros_static(pUnit)
    	castOnPlayerTarget(59795, pUnit)
    end
    
    function A.V.Argatros_attenuation(pUnit)
    	pUnit:CastSpell(50627)
    end
    
    function castOnPlayerTarget(id, pUnit)
    	if not id or not pUnit or pUnit:IsCasting() or pUnit:IsDead() then
    		return
    	end
    	local plr = pUnit:GetRandomPlayer(0)
    	if not plr or plr:IsDead() then
    		return
    	end
    	pUnit:FullCastSpellOnTarget(id, plr)
    end
    
    for i=1,4 do
    	RegisterUnitEvent(NPC_ID, i, "A.V.Arg_Events")
    end
    Note that my code is not perfect and I have not tested this, however it should work and it is a much better solution than yours as it avoids collision and optimises the script.

    ArcEmu should not be being used. It has not been developed for years and is far out of date. Mangos based emulators support Lua as well now that someone took the time to write a full API, so there is no excuse.

  7. #7
    shtriga's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    8
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    This is how you should be programming bosses in Lua:

    Code:
    local NPC_ID = 50000
    
    A = {}
    A.V = {}
    
    local AVmessages = {
    	{12, "More fools to challenge me?"},
    	{14, "See you In Hell"},
    	{14, "Any one else?"},
    	{14, "I... will... return!"}
    }
    
    function A.V.Arg_Events(pUnit, Event)
    	--[[
    	-- Use code below if we want to store variables accross functions
    	local id = pUnit:GetInstanceID() or 1
    	A[id] = A[id] or {V={}}
            A[id].V.unitReference = pUnit
    	]]
    	pUnit:SendChatMessage(AVmessages[Event][1], 0, AVmessages[Event][2])
    	if Event == 1 then
    		pUnit:RegisterEvent("A.V.Argatros_accelerate", 20000, 5)
    		pUnit:RegisterEvent("A.V.Argatros_burst", 10000, 40) 
    		pUnit:RegisterEvent("A.V.Argatros_kick", 30000, 5)
    		pUnit:RegisterEvent("A.V.Argatros_steal", 13000, 20)
    		pUnit:RegisterEvent("A.V.Argatros_nova", 25000, 5)
    		pUnit:RegisterEvent("A.V.Argatros_aegis", 40000, 20)
    		pUnit:RegisterEvent("A.V.Argatros_cc", 60000, 4)
    		pUnit:RegisterEvent("A.V.Argatros_static", 65000, 4)
    		pUnit:RegisterEvent("A.V.Argatros_attenuation", 77000, 2)
    	elseif Event == 2 or Event == 4 then
    		pUnit:RemoveEvents()
    	end
    end
    
    function A.V.Argatros_accelerate(pUnit)
    	pUnit:CastSpell(52635)
    end
    
    function A.V.Argatros_burst(pUnit)
    	pUnit:CastSpell(38539)
    end
    
    function A.V.Argatros_kick(pUnit)
    	castOnPlayerTarget(24671, pUnit)
    end
    
    function A.V.Argatros_steal(pUnit)
    	castOnPlayerTarget(71839, pUnit)
    end
    
    function A.V.Argatros_nova(pUnit)
    	pUnit:CastSpell(59363)
    end
    
    function A.V.Argatros_cc(pUnit)
    	castOnPlayerTarget(64156, pUnit)
    end
    
    function A.V.Argatros_acid(pUnit)
    	castOnPlayerTarget(59419, pUnit)
    end
    
    function A.V.Argatros_aegis(pUnit)
    	pUnit:CastSpell(20620)
    end
    
    function A.V.Argatros_static(pUnit)
    	castOnPlayerTarget(59795, pUnit)
    end
    
    function A.V.Argatros_attenuation(pUnit)
    	pUnit:CastSpell(50627)
    end
    
    function castOnPlayerTarget(id, pUnit)
    	if not id or not pUnit or pUnit:IsCasting() or pUnit:IsDead() then
    		return
    	end
    	local plr = pUnit:GetRandomPlayer(0)
    	if not plr or plr:IsDead() then
    		return
    	end
    	pUnit:FullCastSpellOnTarget(id, plr)
    end
    
    for i=1,4 do
    	RegisterUnitEvent(NPC_ID, i, "A.V.Arg_Events")
    end
    Note that my code is not perfect and I have not tested this, however it should work and it is a much better solution than yours as it avoids collision and optimises the script.

    ArcEmu should not be being used. It has not been developed for years and is far out of date. Mangos based emulators support Lua as well now that someone took the time to write a full API, so there is no excuse.
    That script does however seem far more confusing though :O

  8. #8
    minupii's Avatar Master Sergeant
    Reputation
    25
    Join Date
    Sep 2012
    Posts
    84
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Commented out Stoneharry's script.
    For ease of reading you should insert this into your lua editor as it will show comments as green.

    Code:
    local NPC_ID = 50000
    
    --A would be the table of the unit, each instance of this unit is unique. 
    --If it wasn't and you had two of this unit in the world they could interfere with each other.
    A = {} 
    
    -- V would be the units table, you can store variables for this instance of the unit.
    A.V = {} 
    
    --Table of messages, each message is defined in the table as a number
    local AVmessages = {
    	{12, "More fools to challenge me?"}, -- Would be 1
    	{14, "See you In Hell"}, -- would be 2 ect.
    	{14, "Any one else?"},
    	{14, "I... will... return!"}
    }
    
    -- The function is created in the table V, which is in the table A.
    function A.V.Arg_Events(pUnit, Event)
    	--[[
    	-- Use code below if we want to store variables across functions
    	-- The id is used to define which unit we are going to assign a variable to, the example below uses the instance ID.
    	-- Instance id's are randomly generated and assigned to a group whenever they enter the instance.
    	
    	-- We get the instance id and assign it to the variable "id".
    	-- If the unit isn't in an instance we give it the id 1(I don't know why Stoneharry does this, 
    	-- as that could potentially collide if there were more of than one of this boss in the world.
    	local id = pUnit:GetInstanceID() or 1
    	A[id] = A[id] or {V={}} -- Essentially we just check whether this unit is already stored, if it is not we make create and or clean the table V
    	
    		-- unitReference is a variable created, to refer the unit, so incase we want to do something for this unit in another function
    		-- We call the id and use the id's unit reference.
            A[id].V.unitReference = pUnit 		
    	]]
    	pUnit:SendChatMessage(AVmessages[Event][1], 0, AVmessages[Event][2])
    	
    	-- This literally just removes the need for multiple functions for onDeath and onCombat etc., as we just check which event is registered
    	-- Look at the code where Stoneharry registers the Event to see how it works.	
    	-- Checking if the registered event is 1(onCombat) if it is then register the following functions:
    	if Event == 1 then
    		pUnit:RegisterEvent("A.V.Argatros_accelerate", 20000, 5)
    		pUnit:RegisterEvent("A.V.Argatros_burst", 10000, 40) 
    		pUnit:RegisterEvent("A.V.Argatros_kick", 30000, 5)
    		pUnit:RegisterEvent("A.V.Argatros_steal", 13000, 20)
    		pUnit:RegisterEvent("A.V.Argatros_nova", 25000, 5)
    		pUnit:RegisterEvent("A.V.Argatros_aegis", 40000, 20)
    		pUnit:RegisterEvent("A.V.Argatros_cc", 60000, 4)
    		pUnit:RegisterEvent("A.V.Argatros_static", 65000, 4)
    		pUnit:RegisterEvent("A.V.Argatros_attenuation", 77000, 2)
    		
    	-- If the event id 2 or 4(onLeaveCombat or onDied) remove any events assigned to the unit, so it won't try to use the different spells.
    	elseif Event == 2 or Event == 4 then
    		pUnit:RemoveEvents()
    	end
    end
    
    -- As the function is registered to the V table(this particular units table) in the A table it will only happen for this unit, if it wasn't
    -- it would be global and happen to every instance of the unit in the world / instance.
    -- This goes for every function below.
    function A.V.Argatros_accelerate(pUnit)
    	-- As this does not happen to a particular target we do not need to evaluate the target.
    	-- We would need to evaluate the unit(just like we do for the player (check the next code's comment), 
    	-- if we did not remove the events on this units death, as it would try to cast these spells while dead or after it left combat.
    	-- 
    	pUnit:CastSpell(52635)
    end
    
    function A.V.Argatros_burst(pUnit)
    	pUnit:CastSpell(38539)
    end
    
    function A.V.Argatros_kick(pUnit)
    	-- Where you before just did a cast on a random player nearby Stoneharry has made a function to evaluate the picked target.
    	-- so instead of FullCastSpellOnTarget we call a function, that might do this for us.
    	castOnPlayerTarget(24671, pUnit) 
    
    end
    
    function A.V.Argatros_steal(pUnit)
    	castOnPlayerTarget(71839, pUnit)
    end
    
    function A.V.Argatros_nova(pUnit)
    	pUnit:CastSpell(59363)
    end
    
    function A.V.Argatros_cc(pUnit)
    	castOnPlayerTarget(64156, pUnit)
    end
    
    function A.V.Argatros_acid(pUnit)
    	castOnPlayerTarget(59419, pUnit)
    end
    
    function A.V.Argatros_aegis(pUnit)
    	pUnit:CastSpell(20620)
    end
    
    function A.V.Argatros_static(pUnit)
    	castOnPlayerTarget(59795, pUnit)
    end
    
    function A.V.Argatros_attenuation(pUnit)
    	pUnit:CastSpell(50627)
    end
    
    -- Essentially this is magic!
    
    --The function can take two arguments id and the pUnit, where id would be the spell and pUnit would be the unit trying to cast the spell.
    function castOnPlayerTarget(id, pUnit)
    	--If the call does not contain an id or the unit is nil or the unit is casting / dead then do nothing.
    	if not id or not pUnit or pUnit:IsCasting() or pUnit:IsDead() then
    		return -- This ends the function, so the rest won't be called.
    	end
    	-- We define "plr" as the random player which is gotten by the GetRandomPlayer method.
    	local plr = pUnit:GetRandomPlayer(0)
    	--If the method does not return a player or the player is dead then do nothing.
    	if not plr or plr:IsDead() then
    		return 
    	end
    	else -- If all the checks above pass then cast the spell with the id and on the player.
    	pUnit:FullCastSpellOnTarget(id, plr)
    end
    
    --For events 1,2,3,4 do
    for i=1,4 do
    	RegisterUnitEvent(NPC_ID, i, "A.V.Arg_Events") --Call the function A.V.Arg_Events.
    end
    
    --[[
    On a final note the big difference between this script and yours is that this does not collide.
    Your script would suffice if there was only 1 of your units present in the world at any time, where this script
    is able to tell the difference between them and only call different functions for each unique instance of the unit.
    Hope this commenting helps out a little.
    ]]
    Last edited by minupii; 11-30-2013 at 11:19 AM.

Similar Threads

  1. [Lua Script] Looking for premade Lua Script boss, who is easy to customize
    By Kapperjoe in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 04-02-2014, 12:17 PM
  2. [Lua] My first own Boss Script does not work...
    By Dark Guild in forum WoW EMU Questions & Requests
    Replies: 7
    Last Post: 04-11-2010, 09:53 PM
  3. [Help].DLL files in Script Bin not working?
    By MisterEMU in forum World of Warcraft Emulator Servers
    Replies: 18
    Last Post: 07-08-2008, 05:10 AM
  4. [Help] One part of my lua script doesn't work correctly
    By dude891 in forum World of Warcraft Emulator Servers
    Replies: 10
    Last Post: 06-07-2008, 09:17 AM
  5. [Request] I need some help with lua script (boss on death)
    By Ellenor in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 03-03-2008, 03:47 PM
All times are GMT -5. The time now is 08:54 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