diff --git a/PlayerMethods.h b/PlayerMethods.h index 0f05fc4..188fb4b 100644 --- a/PlayerMethods.h +++ b/PlayerMethods.h @@ -12,7 +12,7 @@ namespace LuaPlayer /* BOOLEAN */ #if (!defined(TBC) && !defined(CLASSIC)) /** - * Returns 'true' if the [Player] can Titan Grip, 'false' otherwise + * Returns 'true' if the [Player] can Titan Grip, 'false' otherwise. * * @return bool canTitanGrip */ @@ -23,7 +23,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] has a talent by ID in specified talent tree, 'false' otherwise + * Returns 'true' if the [Player] has a talent by ID in specified talent tree, 'false' otherwise. * * @param uint32 talentId : talent ID to check * @param uint8 spec : specified talent tree @@ -40,7 +40,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] has completed the specified achievement, 'false' otherwise + * Returns 'true' if the [Player] has completed the specified achievement, 'false' otherwise. * * @param uint32 achievementId * @return bool hasAchieved @@ -58,7 +58,7 @@ namespace LuaPlayer #endif /** - * Returns 'true' if the [Player] has an active [Quest] by specific ID, 'false' otherwise + * Returns 'true' if the [Player] has an active [Quest] by specific ID, 'false' otherwise. * * @param uint32 questId * @return bool hasQuest @@ -72,7 +72,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] has a skill by specific ID, 'false' otherwise + * Returns 'true' if the [Player] has a skill by specific ID, 'false' otherwise. * * @param uint32 skill * @return bool hasSkill @@ -86,7 +86,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] has a [Spell] by specific ID, 'false' otherwise + * Returns 'true' if the [Player] has a [Spell] by specific ID, 'false' otherwise. * * @param uint32 spellId * @return bool hasSpell @@ -117,7 +117,7 @@ namespace LuaPlayer #ifndef CLASSIC /** - * Returns 'true' if the [Player] has a title by specific ID, 'false' otherwise + * Returns 'true' if the [Player] has a title by specific ID, 'false' otherwise. * * @param uint32 titleId * @return bool hasTitle @@ -131,7 +131,15 @@ namespace LuaPlayer return 1; } #endif - + + /** + * Returns 'true' if the [Player] has the given amount of item entry specified, 'false' otherwise. + * + * @param uint32 itemId : entry of the item + * @param uint32 count = 1 : amount of items the player needs should have + * @param bool check_bank = false : determines if the item can be in player bank + * @return bool hasItem + */ int HasItem(Eluna* /*E*/, lua_State* L, Player* player) { uint32 itemId = Eluna::CHECKVAL(L, 2); @@ -140,7 +148,13 @@ namespace LuaPlayer Eluna::Push(L, player->HasItemCount(itemId, count, check_bank)); return 1; } - + + /** + * Returns 'true' if the [Player] has a quest for the item entry specified, 'false' otherwise. + * + * @param uint32 entry : entry of the item + * @return bool hasQuest + */ int HasQuestForItem(Eluna* /*E*/, lua_State* L, Player* player) { uint32 entry = Eluna::CHECKVAL(L, 2); @@ -148,26 +162,35 @@ namespace LuaPlayer Eluna::Push(L, player->HasQuestForItem(entry)); return 1; } - + + /** + * Returns 'true' if the [Player] can use the item or item entry specified, 'false' otherwise. + * + * @proto canUse = (item) + * @proto canUse = (entry) + * @param [Item] item : an instance of an item + * @param uint32 entry : entry of the item + * @return bool canUse + */ int CanUseItem(Eluna* /*E*/, lua_State* L, Player* player) { Item* item = Eluna::CHECKOBJ(L, 2, false); if (item) - Eluna::Push(L, player->CanUseItem(item)); + Eluna::Push(L, player->CanUseItem(item) == EQUIP_ERR_OK); else { uint32 entry = Eluna::CHECKVAL(L, 2); const ItemTemplate* temp = eObjectMgr->GetItemTemplate(entry); if (temp) - Eluna::Push(L, player->CanUseItem(temp)); + Eluna::Push(L, player->CanUseItem(temp) == EQUIP_ERR_OK); else - Eluna::Push(L, EQUIP_ERR_ITEM_NOT_FOUND); + Eluna::Push(L, false); } return 1; } /** - * Returns 'true' if the [Spell] specified by ID is currently on cooldown for the [Player], 'false' otherwise + * Returns 'true' if the [Spell] specified by ID is currently on cooldown for the [Player], 'false' otherwise. * * @param uint32 spellId * @return bool hasSpellCooldown @@ -181,7 +204,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] can share [Quest] specified by ID, 'false' otherwise + * Returns 'true' if the [Player] can share [Quest] specified by ID, 'false' otherwise. * * @param uint32 entryId * @return bool hasSpellCooldown @@ -195,7 +218,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] can currently communicate through chat, 'false' otherwise + * Returns 'true' if the [Player] can currently communicate through chat, 'false' otherwise. * * @return bool canSpeak */ @@ -206,7 +229,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] has permission to uninvite others from the current group, 'false' otherwise + * Returns 'true' if the [Player] has permission to uninvite others from the current group, 'false' otherwise. * * @return bool canUninviteFromGroup */ @@ -218,7 +241,7 @@ namespace LuaPlayer #ifndef CLASSIC /** - * Returns 'true' if the [Player] can fly, 'false' otherwise + * Returns 'true' if the [Player] can fly, 'false' otherwise. * * @return bool canFly */ @@ -252,7 +275,7 @@ namespace LuaPlayer #endif /** - * Returns 'true' if the [Player] is currently in water, 'false' otherwise + * Returns 'true' if the [Player] is currently in water, 'false' otherwise. * * @return bool isInWater */ @@ -263,7 +286,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is currently moving, 'false' otherwise + * Returns 'true' if the [Player] is currently moving, 'false' otherwise. * * @return bool isMoving */ @@ -304,7 +327,7 @@ namespace LuaPlayer #ifndef CLASSIC /** - * Returns 'true' if the [Player] is currently flying, 'false' otherwise + * Returns 'true' if the [Player] is currently flying, 'false' otherwise. * * @return bool isFlying */ @@ -316,7 +339,7 @@ namespace LuaPlayer #endif /** - * Returns 'true' if the [Player] is in a [Group], 'false' otherwise + * Returns 'true' if the [Player] is in a [Group], 'false' otherwise. * * @return bool isInGroup */ @@ -327,7 +350,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is in a [Guild], 'false' otherwise + * Returns 'true' if the [Player] is in a [Guild], 'false' otherwise. * * @return bool isInGuild */ @@ -338,7 +361,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is a Game Master, 'false' otherwise + * Returns 'true' if the [Player] is a Game Master, 'false' otherwise. * * Note: This is only true when GM tag is activated! For alternative see [Player:GetGMRank] * @@ -356,7 +379,7 @@ namespace LuaPlayer #ifndef CLASSIC /** - * Returns 'true' if the [Player] is in an arena team specified by type, 'false' otherwise + * Returns 'true' if the [Player] is in an arena team specified by type, 'false' otherwise. * * @param uint32 type * @return bool isInArenaTeam @@ -373,7 +396,7 @@ namespace LuaPlayer #endif /** - * Returns 'true' if the [Player] is a part of the Horde faction, 'false' otherwise + * Returns 'true' if the [Player] is a part of the Horde faction, 'false' otherwise. * * @return bool isHorde */ @@ -384,9 +407,9 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is a part of the Alliance faction, 'false' otherwise + * Returns 'true' if the [Player] is a part of the Alliance faction, 'false' otherwise. * - * @return bool isHorde + * @return bool isAlliance */ int IsAlliance(Eluna* /*E*/, lua_State* L, Player* player) { @@ -395,7 +418,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is 'Do Not Disturb' flagged, 'false' otherwise + * Returns 'true' if the [Player] is 'Do Not Disturb' flagged, 'false' otherwise. * * @return bool isDND */ @@ -406,7 +429,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is 'Away From Keyboard' flagged, 'false' otherwise + * Returns 'true' if the [Player] is 'Away From Keyboard' flagged, 'false' otherwise. * * @return bool isAFK */ @@ -417,7 +440,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is currently falling, 'false' otherwise + * Returns 'true' if the [Player] is currently falling, 'false' otherwise. * * @return bool isFalling */ @@ -435,7 +458,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is currently in the same raid as another [Player] by object, 'false' otherwise + * Returns 'true' if the [Player] is currently in the same raid as another [Player] by object, 'false' otherwise. * * @param [Player] player * @return bool isInSameRaidWith @@ -448,7 +471,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is currently in the same [Group] as another [Player] by object, 'false' otherwise + * Returns 'true' if the [Player] is currently in the same [Group] as another [Player] by object, 'false' otherwise. * * @param [Player] player * @return bool isInSameGroupWith @@ -461,7 +484,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is eligible for Honor or XP gain by [Unit] specified, 'false' otherwise + * Returns 'true' if the [Player] is eligible for Honor or XP gain by [Unit] specified, 'false' otherwise. * * @param [Unit] unit * @return bool isHonorOrXPTarget @@ -475,7 +498,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] can see anoter [Player] specified by object, 'false' otherwise + * Returns 'true' if the [Player] can see anoter [Player] specified by object, 'false' otherwise. * * @param [Player] player * @return bool isVisibleForPlayer @@ -495,7 +518,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] has taxi cheat activated, 'false' otherwise + * Returns 'true' if the [Player] has taxi cheat activated, 'false' otherwise. * * @return bool isTaxiCheater */ @@ -516,7 +539,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is accepting whispers, 'false' otherwise + * Returns 'true' if the [Player] is accepting whispers, 'false' otherwise. * * @return bool isAcceptingWhispers */ @@ -527,7 +550,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is currently rested, 'false' otherwise + * Returns 'true' if the [Player] is currently rested, 'false' otherwise. * * @return bool isRested */ @@ -538,7 +561,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] is currently in a [BattleGround] queue, 'false' otherwise + * Returns 'true' if the [Player] is currently in a [BattleGround] queue, 'false' otherwise. * * @return bool inBattlegroundQueue */ @@ -554,7 +577,7 @@ namespace LuaPlayer #ifndef CLASSIC /** - * Returns 'true' if the [Player] is currently in an arena, 'false' otherwise + * Returns 'true' if the [Player] is currently in an arena, 'false' otherwise. * * @return bool inArena */ @@ -566,7 +589,7 @@ namespace LuaPlayer #endif /** - * Returns 'true' if the [Player] is currently in a [BattleGround], 'false' otherwise + * Returns 'true' if the [Player] is currently in a [BattleGround], 'false' otherwise. * * @return bool inBattleGround */ @@ -581,7 +604,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] can block incomming attacks, 'false' otherwise + * Returns 'true' if the [Player] can block incomming attacks, 'false' otherwise. * * @return bool canBlock */ @@ -592,7 +615,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player] can parry incomming attacks, 'false' otherwise + * Returns 'true' if the [Player] can parry incomming attacks, 'false' otherwise. * * @return bool canParry */ @@ -687,6 +710,11 @@ namespace LuaPlayer #endif #ifdef WOTLK + /** + * Returns the normal phase of the player instead of the actual phase possibly containing GM phase + * + * @return uint32 phasemask + */ int GetPhaseMaskForSpawn(Eluna* /*E*/, lua_State* L, Player* player) { Eluna::Push(L, player->GetPhaseMaskForSpawn()); @@ -1086,7 +1114,7 @@ namespace LuaPlayer } /** - * Returns 'true' if the [Player]s [Quest] specified by entry ID has been rewarded, 'false' otherwise + * Returns 'true' if the [Player]s [Quest] specified by entry ID has been rewarded, 'false' otherwise. * * @param uint32 questId * @return bool questRewardStatus @@ -1249,7 +1277,12 @@ namespace LuaPlayer Eluna::Push(L, player->GetItemByEntry(entry)); return 1; } - + + /** + * Returns the database textID of the [WorldObject]'s gossip header text for the [Player] + * + * @return uint32 textId : key to npc_text database table + */ int GetGossipTextId(Eluna* /*E*/, lua_State* L, Player* player) { WorldObject* obj = Eluna::CHECKOBJ(L, 2); @@ -1315,12 +1348,19 @@ namespace LuaPlayer Eluna::Push(L, player->GetTeamId()); return 1; } - + + /** + * Returns amount of the specified [Item] the [Player] has. + * + * @param uint32 entry : entry of the item + * @param bool checkinBank = false : also counts the items in player's bank if true + * @return uint32 itemamount + */ int GetItemCount(Eluna* /*E*/, lua_State* L, Player* player) { - int id = Eluna::CHECKVAL(L, 2); + uint32 entry = Eluna::CHECKVAL(L, 2); bool checkinBank = Eluna::CHECKVAL(L, 3, false); - Eluna::Push(L, player->GetItemCount(id, checkinBank)); + Eluna::Push(L, player->GetItemCount(entry, checkinBank)); return 1; } @@ -1472,6 +1512,12 @@ namespace LuaPlayer }*/ /* SETTERS */ + + /** + * Locks the player controls and disallows all movement and casting. + * + * @param bool apply = true : lock if true and unlock if false + */ int SetPlayerLock(Eluna* /*E*/, lua_State* L, Player* player) { bool apply = Eluna::CHECKVAL(L, 2, true); @@ -1927,7 +1973,12 @@ namespace LuaPlayer return 0; } #endif - + + /** + * Shows the mailbox window to the player from specified guid. + * + * @param uint64 guid = playerguid : guid of the mailbox window sender + */ int SendShowMailBox(Eluna* /*E*/, lua_State* L, Player* player) { uint64 guid = Eluna::CHECKVAL(L, 2, player->GET_GUID()); @@ -1980,7 +2031,18 @@ namespace LuaPlayer player->SaveToDB(); return 0; } - + + /** + * Sends a summon request popup for the given [Player] to the given location + * + * @param [Player] target : player to summon + * @param uint32 map + * @param float x + * @param float y + * @param float z + * @param uint32 zoneId + * @param uint32 delay = 2*MINUTE : time for the popup to be available for the target in milliseconds + */ int SummonPlayer(Eluna* /*E*/, lua_State* L, Player* player) { Player* target = Eluna::CHECKOBJ(L, 2); @@ -1988,8 +2050,8 @@ namespace LuaPlayer float x = Eluna::CHECKVAL(L, 4); float y = Eluna::CHECKVAL(L, 5); float z = Eluna::CHECKVAL(L, 6); - float zoneId = Eluna::CHECKVAL(L, 7); - uint32 delay = Eluna::CHECKVAL(L, 8, 0); + uint32 zoneId = Eluna::CHECKVAL(L, 7); + uint32 delay = Eluna::CHECKVAL(L, 8, MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS); if (!MapManager::IsValidMapCoord(map, x, y, z)) return 0; @@ -1997,7 +2059,7 @@ namespace LuaPlayer WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4); data << uint64(player->GetGUIDLow()); data << uint32(zoneId); - data << uint32(delay ? delay* IN_MILLISECONDS : MAX_PLAYER_SUMMON_DELAY * IN_MILLISECONDS); + data << uint32(delay); target->GetSession()->SendPacket(&data); return 0; } @@ -2097,7 +2159,7 @@ namespace LuaPlayer } /** - * Sends a bank window to the [Player] from the [WorldObject] specified + * Sends a bank window to the [Player] from the [WorldObject] specified. * * @param [WorldObject] sender */ @@ -2108,7 +2170,12 @@ namespace LuaPlayer player->GetSession()->SendShowBank(obj->GET_GUID()); return 0; } - + + /** + * Sends a vendor window to the [Player] from the [WorldObject] specified. + * + * @param [WorldObject] sender + */ int SendListInventory(Eluna* /*E*/, lua_State* L, Player* player) { WorldObject* obj = Eluna::CHECKOBJ(L, 2); @@ -2562,7 +2629,17 @@ namespace LuaPlayer player->ToggleAFK(); return 0; } - + + /** + * Equips the given item or item entry to the given slot. Returns the equipped item or nil. + * + * @proto equippedItem = (item, slot) + * @proto equippedItem = (entry, slot) + * @param [Item] item : item to equip + * @param uint32 entry : entry of the item to equip + * @param uint32 slot : equipment slot to equip the item to + * @return [Item] equippedItem : item or nil if equipping failed + */ int EquipItem(Eluna* /*E*/, lua_State* L, Player* player) { uint16 dest = 0; @@ -2599,9 +2676,20 @@ namespace LuaPlayer } Eluna::Push(L, player->EquipItem(dest, item, true)); + player->AutoUnequipOffhandIfNeed(); return 1; } - + + /** + * Returns true if the player can equip the given [Item] or item entry to the given slot, false otherwise. + * + * @proto canEquip = (item, slot) + * @proto canEquip = (entry, slot) + * @param [Item] item : item to equip + * @param uint32 entry : entry of the item to equip + * @param uint32 slot : equipment slot to test + * @return bool canEquip + */ int CanEquipItem(Eluna* /*E*/, lua_State* L, Player* player) { Item* item = Eluna::CHECKOBJ(L, 2, false); @@ -2748,11 +2836,18 @@ namespace LuaPlayer player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills + val); return 0; } - + + /** + * Adds the given amount of the specified item entry to the player. + * + * @param uint32 entry : entry of the item to add + * @param uint32 itemCount = 1 : amount of the item to add + * @return [Item] item : the item that was added or nil + */ int AddItem(Eluna* /*E*/, lua_State* L, Player* player) { uint32 itemId = Eluna::CHECKVAL(L, 2); - uint32 itemCount = Eluna::CHECKVAL(L, 3); + uint32 itemCount = Eluna::CHECKVAL(L, 3, 1); #ifndef TRINITY Eluna::Push(L, player->StoreNewItemInInventorySlot(itemId, itemCount)); @@ -2773,7 +2868,17 @@ namespace LuaPlayer #endif return 1; } - + + /** + * Removes the given amount of the specified [Item] from the player. + * + * @proto item = (item, itemCount) + * @proto item = (entry, itemCount) + * @param [Item] item : item to remove + * @param uint32 entry : entry of the item to remove + * @param uint32 itemCount = 1 : amount of the item to add + * @return [Item] item : the item that was added or nil + */ int RemoveItem(Eluna* /*E*/, lua_State* L, Player* player) { Item* item = Eluna::CHECKOBJ(L, 2, false); @@ -2916,13 +3021,6 @@ namespace LuaPlayer return 0; } - int SendVendorWindow(Eluna* /*E*/, lua_State* L, Player* player) - { - Unit* sendTo = Eluna::CHECKOBJ(L, 2); - player->GetSession()->SendListInventory(sendTo->GET_GUID()); - return 0; - } - /** * Kicks the [Player] from the server */ @@ -2935,7 +3033,7 @@ namespace LuaPlayer /** * Adds or subtracts from the [Player]s money in copper * - * @param int32 copperAmt + * @param int32 copperAmt : negative to remove, positive to add */ int ModifyMoney(Eluna* /*E*/, lua_State* L, Player* player) { @@ -2978,7 +3076,7 @@ namespace LuaPlayer } /** - * Resurrects the [Player] + * Resurrects the [Player]. * * @param float healthPercent = 100.0f * @param bool ressSickness = false @@ -2992,6 +3090,24 @@ namespace LuaPlayer return 0; } + /** + * Adds a new item to the gossip menu shown to the [Player] on next call to [Player:GossipSendMenu]. + * + * sender and intid are numbers which are passed directly to the gossip selection handler. Internally they are partly used for the database gossip handling. + * code specifies whether to show a box to insert text to. The player inserted text is passed to the gossip selection handler. + * money specifies an amount of money the player needs to have to click the option. An error message is shown if the player doesn't have enough money. + * Note that the money amount is only checked client side and is not removed from the player either. You will need to check again in your code before taking action. + * + * See also: [Player:GossipSendMenu], [Player:GossipAddQuests], [Player:GossipComplete], [Player:GossipClearMenu] + * + * @param uint32 icon : number that specifies used icon + * @param string msg : label on the gossip item + * @param uint32 sender : number passed to gossip handlers + * @param uint32 intid : number passed to gossip handlers + * @param uint32 code = false : show text input on click if true + * @param string popup = nil : if non empty string, a popup with given text shown on click + * @param uint32 money = 0 : required money in copper + */ int GossipMenuAddItem(Eluna* /*E*/, lua_State* L, Player* player) { uint32 _icon = Eluna::CHECKVAL(L, 2); @@ -3014,7 +3130,9 @@ namespace LuaPlayer } /** - * Closes the [Player]s currently open Gossip Menu + * Closes the [Player]s currently open Gossip Menu. + * + * See also: [Player:GossipMenuAddItem], [Player:GossipAddQuests], [Player:GossipSendMenu], [Player:GossipClearMenu] */ int GossipComplete(Eluna* /*E*/, lua_State* /*L*/, Player* player) { @@ -3026,23 +3144,34 @@ namespace LuaPlayer return 0; } + /** + * Sends the current gossip items of the player to him as a gossip menu with header text from the given textId. + * + * See also: [Player:GossipMenuAddItem], [Player:GossipAddQuests], [Player:GossipComplete], [Player:GossipClearMenu] + * + * @param uint32 npc_text : entry ID of a header text in npc_text database table, common default is 100 + * @param [Object] sender : object acting as the source of the sent gossip menu + */ int GossipSendMenu(Eluna* /*E*/, lua_State* L, Player* player) { - uint32 _npcText = Eluna::CHECKVAL(L, 2); + uint32 npc_text = Eluna::CHECKVAL(L, 2); Object* sender = Eluna::CHECKOBJ(L, 3); if (sender->GetTypeId() == TYPEID_PLAYER) { uint32 menu_id = Eluna::CHECKVAL(L, 4); player->PlayerTalkClass->GetGossipMenu().SetMenuId(menu_id); } - player->PlayerTalkClass->SendGossipMenu(_npcText, sender->GET_GUID()); + player->PlayerTalkClass->SendGossipMenu(npc_text, sender->GET_GUID()); return 0; } /** - * Clears the [Player]s currently open Gossip Menu + * Clears the [Player]s current gossip item list. + * + * See also: [Player:GossipMenuAddItem], [Player:GossipSendMenu], [Player:GossipAddQuests], [Player:GossipComplete] * - * Note: This is ONLY needed when a [Player] is the sender of a Gossip Menu + * Note: This is needed when you show a gossip menu without using gossip hello or select hooks which do this automatically. + * Usually this is needed when using [Player] is the sender of a Gossip Menu. */ int GossipClearMenu(Eluna* /*E*/, lua_State* /*L*/, Player* player) { @@ -3061,6 +3190,11 @@ namespace LuaPlayer return 0; } + /** + * Attempts to start the taxi/flying to the given pathID + * + * @param uint32 pathId : pathId from DBC or [Global:AddTaxiPath] + */ int StartTaxi(Eluna* /*E*/, lua_State* L, Player* player) { uint32 pathId = Eluna::CHECKVAL(L, 2); @@ -3089,6 +3223,11 @@ namespace LuaPlayer return 0; } + /** + * Adds the gossip items to the [Player]'s gossip for the quests the given [WorldObject] can offer to the player. + * + * @param [WorldObject] source : a questgiver with quests + */ int GossipAddQuests(Eluna* /*E*/, lua_State* L, Player* player) { WorldObject* source = Eluna::CHECKOBJ(L, 2); @@ -3106,16 +3245,22 @@ namespace LuaPlayer return 0; } + /** + * Shows a quest accepting window to the [Player] for the given quest. + * + * @param uint32 questId : entry of a quest + * @param bool activateAccept = true : auto finish the quest + */ int SendQuestTemplate(Eluna* /*E*/, lua_State* L, Player* player) { uint32 questId = Eluna::CHECKVAL(L, 2); - bool activeAccept = Eluna::CHECKVAL(L, 3, true); + bool activateAccept = Eluna::CHECKVAL(L, 3, true); Quest const* quest = eObjectMgr->GetQuestTemplate(questId); if (!quest) return 0; - player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GET_GUID(), activeAccept); + player->PlayerTalkClass->SendQuestGiverQuestDetails(quest, player->GET_GUID(), activateAccept); return 0; } diff --git a/UnitMethods.h b/UnitMethods.h index f5c1da0..3cee44e 100644 --- a/UnitMethods.h +++ b/UnitMethods.h @@ -25,18 +25,33 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is standing. + * + * @return bool isStanding + */ int IsStandState(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->IsStandState()); return 1; } + /** + * Returns true if the [Unit] is mounted. + * + * @return bool isMounted + */ int IsMounted(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->IsMounted()); return 1; } + /** + * Returns true if the [Unit] is rooted. + * + * @return bool isRooted + */ int IsRooted(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef TRINITY @@ -51,12 +66,24 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] has full health. + * + * @return bool hasFullHealth + */ int IsFullHealth(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->IsFullHealth()); return 1; } + /** + * Returns true if the [WorldObject] is within given radius of the [Unit]. + * + * @param [WorldObject] obj + * @param float radius + * @return bool withinDist + */ int IsWithinDistInMap(Eluna* /*E*/, lua_State* L, Unit* unit) { WorldObject* obj = Eluna::CHECKOBJ(L, 2); @@ -66,6 +93,13 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is in an accessible place for the given [Creature]. + * + * @param [WorldObject] obj + * @param float radius + * @return bool isAccessible + */ int IsInAccessiblePlaceFor(Eluna* /*E*/, lua_State* L, Unit* unit) { Creature* creature = Eluna::CHECKOBJ(L, 2); @@ -78,6 +112,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] an auctioneer. + * + * @return bool isAuctioneer + */ int IsAuctioneer(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -88,6 +127,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] a guild master. + * + * @return bool isGuildMaster + */ int IsGuildMaster(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -98,6 +142,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] an innkeeper. + * + * @return bool isInnkeeper + */ int IsInnkeeper(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -108,6 +157,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] a trainer. + * + * @return bool isTrainer + */ int IsTrainer(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -118,6 +172,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is able to show a gossip window. + * + * @return bool hasGossip + */ int IsGossip(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -128,6 +187,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is a taxi master. + * + * @return bool isTaxi + */ int IsTaxi(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -138,6 +202,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is a spirit healer. + * + * @return bool isSpiritHealer + */ int IsSpiritHealer(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -148,6 +217,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is a spirit guide. + * + * @return bool isSpiritGuide + */ int IsSpiritGuide(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -158,6 +232,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is a tabard designer. + * + * @return bool isTabardDesigner + */ int IsTabardDesigner(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -168,6 +247,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] provides services like vendor, training and auction. + * + * @return bool isTabardDesigner + */ int IsServiceProvider(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -178,6 +262,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is a spirit guide or spirit healer. + * + * @return bool isSpiritService + */ int IsSpiritService(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -188,6 +277,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is alive. + * + * @return bool isAlive + */ int IsAlive(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -198,6 +292,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is dead. + * + * @return bool isDead + */ int IsDead(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef MANGOS @@ -208,6 +307,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is dying. + * + * @return bool isDying + */ int IsDying(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef MANGOS @@ -218,6 +322,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is a banker. + * + * @return bool isBanker + */ int IsBanker(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -228,6 +337,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is a vendor. + * + * @return bool isVendor + */ int IsVendor(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -238,6 +352,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is a battle master. + * + * @return bool isBattleMaster + */ int IsBattleMaster(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -248,6 +367,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is a charmed. + * + * @return bool isCharmed + */ int IsCharmed(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -258,6 +382,11 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is an armorer and can repair equipment. + * + * @return bool isArmorer + */ int IsArmorer(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -268,12 +397,22 @@ namespace LuaUnit return 1; } + /** + * Returns true if the [Unit] is attacking a player. + * + * @return bool isAttackingPlayer + */ int IsAttackingPlayer(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->isAttackingPlayer()); return 1; } + /** + * Returns true if the [Unit] flagged for PvP. + * + * @return bool isPvP + */ int IsPvPFlagged(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->IsPvP()); @@ -281,6 +420,11 @@ namespace LuaUnit } #ifndef CLASSIC + /** + * Returns true if the [Unit] is on a [Vehicle]. + * + * @return bool isOnVehicle + */ int IsOnVehicle(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -291,7 +435,12 @@ namespace LuaUnit return 1; } #endif - + + /** + * Returns true if the [Unit] is in combat. + * + * @return bool inCombat + */ int IsInCombat(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -301,25 +450,45 @@ namespace LuaUnit #endif return 1; } - + + /** + * Returns true if the [Unit] is under water. + * + * @return bool underWater + */ int IsUnderWater(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->IsUnderWater()); return 1; } - + + /** + * Returns true if the [Unit] is in water. + * + * @return bool inWater + */ int IsInWater(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->IsInWater()); return 1; } - + + /** + * Returns true if the [Unit] is not moving. + * + * @return bool notMoving + */ int IsStopped(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->IsStopped()); return 1; } - + + /** + * Returns true if the [Unit] is a quest giver. + * + * @return bool questGiver + */ int IsQuestGiver(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifdef CMANGOS @@ -329,19 +498,37 @@ namespace LuaUnit #endif return 1; } - + + /** + * Returns true if the [Unit]'s health is below the given percentage. + * + * @param int32 healthpct : percentage in integer from + * @return bool isBelow + */ int HealthBelowPct(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->HealthBelowPct(Eluna::CHECKVAL(L, 2))); return 1; } - + + /** + * Returns true if the [Unit]'s health is above the given percentage. + * + * @param int32 healthpct : percentage in integer from + * @return bool isAbove + */ int HealthAbovePct(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->HealthAbovePct(Eluna::CHECKVAL(L, 2))); return 1; } - + + /** + * Returns true if the [Unit] has an aura from the given spell entry. + * + * @param uint32 spell : entry of the aura spell + * @return bool hasAura + */ int HasAura(Eluna* /*E*/, lua_State* L, Unit* unit) { uint32 spell = Eluna::CHECKVAL(L, 2); @@ -349,7 +536,13 @@ namespace LuaUnit Eluna::Push(L, unit->HasAura(spell)); return 1; } - + + /** + * Returns true if the [Unit] has the given unit state. + * + * @param uint32 state : an unit state + * @return bool hasState + */ int HasUnitState(Eluna* /*E*/, lua_State* L, Unit* unit) { uint32 state = Eluna::CHECKVAL(L, 2); @@ -380,12 +573,23 @@ namespace LuaUnit }*/ /* GETTERS */ + + /** + * Returns the [Unit]'s owner. + * + * @return [Unit] owner + */ int GetOwner(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->GetOwner()); return 1; } - + + /** + * Returns the [Unit]'s owner's GUID. + * + * @return uint64 ownerGUID + */ int GetOwnerGUID(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -395,13 +599,23 @@ namespace LuaUnit #endif return 1; } - + + /** + * Returns the [Unit]'s mount's modelID. + * + * @return uint32 mountId : displayId of the mount + */ int GetMountId(Eluna* /*E*/, lua_State* L, Unit* unit) { Eluna::Push(L, unit->GetMountID()); return 1; } - + + /** + * Returns the [Unit]'s creator's GUID. + * + * @return uint64 creatorGUID + */ int GetCreatorGUID(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -411,7 +625,12 @@ namespace LuaUnit #endif return 1; } - + + /** + * Returns the [Unit]'s charmer's GUID. + * + * @return uint64 charmerGUID + */ int GetCharmerGUID(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -421,7 +640,12 @@ namespace LuaUnit #endif return 1; } - + + /** + * Returns the GUID of the [Unit]'s charmed entity. + * + * @return uint64 charmedGUID + */ int GetCharmGUID(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -431,7 +655,12 @@ namespace LuaUnit #endif return 1; } - + + /** + * Returns the GUID of the [Unit]'s pet. + * + * @return uint64 petGUID + */ int GetPetGUID(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -441,7 +670,12 @@ namespace LuaUnit #endif return 1; } - + + /** + * Returns the GUID of the [Unit]'s charmer or owner. + * + * @return uint64 controllerGUID + */ int GetControllerGUID(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -451,7 +685,12 @@ namespace LuaUnit #endif return 1; } - + + /** + * Returns the GUID of the [Unit]'s charmer or owner or its own GUID. + * + * @return uint64 controllerGUID + */ int GetControllerGUIDS(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -483,7 +722,12 @@ namespace LuaUnit Eluna::Push(L, unit->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + spellschool)); return 1; } - + + /** + * Returns the [Unit]'s current victim target or nil. + * + * @return [Unit] victim + */ int GetVictim(Eluna* /*E*/, lua_State* L, Unit* unit) { #ifndef TRINITY @@ -495,7 +739,7 @@ namespace LuaUnit } /** - * Returns the currently casted [Spell] of given type or nil + * Returns the currently casted [Spell] of given type or nil. * *
      * enum CurrentSpellTypes
