Jump to content

Recommended Posts

Remember Im a novice at LUA. So please give me a detailed explanation so I can learn more. See Im still not sure how to through code together. So im finding other code and editing it to see if I can make it work for what im wanting to do. This is going to be a Disease Manager for DKs. Once the Disease get to 3 sec left of its target debuff then the DK will recast the move according to the disease to reapply it.

 

if not (UnitIsDead("target")) and not (IsFlying("player")) and not (IsResting("player")) and not (UnitIsAFK("player")) then

    --[[ refresh the Diseases on the target if there are less then 3 sec left (to be sure that it dont run out while a fight ]]
    local timeLeftToCastAgain = 3;
    local idDiseases={59879,59921}
--[[             Blood Plague,Frost Fever ]]
    idDiseases[1]={59879,59921}
--[[             Outbreak,Plague Strike ]]
    idDiseases[2]={77575,45462}
    --[[             Outbreak,Icy Touch ]]
    idDiseases[3]={77575,45477}
    local now=GetTime();
    for i=("1,2"),#idDiseases do
        local spell="";
        local DiseaseFound=()
        for j=1,#idDiseases do
            spellname=GetSpellInfo(idDiseases[j])
            local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitBuff("target",spellname);
            if (name==spellname) then
                local expireTimeLeft = expirationTime-now;
                DiseasesFound=idDiseases[j]
                if (expireTimeLeft < timeLeftToCastAgain) then
                    if (IsUsableSpell(spellname)) then
                        local start, duration, enable = GetSpellCooldown(spellname)
                        if (duration==3) then
                            CastSpellByName(spellname);
                            spell=spellname;
                        end
                    end
                    
                end
                break;
            end
        end
        if (DiseasesFound==0) then
            for j=("1,2"),#idDeases do
                local spellname=GetSpellInfo(idDeases[j])
                if (IsUsableSpell(spellname)) then
                    local start, duration, enable = GetSpellCooldown(spellname)
                    if (duration==0) then
                        CastSpellByName(spellname);
                        spell=spellname;
                        break;
                    end
                end
            end
        end
        if not (spell=="") then
            print("Diseases: "..spell)
            result=true
            break;
        end
        
    end
end
result=(diseased>0)

Link to comment
https://wrobot.eu/forums/topic/1435-can-you-tell-me-why-this-isnt-working/
Share on other sites

local DiseasesFound = 0;
if not (UnitIsDead("target")) and not (IsFlying("player")) and not (IsResting("player")) and not (UnitIsAFK("player")) then
    --[[ refresh the Diseases on the target if there are less then 3 sec left (to be sure that it dont run out while a fight ]]
    local timeLeftToCastAgain = 3;
    local idDiseases={59879,59921}
	--[[ Blood Plague,Frost Fever ]]
    idDiseases[1]={59879,59921}
	--[[ Outbreak,Plague Strike ]]
    idDiseases[2]={77575,45462}
    --[[ Outbreak,Icy Touch ]]
    idDiseases[3]={77575,45477}
    local now=GetTime();
    for i=1,3,1 do
        local spell="";
        --[[local DiseaseFound=()   NOT USED ]]
        for j=1,2,1 do
            spellname=GetSpellInfo(idDiseases[i][j])
            local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitBuff("target",spellname);
            if (name==spellname) then
                local expireTimeLeft = expirationTime-now;
                DiseasesFound=idDiseases[i][j]
                if (expireTimeLeft < timeLeftToCastAgain) then
                    if (IsUsableSpell(spellname)) then
                        local start, duration, enable = GetSpellCooldown(spellname)
                        if (duration==3) then
                            CastSpellByName(spellname);
                            spell=spellname;
                        end
                    end
                    
                end
                break;
            end
        end
        if (DiseasesFound==0) then
            for j=1,2,1 do
                local spellname=GetSpellInfo(idDiseases[i][j])
                if (IsUsableSpell(spellname)) then
                    local start, duration, enable = GetSpellCooldown(spellname)
                    if (duration==0) then
                        CastSpellByName(spellname);
                        spell=spellname;
                        break;
                    end
                end
            end
        end
        if not (spell=="") then
            print("Diseases: "..spell)
            result=true
            break;
        end
        
    end
end
result=(DiseasesFound>0) --[[ replace  result=(diseased>0)]]

Try it

OK Driodz is not casting Plague Strike to put Blood Plague on the target. Its not doing (1,2,1 do)

meaning that

 

    --[[ Outbreak,Plague Strike ]]
idDiseases[2]={77575,45462}

 

Isnt being used for some reason or kept up on the target. But

 

--[[ Outbreak,Icy Touch ]]
idDiseases[3]={77575,45477}

 

Is being kept up on the target.

 

is there a reason why bot spells aren't being fires consecutively??? to keep the debuffs up on the target?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...