[Lua] Spell Problem menu

Shout-Out

User Tag List

Results 1 to 3 of 3
  1. #1
    Sumething 2 r3member's Avatar Member
    Reputation
    1
    Join Date
    Apr 2009
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Lua] Spell Problem

    Well I've been doing lua for about 10-15 min now and I made this script

    Code:
    local King_Varian_Wyrnn
    
    function King_Varian_Wyrnn_Define(Unit, Event)
    King_Varian_Wyrnn = Unit
    end
    
    function King_Varian_Wyrnn_OnCombat(Unit, Event)
    Unit:SendChatMessage(14, 0, "Look what we have here... the horde. After all the time we've let you live in peace, this is what it comes to. A bloody battle that nobody will forget. The existence of the horde will be no more...")
    Unit:RegisterEvent("Phase_1", 1000, 0)
    end
    
    function King_Varian_Wyrnn_OnDied(Unit, Event)
    Unit:SendChatMessage(14, 0, "What... have... I... done?")
    end
    
    function King_Varian_Wyrnn_OnLeaveCombat(Unit, Event)
    Unit:SendChatMessage(14, 0, "Cowards!")
    end
    
    function King_Varian_Wyrnn_OnKilledTarget(Unit, dEvent)
    Unit:SendChatMessage(14, 0, "Another Horde dead. So weak.")
    end
    
    function Phase_1(Unit, Event)
    if Unit:GetHealthPct() <= 90 then
    Unit:RemoveEvents()
    Unit:SendChatMessage(14, 0, "You will soon be dead!")
    Unit:CastSpellOnTarget(41484, Unit:GetRandomPlayer(1))
    Unit:RegisterEvent("FireBall", 35000, 0)
    end
    end
    
    function FireBall(Unit, Event)
    Unit:CastSpellOnTarget(41484, Unit:GetRandomPlayer(1))
    end
    
    RegisterUnitEvent(49582, 1, "King_Varian_Wyrnn_OnCombat")
    RegisterUnitEvent(49582, 2, "King_Varian_Wyrnn_OnLeaveCombat")
    RegisterUnitEvent(49582, 3, "King_Varian_Wyrnn_OnKilledTarget")
    RegisterUnitEvent(49582, 4, "King_Varian_Wyrnn_OnDied")
    And the problem is I try to get him to cast a fireball (Which he does) but he fires it at himself... I've tried all sorts of things, I checked the spell to see if it worked properly and it did.

    I tried changing..

    Code:
    Unit:CastSpellOnTarget(41484,Unit:GetRandomPlayer(1)
    To different flags such as...

    Code:
    :GetRandomPlayer(flag)
    RANDOM_ANY = 0,
     
    RANDOM_IN_SHORTRANGE = 1,
     
    RANDOM_IN_MIDRANGE = 2,
     
    RANDOM_IN_LONGRANGE = 3,
     
    RANDOM_WITH_MANA = 4,
     
    RANDOM_WITH_RAGE = 5,
     
    RANDOM_WITH_ENERGY = 6,
     
    RANDOM_NOT_MAINTANK= 7
    I've also tried

    :GetClosestPlayer()
    :GetMainTank()
    :GetAddTank()

    But sadly still nothing. So if you can please help me I will +Rep when I can lol.

    [Lua] Spell Problem
  2. #2
    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)
    CastSpellOnTarget is sadly bugged, and so will always cast on him self.
    You need to do FullCastSpellOnTarget and it should get him, but to save getting errors in console if somone logouts quickly or such you would do this:


    Code:
    function spell(pUnit, Event)
    local player = pUnit:GetRandomPlayer(0)
    if player == nil then -- If nobody was targeted
    else -- Otherwise they were
    pUnit:FullCastSpellOnTarget(11, player) -- 11 spell id
    end
    end
    Note: I am using pUnit but it doesn't really matter if you use unit Unit or pUnit as long as you define it right in the function (pUnit, Event) part.

  3. #3
    Sumething 2 r3member's Avatar Member
    Reputation
    1
    Join Date
    Apr 2009
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by stoneharry View Post
    CastSpellOnTarget is sadly bugged, and so will always cast on him self.
    You need to do FullCastSpellOnTarget and it should get him, but to save getting errors in console if somone logouts quickly or such you would do this:


    Code:
    function spell(pUnit, Event)
    local player = pUnit:GetRandomPlayer(0)
    if player == nil then -- If nobody was targeted
    else -- Otherwise they were
    pUnit:FullCastSpellOnTarget(11, player) -- 11 spell id
    end
    end
    Note: I am using pUnit but it doesn't really matter if you use unit Unit or pUnit as long as you define it right in the function (pUnit, Event) part.
    Thanks a bunch stoneharry.

Similar Threads

  1. Lua script spell problem
    By bill45 in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 05-13-2008, 01:56 PM
  2. LUA Scripting Problem
    By Knife in forum World of Warcraft Emulator Servers
    Replies: 18
    Last Post: 03-10-2008, 02:00 PM
  3. Lua scripts problem
    By Mr.Ice.Cold in forum World of Warcraft Emulator Servers
    Replies: 12
    Last Post: 02-02-2008, 11:44 AM
  4. .Lua portal problem
    By Kiev in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 01-12-2008, 10:49 AM
  5. Missing spells problem solved...
    By robotjuice in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 01-07-2008, 06:21 AM
All times are GMT -5. The time now is 01:32 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