Code:
--SPELL PRIO
75 Slow (if enemy player)
70 Living Bomb
60 Arcane Missiles@ 2
50 Arcane Barrage @ 4 Arcane Charge
40 Arcane Blast to build Arcane Charge
30 Fire Blast @movement
20 Ice Lance
--TODO: Ice Ward, Spell Steal, IsFalling() -> use feather
---------------------------------------------------------------
--MAGE ARCANE 5.4.1
/run bestCast=-1 bestPrio=-1 castInterruptTime=1.0
/run pMANApct=UnitMana("player")/UnitManaMax("player")
/run pHPpct=UnitHealth("player")/UnitHealthMax("player")
/run tHPpct=UnitHealth("target")/UnitHealthMax("target")
/run movespeed=GetUnitSpeed("player")
--TARGET DEBUFFS
/run LivingBombTimeLeft = -1
/run for i=1,40 do local name,_,_,count,_,_,expirationTime,unitCaster=UnitDebuff("target",i); if unitCaster=="player" then if name=="Living Bomb" then LivingBombTimeLeft=expirationTime-GetTime() end end end
--PLAYER BUFFS
/run ArcaneMissilesTimeLeft = -1
/run ArcaneMissilesCount = -1
/run for i=1,40 do local name,_,_,count,_,_,expirationTime,unitCaster=UnitBuff("player",i); if unitCaster=="player" then if name=="Arcane Missiles!" then ArcaneMissilesTimeLeft=expirationTime-GetTime() ArcaneMissilesCount=count end end end
--PLAYER DEBUFF
/run ArcaneChargeTimeLeft = -1
/run ArcaneChargeCount = -1
/run for i=1,40 do local name,_,_,count,_,_,expirationTime,unitCaster=UnitDebuff("player",i); if unitCaster=="player" then if name=="Arcane Charge" then ArcaneChargeTimeLeft=expirationTime-GetTime() ArcaneChargeCount=count end end end
--ARCANE CHARGE DEBUFF COUNT PREDICTION
/run name,_,_,_,_,endTime=UnitCastingInfo("player") if endTime~=nil then CastArcaneBlastTimeLeft=endTime/1000-GetTime() else CastArcaneBlastTimeLeft=9000 end
/run if CastArcaneBlastTimeLeft<0.5 then ArcaneChargeCount=ArcaneChargeCount+1 end
--COOLDOWNS
/run spell="Arcane Power" if GetSpellCooldown(spell)==0 and IsUsableSpell(spell)==1 and UnitChannelInfo("player")==nil then CastSpellByName(spell) print(spell.." (no GCD)") end
--HAND TINKER CD
/run if GetInventoryItemCooldown("player",10)==0 and UnitChannelInfo("player")==nil then UseInventoryItem(10) end
--PRIO
/run function getSlowPrio() if IsSpellInRange("Slow","target")==1 and not UnitIsFriend("player","target") and UnitIsPlayer("target")==1 then return 75 end return -1 end
--IsSpellInRange("Living Bomb","target")==1 is bugged - use IsActionInRange(12) instead
/run function getLivingBombPrio() if IsActionInRange(12)==1 and LivingBombTimeLeft<1.4 and tHPpct>0.05 and UnitHealth("target")>300000 then return 70 end return -1 end
/run function getArcaneMissilesPrio() if movespeed==0 and IsSpellInRange("Arcane Missiles","target")==1 and ArcaneChargeCount>3 and ArcaneMissilesCount>0 or IsSpellInRange("Arcane Missiles","target")==1 and ArcaneMissilesCount>1 then return 60 end return -1 end
/run function getArcaneBarragePrio() if IsSpellInRange("Arcane Barrage","target")==1 then if ArcaneChargeCount>3 and ArcaneMissilesCount==-1 or movespeed~=0 then return 50 end return -1 end return -1 end
/run function getArcaneBlastPrio() if movespeed==0 and IsSpellInRange("Arcane Blast","target")==1 then return 40 end return -1 end
/run function getFireBlastPrio() if movespeed~=0 and IsSpellInRange("Fire Blast","target")==1 then return 30 end return -1 end
/run function getIceLancePrio() if movespeed~=0 and IsSpellInRange("Ice Lance","target")==1 then return 20 end return -1 end
--PRIOTABLE
/run prioTable={"Slow",getSlowPrio(),"Living Bomb",getLivingBombPrio(),"Arcane Missiles",getArcaneMissilesPrio(),"Arcane Barrage",getArcaneBarragePrio(),"Arcane Blast",getArcaneBlastPrio(),"Fire Blast",getFireBlastPrio(),"Ice Lance",getIceLancePrio()}
/run function prio(i) usable=IsUsableSpell(prioTable[i]) CD=GetSpellCooldown(prioTable[i]) result=-1 if usable ~= 1 or CD>0 then result=-1 usable=-1 else result=prioTable[i+1] end return result end
/run for i=1,getn(prioTable),2 do if prio(i) > bestPrio then bestCast=prioTable[i] bestPrio=prioTable[i+1] end end
--PREVENT ARCANE MISSILES INTERRUPT
/run if UnitChannelInfo("player")~=nil then bestCast = -1 end
/run if bestCast ~= -1 then CastSpellByName(bestCast) print(bestCast.." ("..bestPrio..")") end
--DEBUG PRIO
--/run for i=1,getn(prioTable),2 do print(prioTable[i].." "..prioTable[i+1]) end
edit: added missing line to macro