annotate CensusPlusProfiler.lua @ 21:1aeab8164ef5

Merge 3rd try
author EmFor
date Sun, 14 Aug 2011 17:21:31 +0200
parents 10c85be19b56
children
rev   line source
EmFor@6 1 --[[
EmFor@6 2 CensusPlus for World of Warcraft(tm).
EmFor@6 3
EmFor@6 4 Copyright 2005 - 2006 Cooper Sellers and WarcraftRealms.com
EmFor@6 5
EmFor@6 6 License:
EmFor@6 7 This program is free software; you can redistribute it and/or
EmFor@6 8 modify it under the terms of the GNU General Public License
EmFor@6 9 as published by the Free Software Foundation; either version 2
EmFor@6 10 of the License, or (at your option) any later version.
EmFor@6 11
EmFor@6 12 This program is distributed in the hope that it will be useful,
EmFor@6 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
EmFor@6 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
EmFor@6 15 GNU General Public License for more details.
EmFor@6 16
EmFor@6 17 You should have received a copy of the GNU General Public License
EmFor@6 18 along with this program(see GLP.txt); if not, write to the Free Software
EmFor@6 19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
EmFor@6 20 ]]
EmFor@0 21
EmFor@0 22
EmFor@0 23 CensusPlus_DoThisCharacter = false;
EmFor@0 24 CensusPlus_Profile = {};
EmFor@0 25 CensusPlus_Profile[GetCVar("realmName")] = {} ;
EmFor@0 26 local myCPProfile_LOADED = nil; -- Successful load of the script
EmFor@0 27
EmFor@0 28 -- //////////////////////////////////////////////
EmFor@0 29 -- Configuration Variables
EmFor@0 30 -- //////////////////////////////////////////////
EmFor@0 31 -- set to nil to disable any of the following
EmFor@0 32
EmFor@0 33 myCPProfile_ENABLED = 0; -- Enable the profiler?
EmFor@0 34
EmFor@0 35 local myCPProfile_DoScanInventory = 0; -- get inventory?
EmFor@0 36 local myCPProfile_DoScanBank = 0; -- get bank?
EmFor@0 37 local myCPProfile_DoScanEquipment = 0; -- get equipment?
EmFor@0 38 local myCPProfile_DoScanSkills = 0; -- get skills?
EmFor@0 39 local myCPProfile_DoScanTalents = 0; -- get talents?
EmFor@0 40 local myCPProfile_DoScanProfessions = 0; -- output known tradeskill recipies
EmFor@0 41 local myCPProfile_DoScanReputation = 0; -- get reputation?
EmFor@0 42 local myCPProfile_DoScanQuestLog = 0; -- get quests?
EmFor@0 43 local myCPProfile_DoScanHonor = 0; -- get honor?
EmFor@0 44
EmFor@0 45 local myCPProfile_HTML_Tooltips = 1; -- make html tooltips (non-array format) - separate lines with <br>
EmFor@0 46 local myCPProfile_TALENTS_Full = 1; -- output all talents and tooltips
EmFor@0 47
EmFor@0 48
EmFor@0 49 local myCPProfile_DEBUG = 1; -- enable debugging? unused at this time
EmFor@0 50 local myCPProfile_ALLEVENTS = nil; -- enable all event catching? for debugging only
EmFor@0 51
EmFor@0 52 -- //////////////////////////////////////////////
EmFor@0 53
EmFor@0 54 local TradeSkillDifficultyCode = {};
EmFor@0 55 TradeSkillDifficultyCode['optimal'] = 4;
EmFor@0 56 TradeSkillDifficultyCode['medium'] = 3;
EmFor@0 57 TradeSkillDifficultyCode['easy'] = 2;
EmFor@0 58 TradeSkillDifficultyCode['trivial'] = 1;
EmFor@0 59 TradeSkillDifficultyCode['header'] = 0;
EmFor@0 60
EmFor@0 61 local myCPProfile_VERSION = "1.0.0"; -- this only changes when a new variable is added to the output
EmFor@0 62
EmFor@0 63 local timePlayed = -1;
EmFor@0 64 local timeLevelPlayed = -1;
EmFor@0 65
EmFor@0 66 -- array of inventory slot names
EmFor@0 67 local Profile_slots = {
EmFor@0 68 "Head", -- 1
EmFor@0 69 "Neck", -- 2
EmFor@0 70 "Shoulder", -- 3
EmFor@0 71 "Shirt", -- 4
EmFor@0 72 "Chest", -- 5
EmFor@0 73 "Waist", -- 6
EmFor@0 74 "Legs", -- 7
EmFor@0 75 "Feet", -- 8
EmFor@0 76 "Wrist", -- 9
EmFor@0 77 "Hands", -- 10
EmFor@0 78 "Finger0", -- 11
EmFor@0 79 "Finger1", -- 12
EmFor@0 80 "Trinket0", -- 13
EmFor@0 81 "Trinket1", -- 14
EmFor@0 82 "Back", -- 15
EmFor@0 83 "MainHand", -- 16
EmFor@0 84 "SecondaryHand", -- 17
EmFor@0 85 "Ranged", -- 18
EmFor@0 86 "Tabard", -- 19
EmFor@0 87 };
EmFor@0 88
EmFor@0 89 function CP_ProfileFrame_OnLoad()
EmFor@6 90
EmFor@6 91 -- Shut it down for now
EmFor@6 92 if( true ) then
EmFor@6 93 return;
EmFor@6 94 end
EmFor@0 95 this:RegisterEvent("VARIABLES_LOADED");
EmFor@0 96 if ( myCPProfile_ALLEVENTS ) then -- unused, but keep for testing
EmFor@0 97 this:RegisterEvent("PLAYER_GUILD_UPDATE");
EmFor@0 98 this:RegisterEvent("UNIT_INVENTORY_CHANGED");
EmFor@0 99 this:RegisterEvent("VARIABLES_LOADED");
EmFor@0 100 this:RegisterEvent("TRAINER_CLOSED");
EmFor@0 101 this:RegisterEvent("PLAYER_LEVEL_UP");
EmFor@0 102 end
EmFor@0 103 this:RegisterEvent("TIME_PLAYED_MSG");
EmFor@0 104 this:RegisterEvent("BANKFRAME_CLOSED"); -- 12/17, was OPENED, will it work with closed only?
EmFor@0 105
EmFor@0 106 this:RegisterEvent("TRADE_SKILL_SHOW");
EmFor@0 107 this:RegisterEvent("CRAFT_SHOW");
EmFor@0 108 end
EmFor@0 109
EmFor@0 110 -- since PLAYER_QUITTING and PLAYER_CAMPING events don't work, hook the functions
EmFor@0 111 -- NOTE: Due to server lag, this could be a cause of the client not actually logging the character out until the server catches up
EmFor@0 112 --[[
EmFor@0 113 oldLogout = Logout;
EmFor@0 114 oldQuit = Quit;
EmFor@0 115 function Quit()
EmFor@0 116 RequestTimePlayed();
EmFor@0 117 oldQuit();
EmFor@0 118 end
EmFor@0 119 function Logout()
EmFor@0 120 RequestTimePlayed();
EmFor@0 121 oldLogout();
EmFor@0 122 end
EmFor@0 123 ]]--
EmFor@0 124
EmFor@0 125 function CP_ProfileFrame_OnEvent(event, arg1, arg2)
EmFor@6 126
EmFor@0 127 -- crapout if we're not ready to process, or if not enabled
EmFor@0 128 if ( ( event == "UNIT_INVENTORY_CHANGED" and arg1 ~= "player" ) or not myCPProfile_ENABLED or not UnitName("player") or UnitName("player") == UNKNOWNOBJECT or not GetCVar("realmName") or not CensusPlus_DoThisCharacter ) then
EmFor@0 129 return;
EmFor@0 130 end
EmFor@0 131
EmFor@0 132 -- CensusPlus_Msg( "PROF TEST : " .. event );
EmFor@0 133
EmFor@0 134 -- Got a unit name, now we're loaded
EmFor@0 135 if (event == "VARIABLES_LOADED" and not myCPProfile_LOADED) then
EmFor@0 136 myCPProfile_LOADED = 1;
EmFor@0 137 PaperDollFrame_SetDamage();
EmFor@0 138 PaperDollFrame_SetRangedDamage();
EmFor@0 139 elseif (event == "VARIABLES_LOADED" and myCPProfile_LOADED) then
EmFor@0 140 return;
EmFor@0 141 end
EmFor@0 142
EmFor@0 143 if (event == "TIME_PLAYED_MSG") then
EmFor@0 144 timePlayed = arg1;
EmFor@0 145 timeLevelPlayed = arg2;
EmFor@0 146 end
EmFor@0 147
EmFor@0 148 -- Event hit, process profile
EmFor@0 149 if (myCPProfile_LOADED) then
EmFor@0 150 Profile_InitProfile(); -- Always do this first, creates a profile is it doesn't exist
EmFor@0 151
EmFor@0 152 if( ( event == "BANKFRAME_CLOSED" or event == "BANKFRAME_OPENED" or event == "PLAYERBANKSLOTS_CHANGED" ) and myCPProfile_DoScanBank ) then
EmFor@0 153 Profile_ScanBank();
EmFor@0 154 CP_ProfHidden:ClearLines();
EmFor@0 155 CP_ProfHidden:Hide();
EmFor@0 156 return;
EmFor@0 157 end
EmFor@0 158 if ( not myCPProfile_DoScanBank and CensusPlus_Profile[GetCVar("realmName")][UnitName("player")] ) then
EmFor@0 159 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"] = nil;
EmFor@0 160 end
EmFor@0 161 if ( myCPProfile_DoScanProfessions ) then
EmFor@0 162 if ( event == "TRADE_SKILL_SHOW" ) then
EmFor@0 163 Profile_ScanTradeSkill();
EmFor@0 164 CP_ProfHidden:ClearLines();
EmFor@0 165 CP_ProfHidden:Hide();
EmFor@0 166 return;
EmFor@0 167 end
EmFor@0 168
EmFor@0 169 if ( event == "CRAFT_SHOW" ) then
EmFor@0 170 Profile_ScanCraft();
EmFor@0 171 CP_ProfHidden:ClearLines();
EmFor@0 172 CP_ProfHidden:Hide();
EmFor@0 173 return;
EmFor@0 174 end
EmFor@0 175 elseif ( CensusPlus_Profile[GetCVar("realmName")][UnitName("player")] ) then
EmFor@0 176 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"] = nil;
EmFor@0 177 end
EmFor@0 178
EmFor@0 179 CP_ProfHidden:ClearLines();
EmFor@0 180 CP_ProfHidden:Hide();
EmFor@0 181 end
EmFor@0 182 end
EmFor@0 183
EmFor@0 184 function Profile_InitProfile()
EmFor@0 185 if ( not CensusPlus_Profile ) then
EmFor@0 186 CensusPlus_Profile = {};
EmFor@0 187 end
EmFor@0 188
EmFor@0 189 if ( not CensusPlus_Profile[GetCVar("realmName")] ) then
EmFor@0 190 CensusPlus_Profile[GetCVar("realmName")] = {};
EmFor@0 191 end
EmFor@0 192
EmFor@0 193 if ( not CensusPlus_Profile[GetCVar("realmName")][UnitName("player")] ) then
EmFor@0 194 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")] = {};
EmFor@0 195 else
EmFor@0 196 local tmpBank = CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"];
EmFor@0 197 local tmpProfessions = CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"];
EmFor@0 198
EmFor@0 199 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")] = { };
EmFor@0 200 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"] = tmpBank;
EmFor@0 201 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"] = tmpProfessions;
EmFor@0 202 end
EmFor@0 203
EmFor@0 204 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["ProfilerVersion"] = myCPProfile_VERSION; -- keep track of version and don't work with old data
EmFor@0 205 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Name"] = playerName;
EmFor@0 206
EmFor@0 207 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["DateUpdated"] = date();
EmFor@0 208 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["TimePlayed"] = timePlayed;
EmFor@0 209 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["TimeLevelPlayed"] = timeLevelPlayed;
EmFor@0 210
EmFor@0 211 local sex = "";
EmFor@0 212 if (UnitSex("player") == 0) then
EmFor@0 213 sex = "Male";
EmFor@0 214 else
EmFor@0 215 sex = "Female";
EmFor@0 216 end
EmFor@0 217 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Sex"] = sex;
EmFor@0 218 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Race"] = UnitRace("player");
EmFor@0 219 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Class"] = UnitClass("player");
EmFor@0 220 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Level"] = UnitLevel("player");
EmFor@0 221 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Guild"] = {} ;
EmFor@0 222 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Guild"]["GuildName"], CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Guild"]["Title"], CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Guild"]["Rank"] = GetGuildInfo("player");
EmFor@0 223 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Server"] = GetCVar("realmName");
EmFor@0 224 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["TalentPoints"] = UnitCharacterPoints("player");
EmFor@0 225 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Zone"] = GetZoneText();
EmFor@0 226 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["SubZone"] = GetSubZoneText();
EmFor@0 227
EmFor@0 228 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Experience"] = UnitXP("player") .. ":" .. UnitXPMax("player");
EmFor@0 229
EmFor@0 230 local money = GetMoney();
EmFor@0 231 local gold = floor(money / (COPPER_PER_SILVER * SILVER_PER_GOLD));
EmFor@0 232 local silver = floor((money - (gold * COPPER_PER_SILVER * SILVER_PER_GOLD)) / COPPER_PER_SILVER);
EmFor@0 233 local copper = mod(money, COPPER_PER_SILVER);
EmFor@0 234
EmFor@0 235 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Money"] = {};
EmFor@0 236 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Money"]["Gold"] = gold;
EmFor@0 237 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Money"]["Silver"] = silver;
EmFor@0 238 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Money"]["Copper"] = copper;
EmFor@0 239
EmFor@0 240 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Stats"] = {};
EmFor@0 241
EmFor@0 242 -- "stat" is the same as effectiveStat...
EmFor@0 243 -- problem here is if they have a debuff spell on, the values saved will be wrong
EmFor@0 244 local stat, effectiveStat, posBuff, negBuff = UnitStat("player", 1);
EmFor@0 245 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Stats"]["Strength"] = (stat - posBuff - negBuff) .. ":" .. effectiveStat .. ":" .. posBuff .. ":" .. negBuff;
EmFor@0 246 stat, effectiveStat, posBuff, negBuff = UnitStat("player", 2);
EmFor@0 247 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Stats"]["Agility"] = (stat - posBuff - negBuff) .. ":" .. effectiveStat .. ":" .. posBuff .. ":" .. negBuff;
EmFor@0 248 stat, effectiveStat, posBuff, negBuff = UnitStat("player", 3);
EmFor@0 249 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Stats"]["Stamina"] = (stat - posBuff - negBuff) .. ":" .. effectiveStat .. ":" .. posBuff .. ":" .. negBuff;
EmFor@0 250 stat, effectiveStat, posBuff, negBuff = UnitStat("player", 4);
EmFor@0 251 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Stats"]["Intellect"] = (stat - posBuff - negBuff) .. ":" .. effectiveStat .. ":" .. posBuff .. ":" .. negBuff;
EmFor@0 252 stat, effectiveStat, posBuff, negBuff = UnitStat("player", 5);
EmFor@0 253 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Stats"]["Spirit"] = (stat - posBuff - negBuff) .. ":" .. effectiveStat .. ":" .. posBuff .. ":" .. negBuff;
EmFor@0 254
EmFor@0 255 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Resists"] = {};
EmFor@0 256 local base, resistance, positive, negative = UnitResistance("player", 6);
EmFor@0 257 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Resists"]["Arcane"] = base .. ":" .. resistance .. ":" .. positive .. ":" .. negative;
EmFor@0 258 base, resistance, positive, negative = UnitResistance("player", 2);
EmFor@0 259 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Resists"]["Fire"] = base .. ":" .. resistance .. ":" .. positive .. ":" .. negative;
EmFor@0 260 base, resistance, positive, negative = UnitResistance("player", 3);
EmFor@0 261 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Resists"]["Nature"] = base .. ":" .. resistance .. ":" .. positive .. ":" .. negative;
EmFor@0 262 base, resistance, positive, negative = UnitResistance("player", 4);
EmFor@0 263 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Resists"]["Frost"] = base .. ":" .. resistance .. ":" .. positive .. ":" .. negative;
EmFor@0 264 base, resistance, positive, negative = UnitResistance("player", 5);
EmFor@0 265 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Resists"]["Shadow"] = base .. ":" .. resistance .. ":" .. positive .. ":" .. negative;
EmFor@0 266
EmFor@0 267 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Mana"] = UnitManaMax("player");
EmFor@0 268 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Health"] = UnitHealthMax("player");
EmFor@0 269 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Defense"] = UnitDefense("player");
EmFor@0 270
EmFor@0 271 local baseArm, effectiveArmor, armor, positiveArm, negativeArm = UnitArmor("player");
EmFor@0 272 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Armor"] = baseArm .. ":" .. (baseArm + positiveArm) .. ":" .. positiveArm .. ":" .. negativeArm; -- if they have a debuf on, don't save it
EmFor@0 273
EmFor@0 274 local minDamage, maxDamage, physicalBonusPos, physicalBonusNeg, percent = UnitDamage("player");
EmFor@0 275 -- local baseDamage = (minDamage + maxDamage) * 0.5;
EmFor@0 276 -- local fullDamage = (baseDamage + physicalBonusPos + physicalBonusNeg) * percent;
EmFor@0 277 -- local totalBonus = (fullDamage - baseDamage);
EmFor@0 278 -- local displayMin = floor(minDamage + totalBonus);
EmFor@0 279 -- local displayMax = ceil(maxDamage + totalBonus);
EmFor@0 280
EmFor@0 281 CP_ProfHidden:SetOwner(CensusPlus_ProfileFrame, "ANCHOR_CURSOR");
EmFor@0 282
EmFor@0 283 CP_ProfHidden:SetText(INVTYPE_WEAPONMAINHAND, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 284 CP_ProfHidden:AddDoubleLine(ATTACK_SPEED_COLON, string.format("%.2f", CharacterDamageFrame.attackSpeed), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 285 CP_ProfHidden:AddDoubleLine(DAMAGE_COLON, CharacterDamageFrame.damage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 286 CP_ProfHidden:AddDoubleLine(DAMAGE_PER_SECOND, string.format("%.1f", CharacterDamageFrame.dps), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 287 -- Check for offhand weapon
EmFor@0 288 if ( CharacterDamageFrame.offhandAttackSpeed ) then
EmFor@0 289 CP_ProfHidden:AddLine("<br>");
EmFor@0 290 CP_ProfHidden:AddLine(INVTYPE_WEAPONOFFHAND, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 291 CP_ProfHidden:AddDoubleLine(ATTACK_SPEED_COLON, string.format("%.2f", CharacterDamageFrame.offhandAttackSpeed), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 292 CP_ProfHidden:AddDoubleLine(DAMAGE_COLON, CharacterDamageFrame.offhandDamage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 293 CP_ProfHidden:AddDoubleLine(DAMAGE_PER_SECOND, string.format("%.1f", CharacterDamageFrame.offhandDps), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 294 end
EmFor@0 295
EmFor@0 296 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Melee Attack"] = {};
EmFor@0 297 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Melee Attack"]["AttackRating"] = UnitAttackBothHands("player");
EmFor@0 298 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Melee Attack"]["DamageRange"] = floor(minDamage) .. ":" .. ceil(maxDamage);
EmFor@0 299 local base, posBuff, negBuff = UnitAttackPower("player");
EmFor@0 300 local effective = base + posBuff + negBuff;
EmFor@0 301 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Melee Attack"]["AttackPower"] = base .. ":" .. effective .. ":" .. posBuff .. ":" .. negBuff;
EmFor@0 302 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Melee Attack"]["DamageRangeTooltip"] = CP_Tooltipscan();
EmFor@0 303 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Melee Attack"]["AttackPowerTooltip"] = CharacterAttackPowerFrame.tooltipSubtext;
EmFor@0 304
EmFor@0 305 -- Ranged not saved if there is no ranged weapon equipped
EmFor@0 306 if ( PaperDollFrame.noRanged ) then
EmFor@0 307 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Ranged Attack"] = nil;
EmFor@0 308 else
EmFor@0 309 CP_ProfHidden:SetText(INVTYPE_RANGED, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 310 CP_ProfHidden:AddDoubleLine(ATTACK_SPEED_COLON, string.format("%.2f", CharacterRangedDamageFrame.attackSpeed), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 311 CP_ProfHidden:AddDoubleLine(DAMAGE_COLON, CharacterRangedDamageFrame.damage, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 312 CP_ProfHidden:AddDoubleLine(DAMAGE_PER_SECOND, string.format("%.1f", CharacterRangedDamageFrame.dps), NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b);
EmFor@0 313
EmFor@0 314 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Ranged Attack"] = {};
EmFor@0 315 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Ranged Attack"]["AttackPowerTooltip"] = CharacterRangedAttackPowerFrame.tooltipSubtext;
EmFor@0 316 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Ranged Attack"]["DamageRangeTooltip"] = CP_Tooltipscan();
EmFor@0 317
EmFor@0 318 local RangeSpeeed, RangeMinDMG,RangeMaxDMG = UnitRangedDamage("player");
EmFor@0 319 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Ranged Attack"]["DamageRange"] = max(floor(RangeMinDMG),1) .. ":" .. max(ceil(RangeMaxDMG),1);
EmFor@0 320 local base, pos, neg = UnitRangedAttackPower("player");
EmFor@0 321 local effective = base + pos + neg;
EmFor@0 322 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Ranged Attack"]["AttackPower"] = base .. ":" .. effective .. ":" .. pos .. ":" .. neg;
EmFor@0 323 local base, pos, neg = UnitRangedAttack("player");
EmFor@0 324 if (not neg) then neg = 0; end;
EmFor@0 325 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Ranged Attack"]["AttackRating"] = base;
EmFor@0 326 end
EmFor@0 327
EmFor@0 328 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["DodgePercent"] = strsub(GetDodgeChance(), 0, 5);
EmFor@0 329 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["ParryPercent"] = strsub(GetParryChance(), 0, 5);
EmFor@0 330 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["BlockPercent"] = strsub(GetBlockChance(), 0, 5);
EmFor@0 331
EmFor@0 332 local MainAC, EffAC, AC, PosAC, NegAC = UnitArmor("player");
EmFor@0 333 local Level = UnitLevel("player");
EmFor@0 334 local Mitigation = (EffAC)/((85 * Level)+400);
EmFor@0 335 Mitigation = 100 * (Mitigation/(Mitigation + 1));
EmFor@0 336 Mitigation = strsub(Mitigation, 0, 5);
EmFor@0 337 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["MitigationPercent"] = Mitigation;
EmFor@0 338
EmFor@0 339 local spellIndex = 1;
EmFor@0 340 local spellName, subSpellName = GetSpellName(spellIndex,BOOKTYPE_SPELL);
EmFor@0 341 local tmpStr = nil;
EmFor@0 342 while spellName do
EmFor@0 343 if (spellName == "Attack") then
EmFor@0 344 CP_ProfHidden:SetSpell(spellIndex, BOOKTYPE_SPELL);
EmFor@0 345 if( CP_Tooltipscan() ~= nil ) then
EmFor@0 346 tmpStr = string.gsub(CP_Tooltipscan(), ".*<br/?>(%d?%d?%d%.%d%d?)%%.*", "%1");
EmFor@0 347 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["CritPercent"] = tmpStr;
EmFor@0 348 end
EmFor@0 349 end
EmFor@0 350 spellIndex = spellIndex + 1;
EmFor@0 351 spellName,subSpellName = nil;
EmFor@0 352 spellName,subSpellName = GetSpellName(spellIndex,BOOKTYPE_SPELL);
EmFor@0 353 end
EmFor@0 354 --[[
EmFor@6 355 local speed, offhandSpeed = UnitAttackSpeed("player");
EmFor@6 356 local minDamage, maxDamage, minOffHandDamage, maxOffHandDamage, physicalBonusPos, physicalBonusNeg, percent = UnitDamage("player");
EmFor@6 357 local baseDamage = (minDamage + maxDamage) * 0.5;
EmFor@6 358 local fullDamage = (baseDamage + physicalBonusPos + physicalBonusNeg) * percent;
EmFor@6 359 local damagePerSecond = max( fullDamage, 1 ) / speed;
EmFor@6 360 minDamage = max( floor( minDamage ), 1 );
EmFor@6 361 maxDamage = max( ceil( maxDamage ),1 );
EmFor@6 362 speed = string.format( "%.2f", speed );
EmFor@6 363 damagePerSecond = string.format( "%.1f", damagePerSecond );
EmFor@6 364 local damagerange = minDamage.." - "..maxDamage;
EmFor@6 365 local output = INVTYPE_WEAPONMAINHAND .. "<br>"
EmFor@6 366 .. ATTACK_SPEED_COLON .. speed .. "<br>"
EmFor@6 367 .. DAMAGE_COLON .. damagerange .. "<br>"
EmFor@6 368 .. DAMAGE_PER_SECOND .. damagePerSecond
EmFor@6 369 if ( offhandSpeed ) then
EmFor@6 370 local offhandBaseDamage = (minOffHandDamage + maxOffHandDamage) * 0.5;
EmFor@6 371 local offhandFullDamage = (offhandBaseDamage + physicalBonusPos + physicalBonusNeg) * percent;
EmFor@6 372 local offhandDamagePerSecond = (max(offhandFullDamage,1) / offhandSpeed);
EmFor@6 373 minOffHandDamage=max(floor(minOffHandDamage),1);
EmFor@6 374 maxOffHandDamage=max(ceil(maxOffHandDamage),1);
EmFor@6 375 local damagerange = minOffHandDamage.." - "..maxOffHandDamage;
EmFor@6 376 offhandDamagePerSecond = string.format( "%.1f", offhandDamagePerSecond );
EmFor@6 377 offhandSpeed=string.format("%.2f", offhandSpeed);
EmFor@6 378 output = output .. INVTYPE_WEAPONOFFHAND .. "<br>"
EmFor@6 379 .. ATTACK_SPEED_COLON .. offhandSpeed .. "<br>"
EmFor@6 380 .. DAMAGE_COLON .. damagerange .. "<br>"
EmFor@6 381 .. DAMAGE_PER_SECOND .. offhandDamagePerSecond;
EmFor@6 382 end
EmFor@6 383 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Melee Attack"]["DamageRangeTooltip"] = output;
EmFor@6 384
EmFor@6 385 local speed, minDamage, maxDamage = UnitRangedDamage("player");
EmFor@6 386 minDamage = (minDamage / percent) - physicalBonusPos - physicalBonusNeg;
EmFor@6 387 maxDamage = (maxDamage / percent) - physicalBonusPos - physicalBonusNeg;
EmFor@6 388 local baseDamage = (minDamage + maxDamage) * 0.5;
EmFor@6 389 local fullDamage = (baseDamage + physicalBonusPos + physicalBonusNeg) * percent;
EmFor@6 390 local damagePerSecond = (max(fullDamage,1) / speed);
EmFor@6 391 minDamage = max(floor(minDamage),1);
EmFor@6 392 maxDamage = max(ceil(maxDamage),1);
EmFor@6 393 speed=string.format("%.2f", speed);
EmFor@6 394 damagePerSecond=string.format("%.1f", damagePerSecond);
EmFor@6 395 local damagerange = max(floor(minDamage),1).." - "..max(ceil(maxDamage),1);
EmFor@6 396 output = INVTYPE_RANGED .. "<br>"
EmFor@6 397 .. ATTACK_SPEED_COLON .. speed .. "<br>"
EmFor@6 398 .. DAMAGE_COLON .. damagerange .. "<br>"
EmFor@6 399 .. DAMAGE_PER_SECOND .. damagePerSecond;
EmFor@6 400 local base,pos,neg=UnitRangedAttack( "player" );
EmFor@6 401 if(base==0) then
EmFor@6 402 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Ranged Attack"]["DamageRangeTooltip"] = "";
EmFor@6 403 else
EmFor@6 404 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Ranged Attack"]["DamageRangeTooltip"] = output;
EmFor@6 405 end
EmFor@0 406 ]]--
EmFor@0 407 -- put in dps?
EmFor@0 408
EmFor@0 409 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Locale"] = GetLocale();
EmFor@0 410 Profile_DoBuffs();
EmFor@0 411
EmFor@0 412 if ( myCPProfile_DoScanSkills ) then
EmFor@0 413 Profile_GetSkills();
EmFor@0 414 end
EmFor@0 415 if ( myCPProfile_DoScanEquipment) then
EmFor@0 416 Profile_UpdateInventory();
EmFor@0 417 end
EmFor@0 418 if ( myCPProfile_DoScanInventory ) then
EmFor@0 419 Profile_ScanInventory();
EmFor@0 420 end
EmFor@0 421 if ( myCPProfile_DoScanTalents and UnitLevel("player") > 9 ) then
EmFor@0 422 Profile_GetTalents();
EmFor@0 423 end
EmFor@0 424 if ( myCPProfile_DoScanReputation ) then
EmFor@0 425 Profile_ScanReputation();
EmFor@0 426 end
EmFor@0 427 if ( myCPProfile_DoScanQuestLog ) then
EmFor@0 428 Profile_ScanQuests();
EmFor@0 429 end
EmFor@0 430 if ( myCPProfile_DoScanHonor ) then
EmFor@0 431 Profile_ScanHonor();
EmFor@0 432 end
EmFor@0 433 end
EmFor@0 434
EmFor@0 435 function Profile_ScanQuests()
EmFor@0 436 local header = "Unknown";
EmFor@0 437
EmFor@0 438 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Quests"] = {};
EmFor@0 439 local slot = 1;
EmFor@0 440 for i=1, GetNumQuestLogEntries(), 1 do
EmFor@0 441 local text, level, questtag, isHeader, isCollapsed = GetQuestLogTitle(i);
EmFor@0 442 if ( isHeader ) then
EmFor@0 443 header = text;
EmFor@0 444 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Quests"][header] = {}
EmFor@0 445 else
EmFor@0 446 if ( text ) then
EmFor@0 447 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Quests"][header][slot] = {}
EmFor@0 448 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Quests"][header][slot]["Title"] = text;
EmFor@0 449 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Quests"][header][slot]["Level"] = level;
EmFor@0 450 if ( questtag ) then
EmFor@0 451 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Quests"][header][slot]["Tag"] = questtag;
EmFor@0 452 end
EmFor@0 453 end
EmFor@0 454 slot = slot + 1;
EmFor@0 455 end
EmFor@0 456 end
EmFor@0 457 end
EmFor@0 458
EmFor@0 459 function Profile_ScanHonor()
EmFor@0 460 -- save the honor data
EmFor@0 461 local lastweekHK, lastweekDK, lastweekContribution, lastweekRank = GetPVPLastWeekStats();
EmFor@0 462 local lifetimeHK, lifetimeDK, lifetimeHighestRank = GetPVPLifetimeStats();
EmFor@0 463 local sessionHK, sessionDK = GetPVPSessionStats();
EmFor@0 464 local yesterdayHK, yesterdayDK, yesterdayContribution = GetPVPYesterdayStats();
EmFor@0 465 local lifetimeRankName, lifetimeRankNumber = GetPVPRankInfo(lifetimeHighestRank);
EmFor@0 466 if ( not lifetimeRankName ) then
EmFor@0 467 lifetimeRankName = NONE;
EmFor@0 468 end
EmFor@0 469
EmFor@0 470 local rankName, rankNumber = GetPVPRankInfo(UnitPVPRank("player"));
EmFor@0 471 if ( not rankName ) then
EmFor@0 472 rankName = NONE;
EmFor@0 473 end
EmFor@0 474 local rankInfo = "("..RANK.." "..rankNumber..")";
EmFor@0 475
EmFor@0 476 -- set icon
EmFor@0 477 local rankIcon = "";
EmFor@0 478 if ( rankNumber > 0 ) then
EmFor@0 479 rankIcon = string.format("%s%02d","Interface\\PvPRankBadges\\PvPRank", rankNumber);
EmFor@0 480 end
EmFor@0 481
EmFor@0 482 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"] = {} ;
EmFor@0 483 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["LifetimeHighestRank"] = lifetimeHighestRank;
EmFor@0 484 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["LifetimeRankName"] = lifetimeRankName;
EmFor@0 485 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["LifetimeHK"] = lifetimeHK;
EmFor@0 486 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["LifetimeDK"] = lifetimeDK;
EmFor@0 487 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["SessionHK"] = sessionHK;
EmFor@0 488 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["SessionDK"] = sessionDK;
EmFor@0 489 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["YesterdayHK"] = yesterdayHK;
EmFor@0 490 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["YesterdayDK"] = yesterdayDK;
EmFor@0 491 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["YesterdayContribution"] = yesterdayContribution;
EmFor@0 492 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["LastWeekHK"] = lastweekHK;
EmFor@0 493 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["LastWeekDK"] = lastweekDK;
EmFor@0 494 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["LastWeekContribution"] = lastweekContribution;
EmFor@0 495 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["LastWeekRank"] = lastweekRank;
EmFor@0 496 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["RankName"] = rankName;
EmFor@0 497 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["RankInfo"] = rankInfo;
EmFor@0 498 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Honor"]["RankIcon"] = rankIcon;
EmFor@0 499 end
EmFor@0 500
EmFor@0 501
EmFor@0 502 function Profile_ScanReputation() -- Originally by Leronflon, modified to fit my style =)
EmFor@0 503 local count;
EmFor@0 504 local name, standing, rep, atWar, canToggle, foo2, foo3, thisHeader, isHeader;
EmFor@0 505
EmFor@0 506 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Reputation"] = {};
EmFor@0 507
EmFor@0 508 count = GetNumFactions();
EmFor@0 509
EmFor@0 510 if( count == nil ) then
EmFor@0 511 return;
EmFor@0 512 end
EmFor@0 513
EmFor@0 514 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Reputation"]["Count"] = count;
EmFor@0 515
EmFor@0 516 local Units = { };
EmFor@0 517 Units[1] = 36000; -- Hated
EmFor@0 518 Units[2] = 3000; -- Hostile
EmFor@0 519 Units[3] = 3000; -- Unfriendly
EmFor@0 520 Units[4] = 3000; -- Neutral
EmFor@0 521 Units[5] = 6000; -- Friendly
EmFor@0 522 Units[6] = 12000; -- Honored
EmFor@0 523 Units[7] = 21000; -- Revered
EmFor@0 524 Units[8] = 1000; -- Exaulted
EmFor@0 525
EmFor@0 526 local ReputationKey = { [0] = "Unknown", [1] = "Hated", [2] = "Hostile", [3] = "Unfriendly", [4] = "Neutral", [5] = "Friendly", [6] = "Honored", [7] = "Revered", [8] = "Exaulted" };
EmFor@0 527
EmFor@0 528
EmFor@0 529 thisHeader = "none";
EmFor@0 530 for i = 1, count do
EmFor@0 531 name, description, standing, barValue, atWar, canToggle, isHeader, isCollapsed = GetFactionInfo(i);
EmFor@0 532
EmFor@0 533 if( name ~= nil ) then
EmFor@0 534 if (atWar == nil) then
EmFor@0 535 atWar = 0;
EmFor@0 536 end
EmFor@0 537 if (rep == nil) then
EmFor@0 538 rep = 0;
EmFor@0 539 end
EmFor@0 540 if (standing == nil) then
EmFor@0 541 standing = 0;
EmFor@0 542 end
EmFor@0 543 if (isHeader == nil ) then
EmFor@0 544 thisHeader = name;
EmFor@0 545 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Reputation"][thisHeader] = {};
EmFor@0 546 else
EmFor@0 547 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Reputation"][thisHeader][name] = {};
EmFor@0 548 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Reputation"][thisHeader][name]["Standing"] = ReputationKey[standing];
EmFor@0 549 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Reputation"][thisHeader][name]["AtWar"] = atWar;
EmFor@0 550 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Reputation"][thisHeader][name]["Value"] = round(barValue*Units[standing]).."/"..Units[standing];
EmFor@0 551 -- CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Reputation"][thisHeader][name]["canToggle"] = canToggle;
EmFor@0 552 -- CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Reputation"][thisHeader][name]["Order"] = i;
EmFor@0 553 end
EmFor@0 554 end
EmFor@0 555 end
EmFor@0 556 end
EmFor@0 557
EmFor@0 558 function Profile_GetTalents()
EmFor@0 559 local numTabs = GetNumTalentTabs();
EmFor@0 560 local name, iconTexture, tier, column, rank, maxRank;
EmFor@0 561 local numTalents;
EmFor@0 562 local tabname, texture, points, fileName;
EmFor@0 563
EmFor@0 564 -- Make sure the right frame is loaded
EmFor@0 565 if( not CensusPlus_IsTalentLoaded() ) then
EmFor@0 566 return;
EmFor@0 567 end
EmFor@0 568
EmFor@0 569 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"] = {};
EmFor@0 570
EmFor@0 571 for x=1, numTabs do
EmFor@0 572 PanelTemplates_SetTab(TalentFrame, x);
EmFor@0 573 numTalents = GetNumTalents(PanelTemplates_GetSelectedTab(TalentFrame));
EmFor@0 574 tabname, texture, points, fileName = GetTalentTabInfo(PanelTemplates_GetSelectedTab(TalentFrame));
EmFor@0 575 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname] = {};
EmFor@0 576 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname]["PointsSpent"] = points;
EmFor@0 577 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname]["Background"] = "Interface\\TalentFrame\\" .. fileName;
EmFor@0 578 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname]["Order"] = x;
EmFor@0 579 for i=1, numTalents do
EmFor@0 580 name, iconTexture, tier, column, rank, maxRank = GetTalentInfo(PanelTemplates_GetSelectedTab(TalentFrame), i);
EmFor@0 581 if (rank > 0 or myCPProfile_TALENTS_Full) then
EmFor@0 582 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname][name] = { };
EmFor@0 583 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname][name]["Rank"] = rank .. ":" .. maxRank;
EmFor@0 584 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname][name]["Location"] = tier .. ":" .. column;
EmFor@0 585 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname][name]["Texture"] = iconTexture;
EmFor@0 586 end
EmFor@0 587
EmFor@0 588 if ( myCPProfile_TALENTS_Full ) then
EmFor@0 589 -- double check
EmFor@0 590 if ( not CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname][name] ) then
EmFor@0 591 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname][name] = {};
EmFor@0 592 end
EmFor@0 593 CP_ProfHidden:SetTalent(PanelTemplates_GetSelectedTab(TalentFrame), i)
EmFor@0 594 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Talents"][tabname][name]["Tooltip"] = CP_Tooltipscan();
EmFor@0 595 end
EmFor@0 596 end
EmFor@0 597 end
EmFor@0 598 end
EmFor@0 599
EmFor@0 600 function Profile_DoBuffs()
EmFor@0 601 local iIterator = 0;
EmFor@0 602 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Buffs"] = {};
EmFor@0 603 while( GetPlayerBuffTexture( iIterator ) ) do
EmFor@0 604 buffText = GetPlayerBuffTexture( iIterator);
EmFor@0 605 iIterator = iIterator + 1
EmFor@0 606 CP_ProfHidden:SetUnitBuff( "player", iIterator );
EmFor@0 607
EmFor@0 608 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Buffs"][iIterator] = {};
EmFor@0 609 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Buffs"][iIterator]["Tooltip"] = CP_Tooltipscan();
EmFor@0 610 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Buffs"][iIterator]["Texture"] = buffText;
EmFor@0 611 end
EmFor@0 612 --[[
EmFor@0 613 iIterator = 1;
EmFor@0 614 while( UnitDebuff( "player", iIterator ) ) do
EmFor@0 615 debuffTexture, debuffApplications = UnitDebuff(unitName, debuffIndex);
EmFor@0 616 CP_ProfHidden:SetUnitDebuff( "player", iIterator-1 );
EmFor@0 617
EmFor@0 618 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Debuffs"][iIterator] = {};
EmFor@0 619 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Debuffs"][iIterator]["Tooltip"] = CP_Tooltipscan();
EmFor@0 620 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Debuffs"][iIterator]["Texture"] = debuffTexture;
EmFor@0 621 iIterator = iIterator + 1
EmFor@0 622 end
EmFor@0 623 ]]--
EmFor@0 624 end
EmFor@0 625
EmFor@0 626 function Profile_GetSkills()
EmFor@0 627 -- Reset/Initialize
EmFor@0 628 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Skills"] = {};
EmFor@0 629 local skillheader = '';
EmFor@0 630 local skillinfo = nil;
EmFor@0 631 local rank, maxRank = 0;
EmFor@0 632 local order = 1; -- order in which the headers appear
EmFor@0 633 for i=1, GetNumSkillLines(), 1 do
EmFor@0 634 skillinfo = fixnilempty(GetSkillLineInfo(i));
EmFor@0 635 rank = skillinfo[4];
EmFor@0 636 maxRank = skillinfo[7];
EmFor@0 637 if(skillinfo[2] == 1) then -- if it is a header
EmFor@0 638 skillheader = skillinfo[1];
EmFor@0 639 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Skills"][skillheader] = { };
EmFor@0 640 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Skills"][skillheader]["Order"] = order;
EmFor@0 641 order = order + 1;
EmFor@0 642 else
EmFor@0 643 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Skills"][skillheader][skillinfo[1]] = rank .. ":" .. maxRank;
EmFor@0 644 end
EmFor@0 645 end
EmFor@0 646 end
EmFor@0 647
EmFor@0 648
EmFor@0 649 ---------------------------------------------
EmFor@0 650 -- Process Inventory
EmFor@0 651 ---------------------------------------------
EmFor@0 652
EmFor@0 653 function Profile_UpdateInventory()
EmFor@0 654 local link;
EmFor@0 655 local texture;
EmFor@0 656
EmFor@0 657 -- Reset/Initialize
EmFor@0 658 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Equipment"] = {};
EmFor@0 659
EmFor@0 660 for index,slot in Profile_slots do
EmFor@0 661 link = GetInventoryItemLink("player", index);
EmFor@0 662 texture = GetInventoryItemTexture("player", index);
EmFor@0 663 if( link ) then
EmFor@0 664 for color, item, name in string.gfind(link, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do
EmFor@0 665 if( color ~= nil and item ~= nil and name ~= nil ) then
EmFor@0 666 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Equipment"][slot] = { };
EmFor@0 667 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Equipment"][slot]["Texture"] = texture;
EmFor@0 668 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Equipment"][slot]["Color"] = color;
EmFor@0 669 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Equipment"][slot]["Item"] = item;
EmFor@0 670 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Equipment"][slot]["Name"] = name;
EmFor@0 671 -- Build Tooltip
EmFor@0 672 --CP_ProfHidden:SetHyperlink("item:" .. item);
EmFor@0 673 CP_ProfHidden:SetInventoryItem("player", index);
EmFor@0 674 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Equipment"][slot]["Tooltip"] = CP_Tooltipscan();
EmFor@0 675
EmFor@0 676 end
EmFor@0 677 end
EmFor@0 678 end
EmFor@0 679 end
EmFor@0 680 end
EmFor@0 681
EmFor@0 682 function Profile_ScanInventory()
EmFor@0 683 local bag, bagname, link, texture, color, item, strings, str;
EmFor@0 684
EmFor@0 685 -- Reset/Initialize
EmFor@0 686 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"] = {}
EmFor@0 687
EmFor@0 688 for bag = 0,4 do
EmFor@0 689 if (bag == 0) then
EmFor@0 690 bagname = "Backpack";
EmFor@0 691 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag] = { };
EmFor@0 692 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Name"] = "Backpack";
EmFor@0 693 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Item"] = "Backpack";
EmFor@0 694 if ( myCPProfile_HTML_Tooltips ) then
EmFor@0 695 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Tooltip"] = "Backpack";
EmFor@0 696 else
EmFor@0 697 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Tooltip"] = {};
EmFor@0 698 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Tooltip"][1] = "Backpack";
EmFor@0 699 end
EmFor@0 700 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Color"] = "ffffffff";
EmFor@0 701 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Slots"] = 16;
EmFor@0 702 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Texture"] = "Interface\\Buttons\\Button-Backpack-Up";
EmFor@0 703 ProcessBagItems(bag, bagname);
EmFor@0 704 else
EmFor@0 705 link = GetInventoryItemLink("player", (bag+19));
EmFor@0 706 texture = GetInventoryItemTexture("player", (bag+19));
EmFor@0 707 if( link ) then
EmFor@0 708 for color, item, bagname in string.gfind(link, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do
EmFor@0 709 if( color ~= nil and item ~= nil and bagname ~= nil ) then
EmFor@0 710 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag] = { };
EmFor@0 711 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Item"] = item;
EmFor@0 712 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Color"] = color;
EmFor@0 713 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Texture"] = texture;
EmFor@0 714 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Name"] = bagname;
EmFor@0 715 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Slots"] = GetContainerNumSlots(bag);
EmFor@0 716 CP_ProfHidden:SetInventoryItem("player", (bag+19))
EmFor@0 717 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Tooltip"] = CP_Tooltipscan();
EmFor@0 718 ProcessBagItems(bag);
EmFor@0 719 end
EmFor@0 720 end
EmFor@0 721 end
EmFor@0 722 end
EmFor@0 723 end
EmFor@0 724 end
EmFor@0 725
EmFor@0 726 function ProcessBagItems(bag)
EmFor@0 727 local slot, strings, str, texture, itemCount, locked, quality, link, color, item, name;
EmFor@0 728
EmFor@0 729 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Contents"] = {};
EmFor@0 730
EmFor@0 731 for slot = 1,GetContainerNumSlots(bag) do -- loop through all slots in this bag and get items
EmFor@0 732
EmFor@0 733 CP_ProfHidden:SetBagItem(bag, slot);
EmFor@0 734
EmFor@0 735 texture, itemCount, locked, quality = GetContainerItemInfo(bag,slot);
EmFor@0 736 link = GetContainerItemLink(bag, slot);
EmFor@0 737 if( link ) then
EmFor@0 738 for color, item, name in string.gfind(link, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do
EmFor@0 739 if( color ~= nil and item ~= nil and name ~= nil ) then
EmFor@0 740 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Contents"][slot] = {};
EmFor@0 741 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Contents"][slot]["Tooltip"] = CP_Tooltipscan();
EmFor@0 742 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Contents"][slot]["Texture"] = texture;
EmFor@0 743 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Contents"][slot]["Quantity"] = itemCount;
EmFor@0 744 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Contents"][slot]["Name"] = name;
EmFor@0 745 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Contents"][slot]["Color"] = color;
EmFor@0 746 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Inventory"]["Bag" .. bag]["Contents"][slot]["Item"] = item;
EmFor@0 747 end
EmFor@0 748 end
EmFor@0 749 end
EmFor@0 750 end
EmFor@0 751 end
EmFor@0 752
EmFor@0 753
EmFor@0 754 -- From CosmosCommonFunctions.lua
EmFor@0 755 -- Clears a tooltip for usage.
EmFor@0 756 function ClearTooltip(TooltipNameBase)
EmFor@0 757 for i=1, 15, 1 do
EmFor@0 758 getglobal(TooltipNameBase.."TextLeft"..i):SetText("");
EmFor@0 759 getglobal(TooltipNameBase.."TextRight"..i):SetText("");
EmFor@0 760 end
EmFor@0 761 end
EmFor@0 762
EmFor@0 763
EmFor@0 764 function Profile_ScanBank()
EmFor@0 765 -- Borrowed from Telo's LootLink and restructured to fit my data
EmFor@0 766 local oldBank = nil;
EmFor@0 767 if (CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]) then
EmFor@0 768 oldBank = CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"];
EmFor@0 769 end
EmFor@0 770 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"] = {}
EmFor@0 771 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Contents"] = {}
EmFor@0 772
EmFor@0 773 local bag, size, slot, link;
EmFor@0 774
EmFor@0 775 -- First the bank container itself
EmFor@0 776 size = GetContainerNumSlots(BANK_CONTAINER);
EmFor@0 777 for slot = size, 1, -1 do
EmFor@0 778 link = GetContainerItemLink(BANK_CONTAINER, slot);
EmFor@0 779 local texture, itemCount, locked = GetContainerItemInfo(BANK_CONTAINER, slot);
EmFor@0 780 if( link ) then
EmFor@0 781 for color, item, name in string.gfind(link, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do
EmFor@0 782 if( color ~= nil and item ~= nil and name ~= nil ) then
EmFor@0 783 oldBank = nil; -- When we find items, remove the oldBank variable
EmFor@0 784 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Contents"][slot] = {};
EmFor@0 785 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Contents"][slot]["Texture"] = texture;
EmFor@0 786 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Contents"][slot]["Quantity"] = itemCount;
EmFor@0 787 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Contents"][slot]["Name"] = name;
EmFor@0 788 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Contents"][slot]["Color"] = color;
EmFor@0 789 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Contents"][slot]["Item"] = item;
EmFor@0 790 CP_ProfHidden:SetHyperlink("item:" .. item);
EmFor@0 791 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Contents"][slot]["Tooltip"] = CP_Tooltipscan();
EmFor@0 792 end
EmFor@0 793 end
EmFor@0 794 end
EmFor@0 795 end
EmFor@0 796
EmFor@0 797 -- Now the bank bags
EmFor@0 798 for bag = 5, 10 do
EmFor@0 799 link = GetContainerItemLink(BANK_CONTAINER, (bag+20));
EmFor@0 800 texture, itemCount, locked, quality = GetContainerItemInfo(BANK_CONTAINER, (bag+20));
EmFor@0 801 if( link ) then
EmFor@0 802 for color, item, bagname in string.gfind(link, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do
EmFor@0 803 if( color ~= nil and item ~= nil and bagname ~= nil ) then
EmFor@0 804 oldBank = nil; -- When we find items, remove the oldBank variable
EmFor@0 805 bagnum = bag-4;
EmFor@0 806 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum] = {};
EmFor@0 807 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Name"] = bagname;
EmFor@0 808 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Slots"] = GetContainerNumSlots(bag);
EmFor@0 809 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Texture"] = texture;
EmFor@0 810 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Color"] = color;
EmFor@0 811 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Item"] = item;
EmFor@0 812 CP_ProfHidden:SetHyperlink("item:" .. item);
EmFor@0 813 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Tooltip"] = CP_Tooltipscan();
EmFor@0 814
EmFor@0 815 ProcessBankBagItems(bag, bagnum);
EmFor@0 816 end
EmFor@0 817 end
EmFor@0 818 end
EmFor@0 819 end
EmFor@0 820
EmFor@0 821 if ( oldBank ) then
EmFor@0 822 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"] = oldBank;
EmFor@0 823 end
EmFor@0 824 end
EmFor@0 825
EmFor@0 826 function ProcessBankBagItems(bag, bagnum)
EmFor@0 827
EmFor@0 828 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Contents"] = {};
EmFor@0 829
EmFor@0 830 for slot = 1,GetContainerNumSlots(bag) do -- loop through all slots in this bag and get items
EmFor@0 831 -- CP_ProfHidden:SetBagItem(bag, slot);
EmFor@0 832 texture, itemCount, locked, quality = GetContainerItemInfo(bag,slot);
EmFor@0 833 link = GetContainerItemLink(bag, slot);
EmFor@0 834 if( link ) then
EmFor@0 835 for color, item, name in string.gfind(link, "|c(%x+)|Hitem:(%d+:%d+:%d+:%d+)|h%[(.-)%]|h|r") do
EmFor@0 836 if( color ~= nil and item ~= nil and name ~= nil ) then
EmFor@0 837 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Contents"][slot] = {};
EmFor@0 838 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Contents"][slot]["Texture"] = texture;
EmFor@0 839 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Contents"][slot]["Quantity"] = itemCount;
EmFor@0 840 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Contents"][slot]["Name"] = name;
EmFor@0 841 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Contents"][slot]["Color"] = color;
EmFor@0 842 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Contents"][slot]["Item"] = item;
EmFor@0 843 CP_ProfHidden:SetBagItem(bag, slot);
EmFor@0 844 -- CP_ProfHidden:SetHyperlink("item:" .. item);
EmFor@0 845 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Bank"]["Bag" .. bagnum]["Contents"][slot]["Tooltip"] = CP_Tooltipscan();
EmFor@0 846 end
EmFor@0 847 end
EmFor@0 848 end
EmFor@0 849 end
EmFor@0 850 end
EmFor@0 851
EmFor@0 852
EmFor@0 853 function Profile_ScanTradeSkill()
EmFor@0 854 local skillLineName, skillLineRank, skillLineMaxRank = GetTradeSkillLine();
EmFor@0 855
EmFor@0 856 if( (not skillLineName) or (skillLineName == "") or (skillLineName == "UNKNOWN")) then
EmFor@0 857 return;
EmFor@0 858 end
EmFor@0 859 -- we don't bother saving the following tradeskills
EmFor@0 860 if( (skillLineName == "Fishing") or (skillLineName == "Mining") or (skillLineName == "Herbalism") or (skillLineName == "Skinning") ) then
EmFor@0 861 return;
EmFor@0 862 end
EmFor@0 863
EmFor@0 864 if ( not CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"] ) then
EmFor@0 865 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"] = {};
EmFor@0 866 end
EmFor@0 867 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName] = {};
EmFor@0 868
EmFor@0 869 -- expand the tree so we can see all the recipes
EmFor@0 870 ExpandTradeSkillSubClass(0);
EmFor@0 871
EmFor@0 872 -- get the number of recipes and loop through each one
EmFor@0 873 local numTradeSkills = GetNumTradeSkills();
EmFor@0 874 local skillHeader = skillLineName;
EmFor@0 875 for itemIndex=1, numTradeSkills, 1 do
EmFor@0 876 if( itemIndex == nil or skillLineName==nil or skillHeader==nil ) then
EmFor@0 877 return;
EmFor@0 878 end
EmFor@0 879 local skillText = "";
EmFor@0 880 local skillName, skillDifficulty, numAvailable, isExpanded = GetTradeSkillInfo(itemIndex);
EmFor@0 881 if( skillDifficulty ~= "header" and skillLineName ~= nil and skillLineName ~= "" and skillHeader ~= nil and skillHeader ~= "" and skillName ~= nil and skillName ~= "" ) then
EmFor@0 882 if( not CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader] ) then
EmFor@0 883 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader] = {};
EmFor@0 884 end
EmFor@0 885 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName] = {};
EmFor@0 886 local skillIcon = GetTradeSkillIcon(itemIndex);
EmFor@0 887 if( not skillIcon ) then
EmFor@0 888 skillIcon = "";
EmFor@0 889 end
EmFor@0 890
EmFor@0 891 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName]["Texture"] = skillIcon;
EmFor@0 892
EmFor@0 893 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName]["Difficulty"] = TradeSkillDifficultyCode[skillDifficulty];
EmFor@0 894
EmFor@0 895 CP_ProfHidden:SetTradeSkillItem(itemIndex);
EmFor@0 896 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName]["Tooltip"] = CP_Tooltipscan();
EmFor@0 897
EmFor@0 898
EmFor@0 899
EmFor@0 900 local numReagents = GetTradeSkillNumReagents(itemIndex);
EmFor@0 901 local reagents = '';
EmFor@0 902 for reagentIndex=1, numReagents, 1 do
EmFor@0 903 local reagentName, reagentTexture, reagentCount, playerReagentCount = GetTradeSkillReagentInfo(itemIndex, reagentIndex);
EmFor@0 904 if( not reagentTexture ) then
EmFor@0 905 reagentTexture = "";
EmFor@0 906 end
EmFor@0 907 if( not reagentName ) then
EmFor@0 908 reagentName = "Unknown";
EmFor@0 909 end
EmFor@0 910
EmFor@0 911 if (reagentIndex == numReagents) then
EmFor@0 912 reagents = reagents .. reagentName .. " x" .. reagentCount;
EmFor@0 913 else
EmFor@0 914 reagents = reagents .. reagentName .. " x" .. reagentCount .. "<br>";
EmFor@0 915 end
EmFor@0 916 end
EmFor@0 917 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName]["Reagents"] = reagents;
EmFor@0 918 else
EmFor@0 919 skillHeader = skillName;
EmFor@0 920 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader] = {};
EmFor@0 921 end
EmFor@0 922 end
EmFor@0 923 end
EmFor@0 924
EmFor@0 925 -- is this ever called?!
EmFor@0 926 function Profile_ScanCraft()
EmFor@0 927 local skillLineName, skillLineRank, skillLineMaxRank = GetCraftDisplaySkillLine();
EmFor@0 928
EmFor@0 929 if( (not skillLineName) or (skillLineName == "") or (skillLineName == "UNKNOWN")) then
EmFor@0 930 return;
EmFor@0 931 end
EmFor@0 932
EmFor@0 933 if ( not CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"] ) then
EmFor@0 934 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"] = {};
EmFor@0 935 end
EmFor@0 936 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName] = {};
EmFor@0 937
EmFor@0 938 -- expand the tree so we can see all the recipes
EmFor@0 939 -- ExpandCraftSubClass(0);
EmFor@0 940
EmFor@0 941 -- get the number of recipes and loop through each one
EmFor@0 942 local numCrafts = GetNumCrafts();
EmFor@0 943 local skillHeader = skillLineName; -- default it, enchanting doesn't have categories?
EmFor@0 944 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader] = {};
EmFor@0 945 for itemIndex=1, numCrafts, 1 do
EmFor@0 946 local skillText = "";
EmFor@0 947 local skillName, craftSubSpellName, skillDifficulty, numAvailable, isExpanded = GetCraftInfo(itemIndex);
EmFor@0 948 --Debug(skillName .. ":" .. craftSubSpellName);
EmFor@0 949 if( skillDifficulty ~= "header" and skillLineName and skillLineName ~= "" and skillHeader and skillHeader ~= "" and skillName and skillName ~= "" ) then
EmFor@0 950 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName] = {};
EmFor@0 951 local skillIcon = GetCraftIcon(itemIndex);
EmFor@0 952 if( not skillIcon ) then
EmFor@0 953 skillIcon = "";
EmFor@0 954 end
EmFor@0 955 local description = GetCraftDescription(itemIndex);
EmFor@0 956 if (description == nil) then
EmFor@0 957 description = "";
EmFor@0 958 end
EmFor@0 959
EmFor@0 960 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName]["Texture"] = skillIcon;
EmFor@0 961
EmFor@0 962 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName]["Difficulty"] = TradeSkillDifficultyCode[skillDifficulty];
EmFor@0 963
EmFor@0 964 -- CP_ProfHidden:SetCraftItem(itemIndex);
EmFor@0 965 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName]["Tooltip"] = description;
EmFor@0 966 --Debug(description);
EmFor@0 967
EmFor@0 968 local numReagents = GetCraftNumReagents(itemIndex);
EmFor@0 969 local reagents = '';
EmFor@0 970 for reagentIndex=1, numReagents, 1 do
EmFor@0 971 local reagentName, reagentTexture, reagentCount, playerReagentCount = GetCraftReagentInfo(itemIndex, reagentIndex);
EmFor@0 972 if( not reagentTexture ) then
EmFor@0 973 reagentTexture = "";
EmFor@0 974 end
EmFor@0 975 if( not reagentName ) then
EmFor@0 976 reagentName = "Unknown";
EmFor@0 977 end
EmFor@0 978
EmFor@0 979 if (reagentIndex == numReagents) then
EmFor@0 980 reagents = reagents .. reagentName .. " x" .. reagentCount;
EmFor@0 981 else
EmFor@0 982 reagents = reagents .. reagentName .. " x" .. reagentCount .. "<br>";
EmFor@0 983 end
EmFor@0 984 end
EmFor@0 985 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader][skillName]["Reagents"] = reagents;
EmFor@0 986 else
EmFor@0 987 local skillHeader = skillName;
EmFor@0 988 CensusPlus_Profile[GetCVar("realmName")][UnitName("player")]["Professions"][skillLineName][skillHeader] = {};
EmFor@0 989 end
EmFor@0 990 end
EmFor@0 991 end
EmFor@0 992
EmFor@0 993
EmFor@0 994 -- Utilities go below
EmFor@0 995 -- From CosmosCommonFunctions.lua
EmFor@0 996 -- Gets all lines out of a tooltip.
EmFor@0 997
EmFor@0 998 function CP_Tooltipscan()
EmFor@0 999 --CP_ProfHidden:Show();
EmFor@0 1000
EmFor@0 1001 local TooltipNameBase = "CP_ProfHidden";
EmFor@0 1002 local tooltipFrame = getglobal(TooltipNameBase);
EmFor@0 1003 local strings = {};
EmFor@0 1004 local htmlstr = nil;
EmFor@0 1005
EmFor@0 1006 -- CensusPlus_Msg( "NUM LINES: " .. CP_ProfHidden:NumLines() );
EmFor@0 1007
EmFor@0 1008 for idx = 1, CP_ProfHidden:NumLines() do
EmFor@0 1009 local textLeft = nil;
EmFor@0 1010 local textRight = nil;
EmFor@0 1011 ttext = getglobal(TooltipNameBase.."TextLeft"..idx);
EmFor@0 1012
EmFor@0 1013 if(ttext and ttext:IsVisible() and ttext:GetText() ~= nil) then
EmFor@0 1014 textLeft = ttext:GetText();
EmFor@0 1015 end
EmFor@0 1016
EmFor@0 1017 --if( textLeft ~= nil ) then
EmFor@0 1018 -- CensusPlus_Msg( "LEFT TEXT: " .. textLeft );
EmFor@0 1019 --end
EmFor@0 1020
EmFor@0 1021 ttext = getglobal(TooltipNameBase.."TextRight"..idx);
EmFor@0 1022 if(ttext and ttext:IsVisible() and ttext:GetText() ~= nil) then
EmFor@0 1023 textRight = ttext:GetText();
EmFor@0 1024 end
EmFor@0 1025 --if( textRight ~= nil ) then
EmFor@0 1026 -- CensusPlus_Msg( "RIGHT TEXT: " .. textRight );
EmFor@0 1027 --end
EmFor@0 1028
EmFor@0 1029 if (textLeft or textRight) then
EmFor@0 1030 if ( textRight) then
EmFor@0 1031 textRight = "\t"..textRight;
EmFor@0 1032 else
EmFor@0 1033 textRight = "";
EmFor@0 1034 end
EmFor@0 1035
EmFor@0 1036 if ( htmlstr ~= nil ) then
EmFor@0 1037 htmlstr = htmlstr .. "<br>" .. textLeft .. textRight;
EmFor@0 1038 else
EmFor@0 1039 htmlstr = textLeft .. textRight;
EmFor@0 1040 end
EmFor@0 1041 end
EmFor@0 1042 end
EmFor@0 1043
EmFor@0 1044 -- CP_ProfHidden:ClearLines();
EmFor@0 1045 -- ClearTooltip( "CP_ProfHidden" );
EmFor@0 1046
EmFor@0 1047 return htmlstr;
EmFor@0 1048 end
EmFor@0 1049
EmFor@0 1050 function round(x)
EmFor@0 1051 if(x - math.floor(x) > 0.5) then
EmFor@0 1052 x = x + 0.5;
EmFor@0 1053 end
EmFor@0 1054 return math.floor(x);
EmFor@0 1055 end
EmFor@0 1056
EmFor@0 1057 if (not fixnilempty) then
EmFor@0 1058 fixnilempty = function(...)
EmFor@0 1059 for i=1, arg.n, 1 do
EmFor@0 1060 if(not arg[i]) then
EmFor@0 1061 arg[i] = "";
EmFor@0 1062 end
EmFor@0 1063 end
EmFor@0 1064 return arg;
EmFor@0 1065 end
EmFor@0 1066 end
EmFor@0 1067
EmFor@0 1068