-- Status bar layout functions and tables moved to HealBot_View_Layout.lua function HealBot_AlwaysHeal() return HealBot_Config.EnableHealthy==1 end function HealBot_MayHeal(unit) if not UnitName(unit) or not HealBot_Heals[unit] then return false end if unit ~= 'target' then return true end if not HealBot_Config.TargetHeals or UnitCanAttack("player",unit) then return false end return true; end function HealBot_ShouldHeal(unit) if HealBot_UnitDebuff[unit] and not UnitIsDeadOrGhost(unit) then if HealBot_Range_Check(unit, 30)==1 then return true; end end return HealBot_MayHeal(unit) and UnitHealth(unit)>0 and not UnitIsDeadOrGhost(unit) and (UnitHealth(unit) count then bestBag = bag bestSlot = slot lowestStackSize = count end end end end return bestBag, bestSlot end function HealBot_UseItem(itemName) local bag, slot = HealBot_FindBagSlot(itemName) if not bag then return false end UseContainerItem(bag, slot) return true end function HealBot_Action_HealUnit_OnClick(this,button) local decode_button = HealBot_Decode_Button(button); local pattern = HealBot_Action_SpellPattern(decode_button); if not pattern then return end -- Buff casting override (Spells only) if HealBot_Config.BuffWatch == 1 then local inCombat = UnitAffectingCombat("player") if (not inCombat) or (HealBot_Config.BuffWatchInCombat == 1) then if HealBot_MissingBuffs[this.unit] then local missingBuff = HealBot_MissingBuffs[this.unit] if decode_button == "Left" or decode_button == "Right" then HealBot_CastSpellOnFriend(missingBuff, this.unit) return end end end end -- Priority 1: Inline Scripts (starts with /) if string.sub(pattern, 1, 1) == "/" then local oldTarget = nil if UnitExists("target") then oldTarget = UnitName("target") end TargetUnit(this.unit) HealBot_RunMacroText(pattern) if oldTarget then TargetByName(oldTarget) else ClearTarget() end return end -- Priority 2: Spells -- Resurrection override on dead target first if UnitIsDeadOrGhost(this.unit) then local rezSpell = HealBot_GetRezSpellForClass(); if rezSpell then HealBot_CastSpellOnFriend(rezSpell, this.unit); return end end if HealBot_Spells[pattern] or HealBot_GetSpellId(pattern) then HealBot_HealUnit(this.unit, pattern); return end -- Priority 3: Named Macros if GetMacroIndexByName(pattern) ~= 0 then local oldTarget = nil if UnitExists("target") then oldTarget = UnitName("target") end TargetUnit(this.unit) HealBot_RunMacro(pattern) if oldTarget then TargetByName(oldTarget) else ClearTarget() end return end -- Priority 4: Items local bag, slot = HealBot_FindBagSlot(pattern) if bag then local oldTarget = nil if UnitExists("target") then oldTarget = UnitName("target") end TargetUnit(this.unit) UseContainerItem(bag, slot) if SpellIsTargeting() then SpellTargetUnit(this.unit) end if oldTarget then TargetByName(oldTarget) else ClearTarget() end return end -- Fallback attempt HealBot_HealUnit(this.unit, pattern); end function HealBot_Action_HealUnitCheck_OnClick(this) if not this.unit then return end if this:GetChecked() then table.insert(HealBot_Action_HealTarget,this.unit) else for i=1,table.getn(HealBot_Action_HealTarget) do if HealBot_Action_HealTarget[i]==this.unit then table.remove(HealBot_Action_HealTarget,i); break; end end end HealBot_Action_PartyChanged(); end function HealBot_Action_OptionsButton_OnClick(this) HealBot_TogglePanel(HealBot_Options); end function HealBot_Action_AbortButton_OnClick(this) SpellStopCasting(); end local HealBot_CT_RA_UpdateMTs_Old; function HealBot_CT_RA_UpdateMTs() local value = HealBot_CT_RA_UpdateMTs_Old(); return value; end function HealBot_CT_RaidAssist_DEAD() -- if (type(CT_RA_MemberFrame_OnClick)=="function") then -- HealBot_CT_RA_CustomOnClickFunction_Old = CT_RA_CustomOnClickFunction; -- CT_RA_CustomOnClickFunction = HealBot_CT_RA_CustomOnClickFunction; -- end -- if (type(CT_RA_UpdateMTs)=="function") then -- HealBot_CT_RA_UpdateMTs_Old = CT_RA_UpdateMTs; -- CT_RA_UpdateMTs = HealBot_CT_RA_UpdateMTs; -- end end -------------------------------------------------------------------------------------------------- -- Frame_OnFoo functions -------------------------------------------------------------------------------------------------- function HealBot_Action_OnLoad(this) -- HealBot_CT_RaidAssist(); end function HealBot_Action_OnShow(this) if HealBot_Config.PanelSounds==1 then PlaySound("igAbilityOpen"); end HealBot_Config.ActionVisible = 1 local borderStyle = HealBot_Config.bborder[HealBot_Config.Current_Skin] or 2 if borderStyle == 0 then HealBot_Action:SetBackdropBorderColor(0,0,0,0); elseif borderStyle == 1 then HealBot_Action:SetBackdrop({ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", edgeFile = "Interface\\Buttons\\WHITE8X8", tile = true, tileSize = 8, edgeSize = 1, insets = { left = 1, right = 1, top = 1, bottom = 1 } }) HealBot_Action:SetBackdropBorderColor( HealBot_Config.borcolr[HealBot_Config.Current_Skin], HealBot_Config.borcolg[HealBot_Config.Current_Skin], HealBot_Config.borcolb[HealBot_Config.Current_Skin], HealBot_Config.borcola[HealBot_Config.Current_Skin]); else HealBot_Action:SetBackdrop({ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border", tile = true, tileSize = 8, edgeSize = 16, insets = { left = 4, right = 4, top = 4, bottom = 4 } }) HealBot_Action:SetBackdropBorderColor( HealBot_Config.borcolr[HealBot_Config.Current_Skin], HealBot_Config.borcolg[HealBot_Config.Current_Skin], HealBot_Config.borcolb[HealBot_Config.Current_Skin], HealBot_Config.borcola[HealBot_Config.Current_Skin]); end HealBot_Action:SetBackdropColor( HealBot_Config.backcolr[HealBot_Config.Current_Skin], HealBot_Config.backcolg[HealBot_Config.Current_Skin], HealBot_Config.backcolb[HealBot_Config.Current_Skin], HealBot_Config.backcola[HealBot_Config.Current_Skin]); end function HealBot_Action_OnHide(this) HealBot_StopMoving(this); if not this.ProgrammaticHide then HealBot_Config.ActionVisible = 0 end end function HealBot_Action_OnMouseDown(this,button) if button~="RightButton" then if HealBot_Config.ActionLocked==0 then HealBot_StartMoving(this); end end end function HealBot_Action_OnMouseUp(this,button) if button~="RightButton" then HealBot_StopMoving(this); elseif not HealBot_IsFighting then HealBot_Action_OptionsButton_OnClick(); end end function HealBot_Action_OnClick(this,button) -- HealBot_Action_AddDebug("OnClick("..button..")"); end function HealBot_Action_OnDragStart(this,button) if HealBot_Config.ActionLocked==0 then HealBot_StartMoving(this); end end function HealBot_Action_OnDragStop(this) HealBot_StopMoving(this); end -- http://www.flexbarforums.com/viewtopic.php?t=66 -- no idea what it was link is dead function HealBot_Action_OnKey(this,key,state) local command = GetBindingAction(key); if command then DEFAULT_CHAT_FRAME:AddMessage(key.." "..state.." "..(command or "nil")); keystate = state RunBinding(command,keystate) end DEFAULT_CHAT_FRAME:AddMessage("HealBot_Action_OnKey - "..key); if key=="SHIFT" or key=="CTRL" or key=="ALT" then DEFAULT_CHAT_FRAME:AddMessage((IsShiftKeyDown() or 0).." "..(IsControlKeyDown() or 0).." "..(IsAltKeyDown() or 0)); HealBot_Action_Refresh(); end end