mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 10:31:29 +00:00
[Quest API] Add client->ReadBookByName(book_name, book_type) to Perl/Lua.
- Add $client->ReadBookByName(booK_name, book_type) to Perl. - Add client:ReadBookByName(booK_name, book_type) to Lua. - Allows server operators to put books in to their database and read from their database instead of storing the values in a script, also allows them to read pre-existing books using a script.
This commit is contained in:
parent
ff46a854f9
commit
93acf50bb4
@ -10530,6 +10530,33 @@ void Client::SetDoorToolEntityId(uint16 door_tool_entity_id)
|
||||
Client::m_door_tool_entity_id = door_tool_entity_id;
|
||||
}
|
||||
|
||||
void Client::ReadBookByName(std::string book_name, uint8 book_type)
|
||||
{
|
||||
int16 book_language = 0;
|
||||
std::string book_text = content_db.GetBook(book_name.c_str(), &book_language);
|
||||
int length = book_text.length();
|
||||
|
||||
if (book_text[0] != '\0') {
|
||||
LogDebug("Client::ReadBookByName() Book Name: [{}] Text: [{}]", book_name, book_text.c_str());
|
||||
auto outapp = new EQApplicationPacket(OP_ReadBook, length + sizeof(BookText_Struct));
|
||||
BookText_Struct *out = (BookText_Struct *) outapp->pBuffer;
|
||||
out->window = 0xFF;
|
||||
out->type = book_type;
|
||||
out->invslot = 0;
|
||||
|
||||
memcpy(out->booktext, book_text.c_str(), length);
|
||||
|
||||
if (book_language > 0 && book_language < MAX_PP_LANGUAGE) {
|
||||
if (m_pp.languages[book_language] < 100) {
|
||||
GarbleMessage(out->booktext, (100 - m_pp.languages[book_language]));
|
||||
}
|
||||
}
|
||||
|
||||
QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
}
|
||||
|
||||
// this will fetch raid clients if exists
|
||||
// fallback to group if raid doesn't exist
|
||||
// fallback to self if group doesn't exist
|
||||
|
||||
@ -728,6 +728,7 @@ public:
|
||||
void Stun(int duration);
|
||||
void UnStun();
|
||||
void ReadBook(BookRequest_Struct *book);
|
||||
void ReadBookByName(std::string book_name, uint8 book_type);
|
||||
void QuestReadBook(const char* text, uint8 type);
|
||||
void SendClientMoneyUpdate(uint8 type,uint32 amount);
|
||||
void SendMoneyUpdate();
|
||||
|
||||
@ -2229,6 +2229,11 @@ void Lua_Client::UntrainDiscBySpellID(uint16 spell_id, bool update_client) {
|
||||
self->UntrainDiscBySpellID(spell_id, update_client);
|
||||
}
|
||||
|
||||
void Lua_Client::ReadBookByName(std::string book_name, uint8 book_type) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->ReadBookByName(book_name, book_type);
|
||||
}
|
||||
|
||||
void Lua_Client::SummonBaggedItems(uint32 bag_item_id, luabind::adl::object bag_items_table) {
|
||||
Lua_Safe_Call_Void();
|
||||
if (luabind::type(bag_items_table) != LUA_TTABLE) {
|
||||
@ -2627,6 +2632,7 @@ luabind::scope lua_register_client() {
|
||||
.def("CountItem", (int(Lua_Client::*)(uint32))&Lua_Client::CountItem)
|
||||
.def("RemoveItem", (void(Lua_Client::*)(uint32))&Lua_Client::RemoveItem)
|
||||
.def("RemoveItem", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::RemoveItem)
|
||||
.def("ReadBookByName", (void(Lua_Client::*)(std::string,uint8))&Lua_Client::ReadBookByName)
|
||||
.def("SetGMStatus", (void(Lua_Client::*)(int32))&Lua_Client::SetGMStatus)
|
||||
.def("UntrainDiscBySpellID", (void(Lua_Client::*)(uint16))&Lua_Client::UntrainDiscBySpellID)
|
||||
.def("UntrainDiscBySpellID", (void(Lua_Client::*)(uint16,bool))&Lua_Client::UntrainDiscBySpellID)
|
||||
|
||||
@ -273,6 +273,7 @@ public:
|
||||
uint32 GetRadiantCrystals();
|
||||
uint32 GetEbonCrystals();
|
||||
void QuestReadBook(const char *text, int type);
|
||||
void ReadBookByName(std::string book_name, uint8 book_type);
|
||||
void UpdateGroupAAs(int points, uint32 type);
|
||||
uint32 GetGroupPoints();
|
||||
uint32 GetRaidPoints();
|
||||
|
||||
@ -5693,6 +5693,21 @@ XS(XS_Client_DiaWind) {
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
XS(XS_Client_ReadBookByName);
|
||||
XS(XS_Client_ReadBookByName) {
|
||||
dXSARGS;
|
||||
if (items != 3)
|
||||
Perl_croak(aTHX_ "Usage: Client::ReadBookByName(THIS, string book_name, uint8 book_type)"); // @categories Script Utility
|
||||
{
|
||||
Client *THIS;
|
||||
std::string book_name(SvPV_nolen(ST(1)));
|
||||
uint8 book_type = (uint8) SvUV(ST(2));
|
||||
VALIDATE_THIS_IS_CLIENT;
|
||||
THIS->ReadBookByName(book_name, book_type);
|
||||
}
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
XS(XS_Client_UntrainDiscBySpellID); /* prototype to pass -Wmissing-prototypes */
|
||||
XS(XS_Client_UntrainDiscBySpellID) {
|
||||
dXSARGS;
|
||||
@ -6078,6 +6093,7 @@ XS(boot_Client) {
|
||||
newXSproto(strcpy(buf, "UpdateWho"), XS_Client_UpdateWho, file, "$;$");
|
||||
newXSproto(strcpy(buf, "UseDiscipline"), XS_Client_UseDiscipline, file, "$$$");
|
||||
newXSproto(strcpy(buf, "WorldKick"), XS_Client_WorldKick, file, "$");
|
||||
newXSproto(strcpy(buf, "ReadBookByName"), XS_Client_ReadBookByName, file, "$$$");
|
||||
XSRETURN_YES;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user