function Info_Target_Init() local showmenu = function() ToggleDropDownMenu(1, nil, TargetFrameDropDown, "UIParent", Info_Target:GetLeft(), Info_Target:GetBottom()); end SecureUnitButton_OnLoad(Info_Target, "target", showmenu); target_casting = "" target_cast_fading = false t_fading_time = 0 end function Info_Target_OnEvent(event, ...) if (event == "UNIT_HEALTH" and arg1 == "target") then Info_Target_HP_Update() elseif event == "PLAYER_TARGET_CHANGED" then Info_Update_Target() elseif event == "UNIT_MODEL_CHANGED" and arg1 == "target" then TargetModel:SetUnit("target"); TargetModel:SetCamera(0); elseif (event == ("UNIT_MANA" or "UNIT_RAGE" or "UNIT_ENERGY" or "UNIT_RUNIC_POWER") and arg1 == "target") then Info_Target_Power_Update() elseif event == "UNIT_SPELLCAST_START" and arg1 == "target" then Target_Cast_Start("normal") target_cast_fading = false elseif event == "UNIT_SPELLCAST_STOP" and arg1 == "target" then Target_Cast_Stop() elseif event == ("UNIT_SPELLCAST_CHANNEL_START" or "UNIT_SPELLCAST_CHANNEL_UPDATE") and arg1 == "target" then Target_Cast_Start("channel") elseif event == "UNIT_SPELLCAST_FAILED" and arg1 == "target" then Target_Cast_Fail() elseif event == "UNIT_SPELLCAST_SUCCEEDED" and arg1 == "target" then Target_Cast_Success() end end function Info_Target_OnUpdate(self,elapsed) Info_Update_Target() if target_cast_fading == true then t_fading_time = t_fading_time + elapsed if t_fading_time > fade_time then target_cast_fading = false t_fading_time = 0 end TargetCast:SetAlpha(TargetCast:GetAlpha()-elapsed*2) TargetCastText:SetAlpha(TargetCastText:GetAlpha()-elapsed*2) end if target_casting == "normal" then TargetCast:SetValue(TargetCast:GetValue()+elapsed*1000) elseif target_casting == "channel" then TargetCast:SetValue(TargetCast:GetValue()-elapsed*1000) end end function Info_Update_Target() Info_Target_HP_Update() Info_Target_Power_Update() if UnitGUID("target") == nil then Info_Target_Frame:Hide() else Info_Target_Frame:Show() TargetModel:ClearModel() TargetModel:SetUnit("target") TargetModel:Show() TargetModel:SetCamera(0); class, classFileName = UnitClass("target") TargetClass_Icon:SetTexCoord(0,0,0,0) if classFileName == nil then else TargetClass_Icon:SetTexCoord(CLASS_ICON_TCOORDS[classFileName][1], CLASS_ICON_TCOORDS[classFileName][2], CLASS_ICON_TCOORDS[classFileName][3], CLASS_ICON_TCOORDS[classFileName][4]) end end if HasModel(TargetModel) == false then SetPortraitTexture(Target_Icon,"target") Target_Icon:Show() TargetModel:Hide() else TargetModel:Show() Target_Icon:Hide() end end function Info_Target_HP_Update() TargetHealth:SetMinMaxValues(0, UnitHealthMax("target")) TargetHealth:SetValue(UnitHealth("target")) TargetHealthText:SetText(UnitHealth("target").."/"..UnitHealthMax("target")) end function Info_Target_Power_Update() TargetPower:SetMinMaxValues(0, UnitPowerMax("target")) if UnitPowerMax("target") == 0 then TargetPower:Hide() TargetPowerText:Hide() return else TargetPower:Show() TargetPowerText:Show() end TargetPower:SetValue(UnitPower("target")) TargetPowerText:SetText(UnitPower("target").."/"..UnitPowerMax("target")) local power = UnitPowerType("target") if power == 0 then TargetPower:SetStatusBarColor(PowerBarColor["MANA"].r,PowerBarColor["MANA"].g,PowerBarColor["MANA"].b) elseif power == 1 then TargetPower:SetStatusBarColor(PowerBarColor["RAGE"].r,PowerBarColor["RAGE"].g,PowerBarColor["RAGE"].b) elseif power == 2 then TargetPower:SetStatusBarColor(PowerBarColor["FOCUS"].r,PowerBarColor["FOCUS"].g,PowerBarColor["FOCUS"].b) elseif power == 3 then TargetPower:SetStatusBarColor(PowerBarColor["ENERGY"].r,PowerBarColor["ENERGY"].g,PowerBarColor["ENERGY"].b) elseif power == 6 then TargetPower:SetStatusBarColor(PowerBarColor["RUNIC_POWER"].r,PowerBarColor["RUNIC_POWER"].g,PowerBarColor["RUNIC_POWER"].b) end end function Target_Cast_Start(casttype) target_casting = casttype if casttype == "normal" then name, _, _, _, startTime, endTime = UnitCastingInfo("target") TargetCast:SetMinMaxValues(0, endTime-startTime) TargetCast:SetValue(0) TargetCast:SetAlpha(1) TargetCast:SetStatusBarColor(1,1,1) TargetCastText:SetAlpha(1) TargetCastText:SetText(name) TargetCastText:Show() TargetCast:Show() end if casttype == "channel" then name, _, _, _, startTime, endTime = UnitChannelInfo("target") TargetCast:SetMinMaxValues(0, endTime-startTime) local _, maxValue = TargetCast:GetMinMaxValues() TargetCast:SetValue(maxValue) TargetCast:SetAlpha(1) TargetCast:SetStatusBarColor(1,1,1) TargetCastText:SetAlpha(1) TargetCastText:SetText(name) TargetCastText:Show() TargetCast:Show() end end function Target_Cast_Fail() local _, maxValue = TargetCast:GetMinMaxValues() TargetCast:SetValue(maxValue) TargetCast:SetStatusBarColor(1,0,0) TargetCastText:SetText("Failed") end function Target_Cast_Success() local _, maxValue = TargetCast:GetMinMaxValues() TargetCast:SetValue(maxValue) TargetCast:SetStatusBarColor(0,1,0) end function Target_Cast_Stop() TargetCast_Fade() target_casting = "" end function TargetCast_Fade() target_cast_fading = true end