GameCommandPro=LibStub("AceAddon-3.0"):NewAddon("GameCommandPro","AceConsole-3.0","AceEvent-3.0","AceComm-3.0","AceTimer-3.0") local PartyInfo = {} local SwitchedOff = false GameCommandProCommandLog = {} --[[ Keyed by Name and index (sorted by name) Name Health (%)* Mana (%)* MissingBuff (true/false) UnderAttack (true/false) Connected (true/false) Casting (number: 1=Started,0=ended,2=failed)* SpellName* CastFailTick (number: how long we've been showing failed cast) AFK (true/false) Following (true/false) Ref (number) Target TargetID - ID of target (can be used to index enemy table) TargetRaidIndex - 0 or index of raid marker on target Focus FocusID - ID of target (can be used to index enemy table) FocusRaidIndex - 0 or index of raid marker on focus CCTarget CCTimeLeft (-1 = broken) Screen elements for display (prefixed by GameCommandProForm) (suffixed by 1-5) Label - toon name (grey = afk, green = following, yellow = not following StatusBar (s) - Mana or energy or rage SmallBar (s) - Grey if not responding, red if under attack, yellow if missing buff, or green Cast (s) - green if casting, red if failed, else grey UserBox (suffix only 1-3) Health (s) - bar length = health, Yellow = < 75%, red = < 50%, else green Screen elements for 2nd form - target screen Target - name of target (red = attacking, yellow = angry, green = ok) TargetTarget - name Focus - name of focus (red = attacking, yellow = angry, green = ok) FocusTarget - name ]] local EnemyList = {} --[[ Keyed by GUID and index (sorted by damage) ID Name Ref Target LastSeen AgroList{} - keyed by index (sorted by agro) Name Threat (%) ]] local EnemyNextRef = 0 local QuestStuff = {} --[[ Keyed by QuestTitle QuestTitle NoOfObjectives Objectives {} - Indexed By Item Item QtyNeeded QtyDone[Toon] ObjectiveDesc - contains text description of thing to do if NoOfObjectives = 0 ]] local BuffList = {} local LastMissingBuff = "" local Notified = false local MyMaster = nil local Solo = false local IAmMaster = false local DebugMode = false local MasterFrame = nil local CCSpells = {} -- Valid spells for my class local CCList = {} -- Active spells {Name,Expires} local AutoAccept = true function GameCommandPro:Debug(...) if (DebugMode) then self:Print(...) end end local Box1Allocation = nil local Box1Target = nil local Box1Ref = nil local Box2Allocation = nil local Box2Target = nil local Box2Ref = nil local GCPStartTime = GetTime(); function GameCommandPro:OnInitialize() self:RegisterComm("GCP_A","AuraNotification") self:RegisterComm("GCP_a","AuraDetail") self:RegisterComm("GCP_B","DumpQuestInfo") self:RegisterComm("GCP_b","ProcQuestInfo") self:RegisterComm("GCP_C","SpellNotification") self:RegisterComm("GCP_c","TaxiNotification") self:RegisterComm("GCP_D","CCNotification") self:RegisterComm("GCP_F","FollowNotification") self:RegisterComm("GCP_K","AFKNotification") self:RegisterComm("GCP_O","CombatNotification") self:RegisterComm("GCP_P","PetNotification") self:RegisterComm("GCP_Q","AbandonQuest") self:RegisterComm("GCP_R","RangeNotification") self:RegisterComm("GCP_S","SystemNotification") self:RegisterComm("GCP_T","TargetNotification") -- Target self:RegisterComm("GCP_t","TargetNotification") -- Focus self:RegisterComm("GCP_U","ThreatNotification") self:RegisterComm("GCP_V","MessageNotification") self:RegisterComm("GCP_W","CDNotification") end function GameCommandPro:OnEnable() self:RegisterEvent("AUTOFOLLOW_BEGIN","ChangeFollow") self:RegisterEvent("AUTOFOLLOW_END","ChangeFollow") self:RegisterEvent("PLAYER_REGEN_ENABLED","EndCombat") self:RegisterEvent("PLAYER_REGEN_DISABLED","StartCombat") self:RegisterEvent("UNIT_AURA","ChangeAura") self:RegisterEvent("UNIT_HEALTH","ChangeHealth") self:RegisterEvent("UNIT_MANA","ChangeMana") self:RegisterEvent("UNIT_ENERGY","ChangeMana") self:RegisterEvent("UNIT_RAGE","ChangeMana") self:RegisterEvent("UNIT_FOCUS","ChangeMana") self:RegisterEvent("UNIT_HAPPINESS","ChangePetStatus") self:RegisterEvent("UNIT_PET","ChangePetStatus") self:RegisterEvent("UNIT_THREAT_LIST_UPDATE","ChangeThreat") self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED","CombatEvent") self:RegisterEvent("PLAYER_TARGET_CHANGED","ChangeTarget") self:RegisterEvent("PLAYER_FOCUS_CHANGED","ChangeFocus") -- self:RegisterEvent("PLAYER_LOGIN") self:RegisterEvent("PARTY_INVITE_REQUEST","JoinRequest") -- self:RegisterEvent("RESURRECT_REQUEST") -- self:RegisterEvent("UNIT_HAPPINESS") self:RegisterEvent("QUEST_ACCEPT_CONFIRM","QuestInfo") self:RegisterEvent("QUEST_DETAIL","QuestInfo") self:RegisterEvent("QUEST_COMPLETE","QuestInfo") self:RegisterEvent("QUEST_GREETING","QuestInfo") self:RegisterEvent("QUEST_DETAIL","QuestInfo") self:RegisterEvent("QUEST_COMPLETE","QuestInfo") self:RegisterEvent("QUEST_PROGRESS","QuestInfo") self:RegisterEvent("PARTY_MEMBERS_CHANGED","PartyChange") self:RegisterEvent("PARTY_LEADER_CHANGED","PartyChange") self:RegisterEvent("UNIT_SPELLCAST_SENT","StartCast") self:RegisterEvent("UNIT_SPELLCAST_FAILED","FailCast") self:RegisterEvent("UNIT_SPELLCAST_INTERRUPTED","FailCast") self:RegisterEvent("UNIT_SPELLCAST_STOPPED","StopCast") self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED","StopCast") self:RegisterEvent("PLAYER_FLAGS_CHANGED","CheckAFK") self:RegisterEvent("UI_INFO_MESSAGE","RelayMessage") self:ScheduleRepeatingTimer("Tick", 1,0) self:ScheduleRepeatingTimer("SpellCheck", 0.01,0) self:PartyChange() local Messages = getglobal("GameCommandProFormMessages") Messages:SetFading(true) Messages:SetFadeDuration(4) Messages:SetJustifyH("LEFT") self:RunLog() self:Lock() self:ApplyHUDLabels() self:HookCooldown() if GameCommandProConfigValues["Saved"] == nil then self:ConfigAll() end end local OldRange = "?" local CCClearSent = false local CheckPet = 0 local LastFollowCount = 0 local FollowModeChangeTime = 0 function GameCommandPro:SpellCheck() if (IAmMaster == false) then return end for i=1,#PartyInfo do local PartyMember = PartyInfo[i] local spell, _, _, _, _, endTime = UnitCastingInfo(PartyMember.Name) local CastBar = getglobal("GameCommandProFormCastBar"..i) local lblSpellName = getglobal("GameCommandProFormSpellName"..i.."Label") local lblSpellNameFrame = getglobal("GameCommandProFormSpellName"..i) if spell then local finish = endTime/1000 - GetTime() --CastBar:SetStatusBarColor(1, .694, 0) CastBar:SetValue(finish) lblSpellName:SetText(PartyMember.SpellName) lblSpellNameFrame:SetFrameStrata("TOOLTIP") else local GCD = 0 local CurrentGCD = 1.5 if (PartyMember.CoolDown ~= nil) then CurrentGCD = PartyMember.CoolDown end if (CurrentGCD > 1.5) then CurrentGCD = 1.5 end if(PartyMember.StartCastTime) then GCD = GetTime() - PartyMember.StartCastTime if(GCD < 0 or GCD > CurrentGCD) then GCD = 0 lblSpellName:SetText("") else GCD = CurrentGCD - GCD CastBar:SetStatusBarColor(0, 0, 1) lblSpellName:SetText(PartyMember.SpellName) lblSpellNameFrame:SetFrameStrata("TOOLTIP") end end if(PartyMember.Casting==2) then lblSpellName:SetText(PartyMember.SpellName) lblSpellNameFrame:SetFrameStrata("TOOLTIP") else CastBar:SetValue(GCD) if(GCD == 0) then lblSpellName:SetText("") end end end end end function GameCommandPro:Tick() if(MyMaster ~= nil) then if(UnitName("target") ~= nil) then local NewRange if(CheckInteractDistance("target",1) == nil) then NewRange = ">28" else if(CheckInteractDistance("target",2) == nil) then NewRange = "28" else if(CheckInteractDistance("target",3) == nil) then NewRange = "12" else NewRange = "10" end end end if(OldRange ~= NewRange) then self:SendCommMessage("GCP_R",NewRange,"WHISPER",MyMaster) OldRange = NewRange end end local FoundIt = false if(UnitName("focus") ~= nil) then for Key, CCInfo in pairs(CCList) do if(CCInfo.Expires < GetTime()) then -- expired time self:SendCommMessage("GCP_D","0","WHISPER",MyMaster) FoundIt = true CCInfo[Key] = nil break else for index = 1,40 do local name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitAura("focus",index,"HARMFUL") if(name == nil) then -- unexpected loss self:SendCommMessage("GCP_D","-1","WHISPER",MyMaster) FoundIt = true CCInfo[Key] = nil break else if(CCInfo.Name == name) then CCInfo.Expires = expirationTime expirationTime = tostring(floor(expirationTime - GetTime())) self:SendCommMessage("GCP_D",expirationTime,"WHISPER",MyMaster) FoundIt = true break end end end end end end if(FoundIt) then CCClearSent = false else if(CCClearSent == false) then self:SendCommMessage("GCP_D","-2","WHISPER",MyMaster) CCClearSent = true end end end if (IAmMaster == false) then return end -- Update target change info local SecureEnv = GetManagedEnvironment(MasterFrame) if(SecureEnv ~= nil) then if(SecureEnv.LastSetTarget ~= nil) then local LastSetGroup = SecureEnv.LastSetGroup local LastSetTarget = SecureEnv.LastSetTarget local LastSetRef = SecureEnv.LastSetRef if Box1Allocation == nil then Box1Allocation = LastSetGroup else if Box2Allocation == nil and Box1Allocation ~= LastSetGroup then Box2Allocation = LastSetGroup end end local Target = nil if Box1Allocation == LastSetGroup then Target = getglobal("GameCommandProFormUserBox1Label") Box1Target = LastSetTarget Box1Ref = LastSetRef else if Box2Allocation == LastSetGroup then Target = getglobal("GameCommandProFormUserBox2Label") Box2Target = LastSetTarget Box2Ref = LastSetRef end end if Target ~= nil then if(LastSetTarget == "TBA") then Target:SetText("Changing Target For Group "..LastSetGroup) else local x = "Unknown" if Box1Allocation ~= nil then Target = getglobal("GameCommandProFormUserBox1Label") if(UnitName(Box1Target) ~= nil) then x = UnitName(Box1Target) end Target:SetText("Group "..Box1Allocation.." Targeting "..Box1Ref.."("..x..")") x = "Unknown" end if Box2Allocation ~= nil then Target = getglobal("GameCommandProFormUserBox2Label") if(UnitName(Box2Target) ~= nil) then x = UnitName(Box2Target) end Target:SetText("Group "..Box2Allocation.." Targeting "..Box2Ref.."("..x..")") end end end end end local FollowCount = 0 for i=1,#PartyInfo do local PartyMember = PartyInfo[i] local Bar = getglobal("GameCommandProFormSmallBar"..i) local CastBar = getglobal("GameCommandProFormCast"..i) local CastBar2 = getglobal("GameCommandProFormCastBar"..i) local ManaBar = getglobal("GameCommandProFormStatusBar"..i) local HealthBar = getglobal("GameCommandProFormHealth"..i) local PetHealthBar = getglobal("GameCommandProFormPetHealth"..i) local PetPowerBar = getglobal("GameCommandProFormPetPower"..i) local label = getglobal("GameCommandProFormLabel"..i.."Label") local label2 = getglobal("GameCommandProFormHUDLabel"..i.."Label") if (PartyMember.Connected) then if(PartyMember.HasDebuff) then Bar:SetStatusBarColor(0.9568, 0.3254, 0.8) else if(PartyMember.UnderAttack) then Bar:SetStatusBarColor(1, 0, 0) else if not (PartyMember.PetHappiness == nil) and PartyMember.PetHappiness < 3 then Bar:SetStatusBarColor(0,0,1) else if(PartyMember.MissingBuff) then Bar:SetStatusBarColor(1,.82,0) if(PartyMember.LastMissingBuff) then label:SetText(PartyMember.Name .. " <" .. PartyMember.LastMissingBuff .. ">") end else Bar:SetStatusBarColor(0,1,0) label:SetText(PartyMember.Name) end end end end else Bar:SetStatusBarColor(.96, .86, .70) if (PartyMember.LastRequest == nil or GetTime() - PartyMember.LastRequest > 10) then if(Solo) then self:SendCommMessage("GCP_S","A","WHISPER",UnitName("player")) else local name, thing = UnitName(PartyMember.Name) if thing == nil then self:SendCommMessage("GCP_S","M","WHISPER",UnitName(PartyMember.Name)) end end PartyMember.LastRequest = GetTime() end end if (tonumber(PartyMember.Casting) == 0) then CastBar:SetStatusBarColor(.96, .86, .70) CastBar2:SetStatusBarColor(.96, .86, .70) else if (tonumber(PartyMember.Casting) == 1) then CastBar:SetStatusBarColor(0, 1,0) CastBar2:SetStatusBarColor(0, 1,0) else CastBar:SetStatusBarColor(1, 0,0) CastBar2:SetStatusBarColor(1, 0,0) CastBar2:SetValue(1.5) PartyMember.CastFailTick = PartyMember.CastFailTick + 1 if(PartyMember.CastFailTick > 10) then PartyMember.Casting = 0 CastBar2:SetValue(0) end end end -- Show health if tonumber(PartyMember.Health) < 75 then if tonumber(PartyMember.Health) < 50 then HealthBar:SetStatusBarColor(1,0,0) else HealthBar:SetStatusBarColor(1,.82,0) end else HealthBar:SetStatusBarColor(0,1,0) end HealthBar:SetValue(PartyMember.Health) if not (PartyMember.PetHealth == nil) then if tonumber(PartyMember.PetHealth) < 75 then if tonumber(PartyMember.PetHealth) < 50 then PetHealthBar:SetStatusBarColor(1,0,0) else PetHealthBar:SetStatusBarColor(1,.82,0) end else PetHealthBar:SetStatusBarColor(0,1,0) end PetHealthBar:SetValue(PartyMember.PetHealth) end if not (PartyMember.PetPower == nil) then PetPowerBar:SetValue(PartyMember.PetPower) local info = PowerBarColor[PartyMember.PetPowerType] or PowerBarColor["MANA"]; PetPowerBar:SetStatusBarColor(info.r, info.g, info.b); end local powerType, powerToken = UnitPowerType(PartyMember.Name); local prefix = getglobal(powerToken); local info = PowerBarColor[powerToken]; if ( not info ) then -- couldn't find a power token entry...default to indexing by power type or just mana if we don't have that either info = PowerBarColor[powerType] or PowerBarColor["MANA"]; end ManaBar:SetStatusBarColor(info.r, info.g, info.b); ManaBar:SetValue(PartyMember.Mana) if(PartyMember.AFK) then label:SetTextColor(.96, .86, .70) label2:SetTextColor(.96, .86, .70) else if(PartyMember.Following) then FollowCount = FollowCount + 1 label:SetTextColor(0, 1, 0) label2:SetTextColor(0, 1, 0) else label:SetTextColor(1, .82, 0) label2:SetTextColor(1, .82, 0) end end label = getglobal("GameCommandProEnemyTarget"..i.."Label") if(PartyMember.Target == nil) then label:SetText(" ") else if(PartyMember.Range == nil or PartyMember.Range == ">28") then label:SetTextColor(.96, .86, .70) else if(PartyMember.Range == "28") then label:SetTextColor(0, 1, 0) else label:SetTextColor(1, .82, 0) end end local x = PartyMember.Target if(PartyMember.Range == nil) then label:SetText(x) else label:SetText(x.."("..PartyMember.Range..")") end --[[if (tonumber(PartyMember.TargetRaidIndex) > 0) then self:Debug("Raid Icon "..PartyMember.TargetRaidIndex.." On "..x) local RaidIcon = getglobal("GameCommandProFormRaidIcon"..i.."Texture") SetRaidTargetIconTexture(RaidIcon, PartyMember.TargetRaidIndex) RaidIcon:Show() else RaidIcon:Hide() end ]] end label = getglobal("GameCommandProEnemyFocus"..i.."Label") if(PartyMember.Focus == nil) then label:SetText(" ") else local x = PartyMember.Focus if (PartyMember.CCTimeLeft ~= nil) then if(PartyMember.CCTimeLeft < 0) then x = "<>" else x = x.."<"..PartyMember.CCTimeLeft..">" end end label:SetText(x) end -- we need to check the enemy held by current toon in it's target and focus slots local Enemy = PartyMember.TargetID label = getglobal("GameCommandProEnemyTargetTarget"..i.."Label") label2 = getglobal("GameCommandProEnemyTargetNext"..i.."Label") local x = " " local x2 = " " if (Enemy ~= nil) then Enemy = EnemyList[Enemy] if(Enemy ~= nil) then local AgroList = Enemy.AgroList if(AgroList ~= nil) then local AgroInfo = AgroList[1] if(AgroInfo ~= nil) then x = strmatch(AgroInfo.Name,"[^%s]+$") if(AgroInfo.Threat > 99) then x = "<"..x..">" label:SetTextColor(1, 0, 0) else x = x .. "("..format("%2.2i",AgroInfo.Threat)..")" if(AgroInfo.Threat > 75) then label:SetTextColor(1, .82, 0) else label:SetTextColor(0, 1, 0) end end end if (#AgroList > 1) then local AgroInfo = AgroList[2] if(AgroInfo ~= nil) then x2 = strmatch(AgroInfo.Name,"[^%s]+$") x2 = x2 .. "("..format("%2.2i",AgroInfo.Threat)..")" if(AgroInfo.Threat > 99) then label2:SetTextColor(1, 0, 0) else if(AgroInfo.Threat > 75) then label2:SetTextColor(1, .82, 0) else label2:SetTextColor(0, 1, 0) end end end end end end end label:SetText(x) label2:SetText(x2) Enemy = PartyMember.FocusID label = getglobal("GameCommandProEnemyFocusTarget"..i.."Label") label2 = getglobal("GameCommandProEnemyFocusNext"..i.."Label") x = " " x2 = " " if (Enemy ~= nil) then Enemy = EnemyList[Enemy] if(Enemy ~= nil) then local AgroList = Enemy.AgroList if(AgroList ~= nil) then local AgroInfo = AgroList[1] if(AgroInfo ~= nil) then x = strmatch(AgroInfo.Name,"[^%s]+$") if(AgroInfo.Threat > 99) then x = "<"..x..">" label:SetTextColor(1, 0, 0) else x = x .. "("..format("%2.2i",AgroInfo.Threat)..")" if(AgroInfo.Threat > 75) then label:SetTextColor(1, .82, 0) else label:SetTextColor(0, 1, 0) end end end if (#AgroList > 1) then local AgroInfo = AgroList[2] if(AgroInfo ~= nil) then x2 = strmatch(AgroInfo.Name,"[^%s]+$") x2 = x2 .. "("..format("%2.2i",AgroInfo.Threat)..")" if(AgroInfo.Threat > 99) then label2:SetTextColor(1, 0, 0) else if(AgroInfo.Threat > 75) then label2:SetTextColor(1, .82, 0) else label2:SetTextColor(0, 1, 0) end end end end end end end label:SetText(x) end -- Leave some time for it to settle if GetTime() > FollowModeChangeTime + 2 then if FollowCount ~= LastFollowCount then if FollowCount < LastFollowCount then local Messages = getglobal("GameCommandProFormMessages") Messages:AddMessage("Now " .. FollowCount .. " Following", 0, 1, 0, 1, 12) end LastFollowCount = FollowCount end end end function GameCommandPro:StartCombat() if(MyMaster == nil) then return end self:SendCommMessage("GCP_O","S","WHISPER",MyMaster) end function GameCommandPro:EndCombat() if(MyMaster == nil) then return end self:SendCommMessage("GCP_O","E","WHISPER",MyMaster) end function GameCommandPro:CombatNotification(prefix,message,distribution,sender) if(message == "E") then EnemyList = {} EnemyNextRef = 0 local P = PartyInfo[sender] P.UnderAttack = false end self:Tick() end function GameCommandPro:RangeNotification(prefix,message,distribution,sender) PartyInfo[sender].Range = message self:Tick() end function GameCommandPro:QuestInfo(Event) if(MyMaster == nil) then return end if(IsPartyLeader("player")) or AutoAccept == false then return end if(Event == "QUEST_DETAIL") then AcceptQuest() --for i=1,GetNumQuestLogEntries() do -- SelectQuestLogEntry(i) -- if(GetQuestLogPushable()) then -- QuestLogPushQuest() -- end --end return end if(Event == "QUEST_PROGRESS") then CompleteQuest() return end if(Event == "QUEST_COMPLETE") then if( GetNumQuestChoices() == 0) then GetQuestReward(1) end return end end local LastTargetID = "?" function GameCommandPro:ChangeTarget() if(MyMaster == nil) then return end if (UnitName("target") == nil) then self:SendCommMessage("GCP_T",LastTargetID..",".."-","WHISPER",MyMaster) else if not (UnitIsFriend("player","target")) then if (UnitIsDead("target")) then return end local Index = GetRaidTargetIndex("target") if(Index) then else Index = 0 end self:SendCommMessage("GCP_T",UnitGUID("target")..","..UnitName("target")..","..Index,"WHISPER",MyMaster) LastTargetID = UnitGUID("target") end end end local LastFocusID = "?" function GameCommandPro:ChangeFocus() if(MyMaster == nil) then return end CCList = {} if (UnitName("focus") == nil) then self:SendCommMessage("GCP_t",LastFocusID..",".."-","WHISPER",MyMaster) else if not (UnitIsFriend("player","focus")) then if (UnitIsDead("focus")) then return end local Index = GetRaidTargetIndex("focus") if(Index) then else Index = 0 end self:SendCommMessage("GCP_t",UnitGUID("focus")..","..UnitName("focus")..","..Index,"WHISPER",MyMaster) end end end function GameCommandPro:PurgeEnemyList() local hit = false for _,E in pairs(EnemyList) do if(time() - E.LastSeen > 60) then EnemyList[E.ID] = nil hit = true break end end return hit end function GameCommandPro:EnemySeen(ID,TimeSeen,EnemyName) local Enemy = EnemyList[ID] if(Enemy == nil) then -- When we add a new enemy, we'll purge the old ones while (self:PurgeEnemyList()) do end Enemy = {} Enemy.ID = ID EnemyNextRef = EnemyNextRef + 1 Enemy.Ref = EnemyNextRef Enemy.Name = EnemyName EnemyList[ID] = Enemy end Enemy.LastSeen = TimeSeen return Enemy.Ref end function GameCommandPro:TargetNotification(prefix,message,distribution,sender) local ID,Name,RaidIndex = strsplit(",",message) if(prefix == "GCP_T") then if(Name == "-") then PartyInfo[sender].Target = nil PartyInfo[sender].TargetID = nil else local Ref = self:EnemySeen(ID,time(),Name) PartyInfo[sender].Target = strchar(Ref + 64).."."..strmatch(Name,"[^%s]+$") PartyInfo[sender].TargetID = ID PartyInfo[sender].TargetRaidIndex = RaidIndex end else if(Name == "-") then PartyInfo[sender].Focus = nil PartyInfo[sender].FocusID = nil else local Ref = self:EnemySeen(ID,time(),Name) PartyInfo[sender].Focus = strchar(Ref + 64).."."..strmatch(Name,"[^%s]+$") PartyInfo[sender].FocusID = ID PartyInfo[sender].FocusRaidIndex = RaidIndex end end self:Tick() end function GameCommandPro:ChangeThreat(Event,EnemyUnit) if(MyMaster == nil) then return end if(EnemyUnit ~= nil) then for i=1,#PartyInfo do local PartyMember = PartyInfo[i] isTanking, status, threatpct, rawthreatpct, threatvalue = UnitDetailedThreatSituation(PartyMember.Name, EnemyUnit) if(threatpct ~= nil) then local x = UnitGUID(EnemyUnit)..","..PartyMember.Name..","..threatpct..","..UnitName(EnemyUnit) self:SendCommMessage("GCP_U",x,"WHISPER",MyMaster) end end end end function GameCommandPro:ThreatNotification(prefix,message,distribution,sender) -- this puts an agrolist on each enemy -- its an orderd list of tables, each containing Name and CurrentThreat local ID,ToonName,CurrentThreat,EnemyName = strsplit(",",message) local Enemy = EnemyList[ID] if(Enemy == nil) then if (GameCommandProConfigValues["Threat"]) then self:Print("Threat On "..ToonName.." From "..EnemyName) end self:EnemySeen(ID,time(),EnemyName) Enemy = EnemyList[ID] end Enemy.LastSeen = time() local AgroList = Enemy.AgroList if(AgroList == nil) then AgroList = {} Enemy.AgroList = AgroList end local Found = false local AgroDetails for Index, A in ipairs(AgroList) do if (A.Name == ToonName) then AgroDetails = A Found = true end end if (not Found) then AgroDetails = {} AgroDetails.Name = ToonName tinsert(AgroList,AgroDetails) end AgroDetails.Threat = tonumber(CurrentThreat) local function SortFunc(a,b) return a.Threat > b.Threat end table.sort(AgroList,SortFunc) self:Tick() end function GameCommandPro:CombatEvent(event,timestamp,combatevent,sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,...) if(MyMaster == nil) then return end if(sourceName == nil) then sourceName = "???" end if(destName == nil) then destName = "???" end self:Debug(string.format("%s On %s By %s",combatevent,destName,sourceName)) if (bit.band(sourceFlags,COMBATLOG_OBJECT_REACTION_HOSTILE) ~= 0) then self:EnemySeen(sourceGUID,timestamp,sourceName) end if (bit.band(destFlags,COMBATLOG_OBJECT_REACTION_HOSTILE) ~= 0) then self:EnemySeen(destGUID,timestamp,destName) end end function GameCommandPro:CheckAFK(Event,Unit) if(MyMaster == nil) then return end if(Unit == "player") then if UnitIsAFK("player") then self:SendCommMessage("GCP_K","K","WHISPER",MyMaster) else self:SendCommMessage("GCP_K"," ","WHISPER",MyMaster) end end end function GameCommandPro:AFKNotification(prefix,message,distribution,sender) if (message == "K") then PartyInfo[sender].AFK = true else PartyInfo[sender].AFK = false end self:Tick() end function GameCommandPro:RelayMessage(Event,Message) if(MyMaster == nil) then return end self:SendCommMessage("GCP_V",Message,"WHISPER",MyMaster) end function GameCommandPro:MessageNotification(prefix,message,distribution,sender) if string.find(message, "Buff", 1, 1) then if GameCommandProConfigValues["WarningsBuffs"] == nil or GameCommandProConfigValues["WarningsBuffs"] == 0 then return end end local Messages = getglobal("GameCommandProFormMessages") Messages:AddMessage("["..sender.."] "..message, 0, 1, 0, 1, 12) self:Print("["..sender.."] "..message) end local LastCoolDonwn = 0 function GameCommandPro:HookCooldown() local methods = getmetatable(CreateFrame('Cooldown', nil, nil, 'CooldownFrameTemplate')).__index hooksecurefunc(methods, 'SetCooldown', function(self, start, duration) if(MyMaster == nil) then return end if duration ~= LastCoolDown then LastCoolDown = Duration GameCommandPro:SendCommMessage("GCP_W", ""..duration, "WHISPER", MyMaster) end end) local name, title, notes, enabled, loadable, reason = GetAddOnInfo("Jamba") if reason ~= nil then hooksecurefunc("TakeTaxiNode",function(NodeID) if IsPartyLeader("player") and AutoAccept == true then self:Print("Telling Others To Take Taxi To "..TaxiNodeName(NodeID)) GameCommandPro:SendCommMessage("GCP_c", TaxiNodeName(NodeID), "PARTY") end end) end end function GameCommandPro:CDNotification(prefix,message,distribution,sender) if(PartyInfo[sender] == nil) then return end PartyInfo[sender].CoolDown = tonumber(message) end function GameCommandPro:TaxiNotification(prefix,message,distribution,sender) self:Print("Leader Says Take Taxi To "..message) if IsPartyLeader("player") or AutoAccept == false then return end for i=1,NumTaxiNodes() do if TaxiNodeName(i) == message then TakeTaxiNode(i) break end end end function GameCommandPro:StartCast(Event,Unit,Spell,Rank,Target) if(MyMaster == nil) then return end if(Unit == "player") then self:SendCommMessage("GCP_C",Spell,"WHISPER",MyMaster) end end function GameCommandPro:FailCast(Event,Unit,Spell,Rank,Target) if(MyMaster == nil) then return end if(Unit == "player") then self:SendCommMessage("GCP_C","F,"..Spell,"WHISPER",MyMaster) end end function GameCommandPro:StopCast(Event,Unit,Spell,Rank,Target) if(MyMaster == nil) then return end if(Unit == "player") then self:SendCommMessage("GCP_C","X","WHISPER",MyMaster) end end function GameCommandPro:SpellNotification(prefix,message,distribution,sender) if(PartyInfo[sender] == nil) then return end if(message == "X") then -- normal end PartyInfo[sender].Casting = 0 return end if(string.sub(message,1,2) == "F,") then -- failed end PartyInfo[sender].Casting = 2 PartyInfo[sender].CastFailTick = 0 PartyInfo[sender].SpellName = string.sub(message,3) return end -- Start PartyInfo[sender].Casting = 1 PartyInfo[sender].SpellName = message PartyInfo[sender].StartCastTime = GetTime() self:Tick() end function GameCommandPro:SystemNotification(prefix,message,distribution,sender) if sender == nil then self:Print("Message From nil Not Expected") return end if(message == "M") then MyMaster = sender self:SendCommMessage("GCP_S","A","WHISPER",MyMaster) return end if(message == "A") then if PartyInfo[sender] == nil then return end PartyInfo[sender].Connected = true end if(message == "B") then BuffList = {} self:CheckBuffs() for i=1,#BuffList do self:Print(i..":"..BuffList[i]) end self:Print(#BuffList.." Buffs Found") self:SendCommMessage("GCP_A","O","WHISPER",MyMaster) Notified = false end if(message == "D") then self:Print("Checking Buffs") if (self:CheckBuffs()) then self:Print("Missing "..LastMissingBuff) self:SendCommMessage("GCP_V","Buff Missing " .. LastMissingBuff,"WHISPER",MyMaster) else self:Print("OK") self:SendCommMessage("GCP_V","Buffs OK","WHISPER",MyMaster) end end if(message == "C") then if AutoAccept then AutoAccept = false self:Print("Auto Accept Is Off") else AutoAccept = true self:Print("Auto Accept Is On") end end self:Tick() end function GameCommandPro:ChangeFollow(EventName,Arg1) if(MyMaster == nil) then return end if(EventName == "AUTOFOLLOW_BEGIN") then self:SendCommMessage("GCP_F",Arg1,"WHISPER",MyMaster) else self:SendCommMessage("GCP_F","","WHISPER",MyMaster) end end function GameCommandPro:FollowNotification(prefix,message,distribution,sender) if(PartyInfo[sender] == nil) then return end if(message == "") then PartyInfo[sender].Following = false else PartyInfo[sender].Following = true end FollowModeChangeTime = GetTime() -- self:Tick() end function GameCommandPro:ChangePetStatus(EventName,Arg1) if(MyMaster == nil) then return end if UnitName("pet") == nil then self:SendCommMessage("GCP_P","U,0","WHISPER",MyMaster) return end local powerType, powerToken = UnitPowerType("pet"); if powerType ~= nil then self:SendCommMessage("GCP_P","P,"..powerType,"WHISPER",MyMaster) end local x = tostring(ceil(UnitPower("pet")* 100 / UnitPowerMax("pet"))) if x == nil then x = "0" end self:SendCommMessage("GCP_P","M,"..x,"WHISPER",MyMaster) x = tostring(ceil(UnitHealth("pet")* 100 / UnitHealthMax("pet"))) if x == nil then x = "0" end self:SendCommMessage("GCP_P","U,"..x,"WHISPER",MyMaster) local h = GetPetHappiness() if h == nil then return end self:SendCommMessage("GCP_P","H,"..h,"WHISPER",MyMaster) end function GameCommandPro:PetNotification(prefix,message,distribution,sender) local Mode, Value = strsplit(",",message) if (Mode == "H") then PartyInfo[sender].PetHappiness = tonumber(Value) if PartyInfo[sender].PetHealth == nil then PartyInfo[sender].PetHealth = 100 end return end if (Mode == "U") then PartyInfo[sender].PetHealth = tonumber(Value) if PartyInfo[sender].PetHealth == 0 then PartyInfo[sender].PetPower = 0 end return end if (Mode == "M") then PartyInfo[sender].PetPower = tonumber(Value) return end if (Mode == "P") then PartyInfo[sender].PetPowerType = tonumber(Value) return end end function GameCommandPro:ChangeMana(EventName,Arg1) -- Arg1 = UnitID if MyMaster ~= nil then if(arg1 == "pet") then local x x = tostring(ceil(UnitPower("pet")* 100 / UnitPowerMax("pet"))) self:SendCommMessage("GCP_P","M,"..x,"WHISPER",MyMaster) end end if(IAmMaster == nil) then return end local i for i=1,#PartyInfo do local PartyMember = PartyInfo[i] if(UnitName(arg1) == UnitName(PartyMember.Name)) then local x x = tostring(ceil(UnitPower(arg1)* 100 / UnitPowerMax(arg1))) PartyMember.Mana = tonumber(x) self:Tick() end end end local MyHealth = 100 function GameCommandPro:ChangeHealth(EventName,Arg1) -- Arg1 = UnitID if MyMaster ~= nil then if(arg1 == "pet") then local x x = tostring(ceil(UnitHealth("pet")* 100 / UnitHealthMax("pet"))) self:SendCommMessage("GCP_P","U,"..x,"WHISPER",MyMaster) end end if(IAmMaster == nil) then return end local i for i=1,#PartyInfo do local PartyMember = PartyInfo[i] if(UnitName(arg1) == UnitName(PartyMember.Name)) then local x x = tostring(ceil(UnitHealth(arg1)* 100 / UnitHealthMax(arg1))) if(PartyMember.Health ~= nil) then if (tonumber(x) < PartyMember.Health) then PartyMember.UnderAttack = true else PartyMember.UnderAttack = false end end PartyMember.Health = tonumber(x) self:Tick() end end end function GameCommandPro:ChangeAura(EventName,Arg1) -- Arg1 = UnitID if(MyMaster == nil) then return end if(arg1 == "player") then if (self:CheckBuffs()) then -- if (Notified == false) then local Work = LastMissingBuff if strsub(Work,1,1) == "," then Work = strsub(Work,2) end if strlen(Work) > 10 then local Words = { strsplit(" ", Work) } Work = "" for i=1,#Words do Work = Work .. strsub(Words[i],1,1) end end self:SendCommMessage("GCP_a",Work,"WHISPER",MyMaster) self:SendCommMessage("GCP_A","M","WHISPER",MyMaster) -- Notified = true -- end else -- if (Notified) then self:SendCommMessage("GCP_A","O","WHISPER",MyMaster) -- Notified = false -- end end local rank,icon,count,debuffType,duration,expirationTime, isMine, isStealable BuffName, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitAura("Player",1,"HARMFUL") if BuffName == nil then self:SendCommMessage("GCP_A","X","WHISPER",MyMaster) else self:SendCommMessage("GCP_A","D","WHISPER",MyMaster) end end if(arg1 == "focus") then local index = 1 local s = "" local name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitAura("focus",index,"HARMFUL") while (name ~= nil) do if(expirationTime ~= nil and isMine) then if (CCSpells[name] ~= nil) then local CCInfo = CCList[name] if (CCInfo == nil) then CCInfo = {} CCInfo.Name = name CCInfo.Rank = rank CCList[name] = CCInfo CCInfo.Expires = expirationTime else CCInfo.Expires = expirationTime end end end index = index + 1 name, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitAura("focus",index,"HARMFUL") end end self:Tick() end function GameCommandPro:AuraNotification(prefix,message,distribution,sender) if PartyInfo[sender] == nil then return end if (message == "M") then PartyInfo[sender].MissingBuff = true else if (message == "O") then PartyInfo[sender].MissingBuff = false else if (message == "D") then PartyInfo[sender].HasDebuff = true else if (message == "X") then PartyInfo[sender].HasDebuff = false end end end end self:Tick() end function GameCommandPro:AuraDetail(prefix,message,distribution,sender) if PartyInfo[sender] == nil then return end PartyInfo[sender].LastMissingBuff = message end function GameCommandPro:CCNotification(prefix,message,distribution,sender) local TimeLeft = tonumber(message) PartyMember = PartyInfo[sender] if PartyMember == nil then return end if(TimeLeft == -2) then PartyMember.CCTimeLeft = nil else PartyMember.CCTimeLeft = TimeLeft end end function GameCommandPro:CheckBuffs() local BuffInfo = {} local Missing = false LastMissingBuff = "" -- need to check for lost all buffs if (UnitAura("Player",1,"HELPFUL") == nil) then if(#BuffList > 0) then LastMissingBuff = "All" Missing = true end return Missing end for i=1, 40 do local BuffName = UnitAura("Player",i,"HELPFUL") if BuffName == nil then break else -- self:Print("Player Buff "..BuffName) local Match = false for j=1,#BuffList do if (i == 1) then -- only on first pass - check for missing while we're -- looping here anyway -- self:Print("Checking Loss Of "..BuffList[j]) if (UnitBuff("Player",BuffList[j]) == nil) then -- we lost a buff LastMissingBuff = LastMissingBuff .. "," .. BuffList[j] -- self:Print("Missing") Missing = true end end if (BuffName == BuffList[j]) then -- self:Print("Found In Table "..BuffName) Match = true break end end if not Match then -- New Buff local rank,icon,count,debuffType,duration,expirationTime, isMine, isStealable BuffName, rank, icon, count, debuffType, duration, expirationTime, isMine, isStealable = UnitAura("Player",i,"HELPFUL") if(duration > 300) then BuffList[#BuffList + 1] = BuffName -- self:Print("Added To Table ") end end end end return Missing end function GameCommandPro:JoinRequest(EventName,Arg1) if(SwitchedOff == true) then return end local name, title, notes, enabled, loadable, reason = GetAddOnInfo("Jamba") self:Print("Join Request") if reason ~= nil then if GetTime() < GCPStartTime + 120 then AcceptGroup() end end end local prevnummembers = 0 function GameCommandPro:PartyChange() if(SwitchedOff == true) then return end StaticPopup_Hide("PARTY_INVITE") if prevnummembers ~= GetNumPartyMembers() then local lootmethod, masterlooterPartyID, masterlooterRaidID = GetLootMethod() if lootmethod ~= "freeforall" then SetLootMethod("freeforall") end end prevnummembers = GetNumPartyMembers() if Solo or IsPartyLeader("player") then IAmMaster = true GameCommandProForm:Show() GameCommandProEnemy:Show() else GameCommandProForm:Hide() GameCommandProEnemy:Hide() IAmMaster = false end local function SortRule(a,b) return a.SortIndex < b.SortIndex end -- need to regen partyinfo local NewPartyInfo = {} local PartyMember local Rank PartyMember = {} PartyMember.Name = UnitName("Player") PartyMember.Health = 100 * UnitHealth("Player") PartyMember.Mana = UnitMana("Player") PartyMember.MissingBuff = false PartyMember.UnderAttack = false PartyMember.Connected = false PartyMember.Casting = 0 PartyMember.AFK = false PartyMember.Following = true Rank = GameCommandProSortOrder[PartyMember.Name] if Rank then PartyMember.SortIndex = tonumber(Rank) else if #GameCommandProSortOrder ~= 0 then PartyMember.SortIndex = 0 else PartyMember.SortIndex = 1 end end local j = 0 if PartyMember.SortIndex > 0 then j = j + 1 NewPartyInfo[j] = PartyMember end for i = 1,GetNumPartyMembers(),1 do PartyMember = {} PartyMember.Name = UnitName("Party" .. i) PartyMember.Health = ceil(UnitHealth("Party" .. i)* 100 / UnitHealthMax("Party" .. i)) PartyMember.Mana = ceil(UnitMana("Party" .. i)* 100 / UnitManaMax("Party" .. i)) PartyMember.MissingBuff = false PartyMember.UnderAttack = false PartyMember.Connected = false PartyMember.Casting = 0 PartyMember.AFK = false PartyMember.Following = false Rank = GameCommandProSortOrder[PartyMember.Name] if Rank then PartyMember.SortIndex = tonumber(Rank) else if #GameCommandProSortOrder ~= 0 then PartyMember.SortIndex = 0 else PartyMember.SortIndex = i + 1 end end if UnitName("PartyPet"..i) ~= nil then PartyMember.PetHealth = 100 end if PartyMember.SortIndex > 0 then j = j + 1 NewPartyInfo[j] = PartyMember end end self:TidyDisplay() table.sort(NewPartyInfo,SortRule) PartyInfo = NewPartyInfo; local Target for i = 1,#PartyInfo,1 do local label = getglobal("GameCommandProFormLabel"..i.."Label") PartyMember = PartyInfo[i] label:SetText(PartyMember.Name) PartyMember.Ref = i PartyInfo[PartyMember.Name] = PartyMember end self:ConfigApply() self:Tick() end function GameCommandPro:TidyDisplay() local i PartySize = #PartyInfo for i = 1,5, 1 do -- TODO: Tidy up display if party < 5 local x = getglobal("GameCommandProFormCast"..i) if(i<=PartySize) then if (GameCommandProConfigValues["CastingIndicators"]) then x:Show() end else x:Hide() end x = getglobal("GameCommandProFormHealth"..i) if(i<=PartySize) then if (GameCommandProConfigValues["Health_ManaBars"]) then x:Show() end else x:Hide() end x = getglobal("GameCommandProFormStatusBar"..i) if(i<=PartySize) then if (GameCommandProConfigValues["Health_ManaBars"]) then x:Show() end else x:Hide() end x = getglobal("GameCommandProFormSmallBar"..i) if(i<=PartySize) then if (GameCommandProConfigValues["StatusIndicators"]) then x:Show() end else x:Hide() end x = getglobal("GameCommandProFormLabel"..i) if(i<=PartySize) then if (GameCommandProConfigValues["BarLabels"]) then x:Show() end else x:Hide() end end end GameCommandProConfigValues = {} function GameCommandPro:ConfigChange() local x = getglobal("GameCommandProConfigPetBars") GameCommandProConfigValues["PetBars"] = x:GetChecked() x = getglobal("GameCommandProConfigBarLabels") GameCommandProConfigValues["BarLabels"] = x:GetChecked() x = getglobal("GameCommandProConfigCastingIndicators") GameCommandProConfigValues["CastingIndicators"] = x:GetChecked() x = getglobal("GameCommandProConfigStatusIndicators") GameCommandProConfigValues["StatusIndicators"] = x:GetChecked() x = getglobal("GameCommandProConfigHealth_ManaBars") GameCommandProConfigValues["Health_ManaBars"] = x:GetChecked() x = getglobal("GameCommandProConfigCastingBarNames") GameCommandProConfigValues["CastingBarNames"] = x:GetChecked() x = getglobal("GameCommandProConfigCastingBars") GameCommandProConfigValues["CastingBars"] = x:GetChecked() x = getglobal("GameCommandProConfigSpellNames") GameCommandProConfigValues["SpellNames"] = x:GetChecked() x = getglobal("GameCommandProConfigEnemyNumbers") GameCommandProConfigValues["EnemyNumbers"] = x:GetChecked() x = getglobal("GameCommandProConfigEnemyNames") GameCommandProConfigValues["EnemyNames"] = x:GetChecked() x = getglobal("GameCommandProConfigTargetofEnemy") GameCommandProConfigValues["TargetofEnemy"] = x:GetChecked() x = getglobal("GameCommandProConfigNextonThreat") GameCommandProConfigValues["NextonThreat"] = x:GetChecked() x = getglobal("GameCommandProConfigTargetNumbers") GameCommandProConfigValues["TargetNumbers"] = x:GetChecked() x = getglobal("GameCommandProConfigTargetsName") GameCommandProConfigValues["TargetsName"] = x:GetChecked() x = getglobal("GameCommandProConfigCCTime") GameCommandProConfigValues["CCTime"] = x:GetChecked() x = getglobal("GameCommandProConfigWarningsBuffs") GameCommandProConfigValues["WarningsBuffs"] = x:GetChecked() x = getglobal("GameCommandProConfigThreat") GameCommandProConfigValues["Threat"] = x:GetChecked() GameCommandProConfigValues["Saved"] = 1 self:ConfigApply() end function GameCommandPro:ConfigApply() for i = 1, 5 do local y = getglobal("GameCommandProFormPetHealth"..i) local z = getglobal("GameCommandProFormPetPower"..i) if (GameCommandProConfigValues["PetBars"]) then y:Show() z:Show() else y:Hide() z:Hide() end y = getglobal("GameCommandProFormHUDLabel"..i) if (GameCommandProConfigValues["BarLabels"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProFormCast"..i) if (GameCommandProConfigValues["CastingIndicators"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProFormSmallBar"..i) if (GameCommandProConfigValues["StatusIndicators"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProFormHealth"..i) z = getglobal("GameCommandProFormStatusBar"..i) if (GameCommandProConfigValues["Health_ManaBars"]) then y:Show() z:Show() else y:Hide() z:Hide() end y = getglobal("GameCommandProFormLabel"..i) if (GameCommandProConfigValues["CastingBarNames"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProFormCastBar"..i) if (GameCommandProConfigValues["CastingBars"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProFormSpellName"..i) if (GameCommandProConfigValues["SpellNames"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProEnemyLabel"..i) if (GameCommandProConfigValues["EnemyNumbers"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProEnemyTarget"..i) if (GameCommandProConfigValues["EnemyNames"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProEnemyTargetTarget"..i) if (GameCommandProConfigValues["TargetofEnemy"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProEnemyTargetNext"..i) z = getglobal("GameCommandProEnemyFocusNext"..i) if (GameCommandProConfigValues["NextonThreat"]) then z:Show() y:Show() else z:Hide() y:Hide() end y = getglobal("GameCommandProEnemyLabelb"..i) if (GameCommandProConfigValues["TargetNumbers"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProEnemyFocus"..i) if (GameCommandProConfigValues["TargetsName"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProEnemyFocusTarget"..i) if (GameCommandProConfigValues["CCTime"]) then y:Show() else y:Hide() end end y = getglobal("GameCommandProEnemyEnemy") if (GameCommandProConfigValues["EnemyNames"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProEnemyTarget") if (GameCommandProConfigValues["TargetofEnemy"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProEnemyNextThreat") z = getglobal("GameCommandProEnemyNextThreat2") if (GameCommandProConfigValues["NextonThreat"]) then y:Show() z:Show() else y:Hide() z:Hide() end y = getglobal("GameCommandProEnemyCCTarget") if (GameCommandProConfigValues["TargetsName"]) then y:Show() else y:Hide() end y = getglobal("GameCommandProEnemyCCTime") if (GameCommandProConfigValues["CCTime"]) then y:Show() else y:Hide() end self:TidyDisplay() end function GameCommandPro:ConfigAll() local x = getglobal("GameCommandProConfigPetBars") x:SetChecked(1) x = getglobal("GameCommandProConfigBarLabels") x:SetChecked(1) x = getglobal("GameCommandProConfigCastingIndicators") x:SetChecked(1) x = getglobal("GameCommandProConfigStatusIndicators") x:SetChecked(1) x = getglobal("GameCommandProConfigHealth_ManaBars") x:SetChecked(1) x = getglobal("GameCommandProConfigCastingBarNames") x:SetChecked(1) x = getglobal("GameCommandProConfigCastingBars") x:SetChecked(1) x = getglobal("GameCommandProConfigSpellNames") x:SetChecked(1) x = getglobal("GameCommandProConfigEnemyNumbers") x:SetChecked(1) x = getglobal("GameCommandProConfigEnemyNames") x:SetChecked(1) x = getglobal("GameCommandProConfigTargetofEnemy") x:SetChecked(1) x = getglobal("GameCommandProConfigNextonThreat") x:SetChecked(1) x = getglobal("GameCommandProConfigTargetNumbers") x:SetChecked(1) x = getglobal("GameCommandProConfigTargetsName") x:SetChecked(1) x = getglobal("GameCommandProConfigCCTime") x:SetChecked(1) x = getglobal("GameCommandProConfigWarningsBuffs") x:SetChecked(1) x = getglobal("GameCommandProConfigThreat") x:SetChecked(1) self:ConfigChange() end function GameCommandPro:ConfigAllOff() local x = getglobal("GameCommandProConfigPetBars") x:SetChecked(0) x = getglobal("GameCommandProConfigBarLabels") x:SetChecked(0) x = getglobal("GameCommandProConfigCastingIndicators") x:SetChecked(0) x = getglobal("GameCommandProConfigStatusIndicators") x:SetChecked(0) x = getglobal("GameCommandProConfigHealth_ManaBars") x:SetChecked(0) x = getglobal("GameCommandProConfigCastingBarNames") x:SetChecked(0) x = getglobal("GameCommandProConfigCastingBars") x:SetChecked(0) x = getglobal("GameCommandProConfigSpellNames") x:SetChecked(0) x = getglobal("GameCommandProConfigEnemyNumbers") x:SetChecked(0) x = getglobal("GameCommandProConfigEnemyNames") x:SetChecked(0) x = getglobal("GameCommandProConfigTargetofEnemy") x:SetChecked(0) x = getglobal("GameCommandProConfigNextonThreat") x:SetChecked(0) x = getglobal("GameCommandProConfigTargetNumbers") x:SetChecked(0) x = getglobal("GameCommandProConfigTargetsName") x:SetChecked(0) x = getglobal("GameCommandProConfigCCTime") x:SetChecked(0) x = getglobal("GameCommandProConfigWarningsBuffs") x:SetChecked(0) x = getglobal("GameCommandProConfigThreat") x:SetChecked(0) self:ConfigChange() end function GameCommandPro:ConfigDone() local x = getglobal("GameCommandProConfig") x:Hide() end function GameCommandPro:DoRL() ReloadUI() end function GameCommandPro:DoCheckBuffs() self:Print("Sending Buff Check Request") if (Solo) then self:SendCommMessage("GCP_S","D","WHISPER",UnitName("player")) else self:SendCommMessage("GCP_S","D","PARTY") end end local QI_StateToon = 0 local QI_StateQuest = 0 local QI_StateObjective = 0 local QI_NoOfQuests = 0 local QI_Name = "" local QI_NoOfObjectives = 0 local QI_TextObjective = "" function GameCommandPro:ShowQuestInfo() local QList = getglobal("GameCommandProQuestsList") QList:Clear() GameCommandProQuests:Show() for _,Q in pairs(QuestStuff) do QList:AddMessage(Q.QuestTitle,1,.25,.25) if(Q.ObjectiveDesc ~= nil) then local Obs = Q.Objectives for _,Ob in pairs(Obs) do QList:AddMessage(Q.ObjectiveDesc,0,1,1) local S = "" for k=1,#PartyInfo do local PartyMember = PartyInfo[k] local Q = Ob.QtyDone[PartyMember.Name] if(Q == -1) then S = S .. "X" else if(Q>0) then S = S .. "Y" else S = S .. "N" end end S = S .. " " end QList:AddMessage(S,0,1,.5) end else local Obs = Q.Objectives for _,Ob in pairs(Obs) do QList:AddMessage("Need ".. Ob.QtyNeeded .. " Of " .. Ob.Item ,0,1,1) local S = "" for k=1,#PartyInfo do local PartyMember = PartyInfo[k] local Q = Ob.QtyDone[PartyMember.Name] if(Q == -1) then S = S .. "X" else S = S .. Q end S = S .. " " end QList:AddMessage(S,0,1,.5) end end QList:AddMessage("<---->",1,.25,.25) end QList:ScrollToTop() end function GameCommandPro:AddQuestInfo(Title,NoOfObjectives,Item,Needed,Toon,Done) local Messages = getglobal("GameCommandProFormMessages") if Item == nil then return end Messages:AddMessage(Toon..":"..Title..","..Item, 0, 1, 0, 1, 2) local Target = Title local Q = QuestStuff[Target] if(Q == nil) then Q = {} QuestStuff[Target] = Q Q.QuestTitle = Title Q.NoOfObjectives = NoOfObjectives Q.Objectives = {} end if(NoOfObjectives == 0) then Q.ObjectiveDesc = Item end Target = Item local Ob = Q.Objectives[Target] if(Ob == nil) then Ob = {} Q.Objectives[Target] = Ob Ob.Item = Item Ob.QtyNeeded = Needed Ob.QtyDone={} for i=1,#PartyInfo do local PartyMember = PartyInfo[i] Ob.QtyDone[PartyMember.Name] = -1 end end Ob.QtyDone[Toon] = Done end function GameCommandPro:ProcQuestInfo(prefix,message,distribution,sender) if(QI_StateQuest == 0) then QI_NoOfQuests = tonumber(message) else if(QI_StateObjective < 1) then if(message == "HDR") then QI_StateObjective = 999 else if(QI_StateObjective < 0) then QI_Name = message else if(strsub(message,1,1) == "N") then QI_NoOfObjectives = tonumber(strsub(message,2)) else QI_NoOfObjectives = 1 QI_TextObjective = strsub(message,2) end end end else if(QI_TextObjective ~= "") then self:AddQuestInfo(QI_Name,0,QI_TextObjective,1,sender,tonumber(message)) else local _, _, ItemRequired, NoItemsObtained, NoItemsRequired = string.find(message, "(.*):%s*([%d]+)%s*/%s*([%d]+)") self:AddQuestInfo(QI_Name,QI_NoOfObjectives,ItemRequired,tonumber(NoItemsRequired),sender,tonumber(NoItemsObtained)) end end end -- move to next phase QI_StateObjective = QI_StateObjective + 1 if(QI_StateObjective > QI_NoOfObjectives) then QI_StateQuest = QI_StateQuest + 1 QI_NoOfObjectives = 0 QI_TextObjective="" QI_StateObjective = -1 if(QI_StateQuest > QI_NoOfQuests) then QI_StateToon = QI_StateToon + 1 QI_StateQuest = 0 if (QI_StateToon > #PartyInfo) then self:ShowQuestInfo() return end local PartyMember = PartyInfo[QI_StateToon] local Messages = getglobal("GameCommandProFormMessages") Messages:AddMessage("Working on "..PartyMember.Name, 0, 1, .5, 1, 2) end end local PartyMember = PartyInfo[QI_StateToon] self:SendCommMessage("GCP_B",QI_StateQuest..","..QI_StateObjective,"WHISPER",PartyMember.Name) end function GameCommandPro:DumpQuestInfo(prefix,message,distribution,sender) local StateQuest,StateObjective = strsplit(",",message) StateQuest = tonumber(StateQuest) StateObjective = tonumber(StateObjective) if(StateQuest == 0) then local numEntries, numQuests = GetNumQuestLogEntries() self:SendCommMessage("GCP_b",numEntries.."","WHISPER",sender) return end SelectQuestLogEntry(StateQuest) local questTitle, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily = GetQuestLogTitle(StateQuest) if(isHeader) then self:SendCommMessage("GCP_b","HDR","WHISPER",sender) return end local numQuestLogLeaderBoards = GetNumQuestLeaderBoards() if(StateObjective==-1) then self:SendCommMessage("GCP_b",questTitle,"WHISPER",sender) return end if(StateObjective==0) then if(numQuestLogLeaderBoards > 0) then self:SendCommMessage("GCP_b","N"..numQuestLogLeaderBoards,"WHISPER",sender) else local questDescription, questObjectives = GetQuestLogQuestText() self:SendCommMessage("GCP_b","D"..questObjectives,"WHISPER",sender) end return end local desc, type, done if(numQuestLogLeaderBoards>0) then desc, type, done = GetQuestLogLeaderBoard(StateObjective) else if(isComplete) then desc = "1" else desc = "0" end end self:SendCommMessage("GCP_b",desc,"WHISPER",sender) end function GameCommandPro:ShowQuests(Params) QuestStuff = {} QI_StateToon = 1 QI_StateQuest = 0 QI_StateObjective = -1 QI_NoOfQuests = 0 QI_NoOfObjectives = 0 QI_TextObjective = "" local PartyMember = PartyInfo[QI_StateToon] local Messages = getglobal("GameCommandProFormMessages") Messages:AddMessage("Working on "..PartyMember.Name, 0, 1, .5, 1, 2) self:SendCommMessage("GCP_B",QI_StateQuest..","..QI_StateObjective,"WHISPER",PartyMember.Name) end function GameCommandPro:LearnBuffs() self:Print("Sending Relearn Buff Request") if (Solo) then self:SendCommMessage("GCP_S","B","WHISPER",UnitName("player")) else self:SendCommMessage("GCP_S","B","PARTY") end end function GameCommandPro:ToggleAutoAccept() self:Print("Sending Auto Accept Mode Change Request") if (Solo) then self:SendCommMessage("GCP_S","C","WHISPER",UnitName("player")) else self:SendCommMessage("GCP_S","C","PARTY") end end function GameCommandPro:SlashStatus(Params) local Box,Message = strmatch(Params,"([^,]+),(.+)") local Target = getglobal("GameCommandProFormUserBox"..tonumber(Box).."Label") if (Message == "~") then Target:SetText(" ") else Target:SetText(Message) end end function GameCommandPro:SlashSolo(Params) Solo = true self:PartyChange() MyMaster = UnitName("player") GameCommandProForm:Show() end local MacroButtons = {} local MacroButtonsCount = 0 local MasterStateControl = {} local PrefixList = {" ","SHIFT-", "CTRL-", "ALT-", "CTRL-SHIFT-", "ALT-SHIFT-", "ALT-CTRL-", "ALT-CTRL-SHIFT-",} local Groups = {} local GroupCount = 0 --[[ Groups structure Name Index (index to PrefixList used to refernce macthing structure in secure environment) Targets[] Name (e.g. "Toon1-Target") State (e.g. "T1") ]] function GameCommandPro:SlashGroup(Params) -- Param 1 = Name -- Param 2 - 9 = Target1 - Target8 values local arg = {} for text in string.gmatch(Params,"(.-),") do arg[#arg+1]=text end arg[#arg+1]=strmatch(Params,"[^,]-$") if(arg[2] == nil) then self:Print("Usage : Group ,,[..]") return end if(MasterFrame == nil) then self:SetupMaster() end local Group = Groups[arg[1]] if(Group == nil) then Group = {} Groups[arg[1]] = Group Group.Name = arg[1] GroupCount = GroupCount + 1 Group.Index = GroupCount end local Targets = {} for i=1,8 do local Target = {} if(arg[i + 1] == nil) then Target.Name = arg[2] else Target.Name = arg[i + 1] end Target.State = "T"..i --self:Print("Group "..Group.Name.." Target "..i.." = "..Target.Name.."(State:"..Target.State..")") Targets[i] = Target MasterFrame:Execute("Groups['"..PrefixList[Group.Index].."'].TargetNames['"..PrefixList[i].."'] = '"..Target.Name.."'") end Group.Targets = Targets -- Now update the table in the secure environment MasterFrame:Execute("Groups['"..PrefixList[Group.Index].."'].Name = '"..Group.Name.."'") --self:Print("Group "..Group.Name.." Allocated to '"..PrefixList[Group.Index].."'") end local NextSpellGroupName function GameCommandPro:SlashGroupSet(Params) NextSpellGroupName = Params end function GameCommandPro:MakeButton(Params,Mode) local Keys, SpellText = strsplit(",",Params) local GroupName = nil Keys = strtrim(Keys) SpellText = strtrim(SpellText) if (Keys == nil) then self:Print("Usage : Spell ,") return end local Group if (NextSpellGroupName ~= nil) then GroupName = NextSpellGroupName NextSpellGroupName = nil Group = Groups[GroupName] if(Group == nil) then self:Print("Invalid Group") return end end if(SpellText == "DONOTHING") then self:Debug(Keys.." Reset") SetBindingClick(Keys,"") return end MacroButtonsCount = MacroButtonsCount + 1 local MacroName = "GameCommandProMacroButton"..MacroButtonsCount local button = CreateFrame("Button", MacroName, nil, "SecureActionButtonTemplate"); if(Mode == 1) then button:SetAttribute("type", "spell"); button:SetAttribute("spell", SpellText); elseif(Mode == 2) then button:SetAttribute("type", "action"); button:SetAttribute("action", SpellText); end MacroButtons[MacroButtonsCount] = button SetBindingClick(Keys,MacroName) self:Debug("Spell "..SpellText.." Mapped to "..Keys) if(GroupName == nil) then return end self:Debug("Spell "..SpellText.." In Group "..GroupName) MasterFrame:WrapScript(button,"OnClick","return Groups['".. PrefixList[Group.Index] .."'].Target") local Targets = Group.Targets for i=1,#Targets do --self:Print("*unit-"..Targets[i].State.." = "..Targets[i].Name) button:SetAttribute("*unit-"..Targets[i].State,Targets[i].Name) end end function GameCommandPro:SlashSpell(Params) self:MakeButton(Params,1) end function GameCommandPro:SlashGroupSpell(Params) local Keys,Group,SpellName = strsplit(",",Params) NextSpellGroupName = strtrim(Group) local OutParams = Keys .. "," .. SpellName -- self:Print("Group is " .. NextSpellGroupName) -- self:Print("Params are " .. OutParams) self:MakeButton(OutParams,1) end function GameCommandPro:SlashSlot(Params) self:MakeButton(Params,2) end function GameCommandPro:SlashMacro(Params) local Keys, MacroText = string.match(Params,"([^,]+),(.+)") MacroText = string.gsub(MacroText, "\\", "\n") MacroButtonsCount = MacroButtonsCount + 1 local MacroName = "GameCommandProMacroButton"..MacroButtonsCount local button = CreateFrame("Button", MacroName, nil, "SecureActionButtonTemplate"); button:SetAttribute("type", "macro"); button:SetAttribute("macrotext", MacroText); MacroButtons[MacroButtonsCount] = button SetBindingClick(Keys, MacroName, "") -- last is click, default is "LeftButton" self:Debug("Macro "..MacroText.." Bound To "..Keys) end GameCommandProSpells = {} function GameCommandPro:DumpSpells() GameCommanderProSpells = {} local LastSpell for i = 1,GetNumSpellTabs() do local PageName,Texture,Offset,NumSpells = GetSpellTabInfo(i) for j= 1,NumSpells do local SpellID = j + Offset local Name, Rank = GetSpellName(SpellID, "spell") local name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(Name .. "()") if castTime == nil then castTime = 0 end if(LastSpell ~= Name) then LastSpell = Name GameCommandProSpells["SPELL"..SpellID] = Name.. "(" .. castTime .. ")" end end end for k,v in pairs(GameCommandProSpells) do self:Print(v.."["..k.."]") end end function GameCommandPro:DebugMode() DebugMode = not DebugMode self:Debug("Debug Active") end local Locked = false function GameCommandPro:Lock() Locked = not Locked if (Locked) then local x = getglobal("GameCommandProForm") x:EnableMouse(false) local x = getglobal("GameCommandProEnemy") x:EnableMouse(false) self:Print("Locked") else local x = getglobal("GameCommandProForm") x:EnableMouse(true) local x = getglobal("GameCommandProEnemy") x:EnableMouse(true) self:Print("Unlocked") end end function GameCommandPro:RunLog() self:LoadData(); for _,line in ipairs(GameCommandProCommandLog) do -- self:Print("Command "..line) self:ProcSlashCommand(line) end self:Print(#GameCommandProCommandLog.." Commands Loaded") end GameCommandProHUDLabels = {" ", " ", " ", " ", " "} GameCommandProSortOrder = {} function GameCommandPro:ApplyHUDLabels() for i = 1,5 do local x = getglobal("GameCommandProFormHUDLabel"..i.."Label") x:SetText(GameCommandProHUDLabels[i]) end end function GameCommandPro:SetHUDLabel(params) GameCommandProHUDLabels[1], GameCommandProHUDLabels[2], GameCommandProHUDLabels[3], GameCommandProHUDLabels[4], GameCommandProHUDLabels[5] = strsplit(",",params) self:ApplyHUDLabels() end function GameCommandPro:CommandList() self:DoCommandList() end function GameCommandPro:SetSortOrder(params) local ToonName, Order = strsplit(",",params) ToonName = strupper(string.sub(ToonName, 1, 1))..strlower(string.sub(ToonName, 2)) GameCommandProSortOrder[ToonName] = Order self:Print(ToonName.." Will Be In Slot "..Order) end function GameCommandPro:SlashAbandonQuest(params) local i = GetQuestLogSelection() SelectQuestLogEntry(i) local questTitle, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily = GetQuestLogTitle(i) local Target = questTitle if (Solo) then self:SendCommMessage("GCP_Q",Target,"WHISPER",UnitName("player")) else self:SendCommMessage("GCP_Q",Target,"PARTY") end end function GameCommandPro:AbandonQuest(prefix,Target,distribution,sender) self:Print("Abandoning " .. Target .. "...") for i=1,GetNumQuestLogEntries() do local questTitle, level, questTag, suggestedGroup, isHeader, isCollapsed, isComplete, isDaily = GetQuestLogTitle(i) if questTitle == Target then SelectQuestLogEntry(i) SetAbandonQuest() AbandonQuest() self:Print("Done") end end end function GameCommandPro:SlashTest(params) local s = "\208\177\208\178\208\179\208\180\208\181\209\145\208\182" self:Print(s) --local body = GetMacroBody(params) --local s = "" --for i=1,strlen(body) do -- s = s .. string.byte(body,i) .."," --end --self:Print(s) end function GameCommandPro:Config() local x = getglobal("GameCommandProConfigPetBars") x:SetChecked(GameCommandProConfigValues["PetBars"]) x = getglobal("GameCommandProConfigBarLabels") x:SetChecked(GameCommandProConfigValues["BarLabels"]) x = getglobal("GameCommandProConfigCastingIndicators") x:SetChecked(GameCommandProConfigValues["CastingIndicators"]) x = getglobal("GameCommandProConfigStatusIndicators") x:SetChecked(GameCommandProConfigValues["StatusIndicators"]) x = getglobal("GameCommandProConfigHealth_ManaBars") x:SetChecked(GameCommandProConfigValues["Health_ManaBars"]) x = getglobal("GameCommandProConfigCastingBarNames") x:SetChecked(GameCommandProConfigValues["CastingBarNames"]) x = getglobal("GameCommandProConfigCastingBars") x:SetChecked(GameCommandProConfigValues["CastingBars"]) x = getglobal("GameCommandProConfigSpellNames") x:SetChecked(GameCommandProConfigValues["SpellNames"]) x = getglobal("GameCommandProConfigEnemyNumbers") x:SetChecked(GameCommandProConfigValues["EnemyNumbers"]) x = getglobal("GameCommandProConfigEnemyNames") x:SetChecked(GameCommandProConfigValues["EnemyNames"]) x = getglobal("GameCommandProConfigTargetofEnemy") x:SetChecked(GameCommandProConfigValues["TargetofEnemy"]) x = getglobal("GameCommandProConfigNextonThreat") x:SetChecked(GameCommandProConfigValues["NextonThreat"]) x = getglobal("GameCommandProConfigTargetNumbers") x:SetChecked(GameCommandProConfigValues["TargetNumbers"]) x = getglobal("GameCommandProConfigTargetsName") x:SetChecked(GameCommandProConfigValues["TargetsName"]) x = getglobal("GameCommandProConfigCCTime") x:SetChecked(GameCommandProConfigValues["CCTime"]) x = getglobal("GameCommandProConfigWarningsBuffs") x:SetChecked(GameCommandProConfigValues["WarningsBuffs"]) x = getglobal("GameCommandProConfigThreat") x:SetChecked(GameCommandProConfigValues["Threat"]) x = getglobal("GameCommandProConfig") x:Show() x:SetFrameStrata("TOOLTIP") end function GameCommandPro:Off() MyMaster = nil IAmMaster = false SwitchedOff = true self:Print("Off") end function GameCommandPro:On() SwitchedOff = false self:Print("On") end GameCommandProLockParty = {} function GameCommandPro:LockParty() SwitchedOff = true self:Print("Party Locked") GameCommandProLockParty = {} x = { } for i=1,#PartyInfo do self:Print("Saving " .. PartyInfo[i].Name) x [i] = PartyInfo[i] end GameCommandProLockParty["PartyInfo"] = x GameCommandProLockParty["IAmMaster"] = IAmMaster end function GameCommandPro:LoadParty() SwitchedOff = true x = GameCommandProLockParty["PartyInfo"] for i=1,#x do self:Print("Loading " .. x[i].Name) PartyInfo[i] = x [i] PartyInfo[i].Connected = false PartyInfo[i].LastRequest = nil end for i=1,#PartyInfo do self:Print("Mapping " .. PartyInfo[i].Name) local label = getglobal("GameCommandProFormLabel"..i.."Label") PartyMember = PartyInfo[i] label:SetText(PartyMember.Name) PartyMember.Ref = i PartyInfo[PartyInfo[i].Name] = PartyInfo end IAmMaster = GameCommandProLockParty["IAmMaster"] if(IAmMaster) then self:Print("Setup Display") GameCommandProForm:Show() GameCommandProEnemy:Show() self:TidyDisplay() self:ConfigApply() end self:Print("Done") end local FunctionList = { ["print"] = GameCommandPro.Print, ["status"] = GameCommandPro.SlashStatus, ["solo"] = GameCommandPro.SlashSolo, ["macro"] = GameCommandPro.SlashMacro, ["spell"] = GameCommandPro.SlashSpell, ["groupspell"] = GameCommandPro.SlashGroupSpell, ["slot"] = GameCommandPro.SlashSlot, ["nextgroup"] = GameCommandPro.SlashGroupSet, ["buffs"] = GameCommandPro.LearnBuffs, ["group"] = GameCommandPro.SlashGroup, ["debug"] = GameCommandPro.DebugMode, ["export"] = GameCommandPro.DumpSpells, ["lock"] = GameCommandPro.Lock, ["logmode"] = GameCommandPro.LogMode, ["runlog"] = GameCommandPro.RunLog, ["hudlabel"] = GameCommandPro.SetHUDLabel, ["help"] = GameCommandPro.CommandList, ["order"] = GameCommandPro.SetSortOrder, ["abandon"] = GameCommandPro.SlashAbandonQuest, ["auto"] = GameCommandPro.ToggleAutoAccept, ["test"] = GameCommandPro.SlashTest, ["config"] = GameCommandPro.Config, ["off"] = GameCommandPro.Off, ["on"] = GameCommandPro.On, ["lockparty"] = GameCommandPro.LockParty, ["loadparty"] = GameCommandPro.LoadParty, } function GameCommandPro:DoCommandList() self:Print("GCP Command Help - preceed all with /gcp ") self:Print("----------------------------------------") self:Print("print - - prints message to comms log") self:Print("solo - sets solo mode") self:Print("buffs - relearns buff status") self:Print("export - exports spells at next logoff") self:Print("debug - 1 = debig on,0 = debug off") self:Print("lock - toggles ability to move GCP windows (default locked)") self:Print("HUDLabel - Sets text at top of each column - seperate by comma") self:Print("order - ,Sequence - sets order of toons in GCP GUI") self:Print("abandon - all chars abandon quest in part leaders quest window") self:Print("auto - toggles auto quest acceptance (default on)") self:Print("config - shows configuration options") self:Print("off - turns off GCP") self:Print("on - turns on GCP") self:Print("lockparty - GCP ignores party changes - use /gcp on to revert") end function GameCommandPro:ProcSlashCommand(input) -- input contains stuff from command line following command if(input == "?") then self:DoCommandList() return end if strfind(input,"@") then for a in gmatch(input,"[^@]+") do self:Debug("Remote Call "..a) self:ProcSlashCommand(a) end return end local Command,Params = strmatch(input,"([^%s]+) (.+)") if (Params == nil) then Params = "1" Command = input end Command = strlower(Command) if (FunctionList[Command] == nil) then self:Debug("Command Not Known "..Command) return end self:Debug(input) FunctionList[Command](self,Params) end GameCommandPro:RegisterChatCommand("GCP","ProcSlashCommand") GameCommandPro:RegisterChatCommand("RL","DoRL") GameCommandPro:RegisterChatCommand("QUEST","ShowQuests") GameCommandPro:RegisterChatCommand("CB","DoCheckBuffs") local _, className = UnitClass("player"); if (className == "DRUID") then CCSpells[GetSpellInfo(2637)] = GetSpellInfo(2637) -- Hibernate CCSpells[GetSpellInfo(33786)] = GetSpellInfo(33786) -- Cyclone CCSpells[GetSpellInfo(339)] = GetSpellInfo(339) -- Entangling Roots elseif (className == "HUNTER") then CCSpells[GetSpellInfo(1513)] = GetSpellInfo(1513) -- Scare Beast CCSpells[GetSpellInfo(19386)] = GetSpellInfo(19386) -- Wyvern Sting CCSpells[GetSpellInfo(3355)] = GetSpellInfo(3355) -- Freezing Trap elseif (className == "MAGE") then CCSpells[GetSpellInfo(118)] = GetSpellInfo(118) -- Polymorph elseif (className == "PALADIN") then CCSpells[GetSpellInfo(20066)] = GetSpellInfo(20066) -- Repentance CCSpells[GetSpellInfo(10326)] = GetSpellInfo(10326) -- Turn Evil CCSpells[GetSpellInfo(19725)] = GetSpellInfo(19725) -- Turn Undead elseif (className == "PRIEST") then CCSpells[GetSpellInfo(9484)] = GetSpellInfo(9484) -- Shackle Undead elseif (className == "ROGUE") then CCSpells[GetSpellInfo(2094)] = GetSpellInfo(2094) -- Blind CCSpells[GetSpellInfo(6770)] = GetSpellInfo(6770) -- Sap elseif (className == "SHAMAN") then CCSpells[GetSpellInfo(2094)] = GetSpellInfo(51514) -- Hex elseif (className == "WARLOCK") then CCSpells[GetSpellInfo(710)] = GetSpellInfo(710) -- Banish CCSpells[GetSpellInfo(5782)] = GetSpellInfo(5782) -- Fear CCSpells[GetSpellInfo(6358)] = GetSpellInfo(6358) -- Seduction end function GameCommandPro:SetupMaster() MasterFrame = CreateFrame("Frame","GameCommandProSecureEnvironment",nil,"SecureHandlerBaseTemplate") MasterFrame:Execute("Groups = newtable()") for i = 1,8 do -- set up some defaults - these should be replaced with real groups, but will prevent nil issues MasterFrame:Execute("Groups['"..PrefixList[i].."'] = newtable()") MasterFrame:Execute("Groups['"..PrefixList[i].."'].Name = 'Group"..i.."'") MasterFrame:Execute("Groups['"..PrefixList[i].."'].Target = 'T1'") MasterFrame:Execute("Groups['"..PrefixList[i].."'].Targets = newtable()") MasterFrame:Execute("Groups['"..PrefixList[i].."'].TargetNames = newtable()") MasterFrame:Execute("Groups['"..PrefixList[i].."'].TargetRefs = newtable()") for j=1,8 do --self:Print("Group ID "..PrefixList[i].." Target "..PrefixList[j].." Mapped To "..j) MasterFrame:Execute("Groups['"..PrefixList[i].."'].Targets['"..PrefixList[j].."'] = 'T"..j.."'") MasterFrame:Execute("Groups['"..PrefixList[i].."'].TargetNames['"..PrefixList[j].."'] = '???'") MasterFrame:Execute("Groups['"..PrefixList[i].."'].TargetRefs['"..PrefixList[j].."'] = "..j) end -- set up control buttons local ButtonName = "GameCommandProStateSwitch"..i local Button = CreateFrame("Button",ButtonName,MasterFrame,"SecureActionButtonTemplate") local Keys = "`" if(PrefixList[i] ~= " ") then Keys = PrefixList[i]..Keys end MasterStateControl[i] = Button local Script = " Prefix = '"..PrefixList[i].."'\n" Script = Script .. " if (firstpress== nil) then\n" Script = Script .. " firstpress = Prefix\n" Script = Script .. " LastSetGroup = Groups[firstpress].Name\n" Script = Script .. " LastSetTarget = 'TBA'\n" Script = Script .. " LastSetRef = 0\n" Script = Script .. " else\n" Script = Script .. " Groups[firstpress].Target = Groups[firstpress].Targets[Prefix]\n" Script = Script .. " LastSetGroup = Groups[firstpress].Name\n" Script = Script .. " LastSetTarget = Groups[firstpress].TargetNames[Prefix]\n" Script = Script .. " LastSetRef = Groups[firstpress].TargetRefs[Prefix]\n" Script = Script .. " print(LastSetGroup .. ' Targeting ' .. LastSetTarget)\n" Script = Script .. " firstpress = nil\n" Script = Script .. " end\n" MasterFrame:WrapScript(Button,"OnClick",Script) SetBindingClick(Keys,ButtonName) self:Debug(Keys.."Bound To "..ButtonName) end self:Print("Secure Environment Initialized") end