comparison MyLilPony.lua @ 1:7dfbf42c2d60

Initial commit of MyLilPony
author syzler
date Mon, 04 Apr 2011 04:43:05 +0000
parents
children 9052b32b69c3
comparison
equal deleted inserted replaced
0:f6a1d182682e 1:7dfbf42c2d60
1 -- MyLilPony
2 -- Copyright (c) 2011 Syzler
3 --
4 -- This program is free software: you can redistribute it and/or modify
5 -- it under the terms of the GNU General Public License as published by
6 -- the Free Software Foundation, either version 3 of the License, or
7 -- (at your option) any later version.
8 --
9 -- This program is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- GNU General Public License for more details.
13 --
14 -- You should have received a copy of the GNU General Public License
15 -- along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 function MyLilPony.OnLoad()
18 SlashCmdList["MyLilPony"] = MyLilPony.SlashHandler;
19 SLASH_MyLilPony1 = "/pony";
20 SLASH_MyLilPony2 = "/mlp";
21 SLASH_MyLilPony3 = "/mylilpony";
22
23 MyLilPony.Log(format("Version %s loaded", MYLILPONY_VERSION));
24 MyLilPony.LoadDefaults();
25 end
26
27 function MyLilPony.LoadDefaults()
28 if MyLilPony.AutoDismount == nil then MyLilPony.AutoDismount = true end
29 end
30
31 function MyLilPony.AutoMount()
32 if UnitIsDead("player") or UnitIsGhost("player") then
33 MyLilPony.Log("You are dead");
34 return;
35 end
36
37 if InCombatLockdown() then
38 MyLilPony.Log("You are in combat");
39 return;
40 end
41
42 if IsMounted() and not MyLilPony.AutoDismount then
43 MyLilPony.Log("You are already mounted");
44 return;
45 end
46
47 if IsMounted() and IsFlying() then
48 MyLilPony.Log("You are already flying");
49 return;
50 end
51
52 local zone = GetRealZoneText();
53
54 -- player is in Temple of Ahn'Qiraj (AQ40)
55 if zone == "Ahn'Qiraj" then
56 if not IsModifierKeyDown() and MyLilPony.CallMountByRegex("Qiraji Battle Tank") then
57 return
58 end
59 end
60
61 -- player is in Wintergrasp
62 if zone == "Wintergrasp" then
63 -- always call ground mount if Wintergrasp is in progress
64 local _, _, wintergraspInProgress, _, _, _ = GetWorldPVPAreaInfo(1);
65 if wintergraspInProgress and MyLilPony.CallGroundMount() then
66 return;
67 end
68 end
69
70 -- player is swimming in Vash'jir
71 if IsSwimming() and (zone == "Shimmering Expanse" or zone == "Kelp'thar Forest" or zone == "Abyssal Depths") then
72 -- normal behaviour in Vash'jir is to call the Abyssal Seahorse
73 -- modified behaviour is to attempt flight (i.e. you're at the surface)
74 if not IsModifierKeyDown() and MyLilPony.CallMountByName("Abyssal Seahorse") then
75 return;
76 elseif MyLilPony.CanFlyHere() and MyLilPony.CallFlyingMount() then
77 return;
78 elseif MyLilPony.CallAquaticMount() then
79 return;
80 end
81 end
82
83 -- player is in flyable area and knows how to fly here too
84 if MyLilPony.CanFlyHere() and not IsModifierKeyDown() then
85 -- normal behaviour in flyable area is to call flying mount
86 if MyLilPony.CallFlyingMount() then
87 return;
88 end
89 end
90
91 -- player is swimming
92 if IsSwimming() and not IsModifierKeyDown() then
93 -- normal behaviour while swimming is to call aquatic mount
94 if MyLilPony.CallAquaticMount() then
95 return;
96 end
97 end
98
99 MyLilPony.CallGroundMount();
100 end
101
102 function MyLilPony.SlashHandler(arg)
103 if MyLilPony.StringMatchIgnoreCase(arg, "^auto$") then
104 MyLilPony.AutoMount();
105 elseif MyLilPony.StringMatchIgnoreCase(arg, "^random$")
106 or MyLilPony.StringMatchIgnoreCase(arg, "^rand$")
107 or MyLilPony.StringMatchIgnoreCase(arg, "^rng$")
108 or MyLilPony.StringMatchIgnoreCase(arg, "^r$") then
109 MyLilPony.CallMount();
110 elseif MyLilPony.StringMatchIgnoreCase(arg, "^ground$")
111 or MyLilPony.StringMatchIgnoreCase(arg, "^g$") then
112 MyLilPony.CallGroundMount();
113 elseif MyLilPony.StringMatchIgnoreCase(arg, "^flying$")
114 or MyLilPony.StringMatchIgnoreCase(arg, "^fly$")
115 or MyLilPony.StringMatchIgnoreCase(arg, "^air$")
116 or MyLilPony.StringMatchIgnoreCase(arg, "^a$") then
117 MyLilPony.CallFlyingMount();
118 elseif MyLilPony.StringMatchIgnoreCase(arg, "^aquatic$")
119 or MyLilPony.StringMatchIgnoreCase(arg, "^aqua$")
120 or MyLilPony.StringMatchIgnoreCase(arg, "^swim$")
121 or MyLilPony.StringMatchIgnoreCase(arg, "^s$") then
122 MyLilPony.CallAquaticMount();
123 elseif MyLilPony.StringMatchIgnoreCase(arg, "^target$")
124 or MyLilPony.StringMatchIgnoreCase(arg, "^tgt$")
125 or MyLilPony.StringMatchIgnoreCase(arg, "^t$") then
126 local result = MyLilPony.CallMountByMatch("target");
127 if not result then
128 MyLilPony.Log("No matching mounts were found");
129 end
130 elseif MyLilPony.StringMatchIgnoreCase(arg, "^exact .+$")
131 or MyLilPony.StringMatchIgnoreCase(arg, "^x .+$") then
132 local param = MyLilPony.StringMatchIgnoreCase(arg, "^.+ (.+)$");
133 local result = MyLilPony.CallMountByName(param);
134 if not result then
135 MyLilPony.Log(format("No matching mounts were found with NAME='%s'", param));
136 end
137 elseif MyLilPony.StringMatchIgnoreCase(arg, "^list .+$")
138 or MyLilPony.StringMatchIgnoreCase(arg, "^find .+$")
139 or MyLilPony.StringMatchIgnoreCase(arg, "^l .+$") then
140 local param = MyLilPony.StringMatchIgnoreCase(arg, "^.+ (.+)$");
141 local result = MyLilPony.ListMountsByPattern(param);
142 if not result then
143 MyLilPony.Log(format("No matching mounts were found with NAME like '%s'", param));
144 else
145 for _, name in pairs(result) do
146 MyLilPony.Print(name);
147 end
148 end
149 elseif MyLilPony.StringMatchIgnoreCase(arg, "^%d+$") then
150 local result = MyLilPony.CallMountById(tonumber(arg));
151 if not result then
152 MyLilPony.Log(format("No matching mounts were found with ID=%s", arg));
153 end
154 elseif MyLilPony.StringMatchIgnoreCase(arg, "^.+$") then
155 local result = MyLilPony.CallMountByPattern(arg);
156 if not result then
157 MyLilPony.Log(format("No matching mounts were found with NAME like '%s'", arg));
158 end
159 else
160 MyLilPony.Print(format("MyLilPony %s", MYLILPONY_VERSION));
161 MyLilPony.Print("Slash Command: /mylilpony (/pony, /mlp)");
162 MyLilPony.Print(" /mylilpony auto - Summons a \"suitable\" mount");
163 MyLilPony.Print(" /mylilpony random - Summons random mount");
164 MyLilPony.Print(" /mylilpony ground - Summons random ground mount");
165 MyLilPony.Print(" /mylilpony flying - Summons random flying mount");
166 MyLilPony.Print(" /mylilpony aquatic - Summons random aquatic mount");
167 MyLilPony.Print(" /mylilpony target - Summons same mount as targeted unit");
168 MyLilPony.Print(" /mylilpony list <NAME> - Lists mounts matching name");
169 MyLilPony.Print(" /mylilpony exact <NAME> - Summons mount by exact name");
170 MyLilPony.Print(" /mylilpony <ID> - Summons mount by spell or creature ID");
171 MyLilPony.Print(" /mylilpony <NAME> - Summons random mount matching name");
172 end
173 end