mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-14 15:41:30 +00:00
Implement Lua quest api for expeditions
This commit is contained in:
parent
7798504641
commit
f74605d339
@ -52,6 +52,7 @@ SET(zone_sources
|
||||
lua_encounter.cpp
|
||||
lua_entity.cpp
|
||||
lua_entity_list.cpp
|
||||
lua_expedition.cpp
|
||||
lua_general.cpp
|
||||
lua_group.cpp
|
||||
lua_hate_list.cpp
|
||||
@ -195,6 +196,7 @@ SET(zone_headers
|
||||
lua_encounter.h
|
||||
lua_entity.h
|
||||
lua_entity_list.h
|
||||
lua_expedition.h
|
||||
lua_general.h
|
||||
lua_group.h
|
||||
lua_hate_list.h
|
||||
|
||||
@ -4,7 +4,9 @@
|
||||
#include <luabind/luabind.hpp>
|
||||
|
||||
#include "client.h"
|
||||
#include "expedition_lockout_timer.h"
|
||||
#include "lua_client.h"
|
||||
#include "lua_expedition.h"
|
||||
#include "lua_npc.h"
|
||||
#include "lua_item.h"
|
||||
#include "lua_iteminst.h"
|
||||
@ -1644,7 +1646,76 @@ int Lua_Client::GetClientMaxLevel() {
|
||||
return self->GetClientMaxLevel();
|
||||
}
|
||||
|
||||
Lua_Expedition Lua_Client::CreateExpedition(std::string name, uint32 min_players, uint32 max_players) {
|
||||
Lua_Safe_Call_Class(Lua_Expedition);
|
||||
return self->CreateExpedition(name, min_players, max_players);
|
||||
}
|
||||
|
||||
Lua_Expedition Lua_Client::CreateExpedition(std::string name, uint32 min_players, uint32 max_players, bool has_replay_timer) {
|
||||
Lua_Safe_Call_Class(Lua_Expedition);
|
||||
return self->CreateExpedition(name, min_players, max_players, has_replay_timer);
|
||||
}
|
||||
|
||||
Lua_Expedition Lua_Client::GetExpedition() {
|
||||
Lua_Safe_Call_Class(Lua_Expedition);
|
||||
return self->GetExpedition();
|
||||
}
|
||||
|
||||
luabind::object Lua_Client::GetExpeditionLockouts(lua_State* L)
|
||||
{
|
||||
auto lua_table = luabind::newtable(L);
|
||||
if (d_)
|
||||
{
|
||||
auto self = reinterpret_cast<NativeType*>(d_);
|
||||
auto lockouts = self->GetExpeditionLockouts();
|
||||
|
||||
for (const auto& lockout : lockouts)
|
||||
{
|
||||
auto lockout_table = lua_table[lockout.GetExpeditionName()];
|
||||
if (luabind::type(lockout_table) != LUA_TTABLE)
|
||||
{
|
||||
lockout_table = luabind::newtable(L);
|
||||
}
|
||||
lockout_table[lockout.GetEventName()] = lockout.GetSecondsRemaining();
|
||||
}
|
||||
}
|
||||
return lua_table;
|
||||
}
|
||||
|
||||
luabind::object Lua_Client::GetExpeditionLockouts(lua_State* L, std::string expedition_name)
|
||||
{
|
||||
auto lua_table = luabind::newtable(L);
|
||||
if (d_)
|
||||
{
|
||||
auto self = reinterpret_cast<NativeType*>(d_);
|
||||
auto lockouts = self->GetExpeditionLockouts();
|
||||
|
||||
for (const auto& lockout : lockouts)
|
||||
{
|
||||
if (lockout.GetExpeditionName() == expedition_name)
|
||||
{
|
||||
lua_table[lockout.GetEventName()] = lockout.GetSecondsRemaining();
|
||||
}
|
||||
}
|
||||
}
|
||||
return lua_table;
|
||||
}
|
||||
|
||||
void Lua_Client::AddExpeditionLockout(std::string expedition_name, std::string event_name, uint32 seconds) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->AddNewExpeditionLockout(expedition_name, event_name, seconds);
|
||||
}
|
||||
|
||||
void Lua_Client::RemoveExpeditionLockout(std::string expedition_name, std::string event_name) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->RemoveExpeditionLockout(expedition_name, event_name, true);
|
||||
self->SendExpeditionLockoutTimers();
|
||||
}
|
||||
|
||||
bool Lua_Client::HasExpeditionLockout(std::string expedition_name, std::string event_name) {
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->HasExpeditionLockout(expedition_name, event_name);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_client() {
|
||||
return luabind::class_<Lua_Client, Lua_Mob>("Client")
|
||||
@ -1952,7 +2023,15 @@ luabind::scope lua_register_client() {
|
||||
.def("EnableAreaRegens", &Lua_Client::EnableAreaRegens)
|
||||
.def("DisableAreaRegens", &Lua_Client::DisableAreaRegens)
|
||||
.def("SetClientMaxLevel", (void(Lua_Client::*)(int))&Lua_Client::SetClientMaxLevel)
|
||||
.def("GetClientMaxLevel", (int(Lua_Client::*)(void))&Lua_Client::GetClientMaxLevel);
|
||||
.def("GetClientMaxLevel", (int(Lua_Client::*)(void))&Lua_Client::GetClientMaxLevel)
|
||||
.def("CreateExpedition", (Lua_Expedition(Lua_Client::*)(std::string, uint32, uint32))&Lua_Client::CreateExpedition)
|
||||
.def("CreateExpedition", (Lua_Expedition(Lua_Client::*)(std::string, uint32, uint32, bool))&Lua_Client::CreateExpedition)
|
||||
.def("GetExpedition", (Lua_Expedition(Lua_Client::*)(void))&Lua_Client::GetExpedition)
|
||||
.def("GetExpeditionLockouts", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetExpeditionLockouts)
|
||||
.def("GetExpeditionLockouts", (luabind::object(Lua_Client::*)(lua_State* L, std::string))&Lua_Client::GetExpeditionLockouts)
|
||||
.def("AddExpeditionLockout", (void(Lua_Client::*)(std::string, std::string, uint32))&Lua_Client::AddExpeditionLockout)
|
||||
.def("RemoveExpeditionLockout", (void(Lua_Client::*)(std::string, std::string))&Lua_Client::RemoveExpeditionLockout)
|
||||
.def("HasExpeditionLockout", (bool(Lua_Client::*)(std::string, std::string))&Lua_Client::HasExpeditionLockout);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_inventory_where() {
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
#include "lua_mob.h"
|
||||
|
||||
class Client;
|
||||
class Lua_Expedition;
|
||||
class Lua_Group;
|
||||
class Lua_Raid;
|
||||
class Lua_Inventory;
|
||||
@ -332,12 +333,20 @@ public:
|
||||
void EnableAreaRegens(int value);
|
||||
void DisableAreaRegens();
|
||||
|
||||
|
||||
void SetPrimaryWeaponOrnamentation(uint32 model_id);
|
||||
void SetSecondaryWeaponOrnamentation(uint32 model_id);
|
||||
|
||||
void SetClientMaxLevel(int value);
|
||||
int GetClientMaxLevel();
|
||||
|
||||
Lua_Expedition CreateExpedition(std::string name, uint32 min_players, uint32 max_players);
|
||||
Lua_Expedition CreateExpedition(std::string name, uint32 min_players, uint32 max_players, bool has_replay_timer);
|
||||
Lua_Expedition GetExpedition();
|
||||
luabind::object GetExpeditionLockouts(lua_State* L);
|
||||
luabind::object GetExpeditionLockouts(lua_State* L, std::string expedition_name);
|
||||
void AddExpeditionLockout(std::string expedition_name, std::string event_name, uint32 seconds);
|
||||
void RemoveExpeditionLockout(std::string expedition_name, std::string event_name);
|
||||
bool HasExpeditionLockout(std::string expedition_name, std::string event_name);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
152
zone/lua_expedition.cpp
Normal file
152
zone/lua_expedition.cpp
Normal file
@ -0,0 +1,152 @@
|
||||
/**
|
||||
* EQEmulator: Everquest Server Emulator
|
||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
* are required to give you total support for your newly bought product;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef LUA_EQEMU
|
||||
|
||||
#include "lua_expedition.h"
|
||||
#include "expedition.h"
|
||||
#include "lua.hpp"
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/object.hpp>
|
||||
|
||||
void Lua_Expedition::AddLockout(std::string event_name, uint32_t seconds) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->AddLockout(event_name, seconds);
|
||||
}
|
||||
|
||||
void Lua_Expedition::AddReplayLockout(uint32_t seconds) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->AddReplayLockout(seconds);
|
||||
}
|
||||
|
||||
uint32_t Lua_Expedition::GetID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetID();
|
||||
}
|
||||
|
||||
std::string Lua_Expedition::GetLeaderName() {
|
||||
Lua_Safe_Call_String();
|
||||
return self->GetLeaderName();
|
||||
}
|
||||
|
||||
luabind::object Lua_Expedition::GetLockouts(lua_State* L) {
|
||||
luabind::object lua_table = luabind::newtable(L);
|
||||
|
||||
if (d_)
|
||||
{
|
||||
auto self = reinterpret_cast<NativeType*>(d_);
|
||||
auto lockouts = self->GetLockouts();
|
||||
for (const auto& lockout : lockouts)
|
||||
{
|
||||
lua_table[lockout.first] = lockout.second.GetSecondsRemaining();
|
||||
}
|
||||
}
|
||||
return lua_table;
|
||||
}
|
||||
|
||||
uint32_t Lua_Expedition::GetMemberCount() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetMemberCount();
|
||||
}
|
||||
|
||||
luabind::object Lua_Expedition::GetMembers(lua_State* L) {
|
||||
luabind::object lua_table = luabind::newtable(L);
|
||||
|
||||
if (d_)
|
||||
{
|
||||
auto self = reinterpret_cast<NativeType*>(d_);
|
||||
for (const auto& member : self->GetMembers())
|
||||
{
|
||||
lua_table[member.name] = member.char_id;
|
||||
}
|
||||
}
|
||||
return lua_table;
|
||||
}
|
||||
|
||||
std::string Lua_Expedition::GetName() {
|
||||
Lua_Safe_Call_String();
|
||||
return self->GetName();
|
||||
}
|
||||
|
||||
int Lua_Expedition::GetType() {
|
||||
Lua_Safe_Call_Int();
|
||||
return static_cast<int>(self->GetType());
|
||||
}
|
||||
|
||||
bool Lua_Expedition::HasLockout(std::string event_name) {
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->HasLockout(event_name);
|
||||
}
|
||||
|
||||
bool Lua_Expedition::HasReplayLockout() {
|
||||
Lua_Safe_Call_Bool();
|
||||
return self->HasReplayLockout();
|
||||
}
|
||||
|
||||
void Lua_Expedition::RemoveLockout(std::string event_name) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->RemoveLockout(event_name);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_expedition() {
|
||||
return luabind::class_<Lua_Expedition>("Expedition")
|
||||
.def(luabind::constructor<>())
|
||||
.property("null", &Lua_Expedition::Null)
|
||||
.property("valid", &Lua_Expedition::Valid)
|
||||
.def("AddLockout", (void(Lua_Expedition::*)(std::string, uint32_t))&Lua_Expedition::AddLockout)
|
||||
.def("AddReplayLockout", (void(Lua_Expedition::*)(uint32_t))&Lua_Expedition::AddReplayLockout)
|
||||
.def("GetID", (uint32_t(Lua_Expedition::*)(void))&Lua_Expedition::GetID)
|
||||
.def("GetLeaderName", (std::string(Lua_Expedition::*)(void))&Lua_Expedition::GetLeaderName)
|
||||
.def("GetLockouts", &Lua_Expedition::GetLockouts)
|
||||
.def("GetMemberCount", (uint32_t(Lua_Expedition::*)(void))&Lua_Expedition::GetMemberCount)
|
||||
.def("GetMembers", &Lua_Expedition::GetMembers)
|
||||
.def("GetName", (std::string(Lua_Expedition::*)(void))&Lua_Expedition::GetName)
|
||||
.def("GetType", (int(Lua_Expedition::*)(void))&Lua_Expedition::GetType)
|
||||
.def("HasLockout", (bool(Lua_Expedition::*)(std::string))&Lua_Expedition::HasLockout)
|
||||
.def("HasReplayLockout", (bool(Lua_Expedition::*)())&Lua_Expedition::HasReplayLockout)
|
||||
.def("RemoveLockout", (void(Lua_Expedition::*)(std::string))&Lua_Expedition::RemoveLockout);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_expedition_member_status() {
|
||||
return luabind::class_<ExpeditionMemberStatus>("ExpeditionMemberStatus")
|
||||
.enum_("constants")
|
||||
[
|
||||
luabind::value("Unknown", static_cast<int>(ExpeditionMemberStatus::Unknown)),
|
||||
luabind::value("Online", static_cast<int>(ExpeditionMemberStatus::Online)),
|
||||
luabind::value("Offline", static_cast<int>(ExpeditionMemberStatus::Offline)),
|
||||
luabind::value("InDynamicZone", static_cast<int>(ExpeditionMemberStatus::InDynamicZone)),
|
||||
luabind::value("LinkDead", static_cast<int>(ExpeditionMemberStatus::LinkDead))
|
||||
];
|
||||
}
|
||||
|
||||
luabind::scope lua_register_dynamiczone_types() {
|
||||
return luabind::class_<DynamicZoneType>("DynamicZoneType")
|
||||
.enum_("constants")
|
||||
[
|
||||
luabind::value("None", static_cast<int>(DynamicZoneType::None)),
|
||||
luabind::value("Expedition", static_cast<int>(DynamicZoneType::Expedition)),
|
||||
luabind::value("Tutorial", static_cast<int>(DynamicZoneType::Tutorial)),
|
||||
luabind::value("Task", static_cast<int>(DynamicZoneType::Task)),
|
||||
luabind::value("Mission", static_cast<int>(DynamicZoneType::Mission)),
|
||||
luabind::value("Quest", static_cast<int>(DynamicZoneType::Quest))
|
||||
];
|
||||
}
|
||||
|
||||
#endif // LUA_EQEMU
|
||||
72
zone/lua_expedition.h
Normal file
72
zone/lua_expedition.h
Normal file
@ -0,0 +1,72 @@
|
||||
/**
|
||||
* EQEmulator: Everquest Server Emulator
|
||||
* Copyright (C) 2001-2020 EQEmulator Development Team (https://github.com/EQEmu/Server)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
* are required to give you total support for your newly bought product;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef EQEMU_LUA_EXPEDITION_H
|
||||
#define EQEMU_LUA_EXPEDITION_H
|
||||
#ifdef LUA_EQEMU
|
||||
|
||||
#include "lua_ptr.h"
|
||||
#include "../common/types.h"
|
||||
#include <string>
|
||||
|
||||
class Expedition;
|
||||
class Lua_Client;
|
||||
struct lua_State;
|
||||
|
||||
namespace luabind {
|
||||
struct scope;
|
||||
namespace adl {
|
||||
class object;
|
||||
}
|
||||
using adl::object;
|
||||
}
|
||||
|
||||
luabind::scope lua_register_dynamiczone_types();
|
||||
luabind::scope lua_register_expedition();
|
||||
luabind::scope lua_register_expedition_member_status();
|
||||
|
||||
class Lua_Expedition : public Lua_Ptr<Expedition>
|
||||
{
|
||||
typedef Expedition NativeType;
|
||||
public:
|
||||
Lua_Expedition() : Lua_Ptr(nullptr) { }
|
||||
Lua_Expedition(Expedition *d) : Lua_Ptr(d) { }
|
||||
virtual ~Lua_Expedition() { }
|
||||
|
||||
operator Expedition*() {
|
||||
return reinterpret_cast<Expedition*>(GetLuaPtrData());
|
||||
}
|
||||
|
||||
void AddLockout(std::string event_name, uint32_t seconds);
|
||||
void AddReplayLockout(uint32_t seconds);
|
||||
uint32_t GetID();
|
||||
std::string GetLeaderName();
|
||||
uint32_t GetMemberCount();
|
||||
luabind::object GetMembers(lua_State* L);
|
||||
std::string GetName();
|
||||
int GetType();
|
||||
luabind::object GetLockouts(lua_State* L);
|
||||
bool HasLockout(std::string event_name);
|
||||
bool HasReplayLockout();
|
||||
void RemoveLockout(std::string event_name);
|
||||
};
|
||||
|
||||
#endif // LUA_EQEMU
|
||||
#endif // EQEMU_LUA_EXPEDITION_H
|
||||
@ -18,6 +18,7 @@
|
||||
#include "lua_client.h"
|
||||
#include "lua_npc.h"
|
||||
#include "lua_entity_list.h"
|
||||
#include "lua_expedition.h"
|
||||
#include "quest_parser_collection.h"
|
||||
#include "questmgr.h"
|
||||
#include "qglobals.h"
|
||||
@ -2178,6 +2179,18 @@ void lua_set_content_flag(std::string flag_name, bool enabled){
|
||||
ZoneStore::SetContentFlag(flag_name, enabled);
|
||||
}
|
||||
|
||||
Lua_Expedition lua_get_expedition() {
|
||||
return quest_manager.GetExpeditionForCurrentInstance();
|
||||
}
|
||||
|
||||
Lua_Expedition lua_get_expedition_by_char_id(uint32 char_id) {
|
||||
return quest_manager.GetExpeditionByCharID(char_id);
|
||||
}
|
||||
|
||||
Lua_Expedition lua_get_expedition_by_instance_id(uint32 instance_id) {
|
||||
return quest_manager.GetExpeditionByInstanceID(instance_id);
|
||||
}
|
||||
|
||||
#define LuaCreateNPCParse(name, c_type, default_value) do { \
|
||||
cur = table[#name]; \
|
||||
if(luabind::type(cur) != LUA_TNIL) { \
|
||||
@ -2775,7 +2788,11 @@ luabind::scope lua_register_general() {
|
||||
* Content flags
|
||||
*/
|
||||
luabind::def("is_content_flag_enabled", (bool(*)(std::string))&lua_is_content_flag_enabled),
|
||||
luabind::def("set_content_flag", (void(*)(std::string, bool))&lua_set_content_flag)
|
||||
luabind::def("set_content_flag", (void(*)(std::string, bool))&lua_set_content_flag),
|
||||
|
||||
luabind::def("get_expedition", (Lua_Expedition(*)())&lua_get_expedition),
|
||||
luabind::def("get_expedition_by_char_id", (Lua_Expedition(*)(uint32 char_id))&lua_get_expedition_by_char_id),
|
||||
luabind::def("get_expedition_by_instance_id", (Lua_Expedition(*)(uint32 instance_id))&lua_get_expedition_by_instance_id)
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
#include "lua_parser.h"
|
||||
#include "lua_bit.h"
|
||||
#include "lua_entity.h"
|
||||
#include "lua_expedition.h"
|
||||
#include "lua_item.h"
|
||||
#include "lua_iteminst.h"
|
||||
#include "lua_mob.h"
|
||||
@ -1108,7 +1109,10 @@ void LuaParser::MapFunctions(lua_State *L) {
|
||||
lua_register_ruler(),
|
||||
lua_register_ruleb(),
|
||||
lua_register_journal_speakmode(),
|
||||
lua_register_journal_mode()
|
||||
lua_register_journal_mode(),
|
||||
lua_register_dynamiczone_types(),
|
||||
lua_register_expedition(),
|
||||
lua_register_expedition_member_status()
|
||||
];
|
||||
|
||||
} catch(std::exception &ex) {
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
|
||||
#include "entity.h"
|
||||
#include "event_codes.h"
|
||||
#include "expedition.h"
|
||||
#include "guild_mgr.h"
|
||||
#include "qglobals.h"
|
||||
#include "queryserv.h"
|
||||
@ -4327,3 +4328,22 @@ void QuestManager::UpdateZoneHeader(std::string type, std::string value) {
|
||||
entity_list.QueueClients(0, outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
Expedition* QuestManager::GetExpeditionByCharID(uint32 char_id)
|
||||
{
|
||||
return Expedition::FindCachedExpeditionByCharacterID(char_id);
|
||||
}
|
||||
|
||||
Expedition* QuestManager::GetExpeditionByInstanceID(uint32 instance_id)
|
||||
{
|
||||
return Expedition::FindExpeditionByInstanceID(instance_id);
|
||||
}
|
||||
|
||||
Expedition* QuestManager::GetExpeditionForCurrentInstance()
|
||||
{
|
||||
if (zone && zone->GetInstanceID() != 0)
|
||||
{
|
||||
return Expedition::FindExpeditionByInstanceID(zone->GetInstanceID());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -366,6 +366,9 @@ public:
|
||||
bool DisableRecipe(uint32 recipe_id);
|
||||
void ClearNPCTypeCache(int npctype_id);
|
||||
void ReloadZoneStaticData();
|
||||
Expedition* GetExpeditionByCharID(uint32 char_id);
|
||||
Expedition* GetExpeditionByInstanceID(uint32 instance_id);
|
||||
Expedition* GetExpeditionForCurrentInstance();
|
||||
|
||||
Client *GetInitiator() const;
|
||||
NPC *GetNPC() const;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user