mirror of
https://github.com/araxiaonline/mod-eluna.git
synced 2026-06-13 03:02:27 -04:00
Compare commits
11 Commits
npcbots_3.
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 382ba03e4f | |||
|
|
ec0dbf76f3 | ||
|
|
68d0a09143 | ||
|
|
b39869a556 | ||
|
|
e00386fa5b | ||
|
|
c652ee8e1a | ||
|
|
36e1c715fc | ||
|
|
3fea22bc41 | ||
|
|
067fa20bad | ||
|
|
cc442de602 | ||
|
|
152a491663 |
@@ -237,10 +237,10 @@ class Eluna_AllMapScript : public AllMapScript
|
||||
public:
|
||||
Eluna_AllMapScript() : AllMapScript("Eluna_AllMapScript") { }
|
||||
|
||||
|
||||
void OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript* instanceData, bool /*load*/, std::string /*data*/, uint32 /*completedEncounterMask*/) override
|
||||
{
|
||||
instanceData = sEluna->GetInstanceData(instanceMap);
|
||||
if (instanceData)
|
||||
*instanceData = sEluna->GetInstanceData(instanceMap);
|
||||
}
|
||||
|
||||
void OnDestroyInstance(MapInstanced* /*mapInstanced*/, Map* map) override
|
||||
@@ -331,7 +331,7 @@ class Eluna_CommandSC : public CommandSC
|
||||
public:
|
||||
Eluna_CommandSC() : CommandSC("Eluna_CommandSC") { }
|
||||
|
||||
bool CanExecuteCommand(ChatHandler& handler, std::string_view cmdStr) override
|
||||
bool OnTryExecuteCommand(ChatHandler& handler, std::string_view cmdStr) override
|
||||
{
|
||||
if (!sEluna->OnCommand(handler, std::string(cmdStr).c_str()))
|
||||
{
|
||||
|
||||
@@ -1213,6 +1213,17 @@ auto const& threatlist = creature->GetThreatMgr().GetThreatList();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Creature]'s rank.
|
||||
*
|
||||
* @return [Rank] rank
|
||||
*/
|
||||
int GetRank(lua_State* L, Creature* creature)
|
||||
{
|
||||
Eluna::Push(L, creature->GetCreatureTemplate()->rank);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if defined(CLASSIC) || defined(TBC) || defined(WOTLK)
|
||||
/**
|
||||
* Returns the [Creature]'s shield block value.
|
||||
|
||||
@@ -112,6 +112,42 @@ namespace LuaGlobalFunctions
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the [Map] pointer of the Lua state. Returns null for the "World" state.
|
||||
*
|
||||
* @return [Map] map
|
||||
*/
|
||||
int GetStateMap(lua_State* L)
|
||||
{
|
||||
// Until AC supports multistate, this will always return nil
|
||||
Eluna::Push(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the map ID of the Lua state. Returns -1 for the "World" state.
|
||||
*
|
||||
* @return int32 mapId
|
||||
*/
|
||||
int GetStateMapId(lua_State* L)
|
||||
{
|
||||
// Until AC supports multistate, this will always return -1
|
||||
Eluna::Push(L, -1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the instance ID of the Lua state. Returns 0 for continent maps and the world state.
|
||||
*
|
||||
* @return uint32 instanceId
|
||||
*/
|
||||
int GetStateInstanceId(lua_State* L)
|
||||
{
|
||||
// Until AC supports multistate, this will always return 0
|
||||
Eluna::Push(L, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [Quest] template
|
||||
@@ -2123,8 +2159,6 @@ namespace LuaGlobalFunctions
|
||||
const int BAN_CHARACTER = 1;
|
||||
const int BAN_IP = 2;
|
||||
|
||||
BanMode mode = BanMode::BAN_ACCOUNT;
|
||||
|
||||
switch (banMode)
|
||||
{
|
||||
case BAN_ACCOUNT:
|
||||
@@ -2135,26 +2169,20 @@ namespace LuaGlobalFunctions
|
||||
if (!AccountMgr::normalizeString(nameOrIP))
|
||||
return luaL_argerror(L, 2, "invalid account name");
|
||||
#endif
|
||||
mode = BanMode::BAN_ACCOUNT;
|
||||
break;
|
||||
case BAN_CHARACTER:
|
||||
if (!normalizePlayerName(nameOrIP))
|
||||
return luaL_argerror(L, 2, "invalid character name");
|
||||
mode = BanMode::BAN_CHARACTER;
|
||||
break;
|
||||
case BAN_IP:
|
||||
if (!IsIPAddress(nameOrIP.c_str()))
|
||||
return luaL_argerror(L, 2, "invalid ip");
|
||||
mode = BanMode::BAN_IP;
|
||||
break;
|
||||
default:
|
||||
return luaL_argerror(L, 1, "unknown banmode");
|
||||
}
|
||||
|
||||
BanReturn result;
|
||||
#ifndef AZEROTHCORE
|
||||
result = eWorld->BanAccount(mode, nameOrIP, duration, reason, whoBanned);
|
||||
#else
|
||||
switch (banMode)
|
||||
{
|
||||
case BAN_ACCOUNT:
|
||||
@@ -2167,7 +2195,6 @@ namespace LuaGlobalFunctions
|
||||
result = sBan->BanIP(nameOrIP, std::to_string(duration) + "s", reason, whoBanned);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (result)
|
||||
{
|
||||
@@ -2565,6 +2592,18 @@ namespace LuaGlobalFunctions
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if Eluna is in compatibility mode, `false` if in multistate.
|
||||
*
|
||||
* @return bool isCompatibilityMode
|
||||
*/
|
||||
int IsCompatibilityMode(lua_State* L)
|
||||
{
|
||||
// Until AC supports multistate, this will always return true
|
||||
Eluna::Push(L, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns `true` if the bag and slot is a valid inventory position, otherwise `false`.
|
||||
*
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "Hooks.h"
|
||||
#include "LuaEngine.h"
|
||||
#include "BindingMap.h"
|
||||
#include "Chat.h"
|
||||
#include "ElunaEventMgr.h"
|
||||
#include "ElunaIncludes.h"
|
||||
#include "ElunaTemplate.h"
|
||||
@@ -136,7 +137,7 @@ void Eluna::_ReloadEluna()
|
||||
if (eConfigMgr->GetOption<bool>("Eluna.PlayerAnnounceReload", false))
|
||||
eWorld->SendServerMessage(SERVER_MSG_STRING, "Reloading Eluna...");
|
||||
else
|
||||
eWorld->SendGMText(SERVER_MSG_STRING, "Reloading Eluna...");
|
||||
ChatHandler(nullptr).SendGMText(SERVER_MSG_STRING, "Reloading Eluna...");
|
||||
|
||||
// Remove all timed events
|
||||
sEluna->eventMgr->SetStates(LUAEVENT_STATE_ERASE);
|
||||
|
||||
@@ -84,6 +84,9 @@ luaL_Reg GlobalMethods[] =
|
||||
{ "GetRealmID", &LuaGlobalFunctions::GetRealmID },
|
||||
{ "GetCoreVersion", &LuaGlobalFunctions::GetCoreVersion },
|
||||
{ "GetCoreExpansion", &LuaGlobalFunctions::GetCoreExpansion },
|
||||
{ "GetStateMap", &LuaGlobalFunctions::GetStateMap },
|
||||
{ "GetStateMapId", &LuaGlobalFunctions::GetStateMapId },
|
||||
{ "GetStateInstanceId", &LuaGlobalFunctions::GetStateInstanceId },
|
||||
{ "GetQuest", &LuaGlobalFunctions::GetQuest },
|
||||
{ "GetPlayerByGUID", &LuaGlobalFunctions::GetPlayerByGUID },
|
||||
{ "GetPlayerByName", &LuaGlobalFunctions::GetPlayerByName },
|
||||
@@ -118,6 +121,7 @@ luaL_Reg GlobalMethods[] =
|
||||
{ "GetActiveGameEvents", &LuaGlobalFunctions::GetActiveGameEvents },
|
||||
|
||||
// Boolean
|
||||
{ "IsCompatibilityMode", &LuaGlobalFunctions::IsCompatibilityMode },
|
||||
{ "IsInventoryPos", &LuaGlobalFunctions::IsInventoryPos },
|
||||
{ "IsEquipmentPos", &LuaGlobalFunctions::IsEquipmentPos },
|
||||
{ "IsBankPos", &LuaGlobalFunctions::IsBankPos },
|
||||
@@ -701,7 +705,10 @@ ElunaRegister<Player> PlayerMethods[] =
|
||||
{ "ModifyMoney", &LuaPlayer::ModifyMoney },
|
||||
{ "LearnSpell", &LuaPlayer::LearnSpell },
|
||||
{ "LearnTalent", &LuaPlayer::LearnTalent },
|
||||
|
||||
{ "RunCommand", &LuaPlayer::RunCommand },
|
||||
{ "SetGlyph", &LuaPlayer::SetGlyph },
|
||||
{ "GetGlyph", &LuaPlayer::GetGlyph },
|
||||
#if !defined(CLASSIC)
|
||||
{ "RemoveArenaSpellCooldowns", &LuaPlayer::RemoveArenaSpellCooldowns },
|
||||
#endif
|
||||
@@ -831,6 +838,7 @@ ElunaRegister<Creature> CreatureMethods[] =
|
||||
{ "GetUnitFlags", &LuaCreature::GetUnitFlags },
|
||||
{ "GetUnitFlagsTwo", &LuaCreature::GetUnitFlagsTwo },
|
||||
{ "GetExtraFlags", &LuaCreature::GetExtraFlags },
|
||||
{ "GetRank", &LuaCreature::GetRank },
|
||||
#if defined(CLASSIC) || defined(TBC) || defined(WOTLK)
|
||||
{ "GetShieldBlockValue", &LuaCreature::GetShieldBlockValue },
|
||||
#endif
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
#ifndef PLAYERMETHODS_H
|
||||
#define PLAYERMETHODS_H
|
||||
|
||||
#include "Chat.h"
|
||||
#include "GameTime.h"
|
||||
#include "GossipDef.h"
|
||||
|
||||
/***
|
||||
* Inherits all methods from: [Object], [WorldObject], [Unit]
|
||||
@@ -3802,7 +3804,7 @@ namespace LuaPlayer
|
||||
{
|
||||
std::string msg = Eluna::CHECKVAL<std::string>(L, 2);
|
||||
if (msg.length() > 0)
|
||||
player->GetSession()->SendNotification("%s", msg.c_str());
|
||||
ChatHandler(player->GetSession()).SendNotification("{}", msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3935,6 +3937,25 @@ namespace LuaPlayer
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* Run a chat command as if the player typed it into the chat
|
||||
*
|
||||
* @param string command: text to display in chat or console
|
||||
*/
|
||||
int RunCommand(lua_State* L, Player* player)
|
||||
{
|
||||
auto command = Eluna::CHECKVAL<std::string>(L, 2);
|
||||
|
||||
// In _ParseCommands which is used below no leading . or ! is allowed for the command string.
|
||||
if (command[0] == '.' || command[0] == '!') {
|
||||
command = command.substr(1);
|
||||
}
|
||||
|
||||
auto handler = ChatHandler(player->GetSession());
|
||||
handler._ParseCommands(command);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a glyph specified by `glyphId` to the [Player]'s current talent specialization into the slot with the index `slotIndex`
|
||||
@@ -3953,6 +3974,18 @@ namespace LuaPlayer
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get glyphId of the glyph slot specified by `slotIndex` off the [Player]'s current talent specialization.`
|
||||
* @param uint32 slotIndex
|
||||
* @return glyphId of the glyph in the selected glyph slot or 0 in case the glyph slot is empty
|
||||
*/
|
||||
int GetGlyph(lua_State* L, Player* player)
|
||||
{
|
||||
auto slotIndex = Eluna::CHECKVAL<uint32>(L, 2);
|
||||
Eluna::Push(L,player->GetGlyph(slotIndex));
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if !defined(CLASSIC)
|
||||
/**
|
||||
* Remove cooldowns on spells that have less than 10 minutes of cooldown from the [Player], similarly to when you enter an arena.
|
||||
@@ -4007,7 +4040,15 @@ namespace LuaPlayer
|
||||
const char* _promptMsg = Eluna::CHECKVAL<const char*>(L, 7, "");
|
||||
uint32 _money = Eluna::CHECKVAL<uint32>(L, 8, 0);
|
||||
#if defined TRINITY || AZEROTHCORE
|
||||
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, _icon, msg, _sender, _intid, _promptMsg, _money, _code);
|
||||
if (player->PlayerTalkClass->GetGossipMenu().GetMenuItemCount() < GOSSIP_MAX_MENU_ITEMS)
|
||||
{
|
||||
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, _icon, msg, _sender, _intid, _promptMsg, _money,
|
||||
_code);
|
||||
}
|
||||
else
|
||||
{
|
||||
return luaL_error(L, "GossipMenuItem not added. Reached Max amount of possible GossipMenuItems in this GossipMenu");
|
||||
}
|
||||
#else
|
||||
#ifndef CLASSIC
|
||||
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(_icon, msg, _sender, _intid, _promptMsg, _money, _code);
|
||||
|
||||
Reference in New Issue
Block a user