@@ -519,31 +763,56 @@ namespace LuaUnit
         Eluna::Push(L, unit->GetCurrentSpell(type));
         return 1;
     }
-
+    
+    /**
+     * Returns the [Unit]'s current stand state.
+     *
+     * @return uint8 standState
+     */
     int GetStandState(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->getStandState());
         return 1;
     }
-
+    
+    /**
+     * Returns the [Unit]'s current display ID.
+     *
+     * @return uint32 displayId
+     */
     int GetDisplayId(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->GetDisplayId());
         return 1;
     }
-
+    
+    /**
+     * Returns the [Unit]'s native/original display ID.
+     *
+     * @return uint32 displayId
+     */
     int GetNativeDisplayId(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->GetNativeDisplayId());
         return 1;
     }
-
+    
+    /**
+     * Returns the [Unit]'s level.
+     *
+     * @return uint8 level
+     */
     int GetLevel(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->getLevel());
         return 1;
     }
-
+    
+    /**
+     * Returns the [Unit]'s health amount.
+     *
+     * @return uint32 healthAmount
+     */
     int GetHealth(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->GetHealth());
@@ -566,6 +835,26 @@ namespace LuaUnit
         return (Powers)powerType;
     }
 
+    /**
+     * Returns the [Unit]'s power amount for given power type.
+     *
+     *     enum Powers
+     *     {
+     *         POWER_MANA        = 0,
+     *         POWER_RAGE        = 1,
+     *         POWER_FOCUS       = 2,
+     *         POWER_ENERGY      = 3,
+     *         POWER_HAPPINESS   = 4,
+     *         POWER_RUNE        = 5,
+     *         POWER_RUNIC_POWER = 6,
+     *         MAX_POWERS        = 7,
+     *         POWER_ALL         = 127,         // default for class?
+     *         POWER_HEALTH      = 0xFFFFFFFE   // (-2 as signed value)
+     *     };
+     *
+     * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type
+     * @return uint32 powerAmount
+     */
     int GetPower(Eluna* E, lua_State* L, Unit* unit)
     {
         int type = Eluna::CHECKVAL(L, 2, -1);
@@ -575,6 +864,26 @@ namespace LuaUnit
         return 1;
     }
 
