vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 FollowTheLeader
3  
4 By Torgo <jimmcq@concentric.net>
5  
6 If someone tells you to "follow" them, you will. If they tell you to "stop" you will stop following them. These commands must come in the form of a tell/whisper. You will only follow players that are in your party, on you friends list, or in your guild.
7  
8 Feel free to use any of this code in other mods, or to modify this AddOn itself. My only request is that you send me your modifications.
9  
10 URL: http://curse-gaming.com/mod.php?addid=1216
11  
12 ]]
13  
14 FTL_Version = "1.1.1";
15 FTL_Leader = nil;
16  
17 function FTL_ProcessChat(msg, name)
18 msg = string.lower(msg);
19 if (string.find(msg, "follow") and not string.find(msg, "auto")) then
20 DEFAULT_CHAT_FRAME:AddMessage("I'm in", 1, 0, 0);
21 if (OKtoFollow(name)) then
22 FTL_Leader = name;
23 FollowByName(name);
24 end
25 elseif (string.find(msg, "stop") and name == FTL_Leader) then
26 MoveBackwardStart(GetTime()*1000 + 1);
27 MoveBackwardStop(GetTime()*1000 + 2);
28 MoveForwardStart(GetTime()*1000 + 3);
29 MoveForwardStop(GetTime()*1000 + 4);
30 elseif (string.find(msg, "mount") and name == FTL_Leader and AutoMount_GetMountItemBagSlot) then
31 local bag, slot = AutoMount_GetMountItemBagSlot();
32 if ( bag ) and ( slot ) then
33 UseContainerItem(bag, slot);
34 else
35 if (name ~= UnitName("player")) then
36 SendChatMessage("I can't seem to find my mount.", "WHISPER", GetLanguageByIndex(0), name);
37 end
38 end
39 end
40 end
41  
42 function FTL_ProcessError(msg)
43 if (msg == ERR_AUTOFOLLOW_TOO_FAR) then
44 if (FTL_Leader ~= nil) then
45 FTL_TooFar(FTL_Leader);
46 FTL_Leader = nil;
47 end
48 elseif (msg == ERR_INVALID_FOLLOW_TARGET) then
49 FTL_Leader = nil;
50 elseif (msg == ERR_TOOBUSYTOFOLLOW) then
51 SendChatMessage("I'm too busy to auto-follow you right now, try again in a moment.", "WHISPER", GetLanguageByIndex(0), FTL_Leader);
52 FTL_Leader = nil;
53 end
54 end
55  
56 function FTL_Following(name)
57 SendChatMessage("I'm auto-following you", "WHISPER", GetLanguageByIndex(0), name);
58 FTL_Leader = name;
59 end
60  
61 function FTL_Stopped()
62 if (FTL_Leader ~= nil) then
63 SendChatMessage("I stopped auto-following you", "WHISPER", GetLanguageByIndex(0), FTL_Leader);
64 FTL_Leader = nil;
65 end
66 end
67  
68 function FTL_TooFar(name)
69 tMessage = "I can't auto-follow, you must be too far away. I'm ";
70  
71 x, y = GetPlayerMapPosition("player");
72 x = math.floor(x*100.0);
73 y = math.floor(y*100.0);
74 if ((x > 0) or (y > 0)) then
75 tMessage = tMessage.." at Location: "..x..","..y;
76 end
77  
78 tLoc = GetMinimapZoneText();
79 tMessage = tMessage.." in "..tLoc;
80  
81 SendChatMessage(tMessage, "WHISPER", GetLanguageByIndex(0), name);
82 end
83  
84 function OKtoFollow(name)
85 -- Check to see if 'name' is in your party
86 numParty = GetNumPartyMembers()
87 if (numParty > 0) then
88 for i=1, numParty do
89 if (UnitName("party"..i) == name) then
90 return true;
91 end
92 end
93 end
94  
95 -- Check to see if 'name' is on your friends list
96 local numFriends = GetNumFriends();
97 if ( numFriends > 0 ) then
98 for friendIndex=1, numFriends do
99 friendName = GetFriendInfo(friendIndex);
100 if (friendName == name) then
101 return true;
102 end
103 end
104 end
105  
106 -- Check to see if 'name' is in your guild
107 if (IsInGuild()) then
108 for i=1, GetNumGuildMembers(), 1 do
109 guildMemberName = GetGuildRosterInfo(i);
110 if (guildMemberName == name) then
111 return true;
112 end
113 end
114 end
115  
116 -- None of the above
117 return false;
118 end