From 6d0c50977f7f7229304d3466e009b36381406fbe Mon Sep 17 00:00:00 2001 From: Foereaper Date: Sun, 21 Dec 2014 01:24:43 +0100 Subject: [PATCH 1/3] Added Guild method documentation Todo: Move a couple methods to player methods --- GuildMethods.h | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/GuildMethods.h b/GuildMethods.h index af220e7..fa2622e 100644 --- a/GuildMethods.h +++ b/GuildMethods.h @@ -10,6 +10,11 @@ namespace LuaGuild { /* GETTERS */ + /** + * Returns a table with the [Player]s in this [Guild] + * + * @return table guildPlayers : table of [Player]s + */ int GetMembers(Eluna* /*E*/, lua_State* L, Guild* guild) { lua_newtable(L); @@ -35,12 +40,22 @@ namespace LuaGuild return 1; } + /** + * Returns the member count of this [Guild] + * + * @return uint32 memberCount + */ int GetMemberCount(Eluna* /*E*/, lua_State* L, Guild* guild) { Eluna::Push(L, guild->GetMemberSize()); return 1; } + /** + * Finds and returns the [Guild] leader by their GUID if logged in + * + * @return [Player] leader + */ int GetLeader(Eluna* /*E*/, lua_State* L, Guild* guild) { #ifndef TRINITY @@ -51,6 +66,11 @@ namespace LuaGuild return 1; } + /** + * Returns [Guild] leader GUID + * + * @return uint64 leaderGUID + */ int GetLeaderGUID(Eluna* /*E*/, lua_State* L, Guild* guild) { #ifndef TRINITY @@ -61,24 +81,44 @@ namespace LuaGuild return 1; } + /** + * Returns the [Guild]s entry ID + * + * @return uint32 entryId + */ int GetId(Eluna* /*E*/, lua_State* L, Guild* guild) { Eluna::Push(L, guild->GetId()); return 1; } + /** + * Returns the [Guild]s name + * + * @return string guildName + */ int GetName(Eluna* /*E*/, lua_State* L, Guild* guild) { Eluna::Push(L, guild->GetName()); return 1; } + /** + * Returns the [Guild]s current Message Of The Day + * + * @return string guildMOTD + */ int GetMOTD(Eluna* /*E*/, lua_State* L, Guild* guild) { Eluna::Push(L, guild->GetMOTD()); return 1; } + /** + * Returns the [Guild]s current info + * + * @return string guildInfo + */ int GetInfo(Eluna* /*E*/, lua_State* L, Guild* guild) { #ifndef TRINITY @@ -91,6 +131,11 @@ namespace LuaGuild /* SETTERS */ #ifndef CATA + /** + * Sets the leader of this [Guild] + * + * @param [Player] leader : the [Player] leader to change + */ int SetLeader(Eluna* /*E*/, lua_State* L, Guild* guild) { Player* player = Eluna::CHECKOBJ(L, 2); @@ -105,6 +150,12 @@ namespace LuaGuild #endif #ifndef CLASSIC + /** + * Sets the information of the bank tab specified + * + * @param uint8 tabId : the ID of the tab specified + * @param string info : the information to be set to the bank tab + */ int SetBankTabText(Eluna* /*E*/, lua_State* L, Guild* guild) { uint8 tabId = Eluna::CHECKVAL(L, 2); @@ -120,6 +171,11 @@ namespace LuaGuild /* OTHER */ // SendPacketToGuild(packet) + /** + * Sends a [WorldPacket] to all the [Player]s in the [Guild] + * + * @param [WorldPacket] packet : the [WorldPacket] to be sent to the [Player]s + */ int SendPacket(Eluna* /*E*/, lua_State* L, Guild* guild) { WorldPacket* data = Eluna::CHECKOBJ(L, 2); @@ -129,6 +185,12 @@ namespace LuaGuild } // SendPacketToRankedInGuild(packet, rankId) + /** + * Sends a [WorldPacket] to all the [Player]s at the specified rank in the [Guild] + * + * @param [WorldPacket] packet : the [WorldPacket] to be sent to the [Player]s + * @param uint8 rankId : the rank ID + */ int SendPacketToRanked(Eluna* /*E*/, lua_State* L, Guild* guild) { WorldPacket* data = Eluna::CHECKOBJ(L, 2); @@ -138,12 +200,23 @@ namespace LuaGuild return 0; } + /** + * Disbands the [Guild] + */ int Disband(Eluna* /*E*/, lua_State* /*L*/, Guild* guild) { guild->Disband(); return 0; } + /** + * Adds the specified [Player] to the [Guild] at the specified rank. + * + * If no rank is specified, defaults to none. + * + * @param [Player] player : the [Player] to be added to the guild + * @param uint8 rankId : the rank ID + */ int AddMember(Eluna* /*E*/, lua_State* L, Guild* guild) { Player* player = Eluna::CHECKOBJ(L, 2); @@ -153,6 +226,12 @@ namespace LuaGuild return 0; } + /** + * Removes the specified [Player] from the [Guild]. + * + * @param [Player] player : the [Player] to be removed from the guild + * @param bool isDisbanding : default 'false', should only be set to 'true' if the guild is triggered to disband + */ int DeleteMember(Eluna* /*E*/, lua_State* L, Guild* guild) { Player* player = Eluna::CHECKOBJ(L, 2); @@ -166,6 +245,12 @@ namespace LuaGuild return 0; } + /** + * Promotes/demotes the [Player] to the specified rank. + * + * @param [Player] player : the [Player] to be promoted/demoted + * @param uint8 rankId : the rank ID + */ int SetMemberRank(Eluna* /*E*/, lua_State* L, Guild* guild) { Player* player = Eluna::CHECKOBJ(L, 2); From d6b65cdf4cf5de47779d08955bf76948c0f60830 Mon Sep 17 00:00:00 2001 From: Foereaper Date: Sun, 21 Dec 2014 02:13:33 +0100 Subject: [PATCH 2/3] Added Item method documentation --- ItemMethods.h | 246 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) diff --git a/ItemMethods.h b/ItemMethods.h index dfc8792..cbbc69d 100644 --- a/ItemMethods.h +++ b/ItemMethods.h @@ -10,6 +10,11 @@ namespace LuaItem { /* BOOLEAN */ + /** + * Returns 'true' if the [Item] is soulbound, 'false' otherwise + * + * @return bool isSoulBound + */ int IsSoulBound(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsSoulBound()); @@ -17,6 +22,11 @@ namespace LuaItem } #if (!defined(TBC) && !defined(CLASSIC)) + /** + * Returns 'true' if the [Item] is account bound, 'false' otherwise + * + * @return bool isAccountBound + */ int IsBoundAccountWide(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsBoundAccountWide()); @@ -24,12 +34,23 @@ namespace LuaItem } #endif + /** + * Returns 'true' if the [Item] is bound to a [Player] by an enchant, 'false' otehrwise + * + * @return bool isBoundByEnchant + */ int IsBoundByEnchant(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsBoundByEnchant()); return 1; } + /** + * Returns 'true' if the [Item] is not bound to the [Player] specified, 'false' otherwise + * + * @param [Player] player : the [Player] object to check the item against + * @return bool isNotBound + */ int IsNotBoundToPlayer(Eluna* /*E*/, lua_State* L, Item* item) { Player* player = Eluna::CHECKOBJ(L, 2); @@ -38,12 +59,22 @@ namespace LuaItem return 1; } + /** + * Returns 'true' if the [Item] is locked, 'false' otherwise + * + * @return bool isLocked + */ int IsLocked(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsLocked()); return 1; } + /** + * Returns 'true' if the [Item] is a bag, 'false' otherwise + * + * @return bool isBag + */ int IsBag(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsBag()); @@ -51,6 +82,11 @@ namespace LuaItem } #ifndef CLASSIC + /** + * Returns 'true' if the [Item] is a currency token, 'false' otherwise + * + * @return bool isCurrencyToken + */ int IsCurrencyToken(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsCurrencyToken()); @@ -58,18 +94,33 @@ namespace LuaItem } #endif + /** + * Returns 'true' if the [Item] is a not an empty bag, 'false' otherwise + * + * @return bool isNotEmptyBag + */ int IsNotEmptyBag(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsNotEmptyBag()); return 1; } + /** + * Returns 'true' if the [Item] is broken, 'false' otherwise + * + * @return bool isBroken + */ int IsBroken(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsBroken()); return 1; } + /** + * Returns 'true' if the [Item] can be traded, 'false' otherwise + * + * @return bool isTradeable + */ int CanBeTraded(Eluna* /*E*/, lua_State* L, Item* item) { #if (defined(TBC) || defined(CLASSIC)) @@ -81,24 +132,45 @@ namespace LuaItem return 1; } + /** + * Returns 'true' if the [Item] is currently in a trade window, 'false' otherwise + * + * @return bool isInTrade + */ int IsInTrade(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsInTrade()); return 1; } + /** + * Returns 'true' if the [Item] is currently in a bag, 'false' otherwise + * + * @return bool isInBag + */ int IsInBag(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsInBag()); return 1; } + /** + * Returns 'true' if the [Item] is currently equipped, 'false' otherwise + * + * @return bool isEquipped + */ int IsEquipped(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsEquipped()); return 1; } + /** + * Returns 'true' if the [Item] has the [Quest] specified tied to it, 'false' otherwise + * + * @param uint32 questId : the [Quest] id to be checked + * @return bool hasQuest + */ int HasQuest(Eluna* /*E*/, lua_State* L, Item* item) { uint32 quest = Eluna::CHECKVAL(L, 2); @@ -110,6 +182,11 @@ namespace LuaItem return 1; } + /** + * Returns 'true' if the [Item] is a potion, 'false' otherwise + * + * @return bool isPotion + */ int IsPotion(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsPotion()); @@ -117,12 +194,22 @@ namespace LuaItem } #ifndef CATA + /** + * Returns 'true' if the [Item] is a weapon vellum, 'false' otherwise + * + * @return bool isWeaponVellum + */ int IsWeaponVellum(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsWeaponVellum()); return 1; } + /** + * Returns 'true' if the [Item] is an armor vellum, 'false' otherwise + * + * @return bool isArmorVellum + */ int IsArmorVellum(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsArmorVellum()); @@ -130,6 +217,11 @@ namespace LuaItem } #endif + /** + * Returns 'true' if the [Item] is a conjured consumable, 'false' otherwise + * + * @return bool isConjuredConsumable + */ int IsConjuredConsumable(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->IsConjuredConsumable()); @@ -237,36 +329,67 @@ namespace LuaItem return 1; } + /** + * Returns the [Player] who currently owns the [Item] + * + * @return [Player] player : the [Player] who owns the [Item] + */ int GetOwner(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetOwner()); return 1; } + /** + * Returns the [Item]s stack count + * + * @return uint32 count + */ int GetCount(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetCount()); return 1; } + /** + * Returns the [Item]s max stack count + * + * @return uint32 maxCount + */ int GetMaxStackCount(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetMaxStackCount()); return 1; } + /** + * Returns the [Item]s current slot + * + * @return uint8 slot + */ int GetSlot(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetSlot()); return 1; } + /** + * Returns the [Item]s current bag slot + * + * @return uint8 bagSlot + */ int GetBagSlot(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetBagSlot()); return 1; } + /** + * Returns the [Item]s enchantment ID by enchant slot specified + * + * @param uint32 enchantSlot : the enchant slot specified + * @return uint32 enchantId : the id of the enchant slot specified + */ int GetEnchantmentId(Eluna* /*E*/, lua_State* L, Item* item) { uint32 enchant_slot = Eluna::CHECKVAL(L, 2); @@ -278,6 +401,12 @@ namespace LuaItem return 1; } + /** + * Returns the spell ID tied to the [Item] by spell index + * + * @param uint32 spellIndex : the spell index specified + * @return uint32 spellId : the id of the spell + */ int GetSpellId(Eluna* /*E*/, lua_State* L, Item* item) { uint32 index = Eluna::CHECKVAL(L, 2); @@ -288,6 +417,12 @@ namespace LuaItem return 1; } + /** + * Returns the spell trigger tied to the [Item] by spell index + * + * @param uint32 spellIndex : the spell index specified + * @return uint32 spellTrigger : the spell trigger of the specified index + */ int GetSpellTrigger(Eluna* /*E*/, lua_State* L, Item* item) { uint32 index = Eluna::CHECKVAL(L, 2); @@ -298,78 +433,143 @@ namespace LuaItem return 1; } + /** + * Returns class of the [Item] + * + * @return uint32 class + */ int GetClass(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->Class); return 1; } + /** + * Returns subclass of the [Item] + * + * @return uint32 subClass + */ int GetSubClass(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->SubClass); return 1; } + /** + * Returns the name of the [Item] + * + * @return string name + */ int GetName(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->Name1); return 1; } + /** + * Returns the display ID of the [Item] + * + * @return uint32 displayId + */ int GetDisplayId(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->DisplayInfoID); return 1; } + /** + * Returns the quality of the [Item] + * + * @return uint32 quality + */ int GetQuality(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->Quality); return 1; } + /** + * Returns the default purchase count of the [Item] + * + * @return uint32 count + */ int GetBuyCount(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->BuyCount); return 1; } + /** + * Returns the purchase price of the [Item] + * + * @return uint32 price + */ int GetBuyPrice(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->BuyPrice); return 1; } + /** + * Returns the sell price of the [Item] + * + * @return uint32 price + */ int GetSellPrice(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->SellPrice); return 1; } + /** + * Returns the inventory type of the [Item] + * + * @return uint32 inventoryType + */ int GetInventoryType(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->InventoryType); return 1; } + /** + * Returns the [Player] classes allowed to use this [Item] + * + * @return uint32 allowableClass + */ int GetAllowableClass(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->AllowableClass); return 1; } + /** + * Returns the [Player] races allowed to use this [Item] + * + * @return uint32 allowableRace + */ int GetAllowableRace(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->AllowableRace); return 1; } + /** + * Returns the [Item]s level + * + * @return uint32 itemLevel + */ int GetItemLevel(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->ItemLevel); return 1; } + /** + * Returns the minimum level required to use this [Item] + * + * @return uint32 requiredLevel + */ int GetRequiredLevel(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->RequiredLevel); @@ -384,6 +584,11 @@ namespace LuaItem } #endif + /** + * Returns the random property ID of this [Item] + * + * @return uint32 randomPropertyId + */ int GetRandomProperty(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->RandomProperty); @@ -398,12 +603,22 @@ namespace LuaItem } #endif + /** + * Returns the item set ID of this [Item] + * + * @return uint32 itemSetId + */ int GetItemSet(Eluna* /*E*/, lua_State* L, Item* item) { Eluna::Push(L, item->GetTemplate()->ItemSet); return 1; } + /** + * Returns the bag size of this [Item], 0 if [Item] is not a bag + * + * @return uint32 bagSize + */ int GetBagSize(Eluna* /*E*/, lua_State* L, Item* item) { if (Bag* bag = item->ToBag()) @@ -414,6 +629,11 @@ namespace LuaItem } /* SETTERS */ + /** + * Sets the [Player] specified as the owner of the [Item] + * + * @param [Player] player : the [Player] specified + */ int SetOwner(Eluna* /*E*/, lua_State* L, Item* item) { Player* player = Eluna::CHECKOBJ(L, 2); @@ -425,6 +645,11 @@ namespace LuaItem return 0; } + /** + * Sets the binding of the [Item] to 'true' or 'false' + * + * @param bool setBinding + */ int SetBinding(Eluna* /*E*/, lua_State* L, Item* item) { bool soulbound = Eluna::CHECKVAL(L, 2); @@ -433,6 +658,11 @@ namespace LuaItem return 0; } + /** + * Sets the stack count of the [Item] + * + * @param uint32 count + */ int SetCount(Eluna* /*E*/, lua_State* L, Item* item) { uint32 count = Eluna::CHECKVAL(L, 2); @@ -440,6 +670,13 @@ namespace LuaItem return 0; } + /** + * Sets the specified enchantment of the [Item] to the specified slot + * + * @param uint32 enchantId : the ID of the enchant to be applied + * @param uint32 enchantSlot : the slot for the enchant to be applied to + * @return bool enchantmentSuccess : if enchantment is successfully set to specified slot, returns 'true', otherwise 'false' + */ int SetEnchantment(Eluna* /*E*/, lua_State* L, Item* item) { Player* owner = item->GetOwner(); @@ -468,6 +705,12 @@ namespace LuaItem } /* OTHER */ + /** + * Removes an enchant from the [Item] by the specified slot + * + * @param uint32 enchantSlot : the slot for the enchant to be removed from + * @return bool enchantmentRemoved : if enchantment is successfully removed from specified slot, returns 'true', otherwise 'false' + */ int ClearEnchantment(Eluna* /*E*/, lua_State* L, Item* item) { Player* owner = item->GetOwner(); @@ -493,6 +736,9 @@ namespace LuaItem return 1; } + /** + * Saves the [Item] to the database + */ int SaveToDB(Eluna* /*E*/, lua_State* /*L*/, Item* item) { #ifndef TRINITY From 20eeccf81543d8bebfd23ba32ddfb230b4118b3c Mon Sep 17 00:00:00 2001 From: Foereaper Date: Sun, 21 Dec 2014 06:08:46 +0100 Subject: [PATCH 3/3] Added requested movement method Todo: Implement TC equivalent Part of #80 --- LuaFunctions.cpp | 3 +++ UnitMethods.h | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/LuaFunctions.cpp b/LuaFunctions.cpp index a889023..062a37a 100644 --- a/LuaFunctions.cpp +++ b/LuaFunctions.cpp @@ -263,6 +263,9 @@ ElunaRegister UnitMethods[] = { "GetVehicleKit", &LuaUnit::GetVehicleKit }, // :GetVehicleKit() - Gets unit's Vehicle kit if the unit is a vehicle // {"GetVehicle", &LuaUnit::GetVehicle}, // :GetVehicle() - Gets the Vehicle kit of the vehicle the unit is on #endif +#ifdef MANGOS + { "GetMovementType", &LuaUnit::GetMovementType }, +#endif // Setters { "SetFaction", &LuaUnit::SetFaction }, // :SetFaction(factionId) - Sets the unit's faction diff --git a/UnitMethods.h b/UnitMethods.h index ac2ad98..2d73c57 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -880,6 +880,42 @@ namespace LuaUnit return 1; } + /** + * Returns the current movement type for this [Unit]. + * + *
+    * enum MovementGeneratorType
+    * {
+    *     IDLE_MOTION_TYPE                = 0,
+    *     RANDOM_MOTION_TYPE              = 1,
+    *     WAYPOINT_MOTION_TYPE            = 2,
+    *     MAX_DB_MOTION_TYPE              = 3,
+    * 
+    *     CONFUSED_MOTION_TYPE            = 4,
+    *     CHASE_MOTION_TYPE               = 5,
+    *     HOME_MOTION_TYPE                = 6,
+    *     FLIGHT_MOTION_TYPE              = 7,
+    *     POINT_MOTION_TYPE               = 8,
+    *     FLEEING_MOTION_TYPE             = 9,
+    *     DISTRACT_MOTION_TYPE            = 10,
+    *     ASSISTANCE_MOTION_TYPE          = 11,
+    *     ASSISTANCE_DISTRACT_MOTION_TYPE = 12,          
+    *     TIMED_FLEEING_MOTION_TYPE       = 13,
+    *     FOLLOW_MOTION_TYPE              = 14,
+    *     EFFECT_MOTION_TYPE              = 15,
+    * };
+    * 
+ * + * @return MovementGeneratorType movementType + */ +#ifdef MANGOS + int GetMovementType(Eluna* /*E*/, lua_State* L, Unit* unit) + { + Eluna::Push(L, unit->GetMotionMaster()->GetCurrentMovementGeneratorType()); + return 1; + } +#endif + /* SETTERS */ int SetOwnerGUID(Eluna* /*E*/, lua_State* L, Unit* unit) {