Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function round(num, numDecimalPlaces)
- return tonumber(string.format("%." .. (numDecimalPlaces or 0) .. "f", num))
- end
- function Cast(spellName)
- if (HasSpell(spellName) == 1) then
- if (IsSpellInRange(targetObj, spellName) == 1) then
- if (IsSpellOnCD(spellName) == 0) then
- if (IsAutoCasting(spellName) == 0) then
- --Face Target
- FaceTarget(targetObj);
- --Cast Spell
- CastSpellByName(spellName);
- return true;
- end
- end
- end
- end
- return false;
- end
- function Buff(spellName, player)
- if (HasSpell(spellName) == 1) then
- if (HasBuff(player, spellName) == 0) then
- TargetEnemy(localObj);
- CastSpellByName(spellName);
- TargetEnemy(player);
- return true;
- end
- end
- return false;
- end
- function DeBugInfo()
- y = 150;
- x = 25;
- --[[
- --Spell Info
- castingTime, maxRange, minRange, powerType, Cost, spellID, spellObj = GetSpellInfoX('Fire Blast');
- text = 'castingTime =' .. castingTime ..
- ', minRange=' .. minRange ..
- ', maxRange=' .. maxRange ..
- ', powerType=' .. powerType ..
- ', Cost=' .. Cost ..
- ', spellID=' .. spellID
- DrawText(text, x, y, 66, 255, 244);
- y += 25;
- --]]
- local_ = GetLocalPlayer();
- DrawText('Health:' .. GetHealth(localObj) .. ' ' .. round(GetHealthPercentage(localObj),2) .. '%', x, y, 66, 255, 244); y = y + 15;
- DrawText('Mana:' .. GetMana(localObj) .. ' ' .. round(GetManaPercentage(localObj),2) .. '%', x, y, 66, 255, 244); y = y + 25;
- end
- debug_ = false;
- if (debug_) then
- DeBugInfo();
- end
- --Get Enemy
- targetObj = GetTarget();--GetNearestEnemy();
- localObj = GetLocalPlayer();
- --
- if (IsDead(localObj) == 1) then
- return;
- end
- -- Pre Check
- if (IsChanneling() == 1) then
- return;
- end
- if (IsCasting() == 1) then
- return;
- end
- if (IsStanding() == 0) then
- return;
- end
- -- Do Buff
- --If we don't have the demon skin we probably wont neither have a summon, so we cast it 1st.
- --Note this is just a workaround until I figure out how to check for the demon or the function UnitExists is implemented,
- --if we enter combat just after reviving it's probably not gonna work as intended(just hope to get the 10sec cast interrupted before you die again).
- if (HasBuff(localObj, 'Demon Skin') == 0) then
- if (IsInCombat() == 0) then
- CastSpellByName('Summon Imp');
- end
- end
- if (Buff('Demon Skin', localObj)) then
- return;
- end
- --Valid Enemy
- if (targetObj ~= 0) then
- -- Cant Attack dead targets
- if (IsDead(targetObj) == 1) then
- return;
- end
- if (CanAttack(targetObj) == 0) then
- return;
- end
- -- Dismount
- Dismount();
- -- Auto Attack
- AutoAttack(targetObj);
- --Health/Mana values
- targetHealth = GetHealthPercentage(targetObj);
- localHealth = GetHealthPercentage(localObj);
- localMana = GetManaPercentage(localObj);
- localManaVal = GetMana(localObj);
- -- Opener
- if (IsInCombat() == 0 and localMana >= 40 and localHealth >= 60) then
- --Cast Opener Depending on Movement
- if (IsMoving() == 1) then
- Cast('Curse of Weakness');
- return;
- else
- Cast('Corruption');
- return;
- end
- -- Combat
- else
- --Buff/Debuff checking
- local hasCorruption = HasDebuff(targetObj, 'Corruption')
- local hasWeakness = HasDebuff(targetObj, 'Curse of Weakness')
- local hasImmolate = HasDebuff(targetObj, 'Immolate')
- if (debug_) then
- ToConsole('- Has Debuff= ' .. tostring(hasCorruption))
- end
- --Life Tap
- if localMana < 20 and localHealth > 60 then
- CastSpellByName('Life Tap');
- return;
- end
- --Offensive Spells
- if (hasWeakness == 0) then
- Cast('Curse of Weakness');
- return;
- end
- if (IsMoving() == 0 and hasImmolate == 0) then
- Cast('Immolate');
- return;
- end
- if (IsMoving() == 0 and hasCorruption == 0) then
- Cast('Corruption');
- return;
- end
- if (IsMoving() == 0 and Cast('Shadow Bolt')) then
- return;
- end
- end
- else
- --if (Loot() == 1) then
- -- return;
- --end
- --if (Navigate() == 1) then
- -- return;
- --end
- end
- --Some interesting functions:
- --UnitExists("unit") as seen in the WoW Api, to get info about having or not a pet for example
Advertisement
Add Comment
Please, Sign In to add comment