+    /**
+     * Returns the [Unit]'s max power amount for given power type.
+     *
+     *     enum Powers
+     *     {
+     *         POWER_MANA        = 0,
+     *         POWER_RAGE        = 1,
+     *         POWER_FOCUS       = 2,
+     *         POWER_ENERGY      = 3,
+     *         POWER_HAPPINESS   = 4,
+     *         POWER_RUNE        = 5,
+     *         POWER_RUNIC_POWER = 6,
+     *         MAX_POWERS        = 7,
+     *         POWER_ALL         = 127,         // default for class?
+     *         POWER_HEALTH      = 0xFFFFFFFE   // (-2 as signed value)
+     *     };
+     *
+     * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type
+     * @return uint32 maxPowerAmount
+     */
     int GetMaxPower(Eluna* E, lua_State* L, Unit* unit)
     {
         int type = Eluna::CHECKVAL(L, 2, -1);
@@ -584,6 +893,26 @@ namespace LuaUnit
         return 1;
     }
 
+    /**
+     * Returns the [Unit]'s power percent for given power type.
+     *
+     *     enum Powers
+     *     {
+     *         POWER_MANA        = 0,
+     *         POWER_RAGE        = 1,
+     *         POWER_FOCUS       = 2,
+     *         POWER_ENERGY      = 3,
+     *         POWER_HAPPINESS   = 4,
+     *         POWER_RUNE        = 5,
+     *         POWER_RUNIC_POWER = 6,
+     *         MAX_POWERS        = 7,
+     *         POWER_ALL         = 127,         // default for class?
+     *         POWER_HEALTH      = 0xFFFFFFFE   // (-2 as signed value)
+     *     };
+     *
+     * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type
+     * @return float powerPct
+     */
     int GetPowerPct(Eluna* E, lua_State* L, Unit* unit)
     {
         int type = Eluna::CHECKVAL(L, 2, -1);
@@ -598,6 +927,25 @@ namespace LuaUnit
         return 1;
     }
 
