syzler@1: -- MyLilPony
syzler@1: -- Copyright (c) 2011 Syzler
syzler@1: --
syzler@1: -- This program is free software: you can redistribute it and/or modify
syzler@1: -- it under the terms of the GNU General Public License as published by
syzler@1: -- the Free Software Foundation, either version 3 of the License, or
syzler@1: -- (at your option) any later version.
syzler@1: --
syzler@1: -- This program is distributed in the hope that it will be useful,
syzler@1: -- but WITHOUT ANY WARRANTY; without even the implied warranty of
syzler@1: -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
syzler@1: -- GNU General Public License for more details.
syzler@1: --
syzler@1: -- You should have received a copy of the GNU General Public License
syzler@1: -- along with this program. If not, see .
syzler@1:
syzler@1: function MyLilPony.OnLoad()
syzler@1: SlashCmdList["MyLilPony"] = MyLilPony.SlashHandler;
syzler@1: SLASH_MyLilPony1 = "/pony";
syzler@1: SLASH_MyLilPony2 = "/mlp";
syzler@1: SLASH_MyLilPony3 = "/mylilpony";
syzler@1:
syzler@1: MyLilPony.Log(format("Version %s loaded", MYLILPONY_VERSION));
syzler@1: MyLilPony.LoadDefaults();
syzler@1: end
syzler@1:
syzler@1: function MyLilPony.LoadDefaults()
syzler@1: if MyLilPony.AutoDismount == nil then MyLilPony.AutoDismount = true end
syzler@1: end
syzler@1:
syzler@1: function MyLilPony.AutoMount()
syzler@1: if UnitIsDead("player") or UnitIsGhost("player") then
syzler@1: MyLilPony.Log("You are dead");
syzler@1: return;
syzler@1: end
syzler@1:
syzler@1: if InCombatLockdown() then
syzler@1: MyLilPony.Log("You are in combat");
syzler@1: return;
syzler@1: end
syzler@1:
syzler@1: if IsMounted() and not MyLilPony.AutoDismount then
syzler@1: MyLilPony.Log("You are already mounted");
syzler@1: return;
syzler@1: end
syzler@1:
syzler@1: if IsMounted() and IsFlying() then
syzler@1: MyLilPony.Log("You are already flying");
syzler@1: return;
syzler@1: end
syzler@1:
syzler@1: local zone = GetRealZoneText();
syzler@1:
syzler@1: -- player is in Temple of Ahn'Qiraj (AQ40)
syzler@1: if zone == "Ahn'Qiraj" then
syzler@1: if not IsModifierKeyDown() and MyLilPony.CallMountByRegex("Qiraji Battle Tank") then
syzler@1: return
syzler@1: end
syzler@1: end
syzler@1:
syzler@1: -- player is in Wintergrasp
syzler@1: if zone == "Wintergrasp" then
syzler@1: -- always call ground mount if Wintergrasp is in progress
syzler@1: local _, _, wintergraspInProgress, _, _, _ = GetWorldPVPAreaInfo(1);
syzler@1: if wintergraspInProgress and MyLilPony.CallGroundMount() then
syzler@1: return;
syzler@1: end
syzler@1: end
syzler@1:
syzler@1: -- player is swimming in Vash'jir
syzler@1: if IsSwimming() and (zone == "Shimmering Expanse" or zone == "Kelp'thar Forest" or zone == "Abyssal Depths") then
syzler@1: -- normal behaviour in Vash'jir is to call the Abyssal Seahorse
syzler@1: -- modified behaviour is to attempt flight (i.e. you're at the surface)
syzler@1: if not IsModifierKeyDown() and MyLilPony.CallMountByName("Abyssal Seahorse") then
syzler@1: return;
syzler@1: elseif MyLilPony.CanFlyHere() and MyLilPony.CallFlyingMount() then
syzler@1: return;
syzler@1: elseif MyLilPony.CallAquaticMount() then
syzler@1: return;
syzler@1: end
syzler@1: end
syzler@1:
syzler@1: -- player is in flyable area and knows how to fly here too
syzler@1: if MyLilPony.CanFlyHere() and not IsModifierKeyDown() then
syzler@1: -- normal behaviour in flyable area is to call flying mount
syzler@1: if MyLilPony.CallFlyingMount() then
syzler@1: return;
syzler@1: end
syzler@1: end
syzler@1:
syzler@1: -- player is swimming
syzler@1: if IsSwimming() and not IsModifierKeyDown() then
syzler@1: -- normal behaviour while swimming is to call aquatic mount
syzler@1: if MyLilPony.CallAquaticMount() then
syzler@1: return;
syzler@1: end
syzler@1: end
syzler@1:
syzler@1: MyLilPony.CallGroundMount();
syzler@1: end
syzler@1:
syzler@11: function MyLilPony.SlashHandler(args)
syzler@11: local arg = SecureCmdOptionParse(args);
syzler@1: if MyLilPony.StringMatchIgnoreCase(arg, "^auto$") then
syzler@1: MyLilPony.AutoMount();
syzler@1: elseif MyLilPony.StringMatchIgnoreCase(arg, "^random$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^rand$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^rng$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^r$") then
syzler@1: MyLilPony.CallMount();
syzler@1: elseif MyLilPony.StringMatchIgnoreCase(arg, "^ground$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^g$") then
syzler@1: MyLilPony.CallGroundMount();
syzler@1: elseif MyLilPony.StringMatchIgnoreCase(arg, "^flying$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^fly$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^air$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^a$") then
syzler@1: MyLilPony.CallFlyingMount();
syzler@1: elseif MyLilPony.StringMatchIgnoreCase(arg, "^aquatic$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^aqua$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^swim$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^s$") then
syzler@1: MyLilPony.CallAquaticMount();
syzler@1: elseif MyLilPony.StringMatchIgnoreCase(arg, "^target$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^tgt$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^t$") then
syzler@1: local result = MyLilPony.CallMountByMatch("target");
syzler@1: if not result then
syzler@1: MyLilPony.Log("No matching mounts were found");
syzler@1: end
syzler@1: elseif MyLilPony.StringMatchIgnoreCase(arg, "^exact .+$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^x .+$") then
syzler@1: local param = MyLilPony.StringMatchIgnoreCase(arg, "^.+ (.+)$");
syzler@1: local result = MyLilPony.CallMountByName(param);
syzler@1: if not result then
syzler@1: MyLilPony.Log(format("No matching mounts were found with NAME='%s'", param));
syzler@1: end
syzler@1: elseif MyLilPony.StringMatchIgnoreCase(arg, "^list .+$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^find .+$")
syzler@1: or MyLilPony.StringMatchIgnoreCase(arg, "^l .+$") then
syzler@1: local param = MyLilPony.StringMatchIgnoreCase(arg, "^.+ (.+)$");
syzler@1: local result = MyLilPony.ListMountsByPattern(param);
syzler@1: if not result then
syzler@1: MyLilPony.Log(format("No matching mounts were found with NAME like '%s'", param));
syzler@1: else
syzler@1: for _, name in pairs(result) do
syzler@1: MyLilPony.Print(name);
syzler@1: end
syzler@1: end
syzler@1: elseif MyLilPony.StringMatchIgnoreCase(arg, "^%d+$") then
syzler@1: local result = MyLilPony.CallMountById(tonumber(arg));
syzler@1: if not result then
syzler@1: MyLilPony.Log(format("No matching mounts were found with ID=%s", arg));
syzler@1: end
syzler@1: elseif MyLilPony.StringMatchIgnoreCase(arg, "^.+$") then
syzler@1: local result = MyLilPony.CallMountByPattern(arg);
syzler@1: if not result then
syzler@1: MyLilPony.Log(format("No matching mounts were found with NAME like '%s'", arg));
syzler@1: end
syzler@1: else
syzler@1: MyLilPony.Print(format("MyLilPony %s", MYLILPONY_VERSION));
syzler@1: MyLilPony.Print("Slash Command: /mylilpony (/pony, /mlp)");
syzler@1: MyLilPony.Print(" /mylilpony auto - Summons a \"suitable\" mount");
syzler@1: MyLilPony.Print(" /mylilpony random - Summons random mount");
syzler@1: MyLilPony.Print(" /mylilpony ground - Summons random ground mount");
syzler@1: MyLilPony.Print(" /mylilpony flying - Summons random flying mount");
syzler@1: MyLilPony.Print(" /mylilpony aquatic - Summons random aquatic mount");
syzler@1: MyLilPony.Print(" /mylilpony target - Summons same mount as targeted unit");
syzler@1: MyLilPony.Print(" /mylilpony list - Lists mounts matching name");
syzler@1: MyLilPony.Print(" /mylilpony exact - Summons mount by exact name");
syzler@1: MyLilPony.Print(" /mylilpony - Summons mount by spell or creature ID");
syzler@1: MyLilPony.Print(" /mylilpony - Summons random mount matching name");
syzler@1: end
syzler@1: end