chore: align structure with master
This commit is contained in:
54
src/LuaEngine/methods/AchievementMethods.h
Normal file
54
src/LuaEngine/methods/AchievementMethods.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef ACHIEVEMENTMETHODS_H
|
||||
#define ACHIEVEMENTMETHODS_H
|
||||
|
||||
namespace LuaAchievement
|
||||
{
|
||||
/**
|
||||
* Returns the [Achievement]'s ID.
|
||||
*
|
||||
* @return uint32 id
|
||||
*/
|
||||
int GetId(lua_State* L, AchievementEntry* const achievement)
|
||||
{
|
||||
Eluna::Push(L, achievement->ID);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Achievement]'s name.
|
||||
*
|
||||
* enum LocaleConstant
|
||||
* {
|
||||
* LOCALE_enUS = 0,
|
||||
* LOCALE_koKR = 1,
|
||||
* LOCALE_frFR = 2,
|
||||
* LOCALE_deDE = 3,
|
||||
* LOCALE_zhCN = 4,
|
||||
* LOCALE_zhTW = 5,
|
||||
* LOCALE_esES = 6,
|
||||
* LOCALE_esMX = 7,
|
||||
* LOCALE_ruRU = 8
|
||||
* };
|
||||
*
|
||||
* @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the [Achievement] name in
|
||||
* @return string name
|
||||
*/
|
||||
int GetName(lua_State* L, AchievementEntry* const achievement)
|
||||
{
|
||||
uint8 locale = Eluna::CHECKVAL<uint8>(L, 2, DEFAULT_LOCALE);
|
||||
if (locale >= TOTAL_LOCALES)
|
||||
{
|
||||
return luaL_argerror(L, 2, "valid LocaleConstant expected");
|
||||
}
|
||||
|
||||
Eluna::Push(L, achievement->name[locale]);
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
211
src/LuaEngine/methods/AuraMethods.h
Normal file
211
src/LuaEngine/methods/AuraMethods.h
Normal file
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef AURAMETHODS_H
|
||||
#define AURAMETHODS_H
|
||||
|
||||
/***
|
||||
* The persistent effect of a [Spell] that remains on a [Unit] after the [Spell]
|
||||
* has been cast.
|
||||
*
|
||||
* As an example, if you cast a damage-over-time spell on a target, an [Aura] is
|
||||
* put on the target that deals damage continuously.
|
||||
*
|
||||
* [Aura]s on your player are displayed in-game as a series of icons to the left
|
||||
* of the mini-map.
|
||||
*
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaAura
|
||||
{
|
||||
/**
|
||||
* Returns the [Unit] that casted the [Spell] that caused this [Aura] to be applied.
|
||||
*
|
||||
* @return [Unit] caster
|
||||
*/
|
||||
int GetCaster(lua_State* L, Aura* aura)
|
||||
{
|
||||
Eluna::Push(L, aura->GetCaster());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the GUID of the [Unit] that casted the [Spell] that caused this [Aura] to be applied.
|
||||
*
|
||||
* @return string caster_guid : the GUID of the Unit as a decimal string
|
||||
*/
|
||||
int GetCasterGUID(lua_State* L, Aura* aura)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, aura->GetCasterGUID());
|
||||
#else
|
||||
Eluna::Push(L, aura->GetCasterGuid());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the level of the [Unit] that casted the [Spell] that caused this [Aura] to be applied.
|
||||
*
|
||||
* @return uint32 caster_level
|
||||
*/
|
||||
int GetCasterLevel(lua_State* L, Aura* aura)
|
||||
{
|
||||
Eluna::Push(L, aura->GetCaster()->GetLevel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of time left until the [Aura] expires.
|
||||
*
|
||||
* @return int32 duration : amount of time left in milliseconds
|
||||
*/
|
||||
int GetDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, aura->GetDuration());
|
||||
#else
|
||||
Eluna::Push(L, aura->GetAuraDuration());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the [Spell] that caused this [Aura] to be applied.
|
||||
*
|
||||
* @return uint32 aura_id
|
||||
*/
|
||||
int GetAuraId(lua_State* L, Aura* aura)
|
||||
{
|
||||
Eluna::Push(L, aura->GetId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of time this [Aura] lasts when applied.
|
||||
*
|
||||
* To determine how much time has passed since this Aura was applied,
|
||||
* subtract the result of [Aura]:GetDuration from the result of this method.
|
||||
*
|
||||
* @return int32 max_duration : the maximum duration of the Aura, in milliseconds
|
||||
*/
|
||||
int GetMaxDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, aura->GetMaxDuration());
|
||||
#else
|
||||
Eluna::Push(L, aura->GetAuraMaxDuration());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of times the [Aura] has "stacked".
|
||||
*
|
||||
* This is the same as the number displayed on the [Aura]'s icon in-game.
|
||||
*
|
||||
* @return uint32 stack_amount
|
||||
*/
|
||||
int GetStackAmount(lua_State* L, Aura* aura)
|
||||
{
|
||||
Eluna::Push(L, aura->GetStackAmount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Unit] that the [Aura] has been applied to.
|
||||
*
|
||||
* @return [Unit] owner
|
||||
*/
|
||||
int GetOwner(lua_State* L, Aura* aura)
|
||||
{
|
||||
#if defined TRINITY || defined AZEROTHCORE
|
||||
Eluna::Push(L, aura->GetOwner());
|
||||
#else
|
||||
Eluna::Push(L, aura->GetTarget());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the amount of time before the [Aura] expires.
|
||||
*
|
||||
* @param int32 duration : the new duration of the Aura, in milliseconds
|
||||
*/
|
||||
int SetDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
|
||||
#if defined TRINITY || defined AZEROTHCORE
|
||||
aura->SetDuration(duration);
|
||||
#else
|
||||
aura->GetHolder()->SetAuraDuration(duration);
|
||||
#if (defined(TBC) || defined(CLASSIC))
|
||||
aura->GetHolder()->UpdateAuraDuration();
|
||||
#else
|
||||
aura->GetHolder()->SendAuraUpdate(false);
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the maximum amount of time before the [Aura] expires.
|
||||
*
|
||||
* This does not affect the current duration of the [Aura], but if the [Aura]
|
||||
* is reset to the maximum duration, it will instead change to `duration`.
|
||||
*
|
||||
* @param int32 duration : the new maximum duration of the Aura, in milliseconds
|
||||
*/
|
||||
int SetMaxDuration(lua_State* L, Aura* aura)
|
||||
{
|
||||
int32 duration = Eluna::CHECKVAL<int32>(L, 2);
|
||||
#if defined TRINITY || defined AZEROTHCORE
|
||||
aura->SetMaxDuration(duration);
|
||||
#else
|
||||
aura->GetHolder()->SetAuraMaxDuration(duration);
|
||||
#if (defined(TBC) || defined(CLASSIC))
|
||||
aura->GetHolder()->UpdateAuraDuration();
|
||||
#else
|
||||
aura->GetHolder()->SendAuraUpdate(false);
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the amount of times the [Aura] has "stacked" on the [Unit].
|
||||
*
|
||||
* If `amount` is greater than or equal to the current number of stacks,
|
||||
* then the [Aura] has its duration reset to the maximum duration.
|
||||
*
|
||||
* @param uint32 amount
|
||||
*/
|
||||
int SetStackAmount(lua_State* L, Aura* aura)
|
||||
{
|
||||
uint8 amount = Eluna::CHECKVAL<uint8>(L, 2);
|
||||
#if defined TRINITY || defined AZEROTHCORE
|
||||
aura->SetStackAmount(amount);
|
||||
#else
|
||||
aura->GetHolder()->SetStackAmount(amount);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this [Aura] from the [Unit] it is applied to.
|
||||
*/
|
||||
int Remove(lua_State* L, Aura* aura)
|
||||
{
|
||||
#if defined TRINITY || defined AZEROTHCORE
|
||||
aura->Remove();
|
||||
#else
|
||||
aura->GetTarget()->RemoveSpellAuraHolder(aura->GetHolder(), AURA_REMOVE_BY_CANCEL);
|
||||
#endif
|
||||
Eluna::CHECKOBJ<ElunaObject>(L, 1)->Invalidate();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
250
src/LuaEngine/methods/BattleGroundMethods.h
Normal file
250
src/LuaEngine/methods/BattleGroundMethods.h
Normal file
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef BATTLEGROUNDMETHODS_H
|
||||
#define BATTLEGROUNDMETHODS_H
|
||||
|
||||
/***
|
||||
* Contains the state of a battleground, e.g. Warsong Gulch, Arathi Basin, etc.
|
||||
*
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaBattleGround
|
||||
{
|
||||
/**
|
||||
* Returns the name of the [BattleGround].
|
||||
*
|
||||
* @return string name
|
||||
*/
|
||||
int GetName(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetName());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of alive players in the [BattleGround] by the team ID.
|
||||
*
|
||||
* @param [Team] team : team ID
|
||||
* @return uint32 count
|
||||
*/
|
||||
int GetAlivePlayersCountByTeam(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
uint32 team = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
#ifndef AZEROTHCORE
|
||||
Eluna::Push(L, bg->GetAlivePlayersCountByTeam((Team)team));
|
||||
#else
|
||||
Eluna::Push(L, bg->GetAlivePlayersCountByTeam((TeamId)team));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Map] of the [BattleGround].
|
||||
*
|
||||
* @return [Map] map
|
||||
*/
|
||||
int GetMap(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetBgMap());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bonus honor given by amount of kills in the specific [BattleGround].
|
||||
*
|
||||
* @param uint32 kills : amount of kills
|
||||
* @return uint32 bonusHonor
|
||||
*/
|
||||
int GetBonusHonorFromKillCount(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
uint32 kills = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
Eluna::Push(L, bg->GetBonusHonorFromKill(kills));
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef AZEROTHCORE
|
||||
/**
|
||||
* Returns the bracket ID of the specific [BattleGround].
|
||||
*
|
||||
* @return [BattleGroundBracketId] bracketId
|
||||
*/
|
||||
int GetBracketId(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetBracketId());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the end time of the [BattleGround].
|
||||
*
|
||||
* @return uint32 endTime
|
||||
*/
|
||||
int GetEndTime(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
#ifdef CATA
|
||||
Eluna::Push(L, bg->GetRemainingTime());
|
||||
#else
|
||||
Eluna::Push(L, bg->GetEndTime());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of free slots for the selected team in the specific [BattleGround].
|
||||
*
|
||||
* @param [Team] team : team ID
|
||||
* @return uint32 freeSlots
|
||||
*/
|
||||
int GetFreeSlotsForTeam(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
uint32 team = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
#ifndef AZEROTHCORE
|
||||
Eluna::Push(L, bg->GetFreeSlotsForTeam((Team)team));
|
||||
#else
|
||||
Eluna::Push(L, bg->GetFreeSlotsForTeam((TeamId)team));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance ID of the [BattleGround].
|
||||
*
|
||||
* @return uint32 instanceId
|
||||
*/
|
||||
int GetInstanceId(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetInstanceID());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the map ID of the [BattleGround].
|
||||
*
|
||||
* @return uint32 mapId
|
||||
*/
|
||||
int GetMapId(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetMapId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type ID of the [BattleGround].
|
||||
*
|
||||
* @return [BattleGroundTypeId] typeId
|
||||
*/
|
||||
int GetTypeId(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
#ifndef AZEROTHCORE
|
||||
Eluna::Push(L, bg->GetTypeID());
|
||||
#else
|
||||
Eluna::Push(L, bg->GetBgTypeID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max allowed [Player] level of the specific [BattleGround].
|
||||
*
|
||||
* @return uint32 maxLevel
|
||||
*/
|
||||
int GetMaxLevel(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetMaxLevel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum allowed [Player] level of the specific [BattleGround].
|
||||
*
|
||||
* @return uint32 minLevel
|
||||
*/
|
||||
int GetMinLevel(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetMinLevel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum allowed [Player] count of the specific [BattleGround].
|
||||
*
|
||||
* @return uint32 maxPlayerCount
|
||||
*/
|
||||
int GetMaxPlayers(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
#ifndef AZEROTHCORE
|
||||
Eluna::Push(L, bg->GetMaxPlayers());
|
||||
#else
|
||||
Eluna::Push(L, bg->GetMaxPlayersPerTeam() * 2);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum allowed [Player] count of the specific [BattleGround].
|
||||
*
|
||||
* @return uint32 minPlayerCount
|
||||
*/
|
||||
int GetMinPlayers(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
#ifndef AZEROTHCORE
|
||||
Eluna::Push(L, bg->GetMinPlayers());
|
||||
#else
|
||||
Eluna::Push(L, bg->GetMaxPlayersPerTeam() * 2);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum allowed [Player] count per team of the specific [BattleGround].
|
||||
*
|
||||
* @return uint32 maxTeamPlayerCount
|
||||
*/
|
||||
int GetMaxPlayersPerTeam(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetMaxPlayersPerTeam());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum allowed [Player] count per team of the specific [BattleGround].
|
||||
*
|
||||
* @return uint32 minTeamPlayerCount
|
||||
*/
|
||||
int GetMinPlayersPerTeam(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetMinPlayersPerTeam());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the winning team of the specific [BattleGround].
|
||||
*
|
||||
* @return [Team] team
|
||||
*/
|
||||
int GetWinner(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetWinner());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the status of the specific [BattleGround].
|
||||
*
|
||||
* @return [BattleGroundStatus] status
|
||||
*/
|
||||
int GetStatus(lua_State* L, BattleGround* bg)
|
||||
{
|
||||
Eluna::Push(L, bg->GetStatus());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
192
src/LuaEngine/methods/ChatHandlerMethods.h
Normal file
192
src/LuaEngine/methods/ChatHandlerMethods.h
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef CHATHANDLERMETHODS_H
|
||||
#define CHATHANDLERMETHODS_H
|
||||
|
||||
#include "Chat.h"
|
||||
|
||||
namespace LuaChatHandler
|
||||
{
|
||||
/**
|
||||
* Sends text to the chat handler
|
||||
*
|
||||
* @proto (text)
|
||||
* @proto (entry)
|
||||
* @param string text : text to display in chat or console
|
||||
* @param uint32 entry : id of the string to display
|
||||
*/
|
||||
int SendSysMessage(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
if (lua_isnumber(L, 2))
|
||||
{
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
handler->SendSysMessage(entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string text = Eluna::CHECKVAL<std::string>(L, 2);
|
||||
handler->SendSysMessage(text);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the [ChatHandler] comes from the console, `false` if it comes from a player
|
||||
*
|
||||
* @return bool isConsole
|
||||
*/
|
||||
int IsConsole(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
Eluna::Push(L, handler->IsConsole());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Player] associated with the handler. Returns `nil` in the case of a console handler
|
||||
*
|
||||
* @return [Player] player
|
||||
*/
|
||||
int GetPlayer(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
Eluna::Push(L, handler->GetPlayer());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to all connected players
|
||||
*
|
||||
* @param string text : text to send
|
||||
*/
|
||||
int SendGlobalSysMessage(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
std::string text = Eluna::CHECKVAL<std::string>(L, 2);
|
||||
handler->SendGlobalSysMessage(text.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to all connected Game Masters
|
||||
*
|
||||
* @param string text : text to send
|
||||
*/
|
||||
int SendGlobalGMSysMessage(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
std::string text = Eluna::CHECKVAL<std::string>(L, 2);
|
||||
handler->SendGlobalGMSysMessage(text.c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current security level is lower than the specified [Player]'s account
|
||||
*
|
||||
* @param [Player] player
|
||||
* @param [bool] strong = false : Forces non-player accounts (security level greater than `0`) to go through the regular check if set to `true`.<br>Also, if set to `true`, the current security level will be considered as lower than the [Player]'s security level if the two levels are equal
|
||||
* @return [bool] lower
|
||||
*/
|
||||
int HasLowerSecurity(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
bool strong = Eluna::CHECKVAL<bool>(L, 3);
|
||||
Eluna::Push(L, handler->HasLowerSecurity(player, ObjectGuid::Empty, strong));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the current security level is lower than the specified `account`'s level
|
||||
*
|
||||
* @param [uint32] account : the target account ID to compare security levels with
|
||||
* @param [bool] strong = false : Forces non-player accounts (security level greater than `0`) to go through the regular check if set to `true`.<br>Also, if set to `true`, the current security level will be considered as lower than the `account`'s security level if the two levels are equal
|
||||
* @return [bool] lower
|
||||
*/
|
||||
int HasLowerSecurityAccount(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
uint32 account = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
bool strong = Eluna::CHECKVAL<bool>(L, 3);
|
||||
Eluna::Push(L, handler->HasLowerSecurityAccount(nullptr, account, strong));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected [Player]
|
||||
*
|
||||
* @return [Player] player
|
||||
*/
|
||||
int GetSelectedPlayer(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
Eluna::Push(L, handler->getSelectedPlayer());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected [Creature]
|
||||
*
|
||||
* @return [Creature] creature
|
||||
*/
|
||||
int GetSelectedCreature(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
Eluna::Push(L, handler->getSelectedCreature());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected [Unit]
|
||||
*
|
||||
* @return [Unit] unit
|
||||
*/
|
||||
int GetSelectedUnit(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
Eluna::Push(L, handler->getSelectedUnit());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected [WorldObject]
|
||||
*
|
||||
* @return [WorldObject] object
|
||||
*/
|
||||
int GetSelectedObject(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
Eluna::Push(L, handler->getSelectedObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the selected [Player] or the current [Player] if nothing is targeted or the target is not a player
|
||||
*
|
||||
* @return [Player] player
|
||||
*/
|
||||
int GetSelectedPlayerOrSelf(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
Eluna::Push(L, handler->getSelectedPlayerOrSelf());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the `securityLevel` is available
|
||||
*
|
||||
* @param [uint32] securityLevel
|
||||
* @return [bool] isAvailable
|
||||
*/
|
||||
int IsAvailable(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
uint32 securityLevel = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Eluna::Push(L, handler->IsAvailable(securityLevel));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if other previously called [ChatHandler] methods sent an error
|
||||
*
|
||||
* @return [bool] sentErrorMessage
|
||||
*/
|
||||
int HasSentErrorMessage(lua_State* L, ChatHandler* handler)
|
||||
{
|
||||
Eluna::Push(L, handler->HasSentErrorMessage());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
81
src/LuaEngine/methods/CorpseMethods.h
Normal file
81
src/LuaEngine/methods/CorpseMethods.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef CORPSEMETHODS_H
|
||||
#define CORPSEMETHODS_H
|
||||
|
||||
/***
|
||||
* The remains of a [Player] that has died.
|
||||
*
|
||||
* Inherits all methods from: [Object], [WorldObject]
|
||||
*/
|
||||
namespace LuaCorpse
|
||||
{
|
||||
/**
|
||||
* Returns the GUID of the [Player] that left the [Corpse] behind.
|
||||
*
|
||||
* @return ObjectGuid ownerGUID
|
||||
*/
|
||||
int GetOwnerGUID(lua_State* L, Corpse* corpse)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, corpse->GetOwnerGUID());
|
||||
#else
|
||||
Eluna::Push(L, corpse->GetOwnerGuid());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time when the [Player] became a ghost and spawned this [Corpse].
|
||||
*
|
||||
* @return uint32 ghostTime
|
||||
*/
|
||||
int GetGhostTime(lua_State* L, Corpse* corpse)
|
||||
{
|
||||
Eluna::Push(L, corpse->GetGhostTime());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [CorpseType] of a [Corpse].
|
||||
*
|
||||
* enum CorpseType
|
||||
* {
|
||||
* CORPSE_BONES = 0,
|
||||
* CORPSE_RESURRECTABLE_PVE = 1,
|
||||
* CORPSE_RESURRECTABLE_PVP = 2
|
||||
* };
|
||||
*
|
||||
* @return [CorpseType] corpseType
|
||||
*/
|
||||
int GetType(lua_State* L, Corpse* corpse)
|
||||
{
|
||||
Eluna::Push(L, corpse->GetType());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the "ghost time" to the current time.
|
||||
*
|
||||
* See [Corpse:GetGhostTime].
|
||||
*/
|
||||
int ResetGhostTime(lua_State* /*L*/, Corpse* corpse)
|
||||
{
|
||||
corpse->ResetGhostTime();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the [Corpse] to the database.
|
||||
*/
|
||||
int SaveToDB(lua_State* /*L*/, Corpse* corpse)
|
||||
{
|
||||
corpse->SaveToDB();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
1542
src/LuaEngine/methods/CreatureMethods.h
Normal file
1542
src/LuaEngine/methods/CreatureMethods.h
Normal file
File diff suppressed because it is too large
Load Diff
369
src/LuaEngine/methods/ElunaQueryMethods.h
Normal file
369
src/LuaEngine/methods/ElunaQueryMethods.h
Normal file
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef QUERYMETHODS_H
|
||||
#define QUERYMETHODS_H
|
||||
|
||||
#if defined TRINITY || defined AZEROTHCORE
|
||||
#define RESULT (*result)
|
||||
#else
|
||||
#define RESULT result
|
||||
#endif
|
||||
|
||||
/***
|
||||
* The result of a database query.
|
||||
*
|
||||
* E.g. the return value of [Global:WorldDBQuery].
|
||||
*
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaQuery
|
||||
{
|
||||
static void CheckFields(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 field = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
uint32 count = RESULT->GetFieldCount();
|
||||
if (field >= count)
|
||||
{
|
||||
char arr[256];
|
||||
snprintf(arr, sizeof(arr), "trying to access invalid field index %u. There are %u fields available and the indexes start from 0", field, count);
|
||||
luaL_argerror(L, 2, arr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the specified column of the current row is `NULL`, otherwise `false`.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return bool isNull
|
||||
*/
|
||||
int IsNull(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, RESULT->Fetch()[col].IsNull());
|
||||
#else
|
||||
Eluna::Push(L, RESULT->Fetch()[col].IsNULL());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of columns in the result set.
|
||||
*
|
||||
* @return uint32 columnCount
|
||||
*/
|
||||
int GetColumnCount(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
Eluna::Push(L, RESULT->GetFieldCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of rows in the result set.
|
||||
*
|
||||
* @return uint32 rowCount
|
||||
*/
|
||||
int GetRowCount(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
if (RESULT->GetRowCount() > (uint32)-1)
|
||||
Eluna::Push(L, (uint32)-1);
|
||||
else
|
||||
Eluna::Push(L, (uint32)(RESULT->GetRowCount()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to a boolean.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return bool data
|
||||
*/
|
||||
int GetBool(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<bool>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to an unsigned 8-bit integer.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return uint8 data
|
||||
*/
|
||||
int GetUInt8(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<uint8>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to an unsigned 16-bit integer.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return uint16 data
|
||||
*/
|
||||
int GetUInt16(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<uint16>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to an unsigned 32-bit integer.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return uint32 data
|
||||
*/
|
||||
int GetUInt32(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<uint32>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to an unsigned 64-bit integer.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return uint64 data
|
||||
*/
|
||||
int GetUInt64(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<uint64>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to a signed 8-bit integer.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return int8 data
|
||||
*/
|
||||
int GetInt8(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<int8>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to a signed 16-bit integer.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return int16 data
|
||||
*/
|
||||
int GetInt16(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<int16>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to a signed 32-bit integer.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return int32 data
|
||||
*/
|
||||
int GetInt32(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<int32>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to a signed 64-bit integer.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return int64 data
|
||||
*/
|
||||
int GetInt64(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<int64>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to a 32-bit floating point value.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return float data
|
||||
*/
|
||||
int GetFloat(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<float>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to a 64-bit floating point value.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return double data
|
||||
*/
|
||||
int GetDouble(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<double>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data in the specified column of the current row, casted to a string.
|
||||
*
|
||||
* @param uint32 column
|
||||
* @return string data
|
||||
*/
|
||||
int GetString(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
CheckFields(L, result);
|
||||
Eluna::Push(L, RESULT->Fetch()[col].Get<std::string>());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Advances the [ElunaQuery] to the next row in the result set.
|
||||
*
|
||||
* *Do not* call this immediately after a query, or you'll skip the first row.
|
||||
*
|
||||
* Returns `false` if there was no new row, otherwise `true`.
|
||||
*
|
||||
* @return bool hadNextRow
|
||||
*/
|
||||
int NextRow(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
Eluna::Push(L, RESULT->NextRow());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a table from the current row where keys are field names and values are the row's values.
|
||||
*
|
||||
* All numerical values will be numbers and everything else is returned as a string.
|
||||
*
|
||||
* **For example,** the query:
|
||||
*
|
||||
* SELECT entry, name FROM creature_template
|
||||
*
|
||||
* would result in a table like:
|
||||
*
|
||||
* { entry = 123, name = "some creature name" }
|
||||
*
|
||||
* To move to next row use [ElunaQuery:NextRow].
|
||||
*
|
||||
* @return table rowData : table filled with row columns and data where `T[column] = data`
|
||||
*/
|
||||
int GetRow(lua_State* L, ElunaQuery* result)
|
||||
{
|
||||
uint32 col = RESULT->GetFieldCount();
|
||||
Field* row = RESULT->Fetch();
|
||||
|
||||
lua_createtable(L, 0, col);
|
||||
int tbl = lua_gettop(L);
|
||||
|
||||
#if !defined TRINITY && !AZEROTHCORE
|
||||
const QueryFieldNames& names = RESULT->GetFieldNames();
|
||||
#endif
|
||||
|
||||
for (uint32 i = 0; i < col; ++i)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, RESULT->GetFieldName(i));
|
||||
|
||||
std::string _str = row[i].Get<std::string>();
|
||||
const char* str = _str.c_str();
|
||||
if (row[i].IsNull() || !str)
|
||||
Eluna::Push(L);
|
||||
else
|
||||
{
|
||||
// MYSQL_TYPE_LONGLONG Interpreted as string for lua
|
||||
switch (row[i].GetType())
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
case DatabaseFieldTypes::Int8:
|
||||
case DatabaseFieldTypes::Int16:
|
||||
case DatabaseFieldTypes::Int32:
|
||||
case DatabaseFieldTypes::Int64:
|
||||
case DatabaseFieldTypes::Float:
|
||||
case DatabaseFieldTypes::Double:
|
||||
#else
|
||||
case MYSQL_TYPE_TINY:
|
||||
case MYSQL_TYPE_YEAR:
|
||||
case MYSQL_TYPE_SHORT:
|
||||
case MYSQL_TYPE_INT24:
|
||||
case MYSQL_TYPE_LONG:
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
case MYSQL_TYPE_BIT:
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
case MYSQL_TYPE_DECIMAL:
|
||||
case MYSQL_TYPE_NEWDECIMAL:
|
||||
#endif
|
||||
Eluna::Push(L, strtod(str, NULL));
|
||||
break;
|
||||
default:
|
||||
Eluna::Push(L, str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
Eluna::Push(L, names[i]);
|
||||
|
||||
const char* str = row[i].GetString();
|
||||
if (row[i].IsNULL() || !str)
|
||||
Eluna::Push(L);
|
||||
else
|
||||
{
|
||||
// MYSQL_TYPE_LONGLONG Interpreted as string for lua
|
||||
switch (row[i].GetType())
|
||||
{
|
||||
case MYSQL_TYPE_TINY:
|
||||
case MYSQL_TYPE_SHORT:
|
||||
case MYSQL_TYPE_INT24:
|
||||
case MYSQL_TYPE_LONG:
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
Eluna::Push(L, strtod(str, NULL));
|
||||
break;
|
||||
default:
|
||||
Eluna::Push(L, str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
lua_rawset(L, tbl);
|
||||
}
|
||||
|
||||
lua_settop(L, tbl);
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#undef RESULT
|
||||
|
||||
#endif
|
||||
401
src/LuaEngine/methods/GameObjectMethods.h
Normal file
401
src/LuaEngine/methods/GameObjectMethods.h
Normal file
@@ -0,0 +1,401 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef GAMEOBJECTMETHODS_H
|
||||
#define GAMEOBJECTMETHODS_H
|
||||
|
||||
/***
|
||||
* Inherits all methods from: [Object], [WorldObject]
|
||||
*/
|
||||
namespace LuaGameObject
|
||||
{
|
||||
/**
|
||||
* Returns 'true' if the [GameObject] can give the specified [Quest]
|
||||
*
|
||||
* @param uint32 questId : quest entry Id to check
|
||||
* @return bool hasQuest
|
||||
*/
|
||||
int HasQuest(lua_State* L, GameObject* go)
|
||||
{
|
||||
uint32 questId = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, go->hasQuest(questId));
|
||||
#else
|
||||
Eluna::Push(L, go->HasQuest(questId));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [GameObject] is spawned
|
||||
*
|
||||
* @return bool isSpawned
|
||||
*/
|
||||
int IsSpawned(lua_State* L, GameObject* go)
|
||||
{
|
||||
Eluna::Push(L, go->isSpawned());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [GameObject] is a transport
|
||||
*
|
||||
* @return bool isTransport
|
||||
*/
|
||||
int IsTransport(lua_State* L, GameObject* go)
|
||||
{
|
||||
Eluna::Push(L, go->IsTransport());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [GameObject] is active
|
||||
*
|
||||
* @return bool isActive
|
||||
*/
|
||||
int IsActive(lua_State* L, GameObject* go)
|
||||
{
|
||||
Eluna::Push(L, go->isActiveObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int IsDestructible(lua_State* L, GameObject* go) // TODO: Implementation core side
|
||||
{
|
||||
Eluna::Push(L, go->IsDestructibleBuilding());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns display ID of the [GameObject]
|
||||
*
|
||||
* @return uint32 displayId
|
||||
*/
|
||||
int GetDisplayId(lua_State* L, GameObject* go)
|
||||
{
|
||||
Eluna::Push(L, go->GetDisplayId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of a [GameObject]
|
||||
* Below are client side [GOState]s off of 3.3.5a
|
||||
*
|
||||
* <pre>
|
||||
* enum GOState
|
||||
* {
|
||||
* GO_STATE_ACTIVE = 0, // show in world as used and not reset (closed door open)
|
||||
* GO_STATE_READY = 1, // show in world as ready (closed door close)
|
||||
* GO_STATE_ACTIVE_ALTERNATIVE = 2 // show in world as used in alt way and not reset (closed door open by cannon fire)
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @return [GOState] goState
|
||||
*/
|
||||
int GetGoState(lua_State* L, GameObject* go)
|
||||
{
|
||||
Eluna::Push(L, go->GetGoState());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [LootState] of a [GameObject]
|
||||
* Below are [LootState]s off of 3.3.5a
|
||||
*
|
||||
* <pre>
|
||||
* enum LootState
|
||||
* {
|
||||
* GO_NOT_READY = 0,
|
||||
* GO_READY, // can be ready but despawned, and then not possible activate until spawn
|
||||
* GO_ACTIVATED,
|
||||
* GO_JUST_DEACTIVATED
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @return [LootState] lootState
|
||||
*/
|
||||
int GetLootState(lua_State* L, GameObject* go)
|
||||
{
|
||||
Eluna::Push(L, go->getLootState());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Player] that can loot the [GameObject]
|
||||
*
|
||||
* Not the original looter and may be nil.
|
||||
*
|
||||
* @return [Player] player
|
||||
*/
|
||||
int GetLootRecipient(lua_State* L, GameObject* go)
|
||||
{
|
||||
Eluna::Push(L, go->GetLootRecipient());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Group] that can loot the [GameObject]
|
||||
*
|
||||
* Not the original looter and may be nil.
|
||||
*
|
||||
* @return [Group] group
|
||||
*/
|
||||
int GetLootRecipientGroup(lua_State* L, GameObject* go)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, go->GetLootRecipientGroup());
|
||||
#else
|
||||
Eluna::Push(L, go->GetGroupLootRecipient());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the guid of the [GameObject] that is used as the ID in the database
|
||||
*
|
||||
* @return uint32 dbguid
|
||||
*/
|
||||
int GetDBTableGUIDLow(lua_State* L, GameObject* go)
|
||||
{
|
||||
#if defined(TRINITY) || defined(AZEROTHCORE)
|
||||
Eluna::Push(L, go->GetSpawnId());
|
||||
#else
|
||||
// on mangos based this is same as lowguid
|
||||
Eluna::Push(L, go->GetGUIDLow());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the state of a [GameObject]
|
||||
*
|
||||
* <pre>
|
||||
* enum GOState
|
||||
* {
|
||||
* GO_STATE_ACTIVE = 0, // show in world as used and not reset (closed door open)
|
||||
* GO_STATE_READY = 1, // show in world as ready (closed door close)
|
||||
* GO_STATE_ACTIVE_ALTERNATIVE = 2 // show in world as used in alt way and not reset (closed door open by cannon fire)
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @param [GOState] state : all available go states can be seen above
|
||||
*/
|
||||
int SetGoState(lua_State* L, GameObject* go)
|
||||
{
|
||||
uint32 state = Eluna::CHECKVAL<uint32>(L, 2, 0);
|
||||
|
||||
if (state == 0)
|
||||
go->SetGoState(GO_STATE_ACTIVE);
|
||||
else if (state == 1)
|
||||
go->SetGoState(GO_STATE_READY);
|
||||
else if (state == 2)
|
||||
{
|
||||
#ifdef TRINITY
|
||||
go->SetGoState(GO_STATE_DESTROYED);
|
||||
#else
|
||||
go->SetGoState(GO_STATE_ACTIVE_ALTERNATIVE);
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the [LootState] of a [GameObject]
|
||||
* Below are [LootState]s off of 3.3.5a
|
||||
*
|
||||
* <pre>
|
||||
* enum LootState
|
||||
* {
|
||||
* GO_NOT_READY = 0,
|
||||
* GO_READY, // can be ready but despawned, and then not possible activate until spawn
|
||||
* GO_ACTIVATED,
|
||||
* GO_JUST_DEACTIVATED
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @param [LootState] state : all available loot states can be seen above
|
||||
*/
|
||||
int SetLootState(lua_State* L, GameObject* go)
|
||||
{
|
||||
uint32 state = Eluna::CHECKVAL<uint32>(L, 2, 0);
|
||||
|
||||
if (state == 0)
|
||||
go->SetLootState(GO_NOT_READY);
|
||||
else if (state == 1)
|
||||
go->SetLootState(GO_READY);
|
||||
else if (state == 2)
|
||||
go->SetLootState(GO_ACTIVATED);
|
||||
else if (state == 3)
|
||||
go->SetLootState(GO_JUST_DEACTIVATED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an [Item] to the loot of a [GameObject]
|
||||
* Requires an gameobject with loot_template set to 0.
|
||||
*
|
||||
* @param uint32 entry : The entry of the [Item]
|
||||
* @param uint32 amount = 1 : amount of the [Item] to add to the loot
|
||||
* @return uint32 itemGUIDlow : low GUID of the [Item]
|
||||
*/
|
||||
|
||||
int AddLoot(lua_State* L, GameObject* go)
|
||||
{
|
||||
int i = 1;
|
||||
int argAmount = lua_gettop(L);
|
||||
|
||||
#if defined TRINITY || defined AZEROTHCORE
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
#endif
|
||||
uint8 addedItems = 0;
|
||||
while (i + 2 <= argAmount)
|
||||
{
|
||||
uint32 entry = Eluna::CHECKVAL<uint32>(L, ++i);
|
||||
uint32 amount = Eluna::CHECKVAL<uint32>(L, ++i);
|
||||
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
ItemTemplate const* item_proto = eObjectMgr->GetItemTemplate(entry);
|
||||
#else
|
||||
ItemTemplate const* item_proto = ObjectMgr::GetItemPrototype(entry);
|
||||
#endif
|
||||
if (!item_proto)
|
||||
{
|
||||
luaL_error(L, "Item entry %d does not exist", entry);
|
||||
continue;
|
||||
}
|
||||
if (amount < 1 || (item_proto->MaxCount > 0 && amount > uint32(item_proto->MaxCount)))
|
||||
{
|
||||
luaL_error(L, "Item entry %d has invalid amount %d", entry, amount);
|
||||
continue;
|
||||
}
|
||||
if (Item* item = Item::CreateItem(entry, amount))
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
item->SaveToDB(trans);
|
||||
#else
|
||||
item->SaveToDB();
|
||||
#endif
|
||||
LootStoreItem storeItem(item->GetEntry(), 0, 100, 0, LOOT_MODE_DEFAULT, 0, item->GetCount(), item->GetCount());
|
||||
go->loot.AddItem(storeItem);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, item->GetGUID().GetCounter());
|
||||
#else
|
||||
Eluna::Push(L, item->GetGUIDLow());
|
||||
#endif
|
||||
++addedItems;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
#endif
|
||||
|
||||
return addedItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves [GameObject] to the database
|
||||
*
|
||||
*/
|
||||
int SaveToDB(lua_State* /*L*/, GameObject* go)
|
||||
{
|
||||
go->SaveToDB();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes [GameObject] from the world
|
||||
*
|
||||
* The object is no longer reachable after this and it is not respawned.
|
||||
*
|
||||
* @param bool deleteFromDB : if true, it will delete the [GameObject] from the database
|
||||
*/
|
||||
int RemoveFromWorld(lua_State* L, GameObject* go)
|
||||
{
|
||||
bool deldb = Eluna::CHECKVAL<bool>(L, 2, false);
|
||||
|
||||
// cs_gobject.cpp copy paste
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
ObjectGuid ownerGuid = go->GetOwnerGUID();
|
||||
#else
|
||||
ObjectGuid ownerGuid = go->GetOwnerGuid();
|
||||
#endif
|
||||
if (ownerGuid)
|
||||
{
|
||||
Unit* owner = eObjectAccessor()GetUnit(*go, ownerGuid);
|
||||
if (!owner || !ownerGuid.IsPlayer())
|
||||
return 0;
|
||||
|
||||
owner->RemoveGameObject(go, false);
|
||||
}
|
||||
|
||||
if (deldb)
|
||||
{
|
||||
#ifdef TRINITY
|
||||
GameObject::DeleteFromDB(go->GetSpawnId());
|
||||
#else
|
||||
go->DeleteFromDB();
|
||||
#endif
|
||||
}
|
||||
|
||||
go->SetRespawnTime(0);
|
||||
go->Delete();
|
||||
|
||||
Eluna::CHECKOBJ<ElunaObject>(L, 1)->Invalidate();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activates a door or a button/lever
|
||||
*
|
||||
* @param uint32 delay = 0 : cooldown time in seconds to restore the [GameObject] back to normal. 0 for infinite duration
|
||||
*/
|
||||
int UseDoorOrButton(lua_State* L, GameObject* go)
|
||||
{
|
||||
uint32 delay = Eluna::CHECKVAL<uint32>(L, 2, 0);
|
||||
|
||||
go->UseDoorOrButton(delay);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Despawns a [GameObject]
|
||||
*
|
||||
* The gameobject may be automatically respawned by the core
|
||||
*/
|
||||
int Despawn(lua_State* /*L*/, GameObject* go)
|
||||
{
|
||||
go->SetLootState(GO_JUST_DEACTIVATED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Respawns a [GameObject]
|
||||
*/
|
||||
int Respawn(lua_State* /*L*/, GameObject* go)
|
||||
{
|
||||
go->Respawn();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the respawn or despawn time for the gameobject.
|
||||
*
|
||||
* Respawn time is also used as despawn time depending on gameobject settings
|
||||
*
|
||||
* @param int32 delay = 0 : cooldown time in seconds to respawn or despawn the object. 0 means never
|
||||
*/
|
||||
int SetRespawnTime(lua_State* L, GameObject* go)
|
||||
{
|
||||
int32 respawn = Eluna::CHECKVAL<int32>(L, 2);
|
||||
|
||||
go->SetRespawnTime(respawn);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
3535
src/LuaEngine/methods/GlobalMethods.h
Normal file
3535
src/LuaEngine/methods/GlobalMethods.h
Normal file
File diff suppressed because it is too large
Load Diff
464
src/LuaEngine/methods/GroupMethods.h
Normal file
464
src/LuaEngine/methods/GroupMethods.h
Normal file
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef GROUPMETHODS_H
|
||||
#define GROUPMETHODS_H
|
||||
|
||||
/***
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaGroup
|
||||
{
|
||||
/**
|
||||
* Returns 'true' if the [Player] is the [Group] leader
|
||||
*
|
||||
* @param ObjectGuid guid : guid of a possible leader
|
||||
* @return bool isLeader
|
||||
*/
|
||||
int IsLeader(lua_State* L, Group* group)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
Eluna::Push(L, group->IsLeader(guid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Group] is full
|
||||
*
|
||||
* @return bool isFull
|
||||
*/
|
||||
int IsFull(lua_State* L, Group* group)
|
||||
{
|
||||
Eluna::Push(L, group->IsFull());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Group] is a LFG group
|
||||
*
|
||||
* @return bool isLFGGroup
|
||||
*/
|
||||
int IsLFGGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Eluna::Push(L, group->isLFGGroup());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Group] is a raid [Group]
|
||||
*
|
||||
* @return bool isRaid
|
||||
*/
|
||||
int IsRaidGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Eluna::Push(L, group->isRaidGroup());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Group] is a battleground [Group]
|
||||
*
|
||||
* @return bool isBG
|
||||
*/
|
||||
int IsBGGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Eluna::Push(L, group->isBGGroup());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Player] is a member of this [Group]
|
||||
*
|
||||
* @param ObjectGuid guid : guid of a player
|
||||
* @return bool isMember
|
||||
*/
|
||||
int IsMember(lua_State* L, Group* group)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
Eluna::Push(L, group->IsMember(guid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Player] is an assistant of this [Group]
|
||||
*
|
||||
* @param ObjectGuid guid : guid of a player
|
||||
* @return bool isAssistant
|
||||
*/
|
||||
int IsAssistant(lua_State* L, Group* group)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
Eluna::Push(L, group->IsAssistant(guid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Player]s are in the same subgroup in this [Group]
|
||||
*
|
||||
* @param [Player] player1 : first [Player] to check
|
||||
* @param [Player] player2 : second [Player] to check
|
||||
* @return bool sameSubGroup
|
||||
*/
|
||||
int SameSubGroup(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player1 = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
Player* player2 = Eluna::CHECKOBJ<Player>(L, 3);
|
||||
Eluna::Push(L, group->SameSubGroup(player1, player2));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the subgroup has free slots in this [Group]
|
||||
*
|
||||
* @param uint8 subGroup : subGroup ID to check
|
||||
* @return bool hasFreeSlot
|
||||
*/
|
||||
int HasFreeSlotSubGroup(lua_State* L, Group* group)
|
||||
{
|
||||
uint8 subGroup = Eluna::CHECKVAL<uint8>(L, 2);
|
||||
|
||||
if (subGroup >= MAX_RAID_SUBGROUPS)
|
||||
{
|
||||
luaL_argerror(L, 2, "valid subGroup ID expected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Eluna::Push(L, group->HasFreeSlotSubGroup(subGroup));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new member to the [Group]
|
||||
*
|
||||
* @param [Player] player : [Player] to add to the group
|
||||
* @return bool added : true if member was added
|
||||
*/
|
||||
int AddMember(lua_State* L, Group* group)
|
||||
{
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
if (player->GetGroup() || !group->IsCreated() || group->IsFull())
|
||||
{
|
||||
Eluna::Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (player->GetGroupInvite())
|
||||
player->UninviteFromGroup();
|
||||
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
bool success = group->AddMember(player);
|
||||
if (success)
|
||||
group->BroadcastGroupUpdate();
|
||||
#else
|
||||
bool success = group->AddMember(player->GetObjectGuid(), player->GetName());
|
||||
#endif
|
||||
|
||||
Eluna::Push(L, success);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int IsLFGGroup(lua_State* L, Group* group) // TODO: Implementation
|
||||
{
|
||||
Eluna::Push(L, group->isLFGGroup());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/*int IsBFGroup(lua_State* L, Group* group) // TODO: Implementation
|
||||
{
|
||||
Eluna::Push(L, group->isBFGroup());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns a table with the [Player]s in this [Group]
|
||||
*
|
||||
* @return table groupPlayers : table of [Player]s
|
||||
*/
|
||||
int GetMembers(lua_State* L, Group* group)
|
||||
{
|
||||
lua_newtable(L);
|
||||
int tbl = lua_gettop(L);
|
||||
uint32 i = 0;
|
||||
|
||||
for (GroupReference* itr = group->GetFirstMember(); itr; itr = itr->next())
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Player* member = itr->GetSource();
|
||||
#else
|
||||
Player* member = itr->getSource();
|
||||
#endif
|
||||
|
||||
if (!member || !member->GetSession())
|
||||
continue;
|
||||
|
||||
Eluna::Push(L, member);
|
||||
lua_rawseti(L, tbl, ++i);
|
||||
}
|
||||
|
||||
lua_settop(L, tbl); // push table to top of stack
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [Group] leader GUID
|
||||
*
|
||||
* @return ObjectGuid leaderGUID
|
||||
*/
|
||||
int GetLeaderGUID(lua_State* L, Group* group)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, group->GetLeaderGUID());
|
||||
#else
|
||||
Eluna::Push(L, group->GetLeaderGuid());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Group]'s GUID
|
||||
*
|
||||
* @return ObjectGuid groupGUID
|
||||
*/
|
||||
int GetGUID(lua_State* L, Group* group)
|
||||
{
|
||||
#ifdef CLASSIC
|
||||
Eluna::Push(L, group->GetId());
|
||||
#else
|
||||
Eluna::Push(L, group->GET_GUID());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [Group] member's GUID by their name
|
||||
*
|
||||
* @param string name : the [Player]'s name
|
||||
* @return ObjectGuid memberGUID
|
||||
*/
|
||||
int GetMemberGUID(lua_State* L, Group* group)
|
||||
{
|
||||
const char* name = Eluna::CHECKVAL<const char*>(L, 2);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, group->GetMemberGUID(name));
|
||||
#else
|
||||
Eluna::Push(L, group->GetMemberGuid(name));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the member count of this [Group]
|
||||
*
|
||||
* @return uint32 memberCount
|
||||
*/
|
||||
int GetMembersCount(lua_State* L, Group* group)
|
||||
{
|
||||
Eluna::Push(L, group->GetMembersCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of this [Group]
|
||||
*
|
||||
* <pre>
|
||||
* enum GroupType
|
||||
* {
|
||||
* GROUPTYPE_NORMAL = 0,
|
||||
* GROUPTYPE_BG = 1,
|
||||
* GROUPTYPE_RAID = 2,
|
||||
* GROUPTYPE_LFG_RESTRICTED = 4,
|
||||
* GROUPTYPE_LFG = 8
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @return [GroupType] groupType
|
||||
*/
|
||||
int GetGroupType(lua_State* L, Group* group)
|
||||
{
|
||||
Eluna::Push(L, group->GetGroupType());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Player]'s subgroup ID of this [Group]
|
||||
*
|
||||
* @param ObjectGuid guid : guid of the player
|
||||
* @return uint8 subGroupID : a valid subgroup ID or MAX_RAID_SUBGROUPS+1
|
||||
*/
|
||||
int GetMemberGroup(lua_State* L, Group* group)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
Eluna::Push(L, group->GetMemberGroup(guid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the leader of this [Group]
|
||||
*
|
||||
* @param ObjectGuid guid : guid of the new leader
|
||||
*/
|
||||
int SetLeader(lua_State* L, Group* group)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
group->ChangeLeader(guid);
|
||||
group->SendUpdate();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a specified [WorldPacket] to this [Group]
|
||||
*
|
||||
* @param [WorldPacket] packet : the [WorldPacket] to send
|
||||
* @param bool ignorePlayersInBg : ignores [Player]s in a battleground
|
||||
* @param ObjectGuid ignore : ignore a [Player] by their GUID
|
||||
*/
|
||||
int SendPacket(lua_State* L, Group* group)
|
||||
{
|
||||
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
|
||||
bool ignorePlayersInBg = Eluna::CHECKVAL<bool>(L, 3);
|
||||
ObjectGuid ignore = Eluna::CHECKVAL<ObjectGuid>(L, 4);
|
||||
|
||||
#ifdef CMANGOS
|
||||
group->BroadcastPacket(*data, ignorePlayersInBg, -1, ignore);
|
||||
#else
|
||||
group->BroadcastPacket(data, ignorePlayersInBg, -1, ignore);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a [Player] from this [Group] and returns 'true' if successful
|
||||
*
|
||||
* <pre>
|
||||
* enum RemoveMethod
|
||||
* {
|
||||
* GROUP_REMOVEMETHOD_DEFAULT = 0,
|
||||
* GROUP_REMOVEMETHOD_KICK = 1,
|
||||
* GROUP_REMOVEMETHOD_LEAVE = 2,
|
||||
* GROUP_REMOVEMETHOD_KICK_LFG = 3
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @param ObjectGuid guid : guid of the player to remove
|
||||
* @param [RemoveMethod] method : method used to remove the player
|
||||
* @return bool removed
|
||||
*/
|
||||
int RemoveMember(lua_State* L, Group* group)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
uint32 method = Eluna::CHECKVAL<uint32>(L, 3, 0);
|
||||
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, group->RemoveMember(guid, (RemoveMethod)method));
|
||||
#else
|
||||
Eluna::Push(L, group->RemoveMember(guid, method));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disbands this [Group]
|
||||
*
|
||||
*/
|
||||
int Disband(lua_State* /*L*/, Group* group)
|
||||
{
|
||||
group->Disband();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts this [Group] to a raid [Group]
|
||||
*
|
||||
*/
|
||||
int ConvertToRaid(lua_State* /*L*/, Group* group)
|
||||
{
|
||||
group->ConvertToRaid();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the member's subGroup
|
||||
*
|
||||
* @param ObjectGuid guid : guid of the player to move
|
||||
* @param uint8 groupID : the subGroup's ID
|
||||
*/
|
||||
int SetMembersGroup(lua_State* L, Group* group)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
uint8 subGroup = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
|
||||
if (subGroup >= MAX_RAID_SUBGROUPS)
|
||||
{
|
||||
luaL_argerror(L, 3, "valid subGroup ID expected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!group->HasFreeSlotSubGroup(subGroup))
|
||||
return 0;
|
||||
|
||||
group->ChangeMembersGroup(guid, subGroup);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target icon of an object for the [Group]
|
||||
*
|
||||
* @param uint8 icon : the icon (Skull, Square, etc)
|
||||
* @param ObjectGuid target : GUID of the icon target, 0 is to clear the icon
|
||||
* @param ObjectGuid setter : GUID of the icon setter
|
||||
*/
|
||||
int SetTargetIcon(lua_State* L, Group* group)
|
||||
{
|
||||
uint8 icon = Eluna::CHECKVAL<uint8>(L, 2);
|
||||
ObjectGuid target = Eluna::CHECKVAL<ObjectGuid>(L, 3);
|
||||
ObjectGuid setter = Eluna::CHECKVAL<ObjectGuid>(L, 4, ObjectGuid());
|
||||
|
||||
if (icon >= TARGETICONCOUNT)
|
||||
return luaL_argerror(L, 2, "valid target icon expected");
|
||||
|
||||
#if (defined(CLASSIC) || defined(TBC))
|
||||
group->SetTargetIcon(icon, target);
|
||||
#else
|
||||
group->SetTargetIcon(icon, setter, target);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets or removes a flag for a [Group] member
|
||||
*
|
||||
* <pre>
|
||||
* enum GroupMemberFlags
|
||||
* {
|
||||
* MEMBER_FLAG_ASSISTANT = 0x01,
|
||||
* MEMBER_FLAG_MAINTANK = 0x02,
|
||||
* MEMBER_FLAG_MAINASSIST = 0x04,
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @param ObjectGuid target : GUID of the target
|
||||
* @param bool apply : add the `flag` if `true`, remove the `flag` otherwise
|
||||
* @param [GroupMemberFlags] flag : the flag to set or unset
|
||||
*/
|
||||
int SetMemberFlag(lua_State* L, Group* group)
|
||||
{
|
||||
ObjectGuid target = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
bool apply = Eluna::CHECKVAL<bool>(L, 3);
|
||||
GroupMemberFlags flag = static_cast<GroupMemberFlags>(Eluna::CHECKVAL<uint32>(L, 4));
|
||||
|
||||
group->SetGroupMemberFlag(target, apply, flag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*int ConvertToLFG(lua_State* L, Group* group) // TODO: Implementation
|
||||
{
|
||||
group->ConvertToLFG();
|
||||
return 0;
|
||||
}*/
|
||||
};
|
||||
|
||||
#endif
|
||||
305
src/LuaEngine/methods/GuildMethods.h
Normal file
305
src/LuaEngine/methods/GuildMethods.h
Normal file
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef GUILDMETHODS_H
|
||||
#define GUILDMETHODS_H
|
||||
|
||||
/***
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaGuild
|
||||
{
|
||||
/**
|
||||
* Returns a table with the [Player]s in this [Guild]
|
||||
*
|
||||
* Only the players that are online and on some map.
|
||||
*
|
||||
* @return table guildPlayers : table of [Player]s
|
||||
*/
|
||||
int GetMembers(lua_State* L, Guild* guild)
|
||||
{
|
||||
lua_newtable(L);
|
||||
int tbl = lua_gettop(L);
|
||||
uint32 i = 0;
|
||||
|
||||
#if defined(MANGOS)
|
||||
eObjectAccessor()DoForAllPlayers([&](Player* player)
|
||||
{
|
||||
if (player->IsInWorld() && player->GetGuildId() == guild->GetId())
|
||||
{
|
||||
Eluna::Push(L, player);
|
||||
lua_rawseti(L, tbl, ++i);
|
||||
}
|
||||
});
|
||||
#else
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock());
|
||||
#else
|
||||
HashMapHolder<Player>::ReadGuard g(HashMapHolder<Player>::GetLock());
|
||||
#endif
|
||||
const HashMapHolder<Player>::MapType& m = eObjectAccessor()GetPlayers();
|
||||
for (HashMapHolder<Player>::MapType::const_iterator it = m.begin(); it != m.end(); ++it)
|
||||
{
|
||||
if (Player* player = it->second)
|
||||
{
|
||||
if (player->IsInWorld() && player->GetGuildId() == guild->GetId())
|
||||
{
|
||||
Eluna::Push(L, player);
|
||||
lua_rawseti(L, tbl, ++i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
lua_settop(L, tbl); // push table to top of stack
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the member count of this [Guild]
|
||||
*
|
||||
* @return uint32 memberCount
|
||||
*/
|
||||
int GetMemberCount(lua_State* L, Guild* guild)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, guild->GetMemberCount());
|
||||
#else
|
||||
Eluna::Push(L, guild->GetMemberSize());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and returns the [Guild] leader by their GUID if logged in
|
||||
*
|
||||
* @return [Player] leader
|
||||
*/
|
||||
int GetLeader(lua_State* L, Guild* guild)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, eObjectAccessor()FindPlayer(guild->GetLeaderGUID()));
|
||||
#else
|
||||
Eluna::Push(L, eObjectAccessor()FindPlayer(guild->GetLeaderGuid()));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [Guild] leader GUID
|
||||
*
|
||||
* @return ObjectGuid leaderGUID
|
||||
*/
|
||||
int GetLeaderGUID(lua_State* L, Guild* guild)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, guild->GetLeaderGUID());
|
||||
#else
|
||||
Eluna::Push(L, guild->GetLeaderGuid());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Guild]s entry ID
|
||||
*
|
||||
* @return uint32 entryId
|
||||
*/
|
||||
int GetId(lua_State* L, Guild* guild)
|
||||
{
|
||||
Eluna::Push(L, guild->GetId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Guild]s name
|
||||
*
|
||||
* @return string guildName
|
||||
*/
|
||||
int GetName(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(lua_State* L, Guild* guild)
|
||||
{
|
||||
Eluna::Push(L, guild->GetMOTD());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Guild]s current info
|
||||
*
|
||||
* @return string guildInfo
|
||||
*/
|
||||
int GetInfo(lua_State* L, Guild* guild)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, guild->GetInfo());
|
||||
#else
|
||||
Eluna::Push(L, guild->GetGINFO());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(CLASSIC) || defined(TBC) || defined(WOTLK)
|
||||
/**
|
||||
* Sets the leader of this [Guild]
|
||||
*
|
||||
* @param [Player] leader : the [Player] leader to change
|
||||
*/
|
||||
int SetLeader(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
guild->HandleSetLeader(player->GetSession(), player->GetName());
|
||||
#else
|
||||
guild->SetLeader(player->GET_GUID());
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#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(lua_State* L, Guild* guild)
|
||||
{
|
||||
uint8 tabId = Eluna::CHECKVAL<uint8>(L, 2);
|
||||
const char* text = Eluna::CHECKVAL<const char*>(L, 3);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
guild->SetBankTabText(tabId, text);
|
||||
#else
|
||||
guild->SetGuildBankTabText(tabId, text);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
// 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(lua_State* L, Guild* guild)
|
||||
{
|
||||
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
|
||||
|
||||
#ifdef CMANGOS
|
||||
guild->BroadcastPacket(*data);
|
||||
#else
|
||||
guild->BroadcastPacket(data);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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(lua_State* L, Guild* guild)
|
||||
{
|
||||
WorldPacket* data = Eluna::CHECKOBJ<WorldPacket>(L, 2);
|
||||
uint8 ranked = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
|
||||
#ifdef CMANGOS
|
||||
guild->BroadcastPacketToRank(*data, ranked);
|
||||
#else
|
||||
guild->BroadcastPacketToRank(data, ranked);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disbands the [Guild]
|
||||
*/
|
||||
int Disband(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(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
uint8 rankId = Eluna::CHECKVAL<uint8>(L, 3, GUILD_RANK_NONE);
|
||||
|
||||
#ifdef TRINITY
|
||||
CharacterDatabaseTransaction trans(nullptr);
|
||||
guild->AddMember(trans, player->GET_GUID(), rankId);
|
||||
#else
|
||||
guild->AddMember(player->GET_GUID(), rankId);
|
||||
#endif
|
||||
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(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
bool isDisbanding = Eluna::CHECKVAL<bool>(L, 3, false);
|
||||
|
||||
#if defined TRINITY
|
||||
CharacterDatabaseTransaction trans(nullptr);
|
||||
guild->DeleteMember(trans, player->GET_GUID(), isDisbanding);
|
||||
#elif defined AZEROTHCORE
|
||||
guild->DeleteMember(player->GET_GUID(), isDisbanding);
|
||||
#else
|
||||
guild->DelMember(player->GET_GUID(), isDisbanding);
|
||||
#endif
|
||||
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(lua_State* L, Guild* guild)
|
||||
{
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
uint8 newRank = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
|
||||
#ifdef TRINITY
|
||||
CharacterDatabaseTransaction trans(nullptr);
|
||||
guild->ChangeMemberRank(trans, player->GET_GUID(), newRank);
|
||||
#else
|
||||
guild->ChangeMemberRank(player->GET_GUID(), newRank);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
786
src/LuaEngine/methods/ItemMethods.h
Normal file
786
src/LuaEngine/methods/ItemMethods.h
Normal file
@@ -0,0 +1,786 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef ITEMMETHODS_H
|
||||
#define ITEMMETHODS_H
|
||||
|
||||
/***
|
||||
* Inherits all methods from: [Object]
|
||||
*/
|
||||
namespace LuaItem
|
||||
{
|
||||
/**
|
||||
* Returns 'true' if the [Item] is soulbound, 'false' otherwise
|
||||
*
|
||||
* @return bool isSoulBound
|
||||
*/
|
||||
int IsSoulBound(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->IsSoulBound());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if (!defined(TBC) && !defined(CLASSIC))
|
||||
/**
|
||||
* Returns 'true' if the [Item] is account bound, 'false' otherwise
|
||||
*
|
||||
* @return bool isAccountBound
|
||||
*/
|
||||
int IsBoundAccountWide(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->IsBoundAccountWide());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Item] is bound to a [Player] by an enchant, 'false' otehrwise
|
||||
*
|
||||
* @return bool isBoundByEnchant
|
||||
*/
|
||||
int IsBoundByEnchant(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(lua_State* L, Item* item)
|
||||
{
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
|
||||
Eluna::Push(L, item->IsBindedNotWith(player));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Item] is locked, 'false' otherwise
|
||||
*
|
||||
* @return bool isLocked
|
||||
*/
|
||||
int IsLocked(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(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->IsBag());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CLASSIC
|
||||
/**
|
||||
* Returns 'true' if the [Item] is a currency token, 'false' otherwise
|
||||
*
|
||||
* @return bool isCurrencyToken
|
||||
*/
|
||||
int IsCurrencyToken(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->IsCurrencyToken());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Item] is a not an empty bag, 'false' otherwise
|
||||
*
|
||||
* @return bool isNotEmptyBag
|
||||
*/
|
||||
int IsNotEmptyBag(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(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(lua_State* L, Item* item)
|
||||
{
|
||||
#if (defined(TBC) || defined(CLASSIC))
|
||||
Eluna::Push(L, item->CanBeTraded());
|
||||
#else
|
||||
bool mail = Eluna::CHECKVAL<bool>(L, 2, false);
|
||||
Eluna::Push(L, item->CanBeTraded(mail));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Item] is currently in a trade window, 'false' otherwise
|
||||
*
|
||||
* @return bool isInTrade
|
||||
*/
|
||||
int IsInTrade(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(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(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(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 quest = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, item->hasQuest(quest));
|
||||
#else
|
||||
Eluna::Push(L, item->HasQuest(quest));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Item] is a potion, 'false' otherwise
|
||||
*
|
||||
* @return bool isPotion
|
||||
*/
|
||||
int IsPotion(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->IsPotion());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined CLASSIC || defined(TBC) || defined(WOTLK)
|
||||
/**
|
||||
* Returns 'true' if the [Item] is a weapon vellum, 'false' otherwise
|
||||
*
|
||||
* @return bool isWeaponVellum
|
||||
*/
|
||||
int IsWeaponVellum(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(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->IsArmorVellum());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Item] is a conjured consumable, 'false' otherwise
|
||||
*
|
||||
* @return bool isConjuredConsumable
|
||||
*/
|
||||
int IsConjuredConsumable(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->IsConjuredConsumable());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int IsRefundExpired(lua_State* L, Item* item)// TODO: Implement core support
|
||||
{
|
||||
Eluna::Push(L, item->IsRefundExpired());
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Returns the chat link of the [Item]
|
||||
*
|
||||
* <pre>
|
||||
* enum LocaleConstant
|
||||
* {
|
||||
* LOCALE_enUS = 0,
|
||||
* LOCALE_koKR = 1,
|
||||
* LOCALE_frFR = 2,
|
||||
* LOCALE_deDE = 3,
|
||||
* LOCALE_zhCN = 4,
|
||||
* LOCALE_zhTW = 5,
|
||||
* LOCALE_esES = 6,
|
||||
* LOCALE_esMX = 7,
|
||||
* LOCALE_ruRU = 8
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the [Item]'s name in
|
||||
* @return string itemLink
|
||||
*/
|
||||
int GetItemLink(lua_State* L, Item* item)
|
||||
{
|
||||
uint8 locale = Eluna::CHECKVAL<uint8>(L, 2, DEFAULT_LOCALE);
|
||||
if (locale >= TOTAL_LOCALES)
|
||||
return luaL_argerror(L, 2, "valid LocaleConstant expected");
|
||||
|
||||
const ItemTemplate* temp = item->GetTemplate();
|
||||
std::string name = temp->Name1;
|
||||
if (ItemLocale const* il = eObjectMgr->GetItemLocale(temp->ItemId))
|
||||
{
|
||||
ObjectMgr::GetLocaleString(il->Name, static_cast<LocaleConstant>(locale), name);
|
||||
}
|
||||
|
||||
#ifndef CLASSIC
|
||||
if (int32 itemRandPropId = item->GetItemRandomPropertyId())
|
||||
{
|
||||
#if defined(CATA) || defined (MISTS)
|
||||
char* suffix = NULL;
|
||||
#else
|
||||
#if TRINITY || AZEROTHCORE
|
||||
std::array<char const*, 16> const* suffix = NULL;
|
||||
#else
|
||||
char* const* suffix = NULL;
|
||||
#endif
|
||||
#endif
|
||||
if (itemRandPropId < 0)
|
||||
{
|
||||
const ItemRandomSuffixEntry* itemRandEntry = sItemRandomSuffixStore.LookupEntry(-item->GetItemRandomPropertyId());
|
||||
if (itemRandEntry)
|
||||
{
|
||||
#if TRINITY || AZEROTHCORE
|
||||
suffix = &itemRandEntry->Name;
|
||||
#else
|
||||
suffix = itemRandEntry->nameSuffix;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const ItemRandomPropertiesEntry* itemRandEntry = sItemRandomPropertiesStore.LookupEntry(item->GetItemRandomPropertyId());
|
||||
if (itemRandEntry)
|
||||
{
|
||||
#if TRINITY || AZEROTHCORE
|
||||
suffix = &itemRandEntry->Name;
|
||||
#else
|
||||
suffix = itemRandEntry->nameSuffix;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (suffix)
|
||||
{
|
||||
#if TRINITY || AZEROTHCORE
|
||||
const char* suffixName = (*suffix)[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)];
|
||||
#else
|
||||
const char* suffixName = suffix[(name != temp->Name1) ? locale : uint8(DEFAULT_LOCALE)];
|
||||
#endif
|
||||
if (strcmp(suffixName, "") != 0)
|
||||
{
|
||||
name += ' ';
|
||||
name += suffixName;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Player* owner = item->GetOwner();
|
||||
std::ostringstream oss;
|
||||
oss << "|c" << std::hex << ItemQualityColors[temp->Quality] << std::dec <<
|
||||
"|Hitem:" << temp->ItemId << ":" <<
|
||||
item->GetEnchantmentId(PERM_ENCHANTMENT_SLOT) << ":" <<
|
||||
#ifndef CLASSIC
|
||||
item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT) << ":" <<
|
||||
item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT_2) << ":" <<
|
||||
item->GetEnchantmentId(SOCK_ENCHANTMENT_SLOT_3) << ":" <<
|
||||
item->GetEnchantmentId(BONUS_ENCHANTMENT_SLOT) << ":" <<
|
||||
#endif
|
||||
item->GetItemRandomPropertyId() << ":" << item->GetItemSuffixFactor() << ":" <<
|
||||
(uint32)(owner ? owner->GetLevel() : 0) << "|h[" << name << "]|h|r";
|
||||
|
||||
Eluna::Push(L, oss.str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetOwnerGUID(lua_State* L, Item* item)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, item->GetOwnerGUID());
|
||||
#else
|
||||
Eluna::Push(L, item->GetOwnerGuid());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Player] who currently owns the [Item]
|
||||
*
|
||||
* @return [Player] player : the [Player] who owns the [Item]
|
||||
*/
|
||||
int GetOwner(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetOwner());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Item]s stack count
|
||||
*
|
||||
* @return uint32 count
|
||||
*/
|
||||
int GetCount(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Item]s max stack count
|
||||
*
|
||||
* @return uint32 maxCount
|
||||
*/
|
||||
int GetMaxStackCount(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetMaxStackCount());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Item]s current slot
|
||||
*
|
||||
* @return uint8 slot
|
||||
*/
|
||||
int GetSlot(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetSlot());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Item]s current bag slot
|
||||
*
|
||||
* @return uint8 bagSlot
|
||||
*/
|
||||
int GetBagSlot(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetBagSlot());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Item]s enchantment ID by enchant slot specified
|
||||
*
|
||||
* @param [EnchantmentSlot] enchantSlot : the enchant slot specified
|
||||
* @return uint32 enchantId : the id of the enchant slot specified
|
||||
*/
|
||||
int GetEnchantmentId(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 enchant_slot = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
|
||||
if (enchant_slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
|
||||
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
|
||||
|
||||
Eluna::Push(L, item->GetEnchantmentId(EnchantmentSlot(enchant_slot)));
|
||||
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(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 index = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (index >= MAX_ITEM_PROTO_SPELLS)
|
||||
return luaL_argerror(L, 2, "valid SpellIndex expected");
|
||||
|
||||
Eluna::Push(L, item->GetTemplate()->Spells[index].SpellId);
|
||||
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(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 index = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (index >= MAX_ITEM_PROTO_SPELLS)
|
||||
return luaL_argerror(L, 2, "valid SpellIndex expected");
|
||||
|
||||
Eluna::Push(L, item->GetTemplate()->Spells[index].SpellTrigger);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns class of the [Item]
|
||||
*
|
||||
* @return uint32 class
|
||||
*/
|
||||
int GetClass(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetTemplate()->Class);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns subclass of the [Item]
|
||||
*
|
||||
* @return uint32 subClass
|
||||
*/
|
||||
int GetSubClass(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetTemplate()->SubClass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the [Item]
|
||||
*
|
||||
* @return string name
|
||||
*/
|
||||
int GetName(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(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetTemplate()->DisplayInfoID);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the quality of the [Item]
|
||||
*
|
||||
* @return uint32 quality
|
||||
*/
|
||||
int GetQuality(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(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(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(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(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(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(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetTemplate()->AllowableRace);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Item]s level
|
||||
*
|
||||
* @return uint32 itemLevel
|
||||
*/
|
||||
int GetItemLevel(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(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetTemplate()->RequiredLevel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef WOTLK
|
||||
int GetStatsCount(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetTemplate()->StatsCount);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the random property ID of this [Item]
|
||||
*
|
||||
* @return uint32 randomPropertyId
|
||||
*/
|
||||
int GetRandomProperty(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetTemplate()->RandomProperty);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CLASSIC
|
||||
int GetRandomSuffix(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetTemplate()->RandomSuffix);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns the item set ID of this [Item]
|
||||
*
|
||||
* @return uint32 itemSetId
|
||||
*/
|
||||
int GetItemSet(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(lua_State* L, Item* item)
|
||||
{
|
||||
if (Bag* bag = item->ToBag())
|
||||
Eluna::Push(L, bag->GetBagSize());
|
||||
else
|
||||
Eluna::Push(L, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate] for this [Item].
|
||||
*
|
||||
* @return [ItemTemplate] itemTemplate
|
||||
*/
|
||||
int GetItemTemplate(lua_State* L, Item* item)
|
||||
{
|
||||
Eluna::Push(L, item->GetTemplate());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the [Player] specified as the owner of the [Item]
|
||||
*
|
||||
* @param [Player] player : the [Player] specified
|
||||
*/
|
||||
int SetOwner(lua_State* L, Item* item)
|
||||
{
|
||||
Player* player = Eluna::CHECKOBJ<Player>(L, 2);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
item->SetOwnerGUID(player->GET_GUID());
|
||||
#else
|
||||
item->SetOwnerGuid(player->GET_GUID());
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the binding of the [Item] to 'true' or 'false'
|
||||
*
|
||||
* @param bool setBinding
|
||||
*/
|
||||
int SetBinding(lua_State* L, Item* item)
|
||||
{
|
||||
bool soulbound = Eluna::CHECKVAL<bool>(L, 2);
|
||||
|
||||
item->SetBinding(soulbound);
|
||||
item->SetState(ITEM_CHANGED, item->GetOwner());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stack count of the [Item]
|
||||
*
|
||||
* @param uint32 count
|
||||
*/
|
||||
int SetCount(lua_State* L, Item* item)
|
||||
{
|
||||
uint32 count = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
item->SetCount(count);
|
||||
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(lua_State* L, Item* item)
|
||||
{
|
||||
Player* owner = item->GetOwner();
|
||||
if (!owner)
|
||||
{
|
||||
Eluna::Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32 enchant = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (!sSpellItemEnchantmentStore.LookupEntry(enchant))
|
||||
{
|
||||
Eluna::Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL<uint32>(L, 3);
|
||||
if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
|
||||
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
|
||||
|
||||
owner->ApplyEnchantment(item, slot, false);
|
||||
item->SetEnchantment(slot, enchant, 0, 0);
|
||||
owner->ApplyEnchantment(item, slot, true);
|
||||
Eluna::Push(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* 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(lua_State* L, Item* item)
|
||||
{
|
||||
Player* owner = item->GetOwner();
|
||||
if (!owner)
|
||||
{
|
||||
Eluna::Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
EnchantmentSlot slot = (EnchantmentSlot)Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (slot >= MAX_INSPECTED_ENCHANTMENT_SLOT)
|
||||
return luaL_argerror(L, 2, "valid EnchantmentSlot expected");
|
||||
|
||||
if (!item->GetEnchantmentId(slot))
|
||||
{
|
||||
Eluna::Push(L, false);
|
||||
return 1;
|
||||
}
|
||||
|
||||
owner->ApplyEnchantment(item, slot, false);
|
||||
item->ClearEnchantment(slot);
|
||||
Eluna::Push(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the [Item] to the database
|
||||
*/
|
||||
int SaveToDB(lua_State* /*L*/, Item* item)
|
||||
{
|
||||
#if defined TRINITY || defined AZEROTHCORE
|
||||
CharacterDatabaseTransaction trans = CharacterDatabaseTransaction(nullptr);
|
||||
item->SaveToDB(trans);
|
||||
#else
|
||||
item->SaveToDB();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
191
src/LuaEngine/methods/ItemTemplateMethods.h
Normal file
191
src/LuaEngine/methods/ItemTemplateMethods.h
Normal file
@@ -0,0 +1,191 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef ITEMTEMPLATEMETHODS_H
|
||||
#define ITEMTEMPLATEMETHODS_H
|
||||
|
||||
#include "Chat.h"
|
||||
|
||||
namespace LuaItemTemplate
|
||||
{
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s ID.
|
||||
*
|
||||
* @return uint32 itemId
|
||||
*/
|
||||
int GetItemId(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->ItemId);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s class.
|
||||
*
|
||||
* @return uint32 class
|
||||
*/
|
||||
int GetClass(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->Class);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s subclass.
|
||||
*
|
||||
* @return uint32 subClass
|
||||
*/
|
||||
int GetSubClass(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->SubClass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s name.
|
||||
*
|
||||
* @return string name
|
||||
*/
|
||||
int GetName(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->Name1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s display ID.
|
||||
*
|
||||
* @return uint32 displayId
|
||||
*/
|
||||
int GetDisplayId(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->DisplayInfoID);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s quality.
|
||||
*
|
||||
* @return uint32 quality
|
||||
*/
|
||||
int GetQuality(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->Quality);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s flags.
|
||||
*
|
||||
* @return uint32 flags
|
||||
*/
|
||||
int GetFlags(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->Flags);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s extra flags.
|
||||
*
|
||||
* @return uint32 flags
|
||||
*/
|
||||
int GetExtraFlags(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->Flags2);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s default purchase count.
|
||||
*
|
||||
* @return uint32 buyCount
|
||||
*/
|
||||
int GetBuyCount(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->BuyCount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s purchase price.
|
||||
*
|
||||
* @return int32 buyPrice
|
||||
*/
|
||||
int GetBuyPrice(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->BuyPrice);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s sell price.
|
||||
*
|
||||
* @return uint32 sellPrice
|
||||
*/
|
||||
int GetSellPrice(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->SellPrice);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s inventory type.
|
||||
*
|
||||
* @return uint32 inventoryType
|
||||
*/
|
||||
int GetInventoryType(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->InventoryType);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Player] classes allowed to use this [ItemTemplate].
|
||||
*
|
||||
* @return uint32 allowableClass
|
||||
*/
|
||||
int GetAllowableClass(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->AllowableClass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Player] races allowed to use this [ItemTemplate].
|
||||
*
|
||||
* @return uint32 allowableRace
|
||||
*/
|
||||
int GetAllowableRace(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->AllowableRace);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [ItemTemplate]'s item level.
|
||||
*
|
||||
* @return uint32 itemLevel
|
||||
*/
|
||||
int GetItemLevel(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->ItemLevel);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum level required to use this [ItemTemplate].
|
||||
*
|
||||
* @return uint32 requiredLevel
|
||||
*/
|
||||
int GetRequiredLevel(lua_State* L, ItemTemplate* itemTemplate)
|
||||
{
|
||||
Eluna::Push(L, itemTemplate->RequiredLevel);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
373
src/LuaEngine/methods/MapMethods.h
Normal file
373
src/LuaEngine/methods/MapMethods.h
Normal file
@@ -0,0 +1,373 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef MAPMETHODS_H
|
||||
#define MAPMETHODS_H
|
||||
|
||||
#include "ElunaInstanceAI.h"
|
||||
|
||||
/***
|
||||
* A game map, e.g. Azeroth, Eastern Kingdoms, the Molten Core, etc.
|
||||
*
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaMap
|
||||
{
|
||||
|
||||
#ifndef CLASSIC
|
||||
/**
|
||||
* Returns `true` if the [Map] is an arena [BattleGround], `false` otherwise.
|
||||
*
|
||||
* @return bool isArena
|
||||
*/
|
||||
int IsArena(lua_State* L, Map* map)
|
||||
{
|
||||
Eluna::Push(L, map->IsBattleArena());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns `true` if the [Map] is a non-arena [BattleGround], `false` otherwise.
|
||||
*
|
||||
* @return bool isBattleGround
|
||||
*/
|
||||
int IsBattleground(lua_State* L, Map* map)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, map->IsBattleground());
|
||||
#else
|
||||
Eluna::Push(L, map->IsBattleGround());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the [Map] is a dungeon, `false` otherwise.
|
||||
*
|
||||
* @return bool isDungeon
|
||||
*/
|
||||
int IsDungeon(lua_State* L, Map* map)
|
||||
{
|
||||
Eluna::Push(L, map->IsDungeon());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the [Map] has no [Player]s, `false` otherwise.
|
||||
*
|
||||
* @return bool IsEmpty
|
||||
*/
|
||||
int IsEmpty(lua_State* L, Map* map)
|
||||
{
|
||||
Eluna::Push(L, map->IsEmpty());
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CLASSIC
|
||||
/**
|
||||
* Returns `true` if the [Map] is a heroic, `false` otherwise.
|
||||
*
|
||||
* @return bool isHeroic
|
||||
*/
|
||||
int IsHeroic(lua_State* L, Map* map)
|
||||
{
|
||||
Eluna::Push(L, map->IsHeroic());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns `true` if the [Map] is a raid, `false` otherwise.
|
||||
*
|
||||
* @return bool isRaid
|
||||
*/
|
||||
int IsRaid(lua_State* L, Map* map)
|
||||
{
|
||||
Eluna::Push(L, map->IsRaid());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the [Map].
|
||||
*
|
||||
* @return string mapName
|
||||
*/
|
||||
int GetName(lua_State* L, Map* map)
|
||||
{
|
||||
Eluna::Push(L, map->GetMapName());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the height of the [Map] at the given X and Y coordinates.
|
||||
*
|
||||
* In case of no height found nil is returned
|
||||
*
|
||||
* @param float x
|
||||
* @param float y
|
||||
* @return float z
|
||||
*/
|
||||
int GetHeight(lua_State* L, Map* map)
|
||||
{
|
||||
float x = Eluna::CHECKVAL<float>(L, 2);
|
||||
float y = Eluna::CHECKVAL<float>(L, 3);
|
||||
#if (defined(TBC) || defined(CLASSIC))
|
||||
float z = map->GetHeight(x, y, MAX_HEIGHT);
|
||||
#else
|
||||
uint32 phasemask = Eluna::CHECKVAL<uint32>(L, 4, 1);
|
||||
float z = map->GetHeight(phasemask, x, y, MAX_HEIGHT);
|
||||
#endif
|
||||
if (z != INVALID_HEIGHT)
|
||||
Eluna::Push(L, z);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the difficulty of the [Map].
|
||||
*
|
||||
* Always returns 0 if the expansion is pre-TBC.
|
||||
*
|
||||
* @return int32 difficulty
|
||||
*/
|
||||
int GetDifficulty(lua_State* L, Map* map)
|
||||
{
|
||||
#ifndef CLASSIC
|
||||
Eluna::Push(L, map->GetDifficulty());
|
||||
#else
|
||||
Eluna::Push(L, (Difficulty)0);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance ID of the [Map].
|
||||
*
|
||||
* @return uint32 instanceId
|
||||
*/
|
||||
int GetInstanceId(lua_State* L, Map* map)
|
||||
{
|
||||
Eluna::Push(L, map->GetInstanceId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the player count currently on the [Map] (excluding GMs).
|
||||
*
|
||||
* @return uint32 playerCount
|
||||
*/
|
||||
int GetPlayerCount(lua_State* L, Map* map)
|
||||
{
|
||||
Eluna::Push(L, map->GetPlayersCountExceptGMs());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the [Map].
|
||||
*
|
||||
* @return uint32 mapId
|
||||
*/
|
||||
int GetMapId(lua_State* L, Map* map)
|
||||
{
|
||||
Eluna::Push(L, map->GetId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the area ID of the [Map] at the specified X, Y, and Z coordinates.
|
||||
*
|
||||
* @param float x
|
||||
* @param float y
|
||||
* @param float z
|
||||
* @param uint32 phasemask = PHASEMASK_NORMAL
|
||||
* @return uint32 areaId
|
||||
*/
|
||||
int GetAreaId(lua_State* L, Map* map)
|
||||
{
|
||||
float x = Eluna::CHECKVAL<float>(L, 2);
|
||||
float y = Eluna::CHECKVAL<float>(L, 3);
|
||||
float z = Eluna::CHECKVAL<float>(L, 4);
|
||||
#if defined TRINITY || defined AZEROTHCORE
|
||||
float phasemask = Eluna::CHECKVAL<uint32>(L, 5, PHASEMASK_NORMAL);
|
||||
|
||||
Eluna::Push(L, map->GetAreaId(phasemask, x, y, z));
|
||||
#else
|
||||
Eluna::Push(L, map->GetTerrain()->GetAreaId(x, y, z));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a [WorldObject] by its GUID from the map if it is spawned.
|
||||
*
|
||||
* @param ObjectGuid guid
|
||||
* @return [WorldObject] object
|
||||
*/
|
||||
int GetWorldObject(lua_State* L, Map* map)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
switch (guid.GetHigh())
|
||||
{
|
||||
case HIGHGUID_PLAYER:
|
||||
Eluna::Push(L, eObjectAccessor()GetPlayer(map, guid));
|
||||
break;
|
||||
case HIGHGUID_TRANSPORT:
|
||||
case HIGHGUID_MO_TRANSPORT:
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
Eluna::Push(L, map->GetGameObject(guid));
|
||||
break;
|
||||
case HIGHGUID_VEHICLE:
|
||||
case HIGHGUID_UNIT:
|
||||
Eluna::Push(L, map->GetCreature(guid));
|
||||
break;
|
||||
case HIGHGUID_PET:
|
||||
Eluna::Push(L, map->GetPet(guid));
|
||||
break;
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
Eluna::Push(L, map->GetDynamicObject(guid));
|
||||
break;
|
||||
case HIGHGUID_CORPSE:
|
||||
Eluna::Push(L, map->GetCorpse(guid));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#else
|
||||
Eluna::Push(L, map->GetWorldObject(guid));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the [Weather] type based on [WeatherType] and grade supplied.
|
||||
*
|
||||
* enum WeatherType
|
||||
* {
|
||||
* WEATHER_TYPE_FINE = 0,
|
||||
* WEATHER_TYPE_RAIN = 1,
|
||||
* WEATHER_TYPE_SNOW = 2,
|
||||
* WEATHER_TYPE_STORM = 3,
|
||||
* WEATHER_TYPE_THUNDERS = 86,
|
||||
* WEATHER_TYPE_BLACKRAIN = 90
|
||||
* };
|
||||
*
|
||||
* @param uint32 zone : id of the zone to set the weather for
|
||||
* @param [WeatherType] type : the [WeatherType], see above available weather types
|
||||
* @param float grade : the intensity/grade of the [Weather], ranges from 0 to 1
|
||||
*/
|
||||
int SetWeather(lua_State* L, Map* map)
|
||||
{
|
||||
(void)map; // ensure that the variable is referenced in order to pass compiler checks
|
||||
uint32 zoneId = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
uint32 weatherType = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
float grade = Eluna::CHECKVAL<float>(L, 4);
|
||||
|
||||
#if defined TRINITY
|
||||
if (Weather * weather = map->GetOrGenerateZoneDefaultWeather(zoneId))
|
||||
weather->SetWeather((WeatherType)weatherType, grade);
|
||||
#elif defined AZEROTHCORE
|
||||
Weather* weather = WeatherMgr::FindWeather(zoneId);
|
||||
if (!weather)
|
||||
weather = WeatherMgr::AddWeather(zoneId);
|
||||
if (weather)
|
||||
weather->SetWeather((WeatherType)weatherType, grade);
|
||||
#else
|
||||
if (Weather::IsValidWeatherType(weatherType))
|
||||
map->SetWeather(zoneId, (WeatherType)weatherType, grade, false);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the instance data table for the [Map], if it exists.
|
||||
*
|
||||
* The instance must be scripted using Eluna for this to succeed.
|
||||
* If the instance is scripted in C++ this will return `nil`.
|
||||
*
|
||||
* @return table instance_data : instance data table, or `nil`
|
||||
*/
|
||||
int GetInstanceData(lua_State* L, Map* map)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
ElunaInstanceAI* iAI = NULL;
|
||||
if (InstanceMap* inst = map->ToInstanceMap())
|
||||
iAI = dynamic_cast<ElunaInstanceAI*>(inst->GetInstanceScript());
|
||||
#else
|
||||
ElunaInstanceAI* iAI = dynamic_cast<ElunaInstanceAI*>(map->GetInstanceData());
|
||||
#endif
|
||||
|
||||
if (iAI)
|
||||
Eluna::GetEluna(L)->PushInstanceData(L, iAI, false);
|
||||
else
|
||||
Eluna::Push(L); // nil
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the [Map]'s instance data to the database.
|
||||
*/
|
||||
int SaveInstanceData(lua_State* /*L*/, Map* map)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
ElunaInstanceAI* iAI = NULL;
|
||||
if (InstanceMap* inst = map->ToInstanceMap())
|
||||
iAI = dynamic_cast<ElunaInstanceAI*>(inst->GetInstanceScript());
|
||||
#else
|
||||
ElunaInstanceAI* iAI = dynamic_cast<ElunaInstanceAI*>(map->GetInstanceData());
|
||||
#endif
|
||||
|
||||
if (iAI)
|
||||
iAI->SaveToDB();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a table with all the current [Player]s in the map
|
||||
*
|
||||
* enum TeamId
|
||||
* {
|
||||
* TEAM_ALLIANCE = 0,
|
||||
* TEAM_HORDE = 1,
|
||||
* TEAM_NEUTRAL = 2
|
||||
* };
|
||||
*
|
||||
* @param [TeamId] team : optional check team of the [Player], Alliance, Horde or Neutral (All)
|
||||
* @return table mapPlayers
|
||||
*/
|
||||
int GetPlayers(lua_State* L, Map* map)
|
||||
{
|
||||
uint32 team = Eluna::CHECKVAL<uint32>(L, 2, TEAM_NEUTRAL);
|
||||
|
||||
lua_newtable(L);
|
||||
int tbl = lua_gettop(L);
|
||||
uint32 i = 0;
|
||||
|
||||
Map::PlayerList const& players = map->GetPlayers();
|
||||
for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Player* player = itr->GetSource();
|
||||
#else
|
||||
Player* player = itr->getSource();
|
||||
#endif
|
||||
if (!player)
|
||||
continue;
|
||||
if (player->GetSession() && (team >= TEAM_NEUTRAL || player->GetTeamId() == team))
|
||||
{
|
||||
Eluna::Push(L, player);
|
||||
lua_rawseti(L, tbl, ++i);
|
||||
}
|
||||
}
|
||||
|
||||
lua_settop(L, tbl);
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
477
src/LuaEngine/methods/ObjectMethods.h
Normal file
477
src/LuaEngine/methods/ObjectMethods.h
Normal file
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef OBJECTMETHODS_H
|
||||
#define OBJECTMETHODS_H
|
||||
|
||||
/***
|
||||
* A basic game object (either an [Item] or a [WorldObject]).
|
||||
*
|
||||
* Objects in MaNGOS/Trinity are stored an a giant block of "values".
|
||||
* Subclasses of Object, like [WorldObject], extend the block with more data specific to that subclass.
|
||||
* Further subclasses, like [Player], extend it even further.
|
||||
*
|
||||
* A detailed map of all the fields in this data block can be found in the UpdateFields.h file of your emulator
|
||||
* (it varies depending on the expansion supported).
|
||||
*
|
||||
* The GetValue methods in this class (e.g. [Object:GetInt32Value]) provide low-level access to the data block.
|
||||
* Other methods, like [Object:HasFlag] and [Object:GetScale], merely wrap the GetValue methods and provide a simpler interface.
|
||||
*
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaObject
|
||||
{
|
||||
/**
|
||||
* Returns `true` if the specified flag is set, otherwise `false`.
|
||||
*
|
||||
* @param uint16 index : the index of the flags data in the [Object]
|
||||
* @param uint32 flag : the flag to check for in the flags data
|
||||
* @return bool hasFlag
|
||||
*/
|
||||
int HasFlag(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
|
||||
Eluna::Push(L, obj->HasFlag(index, flag));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the [Object] has been added to its [Map], otherwise `false`.
|
||||
*
|
||||
* @return bool inWorld
|
||||
*/
|
||||
int IsInWorld(lua_State* L, Object* obj)
|
||||
{
|
||||
Eluna::Push(L, obj->IsInWorld());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Object] is a player, 'false' otherwise.
|
||||
*
|
||||
* @return bool IsPlayer
|
||||
*/
|
||||
int IsPlayer(lua_State* L, Object* obj)
|
||||
{
|
||||
#ifdef AZEROTHCORE //AC-only
|
||||
Eluna::Push(L, obj->IsPlayer());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data at the specified index, casted to a signed 32-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @return int32 value
|
||||
*/
|
||||
int GetInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
Eluna::Push(L, obj->GetInt32Value(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data at the specified index, casted to a unsigned 32-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @return uint32 value
|
||||
*/
|
||||
int GetUInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
Eluna::Push(L, obj->GetUInt32Value(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data at the specified index, casted to a single-precision floating point value.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @return float value
|
||||
*/
|
||||
int GetFloatValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
Eluna::Push(L, obj->GetFloatValue(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data at the specified index and offset, casted to an unsigned 8-bit integer.
|
||||
*
|
||||
* E.g. if you want the second byte at index 10, you would pass in 1 as the offset.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint8 offset : should be 0, 1, 2, or 3
|
||||
* @return uint8 value
|
||||
*/
|
||||
int GetByteValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
Eluna::Push(L, obj->GetByteValue(index, offset));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data at the specified index and offset, casted to a signed 16-bit integer.
|
||||
*
|
||||
* E.g. if you want the second half-word at index 10, you would pass in 1 as the offset.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint8 offset : should be 0 or 1
|
||||
* @return uint16 value
|
||||
*/
|
||||
int GetUInt16Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
Eluna::Push(L, obj->GetUInt16Value(index, offset));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scale/size of the [Object].
|
||||
*
|
||||
* This affects the size of a [WorldObject] in-game, but [Item]s don't have a "scale".
|
||||
*
|
||||
* @return float scale
|
||||
*/
|
||||
int GetScale(lua_State* L, Object* obj)
|
||||
{
|
||||
#ifndef AZEROTHCORE
|
||||
Eluna::Push(L, obj->GetObjectScale());
|
||||
#else
|
||||
Eluna::Push(L, obj->GetFloatValue(OBJECT_FIELD_SCALE_X));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entry of the [Object].
|
||||
*
|
||||
* [Player]s do not have an "entry".
|
||||
*
|
||||
* @return uint32 entry
|
||||
*/
|
||||
int GetEntry(lua_State* L, Object* obj)
|
||||
{
|
||||
Eluna::Push(L, obj->GetEntry());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the GUID of the [Object].
|
||||
*
|
||||
* GUID is an unique identifier for the object.
|
||||
*
|
||||
* However on MaNGOS and cMangos creatures and gameobjects inside different maps can share
|
||||
* the same GUID but not on the same map.
|
||||
*
|
||||
* On TrinityCore this value is unique across all maps
|
||||
*
|
||||
* @return ObjectGuid guid
|
||||
*/
|
||||
int GetGUID(lua_State* L, Object* obj)
|
||||
{
|
||||
Eluna::Push(L, obj->GET_GUID());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the low-part of the [Object]'s GUID.
|
||||
*
|
||||
* On TrinityCore all low GUIDs are different for all objects of the same type.
|
||||
* For example creatures in instances are assigned new GUIDs when the Map is created.
|
||||
*
|
||||
* On MaNGOS and cMaNGOS low GUIDs are unique only on the same map.
|
||||
* For example creatures in instances use the same low GUID assigned for that spawn in the database.
|
||||
* This is why to identify a creature you have to know the instanceId and low GUID. See [Map:GetIntstanceId]
|
||||
*
|
||||
* @return uint32 guidLow
|
||||
*/
|
||||
int GetGUIDLow(lua_State* L, Object* obj)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, obj->GetGUID().GetCounter());
|
||||
#else
|
||||
Eluna::Push(L, obj->GetGUIDLow());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the TypeId of the [Object].
|
||||
*
|
||||
* enum TypeID
|
||||
* {
|
||||
* TYPEID_OBJECT = 0,
|
||||
* TYPEID_ITEM = 1,
|
||||
* TYPEID_CONTAINER = 2,
|
||||
* TYPEID_UNIT = 3,
|
||||
* TYPEID_PLAYER = 4,
|
||||
* TYPEID_GAMEOBJECT = 5,
|
||||
* TYPEID_DYNAMICOBJECT = 6,
|
||||
* TYPEID_CORPSE = 7
|
||||
* };
|
||||
*
|
||||
* @return uint8 typeID
|
||||
*/
|
||||
int GetTypeId(lua_State* L, Object* obj)
|
||||
{
|
||||
Eluna::Push(L, obj->GetTypeId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the data at the specified index, casted to an unsigned 64-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @return uint64 value
|
||||
*/
|
||||
int GetUInt64Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
Eluna::Push(L, obj->GetUInt64Value(index));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the specified flag in the data value at the specified index.
|
||||
*
|
||||
* If the flag was already set, it remains set.
|
||||
*
|
||||
* To remove a flag, use [Object:RemoveFlag].
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint32 value
|
||||
*/
|
||||
int SetFlag(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
|
||||
obj->SetFlag(index, flag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data at the specified index to the given value, converted to a signed 32-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param int32 value
|
||||
*/
|
||||
int SetInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
int32 value = Eluna::CHECKVAL<int32>(L, 3);
|
||||
obj->SetInt32Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data at the specified index to the given value, converted to an unsigned 32-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint32 value
|
||||
*/
|
||||
int SetUInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 value = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
obj->SetUInt32Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data at the specified index to the given value, converted to an unsigned 32-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint32 value
|
||||
*/
|
||||
int UpdateUInt32Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 value = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
obj->UpdateUInt32Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data at the specified index to the given value, converted to a single-precision floating point value.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param float value
|
||||
*/
|
||||
int SetFloatValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
float value = Eluna::CHECKVAL<float>(L, 3);
|
||||
|
||||
obj->SetFloatValue(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data at the specified index and offset to the given value, converted to an unsigned 8-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint8 offset : should be 0, 1, 2, or 3
|
||||
* @param uint8 value
|
||||
*/
|
||||
int SetByteValue(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
uint8 value = Eluna::CHECKVAL<uint8>(L, 4);
|
||||
obj->SetByteValue(index, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data at the specified index to the given value, converted to an unsigned 16-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint8 offset : should be 0 or 1
|
||||
* @param uint16 value
|
||||
*/
|
||||
int SetUInt16Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
uint16 value = Eluna::CHECKVAL<uint16>(L, 4);
|
||||
obj->SetUInt16Value(index, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data at the specified index to the given value, converted to a signed 16-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint8 offset : should be 0 or 1
|
||||
* @param int16 value
|
||||
*/
|
||||
int SetInt16Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint8 offset = Eluna::CHECKVAL<uint8>(L, 3);
|
||||
int16 value = Eluna::CHECKVAL<int16>(L, 4);
|
||||
obj->SetInt16Value(index, offset, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the [Object]'s scale/size to the given value.
|
||||
*
|
||||
* @param float scale
|
||||
*/
|
||||
int SetScale(lua_State* L, Object* obj)
|
||||
{
|
||||
float size = Eluna::CHECKVAL<float>(L, 2);
|
||||
|
||||
obj->SetObjectScale(size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data at the specified index to the given value, converted to an unsigned 64-bit integer.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint64 value
|
||||
*/
|
||||
int SetUInt64Value(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint64 value = Eluna::CHECKVAL<uint64>(L, 3);
|
||||
obj->SetUInt64Value(index, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a flag from the value at the specified index.
|
||||
*
|
||||
* @param uint16 index
|
||||
* @param uint32 flag
|
||||
*/
|
||||
int RemoveFlag(lua_State* L, Object* obj)
|
||||
{
|
||||
uint16 index = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
uint32 flag = Eluna::CHECKVAL<uint32>(L, 3);
|
||||
|
||||
obj->RemoveFlag(index, flag);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to convert the [Object] to a [Corpse].
|
||||
*
|
||||
* If the [Object] is not a [Corpse], returns `nil`.
|
||||
*
|
||||
* @return [Corpse] corpse : the [Object] as a [Corpse], or `nil`
|
||||
*/
|
||||
int ToCorpse(lua_State* L, Object* obj)
|
||||
{
|
||||
Eluna::Push(L, obj->ToCorpse());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to convert the [Object] to a [GameObject].
|
||||
*
|
||||
* If the [Object] is not a [GameObject], returns `nil`.
|
||||
*
|
||||
* @return [GameObject] gameObject : the [Object] as a [GameObject], or `nil`
|
||||
*/
|
||||
int ToGameObject(lua_State* L, Object* obj)
|
||||
{
|
||||
Eluna::Push(L, obj->ToGameObject());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to convert the [Object] to a [Unit].
|
||||
*
|
||||
* If the [Object] is not a [Unit], returns `nil`.
|
||||
*
|
||||
* @return [Unit] unit : the [Object] as a [Unit], or `nil`
|
||||
*/
|
||||
int ToUnit(lua_State* L, Object* obj)
|
||||
{
|
||||
Eluna::Push(L, obj->ToUnit());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to convert the [Object] to a [Creature].
|
||||
*
|
||||
* If the [Object] is not a [Creature], returns `nil`.
|
||||
*
|
||||
* @return [Creature] creature : the [Object] as a [Creature], or `nil`
|
||||
*/
|
||||
int ToCreature(lua_State* L, Object* obj)
|
||||
{
|
||||
Eluna::Push(L, obj->ToCreature());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to convert the [Object] to a [Player].
|
||||
*
|
||||
* If the [Object] is not a [Player], returns `nil`.
|
||||
*
|
||||
* @return [Player] player : the [Object] as a [Player], or `nil`
|
||||
*/
|
||||
int ToPlayer(lua_State* L, Object* obj)
|
||||
{
|
||||
Eluna::Push(L, obj->ToPlayer());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
4515
src/LuaEngine/methods/PlayerMethods.h
Normal file
4515
src/LuaEngine/methods/PlayerMethods.h
Normal file
File diff suppressed because it is too large
Load Diff
187
src/LuaEngine/methods/QuestMethods.h
Normal file
187
src/LuaEngine/methods/QuestMethods.h
Normal file
@@ -0,0 +1,187 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef QUESTMETHODS_H
|
||||
#define QUESTMETHODS_H
|
||||
|
||||
/***
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaQuest
|
||||
{
|
||||
/**
|
||||
* Returns 'true' if the [Quest] has the specified flag, false otherwise.
|
||||
* Below flags are based off of 3.3.5a. Subject to change.
|
||||
*
|
||||
* <pre>
|
||||
* enum QuestFlags
|
||||
* {
|
||||
* // Flags used at server and sent to client
|
||||
* QUEST_FLAGS_NONE = 0x0,
|
||||
* QUEST_FLAGS_STAY_ALIVE = 0x1, // Not used currently
|
||||
* QUEST_FLAGS_PARTY_ACCEPT = 0x2, // Not used currently. If player in party, all players that can accept this quest will receive confirmation box to accept quest CMSG_QUEST_CONFIRM_ACCEPT/SMSG_QUEST_CONFIRM_ACCEPT
|
||||
* QUEST_FLAGS_EXPLORATION = 0x4, // Not used currently
|
||||
* QUEST_FLAGS_SHARABLE = 0x8, // Can be shared: Player::CanShareQuest()
|
||||
* QUEST_FLAGS_HAS_CONDITION = 0x10, // Not used currently
|
||||
* QUEST_FLAGS_HIDE_REWARD_POI = 0x20, // Not used currently: Unsure of content
|
||||
* QUEST_FLAGS_RAID = 0x40, // Not used currently
|
||||
* QUEST_FLAGS_TBC = 0x80, // Not used currently: Available if TBC expansion enabled only
|
||||
* QUEST_FLAGS_NO_MONEY_FROM_XP = 0x100, // Not used currently: Experience is not converted to gold at max level
|
||||
* QUEST_FLAGS_HIDDEN_REWARDS = 0x200, // Items and money rewarded only sent in SMSG_QUESTGIVER_OFFER_REWARD (not in SMSG_QUESTGIVER_QUEST_DETAILS or in client quest log(SMSG_QUEST_QUERY_RESPONSE))
|
||||
* QUEST_FLAGS_TRACKING = 0x400, // These quests are automatically rewarded on quest complete and they will never appear in quest log client side.
|
||||
* QUEST_FLAGS_DEPRECATE_REPUTATION = 0x800, // Not used currently
|
||||
* QUEST_FLAGS_DAILY = 0x1000, // Used to know quest is Daily one
|
||||
* QUEST_FLAGS_FLAGS_PVP = 0x2000, // Having this quest in log forces PvP flag
|
||||
* QUEST_FLAGS_UNAVAILABLE = 0x4000, // Used on quests that are not generically available
|
||||
* QUEST_FLAGS_WEEKLY = 0x8000,
|
||||
* QUEST_FLAGS_AUTOCOMPLETE = 0x10000, // auto complete
|
||||
* QUEST_FLAGS_DISPLAY_ITEM_IN_TRACKER = 0x20000, // Displays usable item in quest tracker
|
||||
* QUEST_FLAGS_OBJ_TEXT = 0x40000, // use Objective text as Complete text
|
||||
* QUEST_FLAGS_AUTO_ACCEPT = 0x80000, // The client recognizes this flag as auto-accept. However, NONE of the current quests (3.3.5a) have this flag. Maybe blizz used to use it, or will use it in the future.
|
||||
*
|
||||
* // ... 4.x added flags up to 0x80000000 - all unknown for now
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @param [QuestFlags] flag : all available flags can be seen above
|
||||
* @return bool hasFlag
|
||||
*/
|
||||
int HasFlag(lua_State* L, Quest* quest)
|
||||
{
|
||||
uint32 flag = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, quest->HasFlag(flag));
|
||||
#else
|
||||
Eluna::Push(L, quest->HasQuestFlag((QuestFlags)flag));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifndef CLASSIC
|
||||
/**
|
||||
* Returns 'true' if the [Quest] is a daily quest, false otherwise.
|
||||
*
|
||||
* @return bool isDaily
|
||||
*/
|
||||
int IsDaily(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->IsDaily());
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns 'true' if the [Quest] is repeatable, false otherwise.
|
||||
*
|
||||
* @return bool isRepeatable
|
||||
*/
|
||||
int IsRepeatable(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->IsRepeatable());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns entry ID of the [Quest].
|
||||
*
|
||||
* @return uint32 entryId
|
||||
*/
|
||||
int GetId(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->GetQuestId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Quest]'s level.
|
||||
*
|
||||
* @return uint32 level
|
||||
*/
|
||||
int GetLevel(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->GetQuestLevel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum level required to pick up the [Quest].
|
||||
*
|
||||
* @return uint32 minLevel
|
||||
*/
|
||||
int GetMinLevel(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->GetMinLevel());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next [Quest] entry ID.
|
||||
*
|
||||
* @return int32 entryId
|
||||
*/
|
||||
int GetNextQuestId(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->GetNextQuestId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the previous [Quest] entry ID.
|
||||
*
|
||||
* @return int32 entryId
|
||||
*/
|
||||
int GetPrevQuestId(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->GetPrevQuestId());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the next [Quest] entry ID in the specific [Quest] chain.
|
||||
*
|
||||
* @return int32 entryId
|
||||
*/
|
||||
int GetNextQuestInChain(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->GetNextQuestInChain());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Quest]'s flags.
|
||||
*
|
||||
* @return [QuestFlags] flags
|
||||
*/
|
||||
int GetFlags(lua_State* L, Quest* quest)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, quest->GetFlags());
|
||||
#else
|
||||
Eluna::Push(L, quest->GetQuestFlags());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Quest]'s type.
|
||||
*
|
||||
* TODO: Document types available.
|
||||
*
|
||||
* @return uint32 type
|
||||
*/
|
||||
int GetType(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->GetType());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*int GetMaxLevel(lua_State* L, Quest* quest)
|
||||
{
|
||||
Eluna::Push(L, quest->GetMaxLevel());
|
||||
return 1;
|
||||
}*/
|
||||
};
|
||||
#endif
|
||||
212
src/LuaEngine/methods/RollMethods.h
Normal file
212
src/LuaEngine/methods/RollMethods.h
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef ROLLMETHODS_H
|
||||
#define ROLLMETHODS_H
|
||||
|
||||
#include "Group.h"
|
||||
|
||||
namespace LuaRoll
|
||||
{
|
||||
/**
|
||||
* Returns the rolled [Item]'s GUID.
|
||||
*
|
||||
* @return ObjectGuid guid
|
||||
*/
|
||||
int GetItemGUID(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->itemGUID.GetCounter());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rolled [Item]'s entry.
|
||||
*
|
||||
* @return uint32 entry
|
||||
*/
|
||||
int GetItemId(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->itemid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rolled [Item]'s random property ID.
|
||||
*
|
||||
* @return int32 randomPropId
|
||||
*/
|
||||
int GetItemRandomPropId(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->itemRandomPropId);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rolled [Item]'s random suffix ID.
|
||||
*
|
||||
* @return uint32 randomSuffix
|
||||
*/
|
||||
int GetItemRandomSuffix(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->itemRandomSuffix);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rolled [Item]'s count.
|
||||
*
|
||||
* @return uint8 count
|
||||
*/
|
||||
int GetItemCount(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->itemCount);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the vote type for a [Player] on this [Roll].
|
||||
* See [Roll:GetPlayerVoteGUIDs] to obtain the GUIDs of the [Player]s who rolled.
|
||||
*
|
||||
* <pre>
|
||||
* enum RollVote
|
||||
* {
|
||||
* PASS = 0,
|
||||
* NEED = 1,
|
||||
* GREED = 2,
|
||||
* DISENCHANT = 3,
|
||||
* NOT_EMITED_YET = 4,
|
||||
* NOT_VALID = 5
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @param ObjectGuid guid
|
||||
* @return [RollVote] vote
|
||||
*/
|
||||
int GetPlayerVote(lua_State* L, Roll* roll)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
|
||||
bool found = false;
|
||||
for (std::pair<const ObjectGuid, RollVote>& pair : roll->playerVote)
|
||||
{
|
||||
if (pair.first == guid)
|
||||
{
|
||||
Eluna::Push(L, pair.second);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
Eluna::Push(L);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the GUIDs of the [Player]s who rolled.
|
||||
* See [Roll:GetPlayerVote] to obtain the vote type of a [Player].
|
||||
*
|
||||
* @return table guids
|
||||
*/
|
||||
int GetPlayerVoteGUIDs(lua_State* L, Roll* roll)
|
||||
{
|
||||
lua_newtable(L);
|
||||
int table = lua_gettop(L);
|
||||
uint32 i = 1;
|
||||
for (std::pair<const ObjectGuid, RollVote>& pair : roll->playerVote)
|
||||
{
|
||||
Eluna::Push(L, pair.first);
|
||||
lua_rawseti(L, table, i);
|
||||
++i;
|
||||
}
|
||||
|
||||
lua_settop(L, table); // push table to top of stack
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of players who rolled.
|
||||
*
|
||||
* @return uint8 playersCount
|
||||
*/
|
||||
int GetTotalPlayersRolling(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->totalPlayersRolling);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of players who rolled need.
|
||||
*
|
||||
* @return uint8 playersCount
|
||||
*/
|
||||
int GetTotalNeed(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->totalNeed);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of players who rolled greed.
|
||||
*
|
||||
* @return uint8 playersCount
|
||||
*/
|
||||
int GetTotalGreed(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->totalGreed);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of players who passed.
|
||||
*
|
||||
* @return uint8 playersCount
|
||||
*/
|
||||
int GetTotalPass(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->totalPass);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rolled [Item]'s slot in the loot window.
|
||||
*
|
||||
* @return uint8 slot
|
||||
*/
|
||||
int GetItemSlot(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->itemSlot);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mask applied to this [Roll].
|
||||
*
|
||||
* <pre>
|
||||
* enum RollMask
|
||||
* {
|
||||
* ROLL_FLAG_TYPE_PASS = 0x01,
|
||||
* ROLL_FLAG_TYPE_NEED = 0x02,
|
||||
* ROLL_FLAG_TYPE_GREED = 0x04,
|
||||
* ROLL_FLAG_TYPE_DISENCHANT = 0x08,
|
||||
*
|
||||
* ROLL_ALL_TYPE_NO_DISENCHANT = 0x07,
|
||||
* ROLL_ALL_TYPE_MASK = 0x0F
|
||||
* };
|
||||
* </pre>
|
||||
*
|
||||
* @return [RollMask] rollMask
|
||||
*/
|
||||
int GetRollVoteMask(lua_State* L, Roll* roll)
|
||||
{
|
||||
Eluna::Push(L, roll->rollVoteMask);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
217
src/LuaEngine/methods/SpellMethods.h
Normal file
217
src/LuaEngine/methods/SpellMethods.h
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef SPELLMETHODS_H
|
||||
#define SPELLMETHODS_H
|
||||
|
||||
/***
|
||||
* An instance of a spell, created when the spell is cast by a [Unit].
|
||||
*
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaSpell
|
||||
{
|
||||
/**
|
||||
* Returns `true` if the [Spell] is automatically repeating, `false` otherwise.
|
||||
*
|
||||
* @return bool isAutoRepeating
|
||||
*/
|
||||
int IsAutoRepeat(lua_State* L, Spell* spell)
|
||||
{
|
||||
Eluna::Push(L, spell->IsAutoRepeat());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Unit] that casted the [Spell].
|
||||
*
|
||||
* @return [Unit] caster
|
||||
*/
|
||||
int GetCaster(lua_State* L, Spell* spell)
|
||||
{
|
||||
Eluna::Push(L, spell->GetCaster());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cast time of the [Spell].
|
||||
*
|
||||
* @return int32 castTime
|
||||
*/
|
||||
int GetCastTime(lua_State* L, Spell* spell)
|
||||
{
|
||||
Eluna::Push(L, spell->GetCastTime());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the entry ID of the [Spell].
|
||||
*
|
||||
* @return uint32 entryId
|
||||
*/
|
||||
int GetEntry(lua_State* L, Spell* spell)
|
||||
{
|
||||
Eluna::Push(L, spell->m_spellInfo->Id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the power cost of the [Spell].
|
||||
*
|
||||
* @return uint32 powerCost
|
||||
*/
|
||||
int GetPowerCost(lua_State* L, Spell* spell)
|
||||
{
|
||||
Eluna::Push(L, spell->GetPowerCost());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the reagents needed for the [Spell].
|
||||
*
|
||||
* @return table reagents : a table containing the [ItemTemplate]s and amount of reagents needed for the [Spell]
|
||||
*/
|
||||
int GetReagentCost(lua_State* L, Spell* spell)
|
||||
{
|
||||
auto spellInfo = spell->GetSpellInfo();
|
||||
auto reagents = spellInfo->Reagent;
|
||||
auto reagentCounts = spellInfo->ReagentCount;
|
||||
lua_newtable(L);
|
||||
for (auto i = 0; i < MAX_SPELL_REAGENTS; ++i)
|
||||
{
|
||||
if (reagents[i] <= 0)
|
||||
continue;
|
||||
auto reagent = eObjectMgr->GetItemTemplate(reagents[i]);
|
||||
auto count = reagentCounts[i];
|
||||
Eluna::Push(L, reagent);
|
||||
Eluna::Push(L, count);
|
||||
lua_settable(L, -3);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the spell duration of the [Spell].
|
||||
*
|
||||
* @return int32 duration
|
||||
*/
|
||||
int GetDuration(lua_State* L, Spell* spell)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, spell->GetSpellInfo()->GetDuration());
|
||||
#else
|
||||
Eluna::Push(L, GetSpellDuration(spell->m_spellInfo));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target destination coordinates of the [Spell].
|
||||
*
|
||||
* @return float x : x coordinate of the [Spell]
|
||||
* @return float y : y coordinate of the [Spell]
|
||||
* @return float z : z coordinate of the [Spell]
|
||||
*/
|
||||
int GetTargetDest(lua_State* L, Spell* spell)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
if (!spell->m_targets.HasDst())
|
||||
return 3;
|
||||
float x, y, z;
|
||||
spell->m_targets.GetDstPos()->GetPosition(x, y, z);
|
||||
#else
|
||||
if (!(spell->m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION))
|
||||
return 3;
|
||||
float x, y, z;
|
||||
spell->m_targets.getDestination(x, y, z);
|
||||
#endif
|
||||
Eluna::Push(L, x);
|
||||
Eluna::Push(L, y);
|
||||
Eluna::Push(L, z);
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the target [Object] of the [Spell].
|
||||
*
|
||||
* The target can be any of the following [Object] types:
|
||||
* - [Player]
|
||||
* - [Creature]
|
||||
* - [GameObject]
|
||||
* - [Item]
|
||||
* - [Corpse]
|
||||
*
|
||||
* @return [Object] target
|
||||
*/
|
||||
int GetTarget(lua_State* L, Spell* spell)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
if (GameObject* target = spell->m_targets.GetGOTarget())
|
||||
Eluna::Push(L, target);
|
||||
else if (Item* target = spell->m_targets.GetItemTarget())
|
||||
Eluna::Push(L, target);
|
||||
else if (Corpse* target = spell->m_targets.GetCorpseTarget())
|
||||
Eluna::Push(L, target);
|
||||
else if (Unit* target = spell->m_targets.GetUnitTarget())
|
||||
Eluna::Push(L, target);
|
||||
else if (WorldObject* target = spell->m_targets.GetObjectTarget())
|
||||
Eluna::Push(L, target);
|
||||
#else
|
||||
if (GameObject* target = spell->m_targets.getGOTarget())
|
||||
Eluna::Push(L, target);
|
||||
else if (Item* target = spell->m_targets.getItemTarget())
|
||||
Eluna::Push(L, target);
|
||||
else if (Corpse* target = spell->GetCaster()->GetMap()->GetCorpse(spell->m_targets.getCorpseTargetGuid()))
|
||||
Eluna::Push(L, target);
|
||||
else if (Unit* target = spell->m_targets.getUnitTarget())
|
||||
Eluna::Push(L, target);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the [Spell] to automatically repeat.
|
||||
*
|
||||
* @param bool repeat : set variable to 'true' for spell to automatically repeat
|
||||
*/
|
||||
int SetAutoRepeat(lua_State* L, Spell* spell)
|
||||
{
|
||||
bool repeat = Eluna::CHECKVAL<bool>(L, 2);
|
||||
spell->SetAutoRepeat(repeat);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts the [Spell].
|
||||
*
|
||||
* @param bool skipCheck = false : skips initial checks to see if the [Spell] can be casted or not, this is optional
|
||||
*/
|
||||
int Cast(lua_State* L, Spell* spell)
|
||||
{
|
||||
bool skipCheck = Eluna::CHECKVAL<bool>(L, 2, false);
|
||||
spell->cast(skipCheck);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels the [Spell].
|
||||
*/
|
||||
int Cancel(lua_State* /*L*/, Spell* spell)
|
||||
{
|
||||
spell->cancel();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes the [Spell].
|
||||
*/
|
||||
int Finish(lua_State* /*L*/, Spell* spell)
|
||||
{
|
||||
spell->finish();
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
2728
src/LuaEngine/methods/UnitMethods.h
Normal file
2728
src/LuaEngine/methods/UnitMethods.h
Normal file
File diff suppressed because it is too large
Load Diff
117
src/LuaEngine/methods/VehicleMethods.h
Normal file
117
src/LuaEngine/methods/VehicleMethods.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef VEHICLEMETHODS_H
|
||||
#define VEHICLEMETHODS_H
|
||||
#ifndef CLASSIC
|
||||
#ifndef TBC
|
||||
|
||||
/***
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaVehicle
|
||||
{
|
||||
/**
|
||||
* Returns true if the [Unit] passenger is on board
|
||||
*
|
||||
* @param [Unit] passenger
|
||||
* @return bool isOnBoard
|
||||
*/
|
||||
int IsOnBoard(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, passenger->IsOnVehicle(vehicle->GetBase()));
|
||||
#else
|
||||
Eluna::Push(L, vehicle->HasOnBoard(passenger));
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Vehicle]'s owner
|
||||
*
|
||||
* @return [Unit] owner
|
||||
*/
|
||||
int GetOwner(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
Eluna::Push(L, vehicle->GetBase());
|
||||
#else
|
||||
Eluna::Push(L, vehicle->GetOwner());
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Vehicle]'s entry
|
||||
*
|
||||
* @return uint32 entry
|
||||
*/
|
||||
int GetEntry(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
#ifdef TRINITY
|
||||
Eluna::Push(L, vehicle->GetVehicleInfo()->ID);
|
||||
#elif AZEROTHCORE
|
||||
Eluna::Push(L, vehicle->GetVehicleInfo()->m_ID);
|
||||
#else
|
||||
Eluna::Push(L, vehicle->GetVehicleEntry()->m_ID);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Vehicle]'s passenger in the specified seat
|
||||
*
|
||||
* @param int8 seat
|
||||
* @return [Unit] passenger
|
||||
*/
|
||||
int GetPassenger(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
int8 seatId = Eluna::CHECKVAL<int8>(L, 2);
|
||||
Eluna::Push(L, vehicle->GetPassenger(seatId));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds [Unit] passenger to a specified seat in the [Vehicle]
|
||||
*
|
||||
* @param [Unit] passenger
|
||||
* @param int8 seat
|
||||
*/
|
||||
int AddPassenger(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
int8 seatId = Eluna::CHECKVAL<int8>(L, 3);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
vehicle->AddPassenger(passenger, seatId);
|
||||
#else
|
||||
if (vehicle->CanBoard(passenger))
|
||||
vehicle->Board(passenger, seatId);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes [Unit] passenger from the [Vehicle]
|
||||
*
|
||||
* @param [Unit] passenger
|
||||
*/
|
||||
int RemovePassenger(lua_State* L, Vehicle* vehicle)
|
||||
{
|
||||
Unit* passenger = Eluna::CHECKOBJ<Unit>(L, 2);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
vehicle->RemovePassenger(passenger);
|
||||
#else
|
||||
vehicle->UnBoard(passenger, false);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CLASSIC
|
||||
#endif // TBC
|
||||
#endif // VEHICLEMETHODS_H
|
||||
1233
src/LuaEngine/methods/WorldObjectMethods.h
Normal file
1233
src/LuaEngine/methods/WorldObjectMethods.h
Normal file
File diff suppressed because it is too large
Load Diff
310
src/LuaEngine/methods/WorldPacketMethods.h
Normal file
310
src/LuaEngine/methods/WorldPacketMethods.h
Normal file
@@ -0,0 +1,310 @@
|
||||
/*
|
||||
* Copyright (C) 2010 - 2016 Eluna Lua Engine <http://emudevs.com/>
|
||||
* This program is free software licensed under GPL version 3
|
||||
* Please see the included DOCS/LICENSE.md for more information
|
||||
*/
|
||||
|
||||
#ifndef WORLDPACKETMETHODS_H
|
||||
#define WORLDPACKETMETHODS_H
|
||||
|
||||
/***
|
||||
* A packet used to pass messages between the server and a client.
|
||||
*
|
||||
* Each packet has an opcode that determines the type of message being sent,
|
||||
* e.g. if a CMSG_LOGOUT_REQUEST packet is sent to the server,
|
||||
* the client has sent a message that its [Player] wants to logout.
|
||||
*
|
||||
* The packet can contain further data, the format of which depends on the opcode.
|
||||
*
|
||||
* Inherits all methods from: none
|
||||
*/
|
||||
namespace LuaPacket
|
||||
{
|
||||
/**
|
||||
* Returns the opcode of the [WorldPacket].
|
||||
*
|
||||
* @return uint16 opcode
|
||||
*/
|
||||
int GetOpcode(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
Eluna::Push(L, packet->GetOpcode());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the size of the [WorldPacket].
|
||||
*
|
||||
* @return uint32 size
|
||||
*/
|
||||
int GetSize(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
Eluna::Push(L, packet->size());
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the opcode of the [WorldPacket] to the specified opcode.
|
||||
*
|
||||
* @param [Opcodes] opcode : see Opcodes.h for all known opcodes
|
||||
*/
|
||||
int SetOpcode(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint32 opcode = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
if (opcode >= NUM_MSG_TYPES)
|
||||
return luaL_argerror(L, 2, "valid opcode expected");
|
||||
packet->SetOpcode((OpcodesList)opcode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns a signed 8-bit integer value from the [WorldPacket].
|
||||
*
|
||||
* @return int8 value
|
||||
*/
|
||||
int ReadByte(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int8 _byte;
|
||||
(*packet) >> _byte;
|
||||
Eluna::Push(L, _byte);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns an unsigned 8-bit integer value from the [WorldPacket].
|
||||
*
|
||||
* @return uint8 value
|
||||
*/
|
||||
int ReadUByte(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint8 _ubyte;
|
||||
(*packet) >> _ubyte;
|
||||
Eluna::Push(L, _ubyte);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns a signed 16-bit integer value from the [WorldPacket].
|
||||
*
|
||||
* @return int16 value
|
||||
*/
|
||||
int ReadShort(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int16 _short;
|
||||
(*packet) >> _short;
|
||||
Eluna::Push(L, _short);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns an unsigned 16-bit integer value from the [WorldPacket].
|
||||
*
|
||||
* @return uint16 value
|
||||
*/
|
||||
int ReadUShort(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint16 _ushort;
|
||||
(*packet) >> _ushort;
|
||||
Eluna::Push(L, _ushort);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns a signed 32-bit integer value from the [WorldPacket].
|
||||
*
|
||||
* @return int32 value
|
||||
*/
|
||||
int ReadLong(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int32 _long;
|
||||
(*packet) >> _long;
|
||||
Eluna::Push(L, _long);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns an unsigned 32-bit integer value from the [WorldPacket].
|
||||
*
|
||||
* @return uint32 value
|
||||
*/
|
||||
int ReadULong(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint32 _ulong;
|
||||
(*packet) >> _ulong;
|
||||
Eluna::Push(L, _ulong);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns a single-precision floating-point value from the [WorldPacket].
|
||||
*
|
||||
* @return float value
|
||||
*/
|
||||
int ReadFloat(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
float _val;
|
||||
(*packet) >> _val;
|
||||
Eluna::Push(L, _val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns a double-precision floating-point value from the [WorldPacket].
|
||||
*
|
||||
* @return double value
|
||||
*/
|
||||
int ReadDouble(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
double _val;
|
||||
(*packet) >> _val;
|
||||
Eluna::Push(L, _val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns an unsigned 64-bit integer value from the [WorldPacket].
|
||||
*
|
||||
* @return ObjectGuid value : value returned as string
|
||||
*/
|
||||
int ReadGUID(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
ObjectGuid guid;
|
||||
(*packet) >> guid;
|
||||
Eluna::Push(L, guid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads and returns a string value from the [WorldPacket].
|
||||
*
|
||||
* @return string value
|
||||
*/
|
||||
int ReadString(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
std::string _val;
|
||||
(*packet) >> _val;
|
||||
Eluna::Push(L, _val);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an unsigned 64-bit integer value to the [WorldPacket].
|
||||
*
|
||||
* @param ObjectGuid value : the value to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteGUID(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
ObjectGuid guid = Eluna::CHECKVAL<ObjectGuid>(L, 2);
|
||||
(*packet) << guid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string to the [WorldPacket].
|
||||
*
|
||||
* @param string value : the string to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteString(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
std::string _val = Eluna::CHECKVAL<std::string>(L, 2);
|
||||
(*packet) << _val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a signed 8-bit integer value to the [WorldPacket].
|
||||
*
|
||||
* @param int8 value : the int8 value to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteByte(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int8 byte = Eluna::CHECKVAL<int8>(L, 2);
|
||||
(*packet) << byte;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an unsigned 8-bit integer value to the [WorldPacket].
|
||||
*
|
||||
* @param uint8 value : the uint8 value to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteUByte(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint8 byte = Eluna::CHECKVAL<uint8>(L, 2);
|
||||
(*packet) << byte;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a signed 16-bit integer value to the [WorldPacket].
|
||||
*
|
||||
* @param int16 value : the int16 value to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteShort(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int16 _short = Eluna::CHECKVAL<int16>(L, 2);
|
||||
(*packet) << _short;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an unsigned 16-bit integer value to the [WorldPacket].
|
||||
*
|
||||
* @param uint16 value : the uint16 value to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteUShort(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint16 _ushort = Eluna::CHECKVAL<uint16>(L, 2);
|
||||
(*packet) << _ushort;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a signed 32-bit integer value to the [WorldPacket].
|
||||
*
|
||||
* @param int32 value : the int32 value to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteLong(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
int32 _long = Eluna::CHECKVAL<int32>(L, 2);
|
||||
(*packet) << _long;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an unsigned 32-bit integer value to the [WorldPacket].
|
||||
*
|
||||
* @param uint32 value : the uint32 value to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteULong(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
uint32 _ulong = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
(*packet) << _ulong;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a 32-bit floating-point value to the [WorldPacket].
|
||||
*
|
||||
* @param float value : the float value to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteFloat(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
float _val = Eluna::CHECKVAL<float>(L, 2);
|
||||
(*packet) << _val;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a 64-bit floating-point value to the [WorldPacket].
|
||||
*
|
||||
* @param double value : the double value to be written to the [WorldPacket]
|
||||
*/
|
||||
int WriteDouble(lua_State* L, WorldPacket* packet)
|
||||
{
|
||||
double _val = Eluna::CHECKVAL<double>(L, 2);
|
||||
(*packet) << _val;
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user