+    /**
+     * Returns the [Unit]'s current power type.
+     *
+     *     enum Powers
+     *     {
+     *         POWER_MANA        = 0,
+     *         POWER_RAGE        = 1,
+     *         POWER_FOCUS       = 2,
+     *         POWER_ENERGY      = 3,
+     *         POWER_HAPPINESS   = 4,
+     *         POWER_RUNE        = 5,
+     *         POWER_RUNIC_POWER = 6,
+     *         MAX_POWERS        = 7,
+     *         POWER_ALL         = 127,         // default for class?
+     *         POWER_HEALTH      = 0xFFFFFFFE   // (-2 as signed value)
+     *     };
+     *
+     * @return [Powers] powerType
+     */
     int GetPowerType(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
 #ifdef TRINITY
@@ -608,13 +956,23 @@ namespace LuaUnit
         return 1;
     }
 
+    /**
+     * Returns the [Unit]'s max health.
+     *
+     * @return uint32 maxHealth
+     */
     int GetMaxHealth(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->GetMaxHealth());
         return 1;
     }
 
-    int GetHealthPct(Eluna* /*E*/, lua_State* L, Unit* unit)
+    /**
+     * Returns the [Unit]'s health percent.
+     *
+     * @return float healthPct
+     */
+    int GetHealthPct(Eluna* /*E*/, lua_State* L, Unit* unit) 
     {
 #ifndef TRINITY
         Eluna::Push(L, unit->GetHealthPercent());
@@ -624,24 +982,44 @@ namespace LuaUnit
         return 1;
     }
 
