vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 local playerfaction = "";
2 local enemycarrier = "-";
3 local allycarrier = "-";
4  
5 function TargetFC_OnLoad()
6 this:RegisterEvent("PLAYER_ENTERING_WORLD");
7 this:RegisterEvent("CHAT_MSG_BG_SYSTEM_HORDE");
8 this:RegisterEvent("CHAT_MSG_BG_SYSTEM_ALLIANCE");
9 this:RegisterEvent("CHAT_MSG_BG_SYSTEM_NEUTRAL");
10  
11 SlashCmdList["TargetFC"] = TargetFC_SlashCommandHandler;
12 SLASH_TargetFC1 = "/targetfc";
13 SLASH_TargetFC2 = "/tf";
14  
15 DEFAULT_CHAT_FRAME:AddMessage("TargetFC enabled. /targetfc for more info.");
16 end
17  
18 function TargetFC_OnEvent( event )
19 if (event == "PLAYER_ENTERING_WORLD") then
20 playerfaction = UnitFactionGroup("player");
21 DEFAULT_CHAT_FRAME:AddMessage("Faction: " .. playerfaction);
22  
23 getglobal("TargetFCAllianceButton"):Hide();
24 getglobal("TargetFCHordeButton"):Hide();
25  
26 elseif ((event == "CHAT_MSG_BG_SYSTEM_HORDE") or (event == "CHAT_MSG_BG_SYSTEM_ALLIANCE")) then
27  
28 DEFAULT_CHAT_FRAME:AddMessage("Faction Check: " .. playerfaction);
29  
30 if (string.find(arg1, "The %w+ %w+ was picked up by %w+")) then
31 local _,_,team,player = string.find(arg1, "The (%w+) %w+ was picked up by (%w+)!");
32  
33 if (playerfaction == team) then
34 enemycarrier = player;
35 else
36 allycarrier = player;
37 end
38  
39 if (team == "Horde") then
40 getglobal("TargetFCAlliance"):SetText(player);
41 getglobal("TargetFCAllianceButton"):Show();
42 else
43 getglobal("TargetFCHorde"):SetText(player);
44 getglobal("TargetFCHordeButton"):Show();
45 end
46  
47 elseif (string.find(arg1, "The %w+ %w+ was taken by %w+")) then
48 local _,_,team,player = string.find(arg1, "The (%w+) %w+ was taken by (%w+)!");
49  
50 if (playerfaction == team) then
51 enemycarrier = player;
52 else
53 allycarrier = player;
54 end
55  
56 if (team == "Horde") then
57 getglobal("TargetFCAlliance"):SetText(player);
58 getglobal("TargetFCAllianceButton"):Show();
59 else
60 getglobal("TargetFCHorde"):SetText(player);
61 getglobal("TargetFCHordeButton"):Show();
62 end
63  
64 elseif (string.find(arg1, "The %w+ %w+ was dropped")) then
65 local _,_,team = string.find(arg1, "The (%w+)");
66  
67 if (playerfaction == team) then
68 enemycarrier = "-";
69 else
70 allycarrier = "-";
71 end
72  
73 if (team == "Horde") then
74 getglobal("TargetFCAllianceButton"):Hide();
75 else
76 getglobal("TargetFCHordeButton"):Hide();
77 end
78 end
79  
80 elseif (event == "CHAT_MSG_BG_SYSTEM_NEUTRAL") then
81 if (string.find(arg1, "The flags are now placed at their bases.")) then
82 allycarrier = "-";
83 enemycarrier = "-";
84  
85 getglobal("TargetFCAllianceButton"):Hide();
86 getglobal("TargetFCHordeButton"):Hide();
87 end
88 end
89 end
90  
91  
92 function TargetFC_SlashCommandHandler(msg)
93 if (string.lower(msg) == "enemy") then
94 if (enemycarrier ~= "-") then
95 DEFAULT_CHAT_FRAME:AddMessage("Attempting to target <" .. enemycarrier .. ">.");
96 TargetByName(enemycarrier);
97 if (UnitName("target") ~= enemycarrier) then
98 TargetLastTarget();
99 end
100 else
101 DEFAULT_CHAT_FRAME:AddMessage("No enemy flag carrier.");
102 end
103  
104 elseif (string.lower(msg) == "friendly") then
105 if (allycarrier ~= "-") then
106 DEFAULT_CHAT_FRAME:AddMessage("Attempting to target <" .. allycarrier .. ">.");
107 TargetByName(allycarrier);
108 if (UnitName("target") ~= allycarrier) then
109 TargetLastTarget();
110 end
111 else
112 DEFAULT_CHAT_FRAME:AddMessage("No friendly flag carrier.");
113 end
114  
115 elseif (string.lower(msg) == "horde") then
116 if (playerfaction == "Horde") then
117 TargetFC_SlashCommandHandler("friendly");
118 else
119 TargetFC_SlashCommandHandler("enemy");
120 end
121  
122 elseif (string.lower(msg) == "alliance") then
123 if (playerfaction == "Horde") then
124 TargetFC_SlashCommandHandler("enemy");
125 else
126 TargetFC_SlashCommandHandler("friendly");
127 end
128  
129 elseif (string.lower(msg) == "fix") then
130 playerfaction = UnitFactionGroup("player");
131  
132 elseif (string.lower(msg) == "check") then
133 DEFAULT_CHAT_FRAME:AddMessage("Faction: " .. playerfaction);
134  
135  
136 else
137 DEFAULT_CHAT_FRAME:AddMessage("To target the enemy flag carrier: /tf enemy");
138 DEFAULT_CHAT_FRAME:AddMessage("To target the friendly flag carrier: /tf friendly");
139 DEFAULT_CHAT_FRAME:AddMessage("To check to see if the faction was obtained correctly: /tf check");
140 DEFAULT_CHAT_FRAME:AddMessage("To automatically detect the faction: /tf fix");
141 end
142 end