19 Commits

Author SHA1 Message Date
27ed296419 tweaks to auction house menu 2025-09-30 21:13:16 -04:00
2947c06a7b moved NPCBots into own class methods and updated for new core changes 2025-01-23 00:24:26 -05:00
fa9b7987d2 fixed issue with eluna reloading 2024-12-02 16:23:01 -05:00
aedb410aa8 updated READMe 2024-08-23 01:42:17 -04:00
9f1f4c88b5 added updates to build release to only release off araxia-main 2024-08-22 20:30:41 -04:00
91f9b34836 removed not needed file 2024-08-22 19:56:50 -04:00
fc951497db Added new shared build-release 2024-08-22 19:56:14 -04:00
a0096036ac Updated to latest changes from core 2024-08-22 19:09:14 -04:00
382ba03e4f Merge branch 'npcbots_3.3.5' 2024-08-15 21:56:25 -04:00
Kitzunu
ec0dbf76f3 Update LuaEngine.cpp (#192) 2024-08-10 11:40:16 -03:00
Kitzunu
68d0a09143 https://github.com/azerothcore/azerothcore-wotlk/pull/19491 (#189)
Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com>
2024-08-08 21:36:23 -03:00
sudlud
b39869a556 Fix unused variable warning in GlobalMethods:Ban() (#183) 2024-07-07 17:10:45 +02:00
sudlud
e00386fa5b fix OnBeforeCreateInstanceScript() hook (#182) 2024-07-03 23:01:03 +02:00
AnchyDev
c652ee8e1a Update OnCommand for core hook changes. (#181) 2024-06-17 22:27:48 +02:00
Tralenor
36e1c715fc fix: gossip menu item overflow (#180)
Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com>
2024-06-15 13:11:46 +02:00
Tralenor
3fea22bc41 feat: add player:RunCommand (#176) 2024-06-15 11:34:57 +02:00
Tralenor
067fa20bad feature: Add GetGlyph (#178)
Co-authored-by: 55Honey <71938210+55Honey@users.noreply.github.com>
2024-06-11 21:24:00 +02:00
Foe
cc442de602 feat: Add multistate compatibility methods (#175) 2024-06-05 06:19:41 +02:00
kabigon
152a491663 feat: add GetRank method for creatures (#173) 2024-05-04 21:23:51 +02:00
14 changed files with 517 additions and 344 deletions

24
.github/workflows/build-release.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: Build And Release
on:
push:
branches:
- 'araxia-main'
pull_request:
branches:
- 'araxia-main'
- 'master'
jobs:
build-release:
runs-on: ubuntu-latest
container:
image: ghcr.io/araxiaonline/ac-wotlk-worldserver-devcontainer:latest
options: --user root
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: build
uses: araxiaonline/share-gh-workflows/.github/actions/build-tag-release@main
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag_release: true
event_name: ${{ github.event_name }}

View File

@@ -1,12 +0,0 @@
name: core-build
on:
push:
branches:
- 'master'
pull_request:
jobs:
build:
uses: azerothcore/reusable-workflows/.github/workflows/core_build_modules.yml@main
with:
module_repo: ${{ github.event.repository.name }}

View File

@@ -1,9 +1,22 @@
### [![Eluna](src/LuaEngine/docs/Eluna.png)](https://github.com/ElunaLuaEngine/Eluna)
# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) Azeroth Core Module
## mod-eluna
![Latest Release](https://img.shields.io/github/v/release/araxiaonline/mod-eluna?label=current%20version)
![GitHub Release Date](https://img.shields.io/github/release-date/araxiaonline/mod-eluna)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/araxiaonline/mod-eluna/build-release.yml?branch=araxia-main&event=push&label=build%20status)
<p align="left">
<img src="https://github.com/araxiaonline/docs/blob/main/docs/media/logo-sm.png?raw=true" alt="Araxia Online" width="70" style="vertical-align: middle;"/>
<span style="font-size: 20px; vertical-align: middle;">Player Tested and Modified By Araxia Online</span>
</p>
## About
### [![Eluna](src/LuaEngine/docs/Eluna.png)](https://github.com/ElunaLuaEngine/Eluna)
Eluna Lua Engine &copy; is a lua engine embedded to World of Warcraft emulators. Eluna supports MaNGOS, CMaNGOS, TrinityCore and AzerothCore.
We are currently working hard to make Eluna better from inside and outside.
We are currently working hard to make Eluna better from inside and outside.
If you are having trouble with installation or scripts, please feel free to open an issue.
For documentation and reference see [Eluna API (AC version)](https://www.azerothcore.org/pages/eluna/index.html) and [Lua reference manual](http://www.lua.org/manual/5.2/).
@@ -21,7 +34,6 @@ The official Azerothcore Discord server offers a channel dedicated to lua develo
<img src="https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat" />
</a>
# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) mod-eluna for AzerothCore
- Latest build status with azerothcore: [![Build Status](https://github.com/azerothcore/mod-eluna/workflows/core-build/badge.svg?branch=master&event=push)](https://github.com/azerothcore/mod-eluna)
[english](README.md) | [中文说明](README_CN.md) | [Español](README_ES.md)
@@ -48,7 +60,7 @@ git clone https://github.com/azerothcore/mod-eluna.git mod-eluna
You need to run the cmake again and rebuild the project.
Eluna API for AC:
Eluna API for AC:
[https://www.azerothcore.org/pages/eluna/index.html](https://www.azerothcore.org/pages/eluna/index.html)

17
release.yml Normal file
View File

@@ -0,0 +1,17 @@
name: tag-release
on:
workflow_run:
workflows: ["core-build"]
types:
- completed
jobs:
release-on-push:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Release on Push
uses: rymndhng/release-on-push-action@master
with:
bump_version_scheme: minor

View File

@@ -16,8 +16,9 @@
*/
#include "Chat.h"
#include "ElunaInstanceAI.h"
#include "ElunaEventMgr.h"
#include "Log.h"
#include "Logging/Log.h"
#include "LuaEngine.h"
#include "Pet.h"
#include "Player.h"
@@ -237,10 +238,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
void OnBeforeCreateInstanceScript(InstanceMap* instanceMap, InstanceScript** instanceData, bool /*load*/, std::string /*data*/, uint32 /*completedEncounterMask*/) override
{
instanceData = sEluna->GetInstanceData(instanceMap);
if (instanceData)
*instanceData = static_cast<InstanceScript*>(sEluna->GetInstanceData(instanceMap));
}
void OnDestroyInstance(MapInstanced* /*mapInstanced*/, Map* map) override
@@ -331,7 +332,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()))
{

View File

@@ -58,7 +58,7 @@ if( ${CMAKE_PROJECT_NAME} STREQUAL "MaNGOS" )
${CMAKE_SOURCE_DIR}/src/game/WorldHandlers
${CMAKE_SOURCE_DIR}/src/game/Object
)
if( WIN32 )
if ( MSVC )
add_custom_command(TARGET LuaEngine
@@ -74,7 +74,7 @@ if( ${CMAKE_PROJECT_NAME} STREQUAL "MaNGOS" )
)
endif()
endif()
install(DIRECTORY extensions DESTINATION "${BIN_DIR}/lua_scripts/")
endif()

View File

@@ -393,262 +393,6 @@ namespace LuaCreature
return 1;
}
/** -- NPCBOT Start */
// #if defined(AZEROTHCORE)
/**
* Return `true` if the [Creature] is a NPCBot,
* @return bool isNPCBot
*/
int IsNPCBot(lua_State* L, Creature* creature)
{
Eluna::Push(L, creature->IsNPCBot());
return 1;
}
/**
* Returns the [Creature]'s bot owner.
* @return [Player] botOwner
*/
int GetBotOwner(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
if (ai) {
Eluna::Push(L, ai->GetBotOwner());
return 1;
}
else {
return 0;
}
}
int GetBotOwnerGUID(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
if (ai) {
Eluna::Push(L, ai->GetBotOwnerGuid());
return 1;
}
else {
return 0;
}
}
/**
* Returns the [Creature]'s bot class.
* @return unint8 botClassID
*/
int GetBotClass(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
Eluna::Push(L, creature->GetBotClass());
return 1;
}
/**
* Get the [Creature]'s bot roles Tank, Healer, Damage that are enabled as a mask.
* @return uint32 botRoles
*/
int GetBotRoles(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
Eluna::Push(L, creature->GetBotRoles());
return 1;
}
/**
* Returns `true` if the [Creature] is has an assigned role as tank.
* @return bool isTank
*/
int IsBotTank(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
Eluna::Push(L, ai->IsTank());
return 1;
}
/**
* Returns `true` if the [Creature] is has an assigned role as off-tank.
* @return bool isTank
*/
int IsBotOffTank(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
Eluna::Push(L, ai->IsOffTank());
return 1;
}
/**
* Returns `true` if the [Creature] is free and not assigned to a player
* @return bool isFree
*/
int IsFreeBot(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
Eluna::Push(L, creature->IsFreeBot());
return 1;
}
/**
* Get the [Creature]'s bot average item level of equipped items.
* @return float botAverageItemLevel
*/
int GetBotAverageItemLevel(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
Eluna::Push(L, creature->GetBotAverageItemLevel());
return 1;
}
int GetBotEquipment(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
if(creature->IsFreeBot())
return 0;
uint32 slot = Eluna::CHECKVAL<uint32>(L, 2);
Eluna::Push(L, creature->GetBotEquips(slot));
return 1;
}
int GetBotStat(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
uint8 botstat = Eluna::CHECKVAL<uint8>(L, 2);
Eluna::Push(L, creature->GetTotalBotStat(BotStatMods(botstat)));
return 1;
}
int GetTalentSpec(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
Eluna::Push(L, ai->GetSpec());
return 1;
}
int BotEquipItem(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
// If this bot is not owned by a player return.
if(creature->IsFreeBot())
return 0;
// if the entry passed in was an item object
Item* item = Eluna::CHECKOBJ<Item>(L, 2, false);
uint32 slot = Eluna::CHECKVAL<uint32>(L, 3);
Player* owner = creature->GetBotOwner();
// If an item entry was passed in instead
if(!item)
{
uint32 itemid = Eluna::CHECKVAL<uint32>(L, 2);
item = owner->GetItemByEntry(itemid);
}
if(slot > EQUIPMENT_SLOT_END)
return 0;
bool result = creature->EquipItem(slot, item, owner->GetGUID());
Eluna::Push(L, result);
return 1;
}
int BotCanEquipItem(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
// If this bot is not owned by a player return.
if(creature->IsFreeBot())
return 0;
// if the entry passed in was an item object
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
uint32 slot = Eluna::CHECKVAL<uint32>(L, 3);
// If an item entry was passed in instead
if(entry)
{
const ItemTemplate* proto = eObjectMgr->GetItemTemplate(entry);
if(!proto)
return luaL_argerror(L, 1, "valid ItemEntry expected in BotCanEquipItem");
if(slot > EQUIPMENT_SLOT_END)
return luaL_argerror(L, 1, "valie slot expected in BotCanEquipItem");
bot_ai* ai = creature->GetBotAI();
bool result = ai->CanEquip(proto, slot, true);
Eluna::Push(L, result);
}
return 1;
}
int BotUnequipItem(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
// If this bot is not owned by a player return.
if(creature->IsFreeBot())
return 0;
uint32 slot = Eluna::CHECKVAL<uint32>(L, 2);
Player* owner = creature->GetBotOwner();
bot_ai* ai = creature->GetBotAI();
bool result = ai->UnequipItem(slot, owner->GetGUID());
Eluna::Push(L, result);
return 1;
}
int GetBotDump(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
Player* owner = creature->GetBotOwner();
const char* dump = ai->BotDump(owner, creature);
if(!dump)
return luaL_argerror(L, 1, "BotDump failed for bot.");
Eluna::Push(L, dump);
return 1;
}
// #endif
/** -- NPCBot End */
#if defined(TRINITY) || defined(AZEROTHCORE)
/**
* Returns `true` if the [Creature] is an invisible trigger,
@@ -1213,6 +957,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.

View File

@@ -22,7 +22,7 @@
#endif
#else
#include "Database/QueryResult.h"
#include "Log.h"
#include "Logging/Log.h"
#endif
#if defined(TRINITY) || defined(AZEROTHCORE)

View File

@@ -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`.
*

View File

@@ -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);

View File

@@ -41,6 +41,11 @@ extern "C"
#include "ItemTemplateMethods.h"
#include "RollMethods.h"
// If this is runnong on NPCBOTS core fork include methods for NpcBot management in Lua
#if defined(MOD_PRESENT_NPCBOTS)
#include "NpcBotMethods.h"
#endif
luaL_Reg GlobalMethods[] =
{
// Hooks
@@ -84,6 +89,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 +126,7 @@ luaL_Reg GlobalMethods[] =
{ "GetActiveGameEvents", &LuaGlobalFunctions::GetActiveGameEvents },
// Boolean
{ "IsCompatibilityMode", &LuaGlobalFunctions::IsCompatibilityMode },
{ "IsInventoryPos", &LuaGlobalFunctions::IsInventoryPos },
{ "IsEquipmentPos", &LuaGlobalFunctions::IsEquipmentPos },
{ "IsBankPos", &LuaGlobalFunctions::IsBankPos },
@@ -701,7 +710,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 +843,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
@@ -922,28 +935,28 @@ ElunaRegister<Creature> CreatureMethods[] =
/** -- NPCBOT Start */
#if defined(AZEROTHCORE)
#if defined(AZEROTHCORE) && defined(MOD_PRESENT_NPCBOTS)
// Getters & Flags
{ "IsNPCBot", &LuaCreature::IsNPCBot },
{ "GetBotOwner", &LuaCreature::GetBotOwner },
{ "GetBotOwnerGUID", &LuaCreature::GetBotOwnerGUID },
{ "GetBotClass", &LuaCreature::GetBotClass },
{ "GetBotRoles", &LuaCreature::GetBotRoles },
{ "GetTalentSpec", &LuaCreature::GetTalentSpec },
{ "IsBotTank", &LuaCreature::IsBotTank },
{ "IsBotOffTank", &LuaCreature::IsBotOffTank },
{ "IsFreeBot", &LuaCreature::IsFreeBot },
{ "GetBotAverageItemLevel", &LuaCreature::GetBotAverageItemLevel },
{ "GetBotEquipment", &LuaCreature::GetBotEquipment },
{ "GetBotStat", &LuaCreature::GetBotStat },
{ "GetBotDump", &LuaCreature::GetBotDump },
{ "IsNPCBot", &LuaNpcBot::IsNPCBot },
{ "GetBotOwner", &LuaNpcBot::GetBotOwner },
{ "GetBotOwnerGUID", &LuaNpcBot::GetBotOwnerGUID },
{ "GetBotClass", &LuaNpcBot::GetBotClass },
{ "GetBotRoles", &LuaNpcBot::GetBotRoles },
{ "GetTalentSpec", &LuaNpcBot::GetTalentSpec },
{ "IsBotTank", &LuaNpcBot::IsBotTank },
{ "IsBotOffTank", &LuaNpcBot::IsBotOffTank },
{ "IsFreeBot", &LuaNpcBot::IsFreeBot },
{ "GetBotAverageItemLevel", &LuaNpcBot::GetBotAverageItemLevel },
{ "GetBotEquipment", &LuaNpcBot::GetBotEquipment },
{ "GetBotStat", &LuaNpcBot::GetBotStat },
{ "GetBotDump", &LuaNpcBot::GetBotDump },
// Setters
{ "BotEquipItem", &LuaCreature::BotEquipItem },
{ "BotCanEquipItem", &LuaCreature::BotCanEquipItem },
{ "BotUnequipBotItem", &LuaCreature::BotUnequipItem },
{ "BotEquipItem", &LuaNpcBot::BotEquipItem },
{ "BotCanEquipItem", &LuaNpcBot::BotCanEquipItem },
{ "BotUnequipBotItem", &LuaNpcBot::BotUnequipItem },
#endif
/** -- NPCBOT End */

View File

@@ -0,0 +1,279 @@
#ifndef NPCBOTMETHODS_H
#define NPCBOTMETHODS_H
#include "bot_ai_eluna.h"
/***
* Player controlled bot party members, relies on latest changes to
* NPCBots fork of AzerothCore
*
* Inherits all methods from: [Object], [WorldObject], [Unit]
*/
namespace LuaNpcBot
{
/**
* Return `true` if the [Creature] is a NPCBot,
* @return bool isNPCBot
*/
int IsNPCBot(lua_State* L, Creature* creature)
{
Eluna::Push(L, creature->IsNPCBot());
return 1;
}
/**
* Returns the [Creature]'s bot owner.
* @return [Player] botOwner
*/
int GetBotOwner(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
if (ai) {
Eluna::Push(L, ai->GetBotOwner());
return 1;
}
else {
return 0;
}
}
int GetBotOwnerGUID(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
if (ai) {
Eluna::Push(L, ai->GetBotOwnerGuid());
return 1;
}
else {
return 0;
}
}
/**
* Returns the [Creature]'s bot class.
* @return unint8 botClassID
*/
int GetBotClass(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
Eluna::Push(L, creature->GetBotClass());
return 1;
}
/**
* Get the [Creature]'s bot roles Tank, Healer, Damage that are enabled as a mask.
* @return uint32 botRoles
*/
int GetBotRoles(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
Eluna::Push(L, creature->GetBotRoles());
return 1;
}
/**
* Returns `true` if the [Creature] is has an assigned role as tank.
* @return bool isTank
*/
int IsBotTank(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
Eluna::Push(L, ai->IsTank());
return 1;
}
/**
* Returns `true` if the [Creature] is has an assigned role as off-tank.
* @return bool isTank
*/
int IsBotOffTank(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
Eluna::Push(L, ai->IsOffTank());
return 1;
}
/**
* Returns `true` if the [Creature] is free and not assigned to a player
* @return bool isFree
*/
int IsFreeBot(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
Eluna::Push(L, creature->IsFreeBot());
return 1;
}
/**
* Get the [Creature]'s bot average item level of equipped items.
* @return float botAverageItemLevel
*/
int GetBotAverageItemLevel(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
Eluna::Push(L, creature->GetBotAverageItemLevel());
return 1;
}
int GetBotEquipment(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
if(creature->IsFreeBot())
return 0;
uint32 slot = Eluna::CHECKVAL<uint32>(L, 2);
Eluna::Push(L, creature->GetBotEquips(slot));
return 1;
}
int GetBotStat(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
uint8 botstat = Eluna::CHECKVAL<uint8>(L, 2);
/**
* @fix this to be optional for the bot owner to see the stats
*/
bot_ai* ai = creature->GetBotAI();
Eluna::Push(L, ai->GetTotalBotStat(BotStatMods(botstat)));
return 1;
}
int GetTalentSpec(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
Eluna::Push(L, ai->GetSpec());
return 1;
}
int BotEquipItem(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
// If this bot is not owned by a player return.
if(creature->IsFreeBot())
return 0;
// if the entry passed in was an item object
Item* item = Eluna::CHECKOBJ<Item>(L, 2, false);
uint32 slot = Eluna::CHECKVAL<uint32>(L, 3);
Player* owner = creature->GetBotOwner();
// If an item entry was passed in instead
if(!item)
{
uint32 itemid = Eluna::CHECKVAL<uint32>(L, 2);
item = owner->GetItemByEntry(itemid);
}
if(slot > EQUIPMENT_SLOT_END)
return 0;
bot_ai* ai = creature->GetBotAI();
BotAIEluna elunaAi(ai);
bool result = elunaAi.Equip(slot, item, owner->GetGUID());
Eluna::Push(L, result);
return 1;
}
int BotCanEquipItem(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
// If this bot is not owned by a player return.
if(creature->IsFreeBot())
return 0;
// if the entry passed in was an item object
uint32 entry = Eluna::CHECKVAL<uint32>(L, 2);
uint32 slot = Eluna::CHECKVAL<uint32>(L, 3);
// If an item entry was passed in instead
if(entry)
{
const ItemTemplate* proto = eObjectMgr->GetItemTemplate(entry);
if(!proto)
return luaL_argerror(L, 1, "valid ItemEntry expected in BotCanEquipItem");
if(slot > EQUIPMENT_SLOT_END)
return luaL_argerror(L, 1, "value slot expected in BotCanEquipItem");
bot_ai* ai = creature->GetBotAI();
bool result = BotAIEluna(ai).CanEquip(proto, slot, true);
Eluna::Push(L, result);
}
return 1;
}
int BotUnequipItem(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
// If this bot is not owned by a player return.
if(creature->IsFreeBot())
return 0;
uint32 slot = Eluna::CHECKVAL<uint32>(L, 2);
Player* owner = creature->GetBotOwner();
bot_ai* ai = creature->GetBotAI();
BotAIEluna elunaAi(ai);
bool result = elunaAi.Unequip(slot, owner->GetGUID());
Eluna::Push(L, result);
return 1;
}
int GetBotDump(lua_State* L, Creature* creature)
{
if(!creature->IsNPCBot())
return 0;
bot_ai* ai = creature->GetBotAI();
Player* owner = creature->GetBotOwner();
BotAIEluna elunaAi(ai);
std::string dump = elunaAi.BotDump(owner, creature);
if(dump.empty())
return luaL_argerror(L, 1, "BotDump failed for bot.");
Eluna::Push(L, dump);
return 1;
}
}
#endif // NPCBOTMETHODS_H

View File

@@ -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]
@@ -174,7 +176,7 @@ namespace LuaPlayer
return 1;
}
#endif
/**
* Returns `true` if the [Player] has the given amount of item entry specified, `false` otherwise.
*
@@ -191,7 +193,7 @@ namespace LuaPlayer
Eluna::Push(L, player->HasItemCount(itemId, count, check_bank));
return 1;
}
/**
* Returns `true` if the [Player] has a quest for the item entry specified, `false` otherwise.
*
@@ -205,7 +207,7 @@ namespace LuaPlayer
Eluna::Push(L, player->HasQuestForItem(entry));
return 1;
}
/**
* Returns `true` if the [Player] can use the item or item entry specified, `false` otherwise.
*
@@ -415,7 +417,7 @@ namespace LuaPlayer
Eluna::Push(L, player->HasTankSpec());
return 1;
}
/**
* Returns `true` if the [Player] has a Melee Specialization, `false` otherwise.
*
@@ -426,7 +428,7 @@ namespace LuaPlayer
Eluna::Push(L, player->HasMeleeSpec());
return 1;
}
/**
* Returns `true` if the [Player] has a Caster Specialization, `false` otherwise.
*
@@ -437,7 +439,7 @@ namespace LuaPlayer
Eluna::Push(L, player->HasCasterSpec());
return 1;
}
/**
* Returns `true` if the [Player] has a Heal Specialization, `false` otherwise.
*
@@ -940,8 +942,8 @@ namespace LuaPlayer
{
AchievementEntry const* achievement = sAchievementStore.LookupEntry(pair.first);
if (achievement && (achievement->categoryId != 81 || countFeatsOfStrength))
{
count++;
{
count++;
}
}
@@ -1594,7 +1596,7 @@ namespace LuaPlayer
Eluna::Push(L, player->GetItemByEntry(entry));
return 1;
}
/**
* Returns the database textID of the [WorldObject]'s gossip header text for the [Player]
*
@@ -1666,7 +1668,7 @@ namespace LuaPlayer
Eluna::Push(L, player->GetTeamId());
return 1;
}
/**
* Returns amount of the specified [Item] the [Player] has.
*
@@ -1845,7 +1847,7 @@ namespace LuaPlayer
Eluna::Push(L, ChatHandler(player->GetSession()).GetNearbyGameObject());
return 1;
}*/
/**
* Locks the player controls and disallows all movement and casting.
*
@@ -2343,7 +2345,7 @@ namespace LuaPlayer
return 0;
}
#endif
/**
* Shows the mailbox window to the player from specified guid.
*
@@ -2473,30 +2475,31 @@ namespace LuaPlayer
*
* @param [Unit] sender
*/
int SendAuctionMenu(lua_State* L, Player* player)
int SendAuctionMenu(lua_State* L, Player* /*player*/)
{
Unit* unit = Eluna::CHECKOBJ<Unit>(L, 2);
Eluna::CHECKOBJ<Unit>(L, 2);
#if defined TRINITY || AZEROTHCORE
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->GetFaction());
// AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseFactionFromHouseId(static_cast<AuctionHouseId>(unit->GetFaction()));
// AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit->GetFaction());
#else
AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit);
// AuctionHouseEntry const* ahEntry = AuctionHouseMgr::GetAuctionHouseEntry(unit);
#endif
if (!ahEntry)
return 0;
// if (!ahEntry)
// return 0;
WorldPacket data(MSG_AUCTION_HELLO, 12);
data << unit->GET_GUID();
// WorldPacket data(MSG_AUCTION_HELLO, 12);
// data << unit->GET_GUID();
#ifdef TRINITY
data << uint32(ahEntry->ID);
#else
data << uint32(ahEntry->houseId);
// data << uint32(ahEntry->houseId);
#endif
data << uint8(1);
// data << uint8(1);
#ifdef CMANGOS
player->GetSession()->SendPacket(data);
// player->GetSession()->SendPacket(data);
#else
player->GetSession()->SendPacket(&data);
// player->GetSession()->SendPacket(&data);
#endif
return 0;
}
@@ -2548,7 +2551,7 @@ namespace LuaPlayer
player->GetSession()->SendShowBank(obj->GET_GUID());
return 0;
}
/**
* Sends a vendor window to the [Player] from the [WorldObject] specified.
*
@@ -3456,7 +3459,7 @@ namespace LuaPlayer
player->AutoUnequipOffhandIfNeed();
return 1;
}
/**
* Returns true if the player can equip the given [Item] or item entry to the given slot, false otherwise.
*
@@ -3629,7 +3632,7 @@ namespace LuaPlayer
player->SetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS, currentKills + val);
return 0;
}
/**
* Adds the given amount of the specified item entry to the player.
*
@@ -3664,7 +3667,7 @@ namespace LuaPlayer
#endif
return 1;
}
/**
* Removes the given amount of the specified [Item] from the player.
*
@@ -3802,7 +3805,9 @@ namespace LuaPlayer
{
std::string msg = Eluna::CHECKVAL<std::string>(L, 2);
if (msg.length() > 0)
player->GetSession()->SendNotification("%s", msg.c_str());
// player->GetSession()->SendNotification("%s", msg.c_str());
ChatHandler(player->GetSession()).SendNotification("{}", msg);
return 0;
}
@@ -3935,6 +3940,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 +3977,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.
@@ -3982,9 +4018,9 @@ namespace LuaPlayer
/**
* Adds a new item to the gossip menu shown to the [Player] on next call to [Player:GossipSendMenu].
*
* sender and intid are numbers which are passed directly to the gossip selection handler. Internally they are partly used for the database gossip handling.
* code specifies whether to show a box to insert text to. The player inserted text is passed to the gossip selection handler.
* money specifies an amount of money the player needs to have to click the option. An error message is shown if the player doesn't have enough money.
* sender and intid are numbers which are passed directly to the gossip selection handler. Internally they are partly used for the database gossip handling.
* code specifies whether to show a box to insert text to. The player inserted text is passed to the gossip selection handler.
* money specifies an amount of money the player needs to have to click the option. An error message is shown if the player doesn't have enough money.
* Note that the money amount is only checked client side and is not removed from the player either. You will need to check again in your code before taking action.
*
* See also: [Player:GossipSendMenu], [Player:GossipAddQuests], [Player:GossipComplete], [Player:GossipClearMenu]
@@ -4007,7 +4043,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);
@@ -4064,7 +4108,7 @@ namespace LuaPlayer
* Clears the [Player]s current gossip item list.
*
* See also: [Player:GossipMenuAddItem], [Player:GossipSendMenu], [Player:GossipAddQuests], [Player:GossipComplete]
*
*
* Note: This is needed when you show a gossip menu without using gossip hello or select hooks which do this automatically.
* Usually this is needed when using [Player] is the sender of a Gossip Menu.
*/

View File

@@ -61,7 +61,7 @@ namespace LuaUnit
unit->ApplySpellImmune(0, 5, immunity, apply);
return 0;
}
/**
* The [Unit] modifies a specific stat
*
@@ -139,7 +139,7 @@ namespace LuaUnit
*/
int IsRooted(lua_State* L, Unit* unit)
{
Eluna::Push(L, unit->isInRoots() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT));
Eluna::Push(L, unit->HasRootAura() || unit->HasUnitMovementFlag(MOVEMENTFLAG_ROOT));
return 1;
}