+    /**
+     * Returns the [Unit]'s gender.
+     *
+     * @return uint8 gender : 0 for male, 1 for female and 2 for none
+     */
     int GetGender(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->getGender());
         return 1;
     }
 
+    /**
+     * Returns the [Unit]'s race ID.
+     *
+     * @return uint8 race
+     */
     int GetRace(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->getRace());
         return 1;
     }
 
+    /**
+     * Returns the [Unit]'s class ID.
+     *
+     * @return uint8 class
+     */
     int GetClass(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->getClass());
         return 1;
     }
 
+    /**
+     * Returns the [Unit]'s creature type ID like wolf or humanoid.
+     *
+     * @return uint32 creatureType
+     */
     int GetCreatureType(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->GetCreatureType());
@@ -718,12 +1096,23 @@ namespace LuaUnit
         return 1;
     }
 
+    /**
+     * Returns the [Unit]'s faction ID.
+     *
+     * @return uint32 faction
+     */
     int GetFaction(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Eluna::Push(L, unit->getFaction());
         return 1;
     }
 
+    /**
+     * Returns the [Aura] of the given spell entry on the [Unit] or nil.
+     *
+     * @param uint32 spellID : entry of the aura spell
+     * @return [Aura] aura : aura object or nil
+     */
     int GetAura(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 spellID = Eluna::CHECKVAL(L, 2);
@@ -741,6 +1130,12 @@ namespace LuaUnit
         return 1;
     }
 
