LUA help, how to make npc cast a spell at a certain HP??? menu

User Tag List

Results 1 to 4 of 4
  1. #1
    pioneer1337's Avatar Member
    Reputation
    7
    Join Date
    Nov 2007
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    LUA help, how to make npc cast a spell at a certain HP???

    Well, I'm making a custom boss for my server and I want him to cast enrage on himself at 40% health and I want him to only do it once. This is how I have my code written right now:
    Code:
    function Boss_Enrage(Unit, event, miscunit, misc)
                   if Unit:GetHealthPct() == 40 and Didthat == 0 then
                             Unit:FullCastSpell(34670)
                             Didthat = 1
                else 
                end
    end
     
    RegisterUnitEvent(9999999,1,"Boss_Enrage")
    Well I tried this and when he got to 40% hp nothing happened. I was thinking it might have something to do with the 1 in
    RegisterUnitEvent(9999999,1,"Boss_Enrage") but I dont know. Please help?

    LUA help, how to make npc cast a spell at a certain HP???
  2. #2
    pioneer1337's Avatar Member
    Reputation
    7
    Join Date
    Nov 2007
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does anyone know?

  3. #3
    Lich King's Avatar Contributor
    Reputation
    100
    Join Date
    May 2007
    Posts
    911
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Change to this:
    Code:
    function Boss_Enrage(pUnit, Event)
     if pUnit:GetHealthPct() < 41 then
      pUnit:RemoveEvents();
      pUnit:FullCastSpell(34670)
     end
    end

  4. #4
    Gastricpenguin's Avatar Legendary
    Reputation
    980
    Join Date
    Feb 2007
    Posts
    2,236
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats because when the mob enters combat, it will only check the HP once at the start of the fight. Its better to make 2 functions. Here is the proper script:

    Code:
    function Boss_OnCombat(pUnit, Event)
     pUnit:RegisterEvent("Check1",100, 0)
    end
    RegisterUnitEvent(9999999,1,"Boss_OnCombat")
     
    function Check1(pUnit, Event)
     if pUnit:GetHealthPct() <= 40 then
      pUnit:RemoveEvents()
      pUnit:FullCastSpell(34670)
     end
    end
    Life Puzzler WoW - Website | Forums

Similar Threads

  1. [Guide]How to make NPC casting spells(LUA)
    By paulbechtold in forum WoW EMU Guides & Tutorials
    Replies: 2
    Last Post: 12-30-2009, 07:44 PM
  2. How to make npc cast spell[HELP!]
    By Flake0207 in forum WoW EMU Questions & Requests
    Replies: 10
    Last Post: 12-15-2008, 09:58 AM
  3. [Help] How to make npc say things
    By Ellenor in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 10-08-2008, 05:21 AM
  4. [Help] How to make an NPC Talk with Lua
    By Silentnvd in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 07-26-2008, 08:08 PM
  5. [HELP] How to make a tele npc +rep to helpers!
    By cooper101 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 03-24-2008, 01:41 PM
All times are GMT -5. The time now is 12:28 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