Basic Lua Issues menu

Shout-Out

User Tag List

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

    Basic Lua Issues

    Okay, the person I've scripted is a spellcaster, I want her to be casting frostbolt every time she has a chance, (2 second cast) which she does now! But, my problem is, she'll cast it like 4 times, and then run really close to you, and start casting again, and if you stay there, she will hit you with melee as well. I want her to stay a distance away (or right where she is when you pull her) and spam frostbolt, without being trying to melee, and being successful at it.

    What "I" think the problem is, I need some command for a casting state, but I don't know what it is, or where to put it. Any help would get +Rep! Thank you very much!

    Code:
    function Adept_OnEnterCombat(pUnit,Event)
         pUnit:RegisterEvent("Adept_Spell", 1, 1)
         end
    
    function Adept_Spell(pUnit, Event)
         pUnit:FullCastSpellOnTarget(39064,pUnit:GetRandomPlayer(0)) -- Frostbolt
         pUnit:RemoveEvents()
    pUnit:RegisterEvent("Adept_Spell2", 2000, 0)
    end
    
    function Adept_Spell2(pUnit, Event)
         pUnit:FullCastSpellOnTarget(39064,pUnit:GetRandomPlayer(0)) -- Frostbolt
         pUnit:RemoveEvents()
    pUnit:RegisterEvent("Adept_Spell", 2000, 0)
    end
    
    function Adept_OnLeaveCombat(pUnit, event)
         pUnit:RemoveEvents()
    end
    
    function Adept_Death(pUnit)
         pUnit:RemoveEvents()
    end
    
    function Adept_OnKilledTarget(pUnit)
    end
    
    
    RegisterUnitEvent(80003, 1, "Adept_OnEnterCombat")
    RegisterUnitEvent(80003, 2, "Adept_OnLeaveCombat")
    RegisterUnitEvent(80003, 3, "Adept_OnKilledTarget")
    RegisterUnitEvent(80003, 4, "Adept_Death")

    Basic Lua Issues
  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)
    pUnit:Root()
    or
    pUnit:StopMovement(1000) -- stop for 1 second

    will stop her moving, add that in on combat then:

    pUnit:Set
    CombatMeleeCapable(1)

    will stop her attacking with melee as well.


  3. #3
    jay77's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    55
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    +Rep! Thank you!... I'm also wondering if theres a way she will spam frostbolt perfectly timed each time, so she doesn't sometimes skip one, she casts like 4 then she gets about 95% through through the spell cast, and she starts another one over and does about 4 more.... This is my new script, see if you can't help me! By shortening it? or what, I don't know!

    The mob is supposed to spam frostbolt, without meleeing, and without interrupting herself.
    Code:
    function Adept_OnEnterCombat(pUnit,Event)
         pUnit:RegisterEvent("Adept_Spell", 1, 1)
    end
    
    function Adept_Spell(pUnit, Event)
         pUnit:FullCastSpellOnTarget(39064,pUnit:GetRandomPlayer(0)) -- Frostbolt
    pUnit:RemoveEvents()
         pUnit:RegisterEvent("Adept_Spell2", 2000, 0)
         pUnit:SetCombatMeleeCapable(1)
    end
    
    function Adept_Spell2(pUnit, Event)
         pUnit:FullCastSpellOnTarget(39064,pUnit:GetRandomPlayer(0)) -- Frostbolt
    pUnit:RemoveEvents()
         pUnit:RegisterEvent("Adept_Spell", 2000, 0)
         pUnit:SetCombatMeleeCapable(1)
    end
    
    function Adept_OnLeaveCombat(pUnit, event)
         pUnit:RemoveEvents()
    end
    
    function Adept_Death(pUnit)
         pUnit:RemoveEvents()
    end
    
    function Adept_OnKilledTarget(pUnit)
    end
    
    
    RegisterUnitEvent(80003, 1, "Adept_OnEnterCombat")
    RegisterUnitEvent(80003, 2, "Adept_OnLeaveCombat")
    RegisterUnitEvent(80003, 3, "Adept_OnKilledTarget")
    RegisterUnitEvent(80003, 4, "Adept_Death")

  4. #4
    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)
    If the cast time of the spell is 1000 (1 second), then do 1001 instead of 1000. Should work perfectly each time.

  5. #5
    jay77's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    55
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One more problem with my new guy!

    He is supposed to go Fireball>Fireball>ArcaneMissles(instant kind no channeling)>Fireball.... repeat... He does this fine, I just cant seem to get his spawn creature to work, help would be appreciated =] +Rep if I can haha.
    Code:
    function ScarMag_OnEnterCombat(pUnit,Event)
    	pUnit:RegisterEvent("ScarMag_Spell", 1, 1)
    	pUnit:RegisterEvent("ScarMag_Summon", 1000, 1)
    end
    
    function ScarMag_Spell(pUnit, Event)
    	pUnit:FullCastSpellOnTarget(44189,pUnit:GetRandomPlayer(0)) --Fireball
    	pUnit:RemoveEvents()
    	pUnit:RegisterEvent("ScarMag_Spell2", 2000, 0)
    	pUnit:SetCombatMeleeCapable(1)
    end
    
    function ScarMag_Spell2(pUnit, Event)
    	pUnit:FullCastSpellOnTarget(44189,pUnit:GetRandomPlayer(0)) --Fireball
    	pUnit:RemoveEvents()
    	pUnit:RegisterEvent("ScarMag_Spell3", 2000, 0)
    	pUnit:SetCombatMeleeCapable(1)
    end
    
    function ScarMag_Spell3(pUnit, Event)
    	pUnit:FullCastSpellOnTarget(31743,pUnit:GetRandomPlayer(0)) --Arcane Missles
    	pUnit:RemoveEvents()
    	pUnit:RegisterEvent("ScarMag_Spell", 100, 0)
    	pUnit:SetCombatMeleeCapable(1)
    end
    
    function ScarMag_Summon(Unit, Event)
    	if Unit:GetHealthPct() <= 95 then
    local x = pUnit:GetX();
    local y = pUnit:GetY();
    local z = pUnit:GetZ();
    local o = pUnit:GetO();
    	pUnit:SpawnCreature (80006, x, y, z, o, 14,0);
    	pUnit:RemoveEvents()
    	end
    end
    
    
    function ScarMag_OnLeaveCombat(pUnit, event)
    	pUnit:RemoveEvents()
    end
    
    function ScarMag_Death(pUnit)
    	pUnit:RemoveEvents()
    end
    
    RegisterUnitEvent(80002, 1, "ScarMag_OnEnterCombat")
    RegisterUnitEvent(80002, 2, "ScarMag_OnLeaveCombat")
    RegisterUnitEvent(80002, 4, "ScarMag_Death")

  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)
    pUnit:RegisterEvent("ScarMag_Summon", 1000, 1)
    You tell it to only check once (thats what the 1 means, to check till remove events is 0) but then if you did change it to 0 the cast spell removes events so stops it checking.

  7. #7
    jay77's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    55
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Okay, am I using the wrong spawn command with that or something? Because it doesn't seem to spawn =[. Here's the code again.
    Code:
    function ScarMag_OnEnterCombat(pUnit,Event)
    	pUnit:RegisterEvent("ScarMag_Spell", 1, 1)
    	pUnit:RegisterEvent("ScarMag_Summon", 1000, 0)
    end
    
    function ScarMag_Spell(pUnit, Event)
    	pUnit:FullCastSpellOnTarget(44189,pUnit:GetRandomPlayer(0)) --Fireball
    	pUnit:RemoveEvents()
    	pUnit:RegisterEvent("ScarMag_Spell2", 2002, 0)
    	pUnit:SetCombatMeleeCapable(1)
    end
    
    function ScarMag_Spell2(pUnit, Event)
    	pUnit:FullCastSpellOnTarget(44189,pUnit:GetRandomPlayer(0)) --Fireball
    	pUnit:RemoveEvents()
    	pUnit:RegisterEvent("ScarMag_Spell3", 2002, 0)
    	pUnit:SetCombatMeleeCapable(1)
    end
    
    function ScarMag_Spell3(pUnit, Event)
    	pUnit:FullCastSpellOnTarget(31743,pUnit:GetRandomPlayer(0)) --Arcane Missles
    	pUnit:RemoveEvents()
    	pUnit:RegisterEvent("ScarMag_Spell", 200, 0)
    	pUnit:SetCombatMeleeCapable(1)
    end
    
    function ScarMag_Summon(Unit, Event)
    	if Unit:GetHealthPct() <= 95 then
    local x = pUnit:GetX();
    local y = pUnit:GetY();
    local z = pUnit:GetZ();
    local o = pUnit:GetO();
    	pUnit:SpawnCreature (80006, x, y, z, o, 14,0);
    	pUnit:RemoveEvents()
    	end
    end
    
    
    function ScarMag_OnLeaveCombat(pUnit, event)
    	pUnit:RemoveEvents()
    end
    
    function ScarMag_Death(pUnit)
    	pUnit:RemoveEvents()
    end
    
    RegisterUnitEvent(80002, 1, "ScarMag_OnEnterCombat")
    RegisterUnitEvent(80002, 2, "ScarMag_OnLeaveCombat")
    RegisterUnitEvent(80002, 4, "ScarMag_Death")
    And my boss is angering me now too! The boss is supposed to cast fireball (spam) whenever it's not casting another spell. The other 2 spells are blizzard (which is an instant cast, and it hangs around for 5 seconds) and Arcane Explosion (10 second cast, then blows up everyone around him).

    We wanted blizzard to be every 15 seconds, and Arcane explosion every 50 seconds (equaling 60 because of the cast time)... Fireball is a 3 second cast time, and he doesn't seem to even realize he's supposed to cast something else in-game. He spams fireball, but that's it, and says his stuff ofc. Here is the script, see if you can help!
    Code:
    function WizF_OnEnterCombat(pUnit,Event)
    pUnit:SendChatMessage(14, 0, "You will perish for disrupting my studies!")
    pUnit:RegisterEvent("ArcaneExplosion", 50000, 0)
    pUnit:RegisterEvent("Blizzard", 15000, 0)
    pUnit:RegisterEvent("Fireball", 1, 1)
    end
    
    function Fireball(pUnit, Event)
    pUnit:FullCastSpellOnTarget(61909,pUnit:GetRandomPlayer(0)) -- Fireball
    pUnit:RemoveEvents()
    pUnit:RegisterEvent("Fireball2", 3002, 0)
    pUnit:SetCombatMeleeCapable(1)
    end
    
    function Fireball2(pUnit, Event)
    pUnit:FullCastSpellOnTarget(61909,pUnit:GetRandomPlayer(0)) -- Fireball
    pUnit:RemoveEvents()
    pUnit:RegisterEvent("Fireball", 3002, 0)
    pUnit:SetCombatMeleeCapable(1)
    end
    
    function Blizzard(pUnit, Event)
    pUnit:SendChatMessage(14, 0, "Gettin' chilly in here.")
    pUnit:FullCastSpellOnTarget(59584,pUnit:GetRandomPlayer(0)) -- Blizzard
    pUnit:RemoveEvents()
    pUnit:SetCombatMeleeCapable(1)
    pUnit:RegisterEvent("Fireball", 3002, 0)
    end
    
    function ArcaneExplosion(pUnit, Event)
    pUnit:SendChatMessage(14, 0, "Don't move, this won't take long.")
    pUnit:FullCastSpellOnTarget(29973,pUnit:GetRandomPlayer(0)) -- Arcane Explosion
    pUnit:RemoveEvents()
    pUnit:RegisterEvent("Fireball", 3002, 0)
    pUnit:SetCombatMeleeCapable(1)
    end
    
    function WizF_OnLeaveCombat(pUnit, event)
    pUnit:RemoveEvents()
    end
    
    function WizF_Death(pUnit)
    pUnit:SendChatMessage(14, 0, "All those hours of studying, all for what? TO die in the hands of these lesser beings.")
    pUnit:RemoveEvents()
    end
    
    function WizF_OnKilledTarget(pUnit)
    pUnit:SendChatMessage(14, 0, "This is a lesson.")
    end
    
    RegisterUnitEvent(80000, 1, "WizF_OnEnterCombat")
    RegisterUnitEvent(80000, 2, "WizF_OnLeaveCombat")
    RegisterUnitEvent(80000, 3, "WizF_OnKilledTarget")
    RegisterUnitEvent(80000, 4, "WizF_Death")

  8. #8
    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)
    Code:
    function WizF_OnEnterCombat(pUnit,Event)
    pUnit:SendChatMessage(14, 0, "You will perish for disrupting my studies!")
    pUnit:RegisterEvent("ArcaneExplosion", 50000, 0)
    pUnit:RegisterEvent("Blizzard", 15000, 0)
    pUnit:RegisterEvent("Fireball", 3002, 0)
    pUnit:SetCombatMeleeCapable(1)
    end
    
    function Fireball(pUnit, Event)
        local plr = pUnit:GetRandomPlayer(0)
        if plr == nil then
        else
        pUnit:FullCastSpellOnTarget(61909, plr) -- Fireball
        end
    end
    
    function Blizzard(pUnit, Event)
        pUnit:SendChatMessage(14, 0, "Gettin' chilly in here.")
        local pla = pUnit:GetRandomPlayer(0)
        if pla == nil then
        else
        pUnit:FullCastSpellOnTarget(59584, pla) -- Blizzard
        end
    end
    
    function ArcaneExplosion(pUnit, Event)
    pUnit:SendChatMessage(14, 0, "Don't move, this won't take long.")
    pUnit:FullCastSpell(29973) -- Arcane Explosion is AOE so we don't need to target somone...
    end
    
    function WizF_OnLeaveCombat(pUnit, event)
    pUnit:RemoveEvents()
    end
    
    function WizF_Death(pUnit)
    pUnit:SendChatMessage(14, 0, "All those hours of studying, all for what? TO die in the hands of these lesser beings.")
    pUnit:RemoveEvents()
    end
    
    function WizF_OnKilledTarget(pUnit)
    pUnit:SendChatMessage(14, 0, "This is a lesson.")
    end
    
    RegisterUnitEvent(80000, 1, "WizF_OnEnterCombat")
    RegisterUnitEvent(80000, 2, "WizF_OnLeaveCombat")
    RegisterUnitEvent(80000, 3, "WizF_OnKilledTarget")
    RegisterUnitEvent(80000, 4, "WizF_Death")

    Thats your 2nd script you posted fixed, now for the spawning.


    Code:
    function WizF_OnEnterCombat(pUnit,Event)
    pUnit:SendChatMessage(14, 0, "You will perish for disrupting my studies!")
    pUnit:RegisterEvent("ArcaneExplosion", 50000, 0)
    pUnit:RegisterEvent("Blizzard", 15000, 0)
    pUnit:RegisterEvent("Fireball", 3002, 0)
    pUnit:SetCombatMeleeCapable(1)
    end
    
    function Fireball(pUnit, Event)
        local plr = pUnit:GetRandomPlayer(0)
        if plr == nil then
        else
        pUnit:FullCastSpellOnTarget(61909, plr) -- Fireball
        end
    end
    
    function Blizzard(pUnit, Event)
        pUnit:SendChatMessage(14, 0, "Gettin' chilly in here.")
        local pla = pUnit:GetRandomPlayer(0)
        if pla == nil then
        else
        pUnit:FullCastSpellOnTarget(59584, pla) -- Blizzard
        end
    end
    
    function ArcaneExplosion(pUnit, Event)
    pUnit:SendChatMessage(14, 0, "Don't move, this won't take long.")
    pUnit:FullCastSpell(29973) -- Arcane Explosion is AOE so we don't need to target somone...
    end
    
    function ScarMag_Summon(pUnit, Event)
        if pUnit:GetHealthPct() <= 95 then
        local x = pUnit:GetX();
        local y = pUnit:GetY();
        local z = pUnit:GetZ();
        local o = pUnit:GetO();
        pUnit:SpawnCreature (80006, x, y, z, o, 14,0);
        pUnit:RemoveEvents()
        pUnit:RegisterEvent("ArcaneExplosion", 50000, 0)
        pUnit:RegisterEvent("Blizzard", 15000, 0)
        pUnit:RegisterEvent("Fireball", 3002, 0)
        pUnit:SetCombatMeleeCapable(1)
        end
    end
    
    
    function WizF_OnLeaveCombat(pUnit, event)
    pUnit:RemoveEvents()
    end
    
    function WizF_Death(pUnit)
    pUnit:SendChatMessage(14, 0, "All those hours of studying, all for what? TO die in the hands of these lesser beings.")
    pUnit:RemoveEvents()
    end
    
    function WizF_OnKilledTarget(pUnit)
    pUnit:SendChatMessage(14, 0, "This is a lesson.")
    end
    
    RegisterUnitEvent(80000, 1, "WizF_OnEnterCombat")
    RegisterUnitEvent(80000, 2, "WizF_OnLeaveCombat")
    RegisterUnitEvent(80000, 3, "WizF_OnKilledTarget")
    RegisterUnitEvent(80000, 4, "WizF_Death")
    You had your remove events all messed up, and on spawn of the npc you were using Unit and pUnit.

Similar Threads

  1. Basic LUA guide =]
    By nickelo in forum WoW EMU Guides & Tutorials
    Replies: 20
    Last Post: 01-11-2009, 10:04 AM
  2. Lua issue ( hide seek script)
    By zozoka in forum WoW EMU Questions & Requests
    Replies: 6
    Last Post: 09-30-2008, 04:24 PM
  3. LUA issue..
    By kreegoth in forum WoW EMU Questions & Requests
    Replies: 5
    Last Post: 09-22-2008, 11:56 PM
  4. LUA Issues
    By orion5814 in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 06-20-2008, 04:03 PM
  5. [LUA Issue] Sudden self-targetting
    By Whitethebunny in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 06-07-2008, 09:06 PM
All times are GMT -5. The time now is 06:31 AM. 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