+    /**
+     * Returns a table containing friendly [Unit]'s within given range of the [Unit].
+     *
+     * @param float range = 533.333 : search radius
+     * @return table friendyUnits : table filled with friendly units
+     */
     int GetFriendlyUnitsInRange(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS);
@@ -773,6 +1168,12 @@ namespace LuaUnit
         return 1;
     }
 
+    /**
+     * Returns a table containing unfriendly [Unit]'s within given range of the [Unit].
+     *
+     * @param float range = 533.333 : search radius
+     * @return table unfriendyUnits : table filled with unfriendly units
+     */
     int GetUnfriendlyUnitsInRange(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         float range = Eluna::CHECKVAL(L, 2, SIZE_OF_GRIDS);
@@ -907,6 +1308,12 @@ namespace LuaUnit
 #endif
 
     /* SETTERS */
+
+    /**
+     * Sets the [Unit]'s owner GUID to given GUID.
+     *
+     * @param uint64 guid : new owner guid
+     */
     int SetOwnerGUID(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint64 guid = Eluna::CHECKVAL(L, 2);
@@ -919,6 +1326,11 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s PvP on or off.
+     *
+     * @param bool apply = true : true if set on, false if off
+     */
     int SetPvP(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         bool apply = Eluna::CHECKVAL(L, 2, true);
@@ -927,6 +1339,18 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s sheath state.
+     *
+     *     enum SheathState
+     *     {
+     *         SHEATH_STATE_UNARMED  = 0, // non prepared weapon
+     *         SHEATH_STATE_MELEE    = 1, // prepared melee weapon
+     *         SHEATH_STATE_RANGED   = 2  // prepared ranged weapon
+     *     };
+     *
+     * @param [SheathState] sheathState : valid SheathState
+     */
     int SetSheath(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 sheathed = Eluna::CHECKVAL(L, 2);
@@ -937,6 +1361,11 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s name internally.
+     *
+     * @param string name : new name
+     */
     int SetName(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         const char* name = Eluna::CHECKVAL(L, 2);
@@ -983,6 +1412,11 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s faction.
+     *
+     * @param uint32 faction : new faction ID
+     */
     int SetFaction(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 factionId = Eluna::CHECKVAL(L, 2);
@@ -990,13 +1424,23 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s level.
+     *
+     * @param uint8 level : new level
+     */
     int SetLevel(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
-        uint32 newLevel = Eluna::CHECKVAL(L, 2);
+        uint8 newLevel = Eluna::CHECKVAL(L, 2);
         unit->SetLevel(newLevel);
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s health.
+     *
+     * @param uint32 health : new health
+     */
     int SetHealth(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 amt = Eluna::CHECKVAL(L, 2);
@@ -1004,6 +1448,11 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s max health.
+     *
+     * @param uint32 maxHealth : new max health
+     */
     int SetMaxHealth(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 amt = Eluna::CHECKVAL(L, 2);
@@ -1011,6 +1460,26 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s power amount for the given power type.
+     *
+     *     enum Powers
+     *     {
+     *         POWER_MANA        = 0,
+     *         POWER_RAGE        = 1,
+     *         POWER_FOCUS       = 2,
+     *         POWER_ENERGY      = 3,
+     *         POWER_HAPPINESS   = 4,
+     *         POWER_RUNE        = 5,
+     *         POWER_RUNIC_POWER = 6,
+     *         MAX_POWERS        = 7,
+     *         POWER_ALL         = 127,         // default for class?
+     *         POWER_HEALTH      = 0xFFFFFFFE   // (-2 as signed value)
+     *     };
+     *
+     * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type
+     * @param uint32 power : new power amount
+     */
     int SetPower(Eluna* E, lua_State* L, Unit* unit)
     {
         int type = Eluna::CHECKVAL(L, 2, -1);
@@ -1021,6 +1490,26 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s max power amount for the given power type.
+     *
+     *     enum Powers
+     *     {
+     *         POWER_MANA        = 0,
+     *         POWER_RAGE        = 1,
+     *         POWER_FOCUS       = 2,
+     *         POWER_ENERGY      = 3,
+     *         POWER_HAPPINESS   = 4,
+     *         POWER_RUNE        = 5,
+     *         POWER_RUNIC_POWER = 6,
+     *         MAX_POWERS        = 7,
+     *         POWER_ALL         = 127,         // default for class?
+     *         POWER_HEALTH      = 0xFFFFFFFE   // (-2 as signed value)
+     *     };
+     *
+     * @param int type = -1 : a valid power type from [Powers] or -1 for the [Unit]'s current power type
+     * @param uint32 maxPower : new max power amount
+     */
     int SetMaxPower(Eluna* E, lua_State* L, Unit* unit)
     {
         int type = Eluna::CHECKVAL(L, 2, -1);
@@ -1031,6 +1520,25 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s power type.
+     *
+     *     enum Powers
+     *     {
+     *         POWER_MANA        = 0,
+     *         POWER_RAGE        = 1,
+     *         POWER_FOCUS       = 2,
+     *         POWER_ENERGY      = 3,
+     *         POWER_HAPPINESS   = 4,
+     *         POWER_RUNE        = 5,
+     *         POWER_RUNIC_POWER = 6,
+     *         MAX_POWERS        = 7,
+     *         POWER_ALL         = 127,         // default for class?
+     *         POWER_HEALTH      = 0xFFFFFFFE   // (-2 as signed value)
+     *     };
+     *
+     * @param [Powers] type : a valid power type
+     */
     int SetPowerType(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 type = Eluna::CHECKVAL(L, 2);
@@ -1045,6 +1553,11 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s modelID.
+     *
+     * @param uint32 displayId
+     */
     int SetDisplayId(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 model = Eluna::CHECKVAL(L, 2);
@@ -1052,6 +1565,11 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s native/default modelID.
+     *
+     * @param uint32 displayId
+     */
     int SetNativeDisplayId(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 model = Eluna::CHECKVAL(L, 2);
@@ -1059,6 +1577,11 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s facing/orientation.
+     *
+     * @param uint32 orientation
+     */
     int SetFacing(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         float o = Eluna::CHECKVAL(L, 2);
@@ -1066,6 +1589,11 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit] to face the given [WorldObject]'s direction.
+     *
+     * @param [WorldObject] target
+     */
     int SetFacingToObject(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         WorldObject* obj = Eluna::CHECKOBJ(L, 2);
@@ -1125,6 +1653,11 @@ namespace LuaUnit
     }
 
 #if (!defined(TBC) && !defined(CLASSIC))
+    /**
+     * Sets the [Unit]'s FFA flag on or off.
+     *
+     * @param bool apply = true
+     */
     int SetFFA(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         bool apply = Eluna::CHECKVAL(L, 2, true);
@@ -1148,6 +1681,11 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s sanctuary flag on or off.
+     *
+     * @param bool apply = true
+     */
     int SetSanctuary(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         bool apply = Eluna::CHECKVAL(L, 2, true);
@@ -1164,11 +1702,17 @@ namespace LuaUnit
         return 0;
     }
 
+    /**
+     * Sets the [Unit]'s phase mask.
+     *
+     * @param uint32 phaseMask
+     * @param bool update = true : update visibility to nearby objects
+     */
     int SetPhaseMask(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 phaseMask = Eluna::CHECKVAL(L, 2);
-        bool Update = Eluna::CHECKVAL(L, 3, true);
-        unit->SetPhaseMask(phaseMask, Update);
+        bool update = Eluna::CHECKVAL(L, 3, true);
+        unit->SetPhaseMask(phaseMask, update);
         return 0;
     }
 
@@ -1254,6 +1798,10 @@ namespace LuaUnit
     }*/
 
     /* OTHER */
+
+    /**
+     * Clears the [Unit]'s threat list.
+     */
     int ClearThreatList(Eluna* /*E*/, lua_State* /*L*/, Unit* unit)
     {
 #ifdef MANGOS
@@ -1263,7 +1811,12 @@ namespace LuaUnit
 #endif
         return 0;
     }
-
+    
+    /**
+     * Mounts the [Unit] on the given displayID/modelID.
+     *
+     * @param uint32 displayId
+     */
     int Mount(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 displayId = Eluna::CHECKVAL(L, 2);
@@ -1271,7 +1824,10 @@ namespace LuaUnit
         unit->Mount(displayId);
         return 0;
     }
-
+    
+    /**
+     * Dismounts the [Unit].
+     */
     int Dismount(Eluna* /*E*/, lua_State* /*L*/, Unit* unit)
     {
         if (unit->IsMounted())
@@ -1287,7 +1843,12 @@ namespace LuaUnit
 
         return 0;
     }
-
+    
+    /**
+     * Makes the [Unit] perform the given emote.
+     *
+     * @param uint32 emoteId
+     */
     int Emote(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         unit->HandleEmoteCommand(Eluna::CHECKVAL(L, 2));
@@ -1491,13 +2052,23 @@ namespace LuaUnit
 #endif
         return 0;
     }
-
+    
+    /**
+     * Unmorphs the [Unit] setting it's display ID back to the native display ID.
+     */
     int DeMorph(Eluna* /*E*/, lua_State* /*L*/, Unit* unit)
     {
         unit->DeMorph();
         return 0;
     }
-
+    
+    /**
+     * Makes the [Unit] cast the spell on the target.
+     *
+     * @param [Unit] target : can be self or another unit
+     * @param uint32 spell : entry of a spell
+     * @param bool triggered = false : if true the spell is instant and has no cost
+     */
     int CastSpell(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         Unit* target = Eluna::CHECKOBJ(L, 2);
@@ -1541,7 +2112,16 @@ namespace LuaUnit
         unit->CastCustomSpell(target, spell, has_bp0 ? &bp0 : NULL, has_bp1 ? &bp1 : NULL, has_bp2 ? &bp2 : NULL, triggered, castItem, NULL, ObjectGuid(originalCaster));
         return 0;
     }
-
+    
+    /**
+     * Makes the [Unit] cast the spell to the given coordinates, used for area effect spells.
+     *
+     * @param float x
+     * @param float y
+     * @param float z
+     * @param uint32 spell : entry of a spell
+     * @param bool triggered = false : if true the spell is instant and has no cost
+     */
     int CastSpellAoF(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         float _x = Eluna::CHECKVAL(L, 2);
@@ -1591,7 +2171,14 @@ namespace LuaUnit
         unit->InterruptSpell((CurrentSpellTypes)spellType, delayed);
         return 0;
     }
-
+    
+    /**
+     * Adds the [Aura] of the given spell entry on the given target from the [Unit].
+     *
+     * @param uint32 spell : entry of a spell
+     * @param [Unit] target : aura will be applied on the target
+     * @return [Aura] aura
+     */
     int AddAura(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 spellId = Eluna::CHECKVAL(L, 2);
@@ -1625,14 +2212,24 @@ namespace LuaUnit
 #endif
         return 1;
     }
-
+    
+    /**
+     * Removes [Aura] of the given spell entry from the [Unit].
+     *
+     * @param uint32 spell : entry of a spell
+     */
     int RemoveAura(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 spellId = Eluna::CHECKVAL(L, 2);
         unit->RemoveAurasDueToSpell(spellId);
         return 0;
     }
-
+    
+    /**
+     * Removes all [Aura]'s from the [Unit].
+     *
+     *     Note: talents and racials are also auras, use with caution
+     */
     int RemoveAllAuras(Eluna* /*E*/, lua_State* /*L*/, Unit* unit)
     {
         unit->RemoveAllAuras();
@@ -1666,7 +2263,12 @@ namespace LuaUnit
             unit->PlayDistanceSound(soundId);
         return 0;
     }
-
+    
+    /**
+     * Adds the given unit state for the [Unit].
+     *
+     * @param uint32 state
+     */
     int AddUnitState(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 state = Eluna::CHECKVAL(L, 2);
@@ -1678,7 +2280,12 @@ namespace LuaUnit
 #endif
         return 0;
     }
-
+    
+    /**
+     * Removes the given unit state from the [Unit].
+     *
+     * @param uint32 state
+     */
     int ClearUnitState(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         uint32 state = Eluna::CHECKVAL(L, 2);
@@ -1690,7 +2297,15 @@ namespace LuaUnit
 #endif
         return 0;
     }
-
+    
+    /**
+     * Makes the [Unit] teleport to given coordinates within same map.
+     *
+     * @param float x
+     * @param float y
+     * @param float z
+     * @param float o : orientation
+     */
     int NearTeleport(Eluna* /*E*/, lua_State* L, Unit* unit)
     {
         float x = Eluna::CHECKVAL(L, 2);