Jump to content

Poison Management (a solution)


Bugreporter

Recommended Posts

By default, this solution cast a lethal and a non-lethal poison, depending of the knowledge and the priority-list (idPoisons[1]=lethal, [2]=non-lethal).  If there is already a poison, and the run time of the poison will be less then 13  min, it will be renewed, if we are 

  • not in combat. (We need it before)
  • not AFK (who want casting while afk ?!?)
  • not Falling, Flying or Riding (mounted) (flying + casting = falling)
  • not casting

Why 13 Minutes ? Because of the duration time of a fight with a raid boss. You want more or less ? Change  the 13 in  local timeLeftToCastAgain = 13*60 to another value.

    <FightClassSpell>
      <SpellName>--Poison Managment</SpellName>
      <FightClassConditions>
        <FightClassCondition>
          <ContionType>LuaScript</ContionType>
          <Param xsi:type="FightClassConditionLua">
            <LuaScript>
if (GetUnitSpeed("player") == 0) and not (UnitCastingInfo("player")) and not (UnitChannelInfo("player")) and not (UnitAffectingCombat("player")) and not (IsMounted())  and not (IsFlying())  and not (IsFalling())  and not (IsResting())  and not (UnitIsAFK("player")) then

	--[[ refresh the Poisons if there are less then 13 min left (to be sure that it dont runs out while a raid boss fight ]]
	local timeLeftToCastAgain = 13*60;
	local idPoisons={}
--[[             Deadly,Wound ]]
	idPoisons[1]={2823,8679}
--[[             Leeching,Crippling,Mind-Numbing,Paralytic ]]
	idPoisons[2]={108211,3408,5761,108215}
	local now=GetTime();
	for i=1,#idPoisons do
		local spell="";
		local PoisonFound=0
		for j=1,#idPoisons[i] do
			spellname=GetSpellInfo(idPoisons[i][j])
			local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitBuff("player",spellname); 
			if (name==spellname) then
				local expireTimeLeft = expirationTime-now;
				PoisonFound=idPoisons[i][j]
				if (expireTimeLeft &lt; timeLeftToCastAgain) then
					if (IsUsableSpell(spellname)) then
						local start, duration, enable = GetSpellCooldown(spellname)
						if (duration==0) then 
							CastSpellByName(spellname);
							spell=spellname;
						end
					end
					
				end
				break;
			end
		end
		if (PoisonFound==0) then
			for j=1,#idPoisons[i] do
				local spellname=GetSpellInfo(idPoisons[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("Poison: "..spell)
			result=true
			break;
		end
		
	end
end

</LuaScript>
            <VarRet>result</VarRet>
            <ValueRet>true</ValueRet>
          </Param>
        </FightClassCondition>
      </FightClassConditions>
      <Priority>1</Priority>
      <CombatOnly>false</CombatOnly>
      <CheckIfKnowUsableDistance>false</CheckIfKnowUsableDistance>
      <CheckIfView>false</CheckIfView>
      <AddToSettingsActiveByDefault>true</AddToSettingsActiveByDefault>
      <NotSpellIsLuaScript>true</NotSpellIsLuaScript>
      <CanMoveDuringCast>No</CanMoveDuringCast>
      <DescriptionSpell>Poison Managment</DescriptionSpell>
    </FightClassSpell>

based on WoW 5.4.2.

 

Link to comment
Share on other sites

I have learned that casting is not equal casting. There are channeling spells (spells that works the whole time while channeling i.e heal) and spells that works after a channeling time (i.e. poisons)

 

Because of this I changed the code above from

if not (UnitCastingInfo("player"))...
to

if (GetUnitSpeed("player") == 0) and not (UnitCastingInfo("player")) and not (UnitChannelInfo("player"))...
I have add movedetection ( GetUnitSpeed("player") ) also.
Link to comment
Share on other sites

  • 4 weeks later...

can you edit and repost to the original post... Plus Im looking for a LUA Script that would detect a GCD and us a move to Break the GCD. Best example is Empower Rune Weapon for a Death Knight.

Link to comment
Share on other sites

Sorry, i cant. I only post the (imho) best solution. If you want to get the old solution change only

 

 

if (GetUnitSpeed("player") == 0) and not (UnitCastingInfo("player")) and not (UnitChannelInfo("player"))

 

with

 

if not (UnitCastingInfo("player"))

 

 

GCD is simple to detect. Use Parameter "Is Spell usable" in the fight class editor.

 

in lua try something like this

local spellid=123456  --[[change to the ID-nr of the spell)]]
local spellname=GetSpellInfo(spellid)
                if (IsUsableSpell(spellname)) then
                    local start, duration, enable = GetSpellCooldown(spellname)
                    if (duration==0) then
                        CastSpellByName(spellname);
                        spell=spellname;
                        break;
                    end
                end
Link to comment
Share on other sites

  • 3 weeks later...

ok I got another one for ya. What would the code Look like if this was for a shaman? You know managing the shaman weapon enchants? I have been trying to figure it out but I have failed a lot.

Link to comment
Share on other sites

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...