vanilla-wow-addons – Blame information for rev 1
?pathlinks?
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 | FTL_Leader = name; |
||
58 | end |
||
59 | |||
60 | function FTL_Stopped() |
||
61 | if (FTL_Leader ~= nil) then |
||
62 | FTL_Leader = nil; |
||
63 | end |
||
64 | end |
||
65 | |||
66 | function FTL_TooFar(name) |
||
67 | tMessage = "I can't auto-follow, you must be too far away. I'm "; |
||
68 | |||
69 | x, y = GetPlayerMapPosition("player"); |
||
70 | x = math.floor(x*100.0); |
||
71 | y = math.floor(y*100.0); |
||
72 | if ((x > 0) or (y > 0)) then |
||
73 | tMessage = tMessage.." at Location: "..x..","..y; |
||
74 | end |
||
75 | |||
76 | tLoc = GetMinimapZoneText(); |
||
77 | tMessage = tMessage.." in "..tLoc; |
||
78 | |||
79 | SendChatMessage(tMessage, "WHISPER", GetLanguageByIndex(0), name); |
||
80 | end |
||
81 | |||
82 | function OKtoFollow(name) |
||
83 | -- Check to see if 'name' is in your party |
||
84 | numParty = GetNumPartyMembers() |
||
85 | if (numParty > 0) then |
||
86 | for i=1, numParty do |
||
87 | if (UnitName("party"..i) == name) then |
||
88 | return true; |
||
89 | end |
||
90 | end |
||
91 | end |
||
92 | |||
93 | -- Check to see if 'name' is on your friends list |
||
94 | local numFriends = GetNumFriends(); |
||
95 | if ( numFriends > 0 ) then |
||
96 | for friendIndex=1, numFriends do |
||
97 | friendName = GetFriendInfo(friendIndex); |
||
98 | if (friendName == name) then |
||
99 | return true; |
||
100 | end |
||
101 | end |
||
102 | end |
||
103 | |||
104 | -- Check to see if 'name' is in your guild |
||
105 | if (IsInGuild()) then |
||
106 | for i=1, GetNumGuildMembers(), 1 do |
||
107 | guildMemberName = GetGuildRosterInfo(i); |
||
108 | if (guildMemberName == name) then |
||
109 | return true; |
||
110 | end |
||
111 | end |
||
112 | end |
||
113 | |||
114 | -- None of the above |
||
115 | return false; |
||
116 | end |