[Lua] Mobs always cast spells on themselves. Not the target menu

Shout-Out

User Tag List

Results 1 to 11 of 11
  1. #1
    Wheeze201's Avatar Active Member
    Reputation
    51
    Join Date
    Apr 2007
    Posts
    660
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Lua] Mobs always cast spells on themselves. Not the target

    Code:
    function general_OnCombat(pUnit, event)
        pUnit:CastSpellOnTarget(100, pUnit:GetMainTank())
        pUnit:RegisterEvent("cleave", 3000, 2)
        pUnit:RegisterEvent("bleed", 1800, 1)
    end
    
    function cleave(pUnit, event)
    pUnit:CastSpellOnTarget(30619, pUnit:GetMainTank())
    end
    
    function bleed(pUnit, event)
    pUnit:CastSpellOnTarget(59343, pUnit:GetMainTank())
    end
    
    RegisterUnitEvent(990914, 1, "general_OnCombat")
    I've looked at other code i've done and it's exactly the same and it doesn't have this problem.
    I've tried using locals.
    like: "local target = pUnit:GetMainTank()"

    [Lua] Mobs always cast spells on themselves. Not the target
  2. #2
    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)
    You could try this.

    function General_Cleave(pUnit, Event)
    local plr = pUnit:GetMainTank()
    if (plr ~= nil) then
    pUnit:FullCastSpellOnTarget(SPELLID, plr)
    end
    end
    I hope its usefull

  3. #3
    Vision1000's Avatar Member
    Reputation
    104
    Join Date
    Jun 2008
    Posts
    122
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ascelyn's example should work.

    But for future reference, CastSpellOnTarget() is bugged for a lot of Lua Engines and will always have the NPC cast it on themselves.

  4. #4
    SirRFI's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This post has been a bit modified since first "version"
    I had similar problem and some questions but I already found answers by myself


    Well, I made some tests to answer for my questions and your's questions.

    I made a NPC scripts and added following lines:
    function FireBall(Unit, Event)
    Unit:CastSpellOnTarget(133, Unit:GetMainTank())
    end


    function FrostBolt(Unit, Event)
    Unit:FullCastSpellOnTarget(116, Unit:GetMainTank())
    end


    function Wrath(pUnit, Event)
    local plr = pUnit:GetMainTank()
    if (plr ~= nil) then
    pUnit:FullCastSpellOnTarget(5176, plr)
    end
    end
    All of these spells are player's spells with 1.5 sec casting time. Difference between them (expect spell ID etc) is just the code.

    RESULTS:

    FireBall <- Used "CastSpellOnTarget" code. Result: Mob instantly casted this spell on ITSELF.

    FrostBolt <- Used "FullCastSpellOnTarget" code. Result: Mob casted the spell on the TANK with CASTING TIME.

    Wrath <- Used Ascelyn's method (with "FullCastSpellOnTarget" code). Result: Mob casted the spell on the TANK with CASTING TIME.

    Originally Posted by Ascelyn View Post
    You could try this.
    Code:
    function General_Cleave(pUnit, Event)
    local plr = pUnit:GetMainTank()
    if (plr ~= nil) then
    pUnit:FullCastSpellOnTarget(SPELLID, plr)
    end
    end
    I hope its usefull
    Yes, this works but there are needless lines since simpler version works same (look at FrostBolt code)


    Originally Posted by Vision1000 View Post
    But for future reference, CastSpellOnTarget() is bugged for a lot of Lua Engines and will always have the NPC cast it on themselves.
    My test confirmed your's opinion.

    Also some information that I just discovered about this:
    Code:
    	Unit:RegisterEvent("Spell1", 30000, 5)
    	Unit:RegisterEvent("Spell2", 30000, 8)
    30000 is time in miliseconds (1000 miliseconds = 1 second) after which the NPC casts the spell. The number after this value (in Spell1 it is 5, in Spell2 it is 8 in our example) is how many times NPC repeat this action. In our example this will be like: NPC will cast Spell1 5 times with delay 30 seconds between them. After 5 times he won't cast this spell anymore.

    Thanks for help, also I hope my test-results helped You somehow guys too.

    =======
    +Rep me if I helped
    Last edited by SirRFI; 08-17-2009 at 11:41 AM.

  5. #5
    SirRFI's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, double post by mistake. Please delete this post. Thanks in advice.

  6. #6
    tea91's Avatar Member
    Reputation
    1
    Join Date
    Dec 2008
    Posts
    9
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SirRFI // thx

  7. #7
    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)
    Sirfi, How do you fix the fact mobs cast the spell even when they went out of mana? :S I was able to add so when he gets underneath 25% of mana he uses evocation but I want to do it without..

  8. #8
    SirRFI's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Ascelyn View Post
    Sirfi, How do you fix the fact mobs cast the spell even when they went out of mana? :S I was able to add so when he gets underneath 25% of mana he uses evocation but I want to do it without..
    While testing I didnt make my mobs castings spells more than 1 time so they had no time to spent all mana. I don't even know if they will continue casting spells when they are without mana and those spells require mana. As I wrote in old version of my post, I made an DK copy that uses DK spellsand they works without runicpower since mobs cannot have runicpower. Most of blizzlike mobs using spells not avaiable for players that don't require mana, so there is no problem for them.
    Anyway, if you still want your's mob to cast player's spells that require mana, you can at least do one more spell line that will restore the mana. The spell is Mana Potion (spell id: 32453)

    I begun my advanture with lua npc scripting few days ago, so I'm not expriencied on it a bit yet. My first post in this thread was question-post at the beginning, mean while waiting for an answer I tested few things and found answers for my questions and shered them with you.

    -- EDIT:
    I can see that when mob cast spell with mp requiment, he gets the mana back in a second.
    Last edited by SirRFI; 08-17-2009 at 06:42 AM.

  9. #9
    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)
    Well I did this.
    local Didthat = 0

    function Mage_OnCombat (Unit, Event)
    Unit:RegisterEvent("Mage_Frostnova",35000, 0)
    Unit:RegisterEvent("Mage_Barrier", 40000, 2)
    Unit:RegisterEvent("Mage_Evocation",10000,0)
    end

    function Mage_Evocation(pUnit, Event)
    if pUnit:GetManaPct() < 25 then
    pUnit:FullCastSpell(52869) -- Evocation
    else
    local plr = pUnit:GetRandomPlayer(0)
    if plr == nil then
    else
    pUnit:FullCastSpellOnTarget(42842, plr)
    end
    end
    end
    Just a part of my script, And that works. But I want him to just cast and when he gets under 25% he just uses melee instead of bugging up >_>

  10. #10
    Wheeze201's Avatar Active Member
    Reputation
    51
    Join Date
    Apr 2007
    Posts
    660
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Alright so..
    FullCastSpellOnTarget only works for targets ?

    Kind of weird.. and a disappointment. Since there are alot of spells which have casting time you don't want.

  11. #11
    SirRFI's Avatar Member
    Reputation
    1
    Join Date
    Jan 2009
    Posts
    28
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ascelyn - I did something like:
    Code:
    function MyNPC_OnCombat(Unit, Event)
    	Unit:RegisterEvent("HpTest", 1000, 0)
    	Unit:RegisterEvent("MpTest", 1000, 0)
    end
    Code:
    function HpTest(Unit, Event)
    	if unit:GetHealthPct() < 75 then
    		unit:SendChatMessage(12, 7, "Auu!")
    		Unit:FullCastSpellOnTarget(5176, Unit:GetMainTank())
    	else
    	end
    end
    
    function MpTest(Unit, Event)
    	if unit:GetManaPct() < 75 then
    		unit:SendChatMessage(12, 7, "Ahh... losing ... mana...")
    		Unit:FullCastSpellOnTarget(8921, Unit:GetMainTank())
    	else
    	end
    end
    And does NOT work also.



    But found this:
    Code:
    function kt_OnCombat(Unit, Event)
    	local phase3 = 0
    	(...)
    	Unit:RegisterEvent("Phase3",1000,0)
    end
    Code:
    function Phase3(Unit, Event)
    		if Unit:GetHealthPct() < 41 then
    			if phase3==0 then
    				Unit:SendChatMessage(14,0, "Something happens...")
    				phase3 = 1
    			else
    			end
    		end
    end
    This is cutted part from BOSS-Naxxramas-KelThuzad.lua by ArcEmu (game version 2.4.3). Check it out, may work... I will test it later. But I think it's like that:
    " local phase3 = 0 " = PHASE3 is marked as 0 (not happen yet) because the NPC just entered combat
    " if phase3==0 then " = if function named PHASE3 is TRUE then something happens (lines below it)
    " phase3 = 1 " = PHASE3 has been marked as 1 (already happen)


    ===========

    Wheezee201 - seems to. You can try some other methods by yourself or use different spell ID or so.

    =======
    +Rep me if I helped
    Last edited by SirRFI; 08-17-2009 at 11:42 AM.

Similar Threads

  1. [Lua] Mobs only ever cast spells on themselves
    By RoyPwns in forum WoW EMU Questions & Requests
    Replies: 9
    Last Post: 04-20-2010, 05:10 PM
  2. Custom Mobs dont cast spells - Quince
    By handofoberon in forum WoW EMU Questions & Requests
    Replies: 12
    Last Post: 12-14-2009, 03:12 AM
  3. [Script a Mob to cast spells] Guide
    By P1raten in forum WoW EMU Guides & Tutorials
    Replies: 7
    Last Post: 03-17-2009, 04:10 PM
  4. [Question] hmm, how do i make a mob rapidly cast spells?
    By Creepfold in forum World of Warcraft Emulator Servers
    Replies: 9
    Last Post: 12-27-2007, 10:38 AM
  5. [GUIDE] - Scripting for Antrix, Making Mobs Talk, Cast Spells, etc
    By Greed in forum WoW EMU Guides & Tutorials
    Replies: 6
    Last Post: 12-10-2007, 07:51 PM
All times are GMT -5. The time now is 04:20 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search