LUA script help/information menu

User Tag List

Results 1 to 7 of 7
  1. #1
    Ascelyn's Avatar Member
    Reputation
    22
    Join Date
    Jul 2009
    Posts
    129
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    LUA script help/information

    So I have a few questions about LUA scripting

    Code:
    function Mage_OnCombat (Unit, Event)
    Unit:RegisterEvent("Mage_Frostbolt",10000, 0)
    Unit:RegisterEvent("Mage_Frostnova",35000, 0)
    Unit:RegisterEvent("Mage_Barrier", 40000, 2)
    Unit:RegisterEvent("Mage_Evocation",1000,0)
    end
    
    
    
    function Mage_Frostbolt(pUnit, Event)
    pUnit:FullCastSpellOnTarget (42842, pUnit:GetRandomPlayer(0) )
    end
    
    function Mage_Frostnova(pUnit, Event)
    pUnit:CastSpell (42917)
    end
    
    function Mage_Barrier(pUnit, Event)
    pUnit:CastSpell (36481)
    end
    
    function Mage_OnDied (Unit, Event)
    Unit:RemoveEvents()
    end
    
    function Mage_OnKilledTarget (Unit, Event)
    end
    
    function Mage_OnLeaveCombat (Unit, Event)
    Unit:RemoveEvents()
    end
    
    RegisterUnitEvent (1759, 1, "Mage_OnCombat")
    RegisterUnitEvent (1759, 2, "Mage_OnLeaveCombat")
    RegisterUnitEvent(1759, 3, "Mage_OnKilledTarget")
    RegisterUnitEvent(1759, 4, "Mage_OnDied")
    So this is my script for a mage ( I'm new at LU so no flaming pls :P)
    But when my mob runs out of mana, He still tries to cast his spells..

    1. I've tried adding something like
    Code:
    function Mage_Evocation(Unit, event, miscunit, misc)
    	if Unit:GetManaPct() < 25 and Didthat == 0 then
    		print "Mage Evocation"
    		Unit:FullCastSpell(30254)
    		Didthat = 1
    	else
    	end
    	end
    in it but he doesnt cast the evocation so if you could help me with that

    2.But what would be even better is, Is there any code or function so the mob knows when he doesnt have enough mana, He doesnt need to cast the spell? :P

    3. They always seem to cast the spell on me only, even when they're fighting against other hostile mobs.

    Thanks in advance.

    -Greetings Ascelyn.

    LUA script help/information
  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)
    I think your function doesn't work because you need to define what Didthat is.
    Add at the top of the script outside any functions:

    local Didthat = 0

    Then on death / leave combat:

    Didthat = 0

    As for checking when casting the spell:
    Code:
    function x(pUnit, Event)
       if pUnit:GetManaPct() < 25 then
       pUnit:FullCastSpell(
    Code:
    30254) -- Evocation
    
    Code:
       else
       local plr = pUnit:GetRandomPlayer(0)
       if plr == nil then
       else
       pUnit:FullCastSpellOnTarget(11, plr)
       end
       end
    end
    


    To make a creature cast a spell on another creature, you have to define the hostile creature first.

    Code:
    local Hostile
    
    function Hastile_Spawned(pUnit, Event)
         Hostile = pUnit
    end
    
    RegisterUnitEvent(npcid, 18, "Hastile_Spawned") -- 6 with some Lua engines
    
    
    -- FURTHER DOWN IN THE SAME SCRIPT ON THE NPC YOU WANT TO CAST A SPELL ON THE OTHER WITH
    -- HAS TO BE SAME SCRIPT
    
    function X(pUnit, Event)
          pUnit:FullCastSpellOnTarget(11, Hostile)
    end
    Good luck

    Edit: Code boxes screwed up, you get the idea.
    Last edited by stoneharry; 07-31-2009 at 12:44 PM.

  3. #3
    Ascelyn's Avatar Member
    Reputation
    22
    Join Date
    Jul 2009
    Posts
    129
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks man really +rep

  4. #4
    Ascelyn's Avatar Member
    Reputation
    22
    Join Date
    Jul 2009
    Posts
    129
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But eh, So you have to make another script for a creature you want your mob to atk? So there's no possibility that you can script it so it attacks both players and other creatures?

    and could you define the last part? O.o

    local plr = pUnit:GetRandomPlayer(0)
    if plr == nil then
    else
    pUnit:FullCastSpellOnTarget(11, plr)
    end
    end
    end
    so if he cant get a random player he'll cast a another spell?
    Last edited by Ascelyn; 07-31-2009 at 12:51 PM.

  5. #5
    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)
    First question, you can make it do this command,

    local target = pUnit:GetTarget()
    if target:IsCreature() == true then
    else

    and do your stuff in there.

    For your second question:

    local plr = pUnit:GetRandomPlayer(0) -- we say plr is a random player
    if plr == nil -- If the player is equel to nil (means if it is nothing
    else - else if it is something
    pUnitoStuff

    Hope this answers your questions.

  6. #6
    Ascelyn's Avatar Member
    Reputation
    22
    Join Date
    Jul 2009
    Posts
    129
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Where about should I add the
    local target = pUnit:GetTarget()
    if target:IsCreature() == true then
    else
    and what to I type following?
    function_x(Unit, Event)
    pUnit: bla bla? or something else?

    Sorry i'm not good at LUA Tried many guides..

  7. #7
    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)
    "So there's no possibility that you can script it so it attacks both players and other creatures?"

    X in maths is usually something that you need to find / change / define, for example the classic:



    So I tend to use that a lot in examples.
    This is how it would answer your question:

    function x(pUnit, Event)

    x can be whatever you want it to be, so for example

    function Check_If_He_Is_A_Creature_And_Do_Something(pUnit, Event)

    Long name but you get the idea, so now I want to do something depending on whether it's a creature or a player.

    Code:
    function x(pUnit, Event) -- Note here, were using pUnit, NOT unit or Unit.
        local target = pUnit:GetTarget() -- Get who were targeting
        if target == nil then -- Is there nobody there?
        else -- There is somone here
             if target:IsCreature() == true
             pUnit:FullCastSpellOnTarget(11, hostile) -- I talked about defining hostile in a post earlier on, 11 is the spell id
             else -- He's not a creature
             pUnit:FullCastSpellOnTarget(11, pUnit:GetRandomPlayer(0)) -- He's not a creature so cast on the player
              end
         end
    end


Similar Threads

  1. Simple LUA Script Help
    By Wolfly in forum WoW EMU Questions & Requests
    Replies: 7
    Last Post: 09-02-2008, 04:22 PM
  2. LUA Script Help Thread
    By mager1794 in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 07-04-2008, 12:46 AM
  3. LuA Scripting Help
    By Jlp in forum World of Warcraft Emulator Servers
    Replies: 15
    Last Post: 06-27-2008, 03:33 AM
  4. Lua script help and general questions from beginner
    By WinKIller0 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 02-23-2008, 04:38 AM
  5. Need LUA Scripting Help ?
    By Snailz in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 02-04-2008, 12:36 PM
All times are GMT -5. The time now is 05:42 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