Add MoveZoneInstance methods to Perl/Lua.

This commit is contained in:
Alex 2020-06-29 19:24:14 -04:00
parent f32126faac
commit 1b2c2a1dd0
5 changed files with 200 additions and 0 deletions

View File

@ -636,6 +636,9 @@ public:
void MoveZone(const char *zone_short_name); void MoveZone(const char *zone_short_name);
void MoveZoneGroup(const char *zone_short_name); void MoveZoneGroup(const char *zone_short_name);
void MoveZoneRaid(const char *zone_short_name); void MoveZoneRaid(const char *zone_short_name);
void MoveZoneInstance(uint16 instance_id);
void MoveZoneInstanceGroup(uint16 instance_id);
void MoveZoneInstanceRaid(uint16 instance_id);
void SendToGuildHall(); void SendToGuildHall();
void AssignToInstance(uint16 instance_id); void AssignToInstance(uint16 instance_id);
void RemoveFromInstance(uint16 instance_id); void RemoveFromInstance(uint16 instance_id);

View File

@ -340,6 +340,21 @@ void Lua_Client::MoveZoneRaid(const char *zone_short_name) {
self->MoveZoneRaid(zone_short_name); self->MoveZoneRaid(zone_short_name);
} }
void Lua_Client::MoveZoneInstance(uint16 instance_id) {
Lua_Safe_Call_Void();
self->MoveZoneInstance(instance_id);
}
void Lua_Client::MoveZoneInstanceGroup(uint16 instance_id) {
Lua_Safe_Call_Void();
self->MoveZoneInstanceGroup(instance_id);
}
void Lua_Client::MoveZoneInstanceRaid(uint16 instance_id) {
Lua_Safe_Call_Void();
self->MoveZoneInstanceRaid(instance_id);
}
void Lua_Client::ChangeLastName(const char *in) { void Lua_Client::ChangeLastName(const char *in) {
Lua_Safe_Call_Void(); Lua_Safe_Call_Void();
self->ChangeLastName(in); self->ChangeLastName(in);
@ -1676,6 +1691,9 @@ luabind::scope lua_register_client() {
.def("MoveZone", (void(Lua_Client::*)(const char*))&Lua_Client::MoveZone) .def("MoveZone", (void(Lua_Client::*)(const char*))&Lua_Client::MoveZone)
.def("MoveZoneGroup", (void(Lua_Client::*)(const char*))&Lua_Client::MoveZoneGroup) .def("MoveZoneGroup", (void(Lua_Client::*)(const char*))&Lua_Client::MoveZoneGroup)
.def("MoveZoneRaid", (void(Lua_Client::*)(const char*))&Lua_Client::MoveZoneRaid) .def("MoveZoneRaid", (void(Lua_Client::*)(const char*))&Lua_Client::MoveZoneRaid)
.def("MoveZoneInstance", (void(Lua_Client::*)(uint16))&Lua_Client::MoveZoneInstance)
.def("MoveZoneInstanceGroup", (void(Lua_Client::*)(uint16))&Lua_Client::MoveZoneInstanceGroup)
.def("MoveZoneInstanceRaid", (void(Lua_Client::*)(uint16))&Lua_Client::MoveZoneInstanceRaid)
.def("ChangeLastName", (void(Lua_Client::*)(const char *in))&Lua_Client::ChangeLastName) .def("ChangeLastName", (void(Lua_Client::*)(const char *in))&Lua_Client::ChangeLastName)
.def("GetFactionLevel", (int(Lua_Client::*)(uint32,uint32,uint32,uint32,uint32,uint32,Lua_NPC))&Lua_Client::GetFactionLevel) .def("GetFactionLevel", (int(Lua_Client::*)(uint32,uint32,uint32,uint32,uint32,uint32,Lua_NPC))&Lua_Client::GetFactionLevel)
.def("SetFactionLevel", (void(Lua_Client::*)(uint32,uint32,int,int,int))&Lua_Client::SetFactionLevel) .def("SetFactionLevel", (void(Lua_Client::*)(uint32,uint32,int,int,int))&Lua_Client::SetFactionLevel)

View File

@ -94,6 +94,9 @@ public:
void MoveZone(const char *zone_short_name); void MoveZone(const char *zone_short_name);
void MoveZoneGroup(const char *zone_short_name); void MoveZoneGroup(const char *zone_short_name);
void MoveZoneRaid(const char *zone_short_name); void MoveZoneRaid(const char *zone_short_name);
void MoveZoneInstance(uint16 instance_id);
void MoveZoneInstanceGroup(uint16 instance_id);
void MoveZoneInstanceRaid(uint16 instance_id);
void ChangeLastName(const char *in); void ChangeLastName(const char *in);
int GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 race, uint32 class_, uint32 deity, uint32 faction, Lua_NPC npc); int GetFactionLevel(uint32 char_id, uint32 npc_id, uint32 race, uint32 class_, uint32 deity, uint32 faction, Lua_NPC npc);
void SetFactionLevel(uint32 char_id, uint32 npc_id, int char_class, int char_race, int char_deity); void SetFactionLevel(uint32 char_id, uint32 npc_id, int char_class, int char_race, int char_deity);

View File

@ -1445,6 +1445,132 @@ XS(XS_Client_MoveZoneRaid) {
XSRETURN_EMPTY; XSRETURN_EMPTY;
} }
XS(XS_Client_MoveZoneInstance); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_MoveZoneInstance) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Client::MoveZoneInstance(THIS, uint16 instance_id)");
{
Client *THIS;
uint16 instance_id = (uint16) SvUV(ST(1));
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(Client *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type Client");
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
if (THIS->IsClient()) {
THIS->MoveZoneInstance(instance_id);
} else {
if (THIS->IsMerc()) {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstance) attempted to process a type Merc reference");
}
#ifdef BOTS
else if (THIS->IsBot()) {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstance) attempted to process a type Bot reference");
}
#endif
else if (THIS->IsNPC()) {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstance) attempted to process a type NPC reference");
}
else {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstance) attempted to process an Unknown type reference");
}
Perl_croak(aTHX_ "THIS is not of type Client");
}
}
XSRETURN_EMPTY;
}
XS(XS_Client_MoveZoneInstanceGroup); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_MoveZoneInstanceGroup) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Client::MoveZoneInstanceGroup(THIS, uint16 instance_id)");
{
Client *THIS;
uint16 instance_id = (uint16) SvUV(ST(1));
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(Client *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type Client");
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
if (THIS->IsClient()) {
THIS->MoveZoneInstanceGroup(instance_id);
} else {
if (THIS->IsMerc()) {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstanceGroup) attempted to process a type Merc reference");
}
#ifdef BOTS
else if (THIS->IsBot()) {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstanceGroup) attempted to process a type Bot reference");
}
#endif
else if (THIS->IsNPC()) {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstanceGroup) attempted to process a type NPC reference");
}
else {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstanceGroup) attempted to process an Unknown type reference");
}
Perl_croak(aTHX_ "THIS is not of type Client");
}
}
XSRETURN_EMPTY;
}
XS(XS_Client_MoveZoneInstanceRaid); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_MoveZoneInstanceRaid) {
dXSARGS;
if (items != 2)
Perl_croak(aTHX_ "Usage: Client::MoveZoneInstanceRaid(THIS, uint16 instance_id)");
{
Client *THIS;
uint16 instance_id = (uint16) SvUV(ST(1));
if (sv_derived_from(ST(0), "Client")) {
IV tmp = SvIV((SV *) SvRV(ST(0)));
THIS = INT2PTR(Client *, tmp);
} else
Perl_croak(aTHX_ "THIS is not of type Client");
if (THIS == nullptr)
Perl_croak(aTHX_ "THIS is nullptr, avoiding crash.");
if (THIS->IsClient()) {
THIS->MoveZoneInstanceRaid(instance_id);
} else {
if (THIS->IsMerc()) {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstanceRaid) attempted to process a type Merc reference");
}
#ifdef BOTS
else if (THIS->IsBot()) {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstanceRaid) attempted to process a type Bot reference");
}
#endif
else if (THIS->IsNPC()) {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstanceRaid) attempted to process a type NPC reference");
}
else {
LogDebug("[CLIENT] Perl(XS_Client_MoveZoneInstanceRaid) attempted to process an Unknown type reference");
}
Perl_croak(aTHX_ "THIS is not of type Client");
}
}
XSRETURN_EMPTY;
}
XS(XS_Client_ChangeLastName); /* prototype to pass -Wmissing-prototypes */ XS(XS_Client_ChangeLastName); /* prototype to pass -Wmissing-prototypes */
XS(XS_Client_ChangeLastName) { XS(XS_Client_ChangeLastName) {
dXSARGS; dXSARGS;
@ -6715,6 +6841,9 @@ XS(boot_Client) {
newXSproto(strcpy(buf, "MoveZone"), XS_Client_MoveZone, file, "$$"); newXSproto(strcpy(buf, "MoveZone"), XS_Client_MoveZone, file, "$$");
newXSproto(strcpy(buf, "MoveZoneGroup"), XS_Client_MoveZoneGroup, file, "$$"); newXSproto(strcpy(buf, "MoveZoneGroup"), XS_Client_MoveZoneGroup, file, "$$");
newXSproto(strcpy(buf, "MoveZoneRaid"), XS_Client_MoveZoneRaid, file, "$$"); newXSproto(strcpy(buf, "MoveZoneRaid"), XS_Client_MoveZoneRaid, file, "$$");
newXSproto(strcpy(buf, "MoveZoneInstance"), XS_Client_MoveZoneInstance, file, "$$");
newXSproto(strcpy(buf, "MoveZoneInstanceGroup"), XS_Client_MoveZoneInstanceGroup, file, "$$");
newXSproto(strcpy(buf, "MoveZoneInstanceRaid"), XS_Client_MoveZoneInstanceRaid, file, "$$");
newXSproto(strcpy(buf, "NPCSpawn"), XS_Client_NPCSpawn, file, "$$$;$"); newXSproto(strcpy(buf, "NPCSpawn"), XS_Client_NPCSpawn, file, "$$$;$");
newXSproto(strcpy(buf, "NukeItem"), XS_Client_NukeItem, file, "$$;$"); newXSproto(strcpy(buf, "NukeItem"), XS_Client_NukeItem, file, "$$;$");
newXSproto(strcpy(buf, "OpenLFGuildWindow"), XS_Client_OpenLFGuildWindow, file, "$"); newXSproto(strcpy(buf, "OpenLFGuildWindow"), XS_Client_OpenLFGuildWindow, file, "$");

View File

@ -461,6 +461,53 @@ void Client::MoveZoneRaid(const char *zone_short_name) {
} }
} }
void Client::MoveZoneInstance(uint16 instance_id) {
if (!database.CharacterInInstanceGroup(instance_id, CharacterID())) {
database.AddClientToInstance(instance_id, CharacterID());
}
auto pack = new ServerPacket(ServerOP_ZoneToZoneRequest, sizeof(ZoneToZone_Struct));
ZoneToZone_Struct* ztz = (ZoneToZone_Struct*) pack->pBuffer;
ztz->response = 0;
ztz->current_zone_id = zone->GetZoneID();
ztz->current_instance_id = zone->GetInstanceID();
ztz->requested_zone_id = database.ZoneIDFromInstanceID(instance_id);
ztz->requested_instance_id = instance_id;
ztz->admin = Admin();
strcpy(ztz->name, GetName());
ztz->guild_id = GuildID();
ztz->ignorerestrictions = 3;
worldserver.SendPacket(pack);
safe_delete(pack);
}
void Client::MoveZoneInstanceGroup(uint16 instance_id) {
if (!GetGroup()) {
MoveZoneInstance(instance_id);
} else {
auto client_group = GetGroup();
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
auto group_member = client_group->members[member_index]->CastToClient();
group_member->MoveZoneInstance(instance_id);
}
}
}
}
void Client::MoveZoneInstanceRaid(uint16 instance_id) {
if (!GetRaid()) {
MoveZoneInstance(instance_id);
} else {
auto client_raid = GetRaid();
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
auto raid_member = client_raid->members[member_index].member->CastToClient();
raid_member->MoveZoneInstance(instance_id);
}
}
}
}
void Client::ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions, ZoneMode zm) void Client::ProcessMovePC(uint32 zoneID, uint32 instance_id, float x, float y, float z, float heading, uint8 ignorerestrictions, ZoneMode zm)
{ {
// From what I have read, dragged corpses should stay with the player for Intra-zone summons etc, but we can implement that later. // From what I have read, dragged corpses should stay with the player for Intra-zone summons etc, but we can implement that later.