eqemu-server/zone/lua_group.cpp
hg 55155ff800
[Expeditions] Move expedition code into DynamicZone (#4672)
This removes the separate Expedition class and moves lockout code and
/dz command handlers into DynamicZone classes. It also refactors some
code to reduce bloat and some database usage.

This completes the effort of moving everything to DynamicZone that
started when implementing shared tasks. It also makes sense to do this
since expeditions are just dynamic zones internally despite dzs being
used for other types. Expedition specific things are just handled with
dz type checks.

Functionally nothing should change. This is mainly internal refactoring
and moving code around along with some bug fixes and reduced database
usage.

Main changes:

 - The `expeditions` database table has been removed

 - Expeditions no longer use a separate id, the expedition id is just the dz id

 - Expedition lock state and replay timer option were moved to the
   `dynamic_zones` table

 - Expeditions no longer have a separate cache from dynamic zones

 - Expedition creation no longer has every zone query the database to cache it

 - Expedition internal lockouts are now stored on DynamicZone

 - The `expedition_lockouts` table has been renamed to `dynamic_zone_lockouts`

 - Fixed a small bug with the UpdateLockoutDuration api where the
   internal lockout would get the time added twice in memory in the
   initiating zone (this api is likely rarely used)

 - Fixed an issue where use of the group/raid DoesAnyMemberHaveExpeditionLockout
   api would query once for every out of zone character.

   - This api now checks all members in the current zone first and only
     performs a single bulk query for out of zone members if that check
     is exhausted

 - Deprecated the max_check_count param of DoesAnyMemberHaveExpeditionLockout,
   the quest api still exists to avoid api break but a passed arg has no effect
2025-02-15 18:40:35 -06:00

174 lines
5.6 KiB
C++

#ifdef LUA_EQEMU
#include "../common/data_verification.h"
#include <luabind/luabind.hpp>
#include <luabind/object.hpp>
#include "groups.h"
#include "masterentity.h"
#include "lua_group.h"
#include "lua_mob.h"
#include "lua_client.h"
#include "lua_npc.h"
void Lua_Group::DisbandGroup() {
Lua_Safe_Call_Void();
self->DisbandGroup();
}
bool Lua_Group::IsGroupMember(const char* name) {
Lua_Safe_Call_Bool();
return self->IsGroupMember(name);
}
bool Lua_Group::IsGroupMember(Lua_Mob c) {
Lua_Safe_Call_Bool();
return self->IsGroupMember(c);
}
void Lua_Group::CastGroupSpell(Lua_Mob caster, int spell_id) {
Lua_Safe_Call_Void();
self->CastGroupSpell(caster, spell_id);
}
void Lua_Group::SplitExp(uint64 exp, Lua_Mob other) {
Lua_Safe_Call_Void();
self->SplitExp(ExpSource::Quest, exp, other);
}
void Lua_Group::GroupMessage(Lua_Mob sender, const char* message) {
Lua_Safe_Call_Void();
self->GroupMessage(sender, Language::CommonTongue, Language::MaxValue, message);
}
void Lua_Group::GroupMessage(Lua_Mob sender, uint8 language, const char* message) {
Lua_Safe_Call_Void();
self->GroupMessage(sender, language, Language::MaxValue, message);
}
uint32 Lua_Group::GetTotalGroupDamage(Lua_Mob other) {
Lua_Safe_Call_Int();
return self->GetTotalGroupDamage(other);
}
void Lua_Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum) {
Lua_Safe_Call_Void();
self->SplitMoney(copper, silver, gold, platinum);
}
void Lua_Group::SplitMoney(uint32 copper, uint32 silver, uint32 gold, uint32 platinum, Lua_Client splitter) {
Lua_Safe_Call_Void();
self->SplitMoney(copper, silver, gold, platinum, splitter);
}
void Lua_Group::SetLeader(Lua_Mob c) {
Lua_Safe_Call_Void();
self->SetLeader(c);
}
Lua_Mob Lua_Group::GetLeader() {
Lua_Safe_Call_Class(Lua_Mob);
return self->GetLeader();
}
std::string Lua_Group::GetLeaderName() {
Lua_Safe_Call_String();
return self->GetLeaderName();
}
bool Lua_Group::IsLeader(const char* name) {
Lua_Safe_Call_Bool();
return self->IsLeader(name);
}
bool Lua_Group::IsLeader(Lua_Mob c) {
Lua_Safe_Call_Bool();
return self->IsLeader(c);
}
int Lua_Group::GroupCount() {
Lua_Safe_Call_Int();
return self->GroupCount();
}
uint32 Lua_Group::GetHighestLevel() {
Lua_Safe_Call_Int();
return self->GetHighestLevel();
}
uint32 Lua_Group::GetLowestLevel() {
Lua_Safe_Call_Int();
return self->GetLowestLevel();
}
void Lua_Group::TeleportGroup(Lua_Mob sender, uint32 zone_id, uint32 instance_id, float x, float y, float z, float h) {
Lua_Safe_Call_Void();
self->TeleportGroup(sender, zone_id, instance_id, x, y, z, h);
}
int Lua_Group::GetID() {
Lua_Safe_Call_Int();
return self->GetID();
}
Lua_Mob Lua_Group::GetMember(int member_index) {
Lua_Safe_Call_Class(Lua_Mob);
if (!EQ::ValueWithin(member_index, 0, 5)) {
return Lua_Mob();
}
return self->members[member_index];
}
bool Lua_Group::DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name)
{
Lua_Safe_Call_Bool();
return self->AnyMemberHasDzLockout(expedition_name, event_name);
}
bool Lua_Group::DoesAnyMemberHaveExpeditionLockout(std::string expedition_name, std::string event_name, int max_check_count)
{
Lua_Safe_Call_Bool();
return self->AnyMemberHasDzLockout(expedition_name, event_name); // max_check_count deprecated
}
uint32 Lua_Group::GetAverageLevel() {
Lua_Safe_Call_Int();
return self->GetAvgLevel();
}
luabind::scope lua_register_group() {
return luabind::class_<Lua_Group>("Group")
.def(luabind::constructor<>())
.property("null", &Lua_Group::Null)
.property("valid", &Lua_Group::Valid)
.def("CastGroupSpell", (void(Lua_Group::*)(Lua_Mob,int))&Lua_Group::CastGroupSpell)
.def("DisbandGroup", (void(Lua_Group::*)(void))&Lua_Group::DisbandGroup)
.def("DoesAnyMemberHaveExpeditionLockout", (bool(Lua_Group::*)(std::string, std::string))&Lua_Group::DoesAnyMemberHaveExpeditionLockout)
.def("DoesAnyMemberHaveExpeditionLockout", (bool(Lua_Group::*)(std::string, std::string, int))&Lua_Group::DoesAnyMemberHaveExpeditionLockout)
.def("GetAverageLevel", (uint32(Lua_Group::*)(void))&Lua_Group::GetAverageLevel)
.def("GetHighestLevel", (uint32(Lua_Group::*)(void))&Lua_Group::GetHighestLevel)
.def("GetID", (int(Lua_Group::*)(void))&Lua_Group::GetID)
.def("GetLeader", (Lua_Mob(Lua_Group::*)(void))&Lua_Group::GetLeader)
.def("GetLeaderName", (const char*(Lua_Group::*)(void))&Lua_Group::GetLeaderName)
.def("GetLowestLevel", (uint32(Lua_Group::*)(void))&Lua_Group::GetLowestLevel)
.def("GetMember", (Lua_Mob(Lua_Group::*)(int))&Lua_Group::GetMember)
.def("GetTotalGroupDamage", (uint32(Lua_Group::*)(Lua_Mob))&Lua_Group::GetTotalGroupDamage)
.def("GroupCount", (int(Lua_Group::*)(void))&Lua_Group::GroupCount)
.def("GroupMessage", (void(Lua_Group::*)(Lua_Mob,const char*))&Lua_Group::GroupMessage)
.def("GroupMessage", (void(Lua_Group::*)(Lua_Mob,uint8,const char*))&Lua_Group::GroupMessage)
.def("IsGroupMember", (bool(Lua_Group::*)(const char*))&Lua_Group::IsGroupMember)
.def("IsGroupMember", (bool(Lua_Group::*)(Lua_Mob))&Lua_Group::IsGroupMember)
.def("IsLeader", (bool(Lua_Group::*)(const char*))&Lua_Group::IsLeader)
.def("IsLeader", (bool(Lua_Group::*)(Lua_Mob))&Lua_Group::IsLeader)
.def("SetLeader", (void(Lua_Group::*)(Lua_Mob))&Lua_Group::SetLeader)
.def("SplitExp", (void(Lua_Group::*)(uint32,Lua_Mob))&Lua_Group::SplitExp)
.def("SplitMoney", (void(Lua_Group::*)(uint32,uint32,uint32,uint32))&Lua_Group::SplitMoney)
.def("SplitMoney", (void(Lua_Group::*)(uint32,uint32,uint32,uint32,Lua_Client))&Lua_Group::SplitMoney)
.def("TeleportGroup", (void(Lua_Group::*)(Lua_Mob,uint32,uint32,float,float,float,float))&Lua_Group::TeleportGroup);
}
#endif