[LEFT]First thankyou. I have tried your combat engine.I think my problem is my notepad.I have noticed a big space bettween the combat engine and the scripts that i can not reproduce. this is what i have







g_skill = {}
function Msg(outstr,a1,a2,a3)
DEFAULT_CHAT_FRAME:AddMessage(tostring(outstr),a1,a2,a3)
end
function ReadSkills()
g_skill = {}
local skillname,slot
Msg("- Reading Class Skills")
for page = 2,4 do
slot = 1
skillname = GetSkillDetail(page,slot)
repeat
local a1,a2,a3,a4,a5,a6,a7,a8,skillusable = GetSkillDetail(page,slot)
if skillusable then
g_skill[skillname] = { ['page'] = page, ['slot'] = slot }
end
slot = slot + 1
skillname = GetSkillDetail(page,slot)
until skillname == nil
end
end
ReadSkills() -- Read skills into g_skill table at login
function PctH(tgt)
return (UnitHealth(tgt)/UnitMaxHealth(tgt))
end
function PctM(tgt)
return (UnitMana(tgt)/UnitMaxMana(tgt))
end
function ChkBuff(tgt,buffname)
local cnt = 1
local buffcmd = UnitBuff
if UnitCanAttack("player",tgt) then
buffcmd = UnitDebuff
end
local buff = buffcmd(tgt,cnt)
while buff ~= nil do
if string.gsub(buff, "(%()(.)(%))", "%2") == buffname then
return true
end
cnt = cnt + 1
buff = buffcmd(tgt,cnt)
end
return false
end
function BuffList(tgt)
local cnt = 1
local buffcmd = UnitBuff
local buffstr = "/"
if UnitCanAttack("player",tgt) then
buffcmd = UnitDebuff
end
local buff = buffcmd(tgt,cnt)
while buff ~= nil do
buffstr = buffstr..buff.."/"
cnt = cnt + 1
buff = buffcmd(tgt,cnt)
end
return string.gsub(buffstr, "(%()(.)(%))", "%2")
end
function CD(skillname)
local firstskill = GetSkillDetail(2,1)
if (g_skill[firstskill] == nil) or (g_skill[firstskill].page ~= 2) then
ReadSkills()
end
if g_skill[skillname] ~= nil then
local tt,cd = GetSkillCooldown(g_skill[skillname].page,g_skill[skillname].slot)
return cd==0
else
Msg("Skill not available: "..skillname)
return false
end
end
function MyCombat(Skill,arg1)
local spell_name,cast_max,cast_current = UnitCastingTime("player")
local talktome = ((arg1 == "v1") or (arg1 == "v2"))
local action,actioncd,actioncnt
if spell_name ~= nil then
if (arg1 == "v2") then Msg("- ['..spell_name..']",0,1,1) end
return true
end
for x,tbl in ipairs(Skill) do
if string.find(Skill[x].name, "Action:") then
if Skill[x].use then
action = tonumber((string.gsub(Skill[x].name, "(Action

( *)(.*)", "%3")))
_1,actioncd = GetActionCooldown(action)
_1,_2,actioncnt = GetActionInfo(action)
if GetActionUsable(action) and (actioncd == 0) and (GetActionInfo(action) ~= nil) and (actioncnt > 0) then
if talktome then Msg("- "..Skill[x].name) end
UseAction(action)
return true
end
end
elseif string.find(Skill[x].name, "Item:") then
if Skill[x].use then
action = string.gsub(Skill[x].name, "(Item

( *)(.*)", "%3")
if talktome then Msg("- "..Skill[x].name) end
UseItemByName(action)
return true
end
elseif CD(Skill[x].name) and Skill[x].use then
if talktome then Msg("- "..Skill[x].name) end
CastSpellByName(Skill[x].name)
return true
end
end
if (arg1 == "v2") then Msg("- IDLE") end
return false
endfunction KWCombat(arg1,arg2)
local Skill = {}
local i = 0
local tgt = "player"
local rage = UnitSkill("player")
local friendly = (not UnitCanAttack("player","target"))
local shield = true
local health = PctH("player")
local tgtcast = UnitCastingTime("target")
if GetEquipSlotInfo(17) == nil then
shield = false
end
local pbuffs = BuffList("player")
local tbuffs = BuffList("target")
i=i+1; Skill
= { ['name'] = "Holy Shield", ['use'] = (health <= .20) }
i=i+1; Skill[i] = { ['name'] = "Resolution", ['use'] = (health <= .33) }
-- i=i+1; Skill[i] = { ['name'] = "Shield of Atonement", ['use'] = ((not friendly) and (health <= .40) and shield) }
-- i=i+1; Skill[i] = { ['name'] = "Shield of Valor", ['use'] = ((not friendly) and (health <= .50) and shield) }
-- i=i+1; Skill[i] = { ['name'] = "Shield of Discipline", ['use'] = ((not friendly) and (tgtcast ~= nil) and shield) }
i=i+1; Skill[i] = { ['name'] = "Enhanced Armor", ['use'] = (not string.find(pbuffs,"Enhanced Armor")) }
i=i+1; Skill[i] = { ['name'] = "Holy Seal", ['use'] = (not string.find(pbuffs,"Holy Seal")) }
i=i+1; Skill[i] = { ['name'] = "Threaten", ['use'] = (string.find(tbuffs,"Holy Seal III") and (not string.find(pbuffs,"Threaten")) and (arg2 == "threaten")) }
i=i+1; Skill[i] = { ['name'] = "Mana Return", ['use'] = (string.find(tbuffs,"Holy Seal III")) }
i=i+1; Skill[i] = { ['name'] = "Whirlwind Shield", ['use'] = ((not friendly) and shield) }
i=i+1; Skill[i] = { ['name'] = "Punishment", ['use'] = (string.find(tbuffs,"Light Seal III")) }
i=i+1; Skill[i] = { ['name'] = "Disarmament", ['use'] = (not string.find(tbuffs,"Disarmament IV") and (arg2 == "disarm")) }
i=i+1; Skill[i] = { ['name'] = "Slash", ['use'] = ((not friendly) and (rage >=75)) }
i=i+1; Skill[i] = { ['name'] = "Holy Strike", ['use'] = (not friendly) }
MyCombat(Skill,arg1)
end[/LEFT]