Hello & Welcome to our community. Is this your first visit? Register
Follow us on
Follow us on Facebook Follow us on Twitter Watch us on YouTube


MMOCoin

Likes Likes:  0
Results 1 to 3 of 3
  1. #1
    Scout

    Join Date
    Mar 2009
    Posts
    14
    Post Thanks / Like
    Rep Power
    16
    Reputation
    17

    [Lua] Mage of the Elements


    Register to remove this ad
    Hai thar!
    This is just a quick script that I put together which I quite like. It is a Lua script of a mage that, when it enters combat, has a random chance of being a fire, ice, or arcane mage.
    One feature I like about it is that, if it gets "specced" arcane, then it has the spell Polymorph. However, the Polymorph spell has a random chance to be either a, cat, serpent, turkey, sheep, turtle, or a rabbit polymorph.
    I have included an SQL query. Execute it to your database, but...
    In this script you can define the creatures health, mana, faction, scale and display ID. If you leave them to 0 or blank then the value remains as in the SQL for the creature.
    Note: You must execute an SQL for the creature either way.
    In the SQL I've provided, its entry ID is 12345

    Here is the Lua:
    Code:
    --   Mage of the Elements   --
    --   Scripted by Alvanaar   --
    --[[ !> Ensure you exectue my provided SQL <! ]]--
    local MAGE_ENTRYID = 12345 -- Change to the mage's entry ID
    -- Define the mage's health, mana, displayID, scale and faction.
    -- Note: If you leave the following blank they will stay the same as
    -- in the SQL I provided.
    --      --      --      --      --      --      --      --      --      --
    local MAGE_HEALTH = 500000 -- change to your desired mage's HEALTH. Or leave blank or 0.
    local MAGE_MANA = 125000 -- change to your desired mage's MANA. Or leave blank or 0.
    local MAGE_DISPLAY = 00000 -- change to your desired mage's DISPLAY ID. Or leave blank or 0.
    local MAGE_SCALE = 1.2 -- change to your desired mage's SCALE. Or leave blank or 0.
    local MAGE_FACTION = 14 -- change to your desired mage's FACTION. Or leave blank or 0.
    -- Don't edit below here, unless you know what you're doing :) --
    function Mage_OnCombat(unit, event)
       if (RandSpec() == "Fire") then
       unit:RegisterEvent("FireBall", math.random(7000, 9000), 0)
       unit:RegisterEvent("FireBlast", math.random(10000, 12000), 0)
       unit:RegisterEvent("BlastWave", math.random(13000, 15000), 0)
       unit:RegisterEvent("DragonBreath", math.random(16000, 17500), 0)
       end
       if (RandSpec() == "Frost") then
       unit:RegisterEvent("FrostBolt", math.random(10000, 12000), 0)
       unit:RegisterEvent("Blizzard", math.random(13000, 14500), 0)
       unit:RegisterEvent("FrostNova", math.random(7000, 9000), 0)
       unit:RegisterEvent("ConeOfCold", 9000, 0)
       end
       if (RandSpec() == "Arcane") then
       unit:RegisterEvent("ArcaneBlast", math.random(9000, 11000), 0)
       unit:RegisterEvent("ArcaneMissiles", math.random(14000, 15000), 0)
       unit:RegisterEvent("ArcaneExplosion", math.random(11000, 12000), 0)
       unit:RegisterEvent("Polymorph", math.random(15000, 18000), 0)
       end
    end
    function Mage_OnLeaveCombat(unit, event)
    unit:RemoveEvents()
    end
    function Mage_OnDied(unit, event)
    local chance = math.random(1, 6)
       if (chance == 1) then
       local tank = unit:GetMainTank()
          if (tank ~= nil) then
          unit:SendChatMessage(12, 0, "You got lucky, "..tank:GetName().."!")
       else
          unit:SendChatMessage(12, 0, "You got lucky this time!")
          end
       end
       if (chance == 2) then
       unit:SendChatMessage(12, 0, "How can this be?!")
       end
       if (chance == 3) then
       unit:SendChatMessage(12, 0, "I... cannot... believe it!")
       end
       if (chance == 4) then
       end
       if (chance == 5) then
       end
       if (chance == 6) then
       local tank = unit:GetMainTank()
          if (tank ~= nil) then
          unit:SendChatMessageToPlayer(15, 0, "You will be destroyed next time, "..tank:GetName().."!", tank)
       else
          unit:SendChatMessage(12, 0, "You won't last much longer!")
          end
       end
    unit:RemoveEvents()
    end
    function Mage(unit, event)
       if (MAGE_HEALTH ~= nil or MAGE_HEALTH ~= 0) then
       unit:SetHealth(MAGE_HEALTH)
       end
       if (MAGE_MANA ~= nil or MAGE_MANA ~= 0) then
       unit:SetMana(MAGE_MANA)
       end
       if (MAGE_SCALE ~= nil or MAGE_SCALE ~= 0) then
       unit:SetScale(MAGE_SCALE)
       end
       if (MAGE_DISPLAY ~= nil or MAGE_DISPLAY ~= 0) then
       unit:SetModel(MAGE_DISPLAY)
       end
       if (MAGE_FACTION ~= nil or MAGE_FACTION ~= 0) then
       unit:SetFaction(MAGE_FACTION)
       end
    end
    RegisterUnitEvent(MAGE_ENTRYID, 1, "Mage_OnCombat")
    RegisterUnitEvent(MAGE_ENTRYID, 2, "Mage_OnLeaveCombat")
    RegisterUnitEvent(MAGE_ENTRYID, 4, "Mage_OnDied")
    RegisterUnitEvent(MAGE_ENTRYID, 18, "Mage")
    
    -- Fire spells --
    function FireBall(unit, event)
    local tank = unit:GetMainTank()
       if (tank ~= nil) then
       unit:FullCastSpellOnTarget(61909, tank)
       end
    end
    function FireBlast(unit, event)
    local tank = unit:GetMainTank()
       if (tank ~= nil) then
       unit:FullCastSpellOnTarget(20679, tank)
       end
    end
    function BlastWave(unit, event)
    unit:FullCastSpell(38536)
    end
    function DragonBreath(unit, event)
    unit:FullCastSpell(37289)
    end
    -- Frost spells --
    function FrostBolt(unit, event)
    local tank = unit:GetMainTank()
       if (tank ~= nil) then
       unit:FullCastSpellOnTarget(65807, tank)
       end
    end
    function Blizzard(unit, event)
    unit:FullCastSpell(56936)
    end
    function ConeOfCold(unit, event)
    unit:FullCastSpell(65023)
    end
    function FrostNova(unit, event)
    unit:FullCastSpell(43426)
    end
    -- Arcane spells --
    function ArcaneBlast(unit, event)
    local tank = unit:GetMainTank()
       if (tank ~= nil) then
       unit:FullCastSpellOnTarget(56969, tank)
       end
    end
    function ArcaneExplosion(unit, event)
    unit:FullCastSpell(59245)
    end
    function ArcaneMissiles(unit, event)
    local tank = unit:GetMainTank()
       if (tank ~= nil) then
       unit:FullCastSpellOnTarget(42846, tank)
       end
    end
    function Polymorph(unit, event)
    local tank, polytype = unit:GetMainTank(), math.random(1, 6)
       if (tank ~= nil) then
          if (polytype == 1) then
          unit:FullCastSpellOnTarget(12826, tank)
          end
          if (polytype == 2) then
          unit:FullCastSpellOnTarget(28271, tank)
          end
          if (polytype == 3) then
          unit:FullCastSpellOnTarget(61780, tank)
          end
          if (polytype == 4) then
          unit:FullCastSpellOnTarget(28272, tank)
          end
          if (polytype == 5) then
          unit:FullCastSpellOnTarget(61721, tank)
          end
          if (polytype == 6) then
          unit:FullCastSpellOnTarget(61305, tank)
          end
       end
    end
     
    
    function RandSpec()
    local specvar = math.random(1, 3)
       if (specvar == 1) then
       return "Fire"
       end
       if (specvar == 2) then
       return "Frost"
       end
       if (specvar == 3) then
       return "Arcane"
       end
    end
    Here is the SQL:
    Code:
    insert into `creature_names` (`entry`, `name`, `subname`, `info_str`, `Flags1`, `type`, `family`, `rank`, `unk4`, `spelldataid`, `male_displayid`, `female_displayid`, `male_displayid2`, `female_displayid2`, `unknown_float1`, `unknown_float2`, `civilian`, `leader`) 
    values ('12345', "Mage of the Elements", "", '', '0', '10', '0', '1', '0', '0', '2561', '0', '0', '0', '1', '1', '0', '0');
    insert into `creature_proto` (`entry`, `minlevel`, `maxlevel`, `faction`, `minhealth`, `maxhealth`, `mana`, `scale`, `npcflags`, `attacktime`, `attacktype`, `mindamage`, `maxdamage`, `can_ranged`, `rangedattacktime`, `rangedmindamage`, `rangedmaxdamage`, `respawntime`, `armor`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `combat_reach`, `bounding_radius`, `auras`, `boss`, `money`, `invisibility_type`, `death_state`, `walk_speed`, `run_speed`, `fly_speed`, `extra_a9_flags`, `spell1`, `spell2`, `spell3`, `spell4`, `spell_flags`, `modImmunities`) 
    values ('12345', '80', '80', '14', '400000', '400000', '100000', '1', '0', '2800', '0', '1500', '2000', '0', '0', '0', '0', '300000', '5000', '0', '0', '0', '0', '0', '0', '0', '0', "0", '0', '1750000', '0', '0', '2.50', '8.00', '14.00', '0', '0', '0', '0', '0', '0', '0');
    I haven't got around to testing this yet, though it should work. Please report any bugs to me.

    Enjoy,
    Alvanaar



    › See More: [Lua] Mage of the Elements

  2. #2
    Founder
    Apple's Avatar
    Join Date
    Jul 2008
    Location
    HeaveN
    Posts
    15,916
    Post Thanks / Like
    Rep Power
    10
    Reputation
    295
    hmm , nice one





  3. #3
    Scout

    Join Date
    Mar 2009
    Posts
    14
    Post Thanks / Like
    Rep Power
    16
    Reputation
    17

    Register to remove this ad
    Thanks.

    Bump.




  4. Related Threads - Scroll Down after related threads if you are only interested to view replies for above post/thread

 

 

Visitors found this page by searching for:

lua 3.3.5a

mage lua script

SEO Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -5. The time now is 06:05 PM.
Powered by vBulletin® Copyright ©2000-2024, Jelsoft Enterprises Ltd.
See More links by ForumSetup.net. Feedback Buttons provided by Advanced Post Thanks / Like (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
vBulletin Licensed to: MMOPro.org