annotate libMyLilPony/libMyLilPony_miscFunctions.lua @ 48:83e9649a6606 1.1.7

Fixed Abyssal Seahorse mounting in certain subzones of Vashj'ir
author syzler
date Thu, 20 Sep 2012 01:28:44 -0400
parents 21764271e02f
children 22011265a16f
rev   line source
syzler@14 1 -- Copyright (c) 2011, Syzler
syzler@14 2 -- All rights reserved.
syzler@1 3 --
syzler@14 4 -- Redistribution and use in source and binary forms, with or without
syzler@14 5 -- modification, are permitted provided that the following conditions
syzler@14 6 -- are met:
syzler@1 7 --
syzler@14 8 -- * Redistributions of source code must retain the above copyright
syzler@14 9 -- notice, this list of conditions and the following disclaimer.
syzler@14 10 -- * Redistributions in binary form must reproduce the above copyright
syzler@14 11 -- notice, this list of conditions and the following disclaimer in
syzler@14 12 -- the documentation and/or other materials provided with the
syzler@14 13 -- distribution.
syzler@14 14 -- * Neither the name of the MyLilPony Project nor the names of its
syzler@14 15 -- contributors may be used to endorse or promote products derived
syzler@14 16 -- from this software without specific prior written permission.
syzler@1 17 --
syzler@14 18 -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
syzler@14 19 -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
syzler@14 20 -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
syzler@14 21 -- FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
syzler@14 22 -- COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
syzler@14 23 -- INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
syzler@14 24 -- BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
syzler@14 25 -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
syzler@14 26 -- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
syzler@14 27 -- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
syzler@14 28 -- ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
syzler@14 29 -- POSSIBILITY OF SUCH DAMAGE.
syzler@1 30
syzler@15 31 ------------------------------------------------------------------------
syzler@15 32 -- Project: libMyLilPony
syzler@15 33 -- Project Version: @project-version@
syzler@15 34 -- Last Author: @file-author@
syzler@15 35 -- Last Updated: @file-date-iso@
syzler@15 36 --
syzler@1 37 -- Misc helper functions used in the library
syzler@15 38 ------------------------------------------------------------------------
syzler@1 39
syzler@7 40 --- Gets a hashtable of buffs on the specified unit.
syzler@7 41 -- @param unit The unit frame name (e.g. "target", "player", "focus") of the unit whose buffs are to be retrieved.
syzler@7 42 -- @returns a hashtable of buff spell IDs keyed on the ID.
syzler@1 43 function MyLilPony.GetUnitBuffs(unit)
syzler@1 44 local buffs = {};
syzler@1 45 for i = 1, 40 do
syzler@1 46 local _, _, _, _, _, _, _, _, _, _, id = UnitAura(unit, i, "HELPFUL");
syzler@1 47 if id ~= nil then
syzler@1 48 buffs[id] = id;
syzler@1 49 end
syzler@1 50 end
syzler@1 51 return buffs;
syzler@1 52 end
syzler@1 53
syzler@7 54 --- Performs case-insensitive string pattern matching.
syzler@7 55 -- @param subject The string on which the pattern matching is performed.
syzler@7 56 -- @param pattern The pattern to be matched.
syzler@7 57 -- @returns The match result captures, the entire string if there are no captures, or nil if the subject is not a match.
syzler@1 58 function MyLilPony.StringMatchIgnoreCase(subject, pattern)
syzler@1 59 if subject == nil and pattern == nil then return true end
syzler@1 60 if subject == nil or pattern == nil then return false end
syzler@1 61 local lSub = string.lower(subject);
syzler@1 62 local lPat = string.lower(pattern);
syzler@1 63 return string.match(lSub, lPat);
syzler@1 64 end
syzler@1 65
syzler@7 66 --- Calls a companion if a specified condition checks out.
syzler@7 67 -- @param companionType The type of companion to be called (e.g. "MOUNT").
syzler@7 68 -- @param companionNumber The slot number of the companion to be called.
syzler@7 69 -- @param condition An optional Boolean condition.
syzler@1 70 function MyLilPony.CallCompanion(companionType, companionNumber, condition)
syzler@1 71 if condition == nil or condition then
syzler@1 72 CallCompanion(companionType, companionNumber);
syzler@1 73 end
syzler@1 74 end
syzler@1 75
syzler@7 76 --- Gets a value indicating whether or not the current character is able to fly at the current location.
syzler@7 77 -- This function checks whether or not the current location is a flyable area, and then additionally checks for knowledge of the proper flying skill (e.g. Cold Weather Flying for Northrend).
syzler@7 78 -- @returns A Boolean value indicating whether or not the current character is able to fly at the current location.
syzler@1 79 function MyLilPony.CanFlyHere()
syzler@1 80 if IsFlyableArea() then
syzler@1 81 SetMapToCurrentZone();
syzler@1 82 local continent = GetCurrentMapContinent();
syzler@1 83 if continent == 4 then
syzler@1 84 -- Northrend: requires Cold Weather Flying
syzler@1 85 return IsSpellKnown(54197);
syzler@1 86 elseif (continent == 1 or continent == 2) then
syzler@1 87 -- Old World: requires Flight Master's License
syzler@1 88 return IsSpellKnown(90267);
syzler@1 89 end
syzler@1 90 return true;
syzler@1 91 end
syzler@1 92 return false;
syzler@1 93 end
syzler@1 94
syzler@1 95 function MyLilPony.Print(msg)
syzler@1 96 DEFAULT_CHAT_FRAME:AddMessage("|cff8ed6f0"..msg);
syzler@1 97 end
syzler@1 98
syzler@1 99 function MyLilPony.Log(msg)
syzler@1 100 if MYLILPONY_DEBUG_LOGGING then
syzler@1 101 DEFAULT_CHAT_FRAME:AddMessage("|cff8ed6f0"..format("MyLilPony: %s", msg));
syzler@1 102 end
syzler@1 103 end