summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsheraf <acheraf1998@gmail.com>2019-08-10 12:05:02 +0100
committerHaru <haru@dotalux.com>2019-09-22 20:00:36 +0200
commit3cbec0a83b20c88ceb7c68fea532b79260c583a8 (patch)
tree2811ec6f8206468a5905c1c46615136566e701b9
parentf7da0d838ee8a60cf449bbe4add04262958a839a (diff)
downloadhercules-3cbec0a83b20c88ceb7c68fea532b79260c583a8.tar.gz
hercules-3cbec0a83b20c88ceb7c68fea532b79260c583a8.tar.bz2
hercules-3cbec0a83b20c88ceb7c68fea532b79260c583a8.tar.xz
hercules-3cbec0a83b20c88ceb7c68fea532b79260c583a8.zip
Implementation of new guild ui client features
-rw-r--r--db/castle_db.conf202
-rw-r--r--sql-files/upgrades/2019-08-08--19-43.sql2
-rw-r--r--src/common/mmo.h8
-rw-r--r--src/map/clif.c126
-rw-r--r--src/map/clif.h12
-rw-r--r--src/map/guild.c52
-rw-r--r--src/map/guild.h1
-rw-r--r--src/map/packets.h5
-rw-r--r--src/map/packets_struct.h43
-rw-r--r--src/map/script.c5
-rw-r--r--src/map/script.h10
11 files changed, 464 insertions, 2 deletions
diff --git a/db/castle_db.conf b/db/castle_db.conf
index 0e37d50a9..c50d04c48 100644
--- a/db/castle_db.conf
+++ b/db/castle_db.conf
@@ -39,6 +39,14 @@ castle_db: (
CastleName: (string) Name of the castle (used by scripts and guardian name tags)
OnGuildBreakEventName: (string) NPC unique name to invoke ::OnGuildBreak on, when a occupied
castle is abandoned during guild break.
+ // ================ Optional fields ===============================
+ SiegeType: (string, default to SIEGE_TYPE_FE) define siege type
+ EnableClientWarp: (bool, default to false) enable or disable client teleport features
+ ClientWarp: {
+ Position: (int, int) x, y position of warp request
+ ZenyCost: (int) The zeny cost of warp
+ ZenyCostSiegeTime: (int) The zeny cost of warp durring woe
+ }
},
**************************************************************************/
//================
@@ -49,30 +57,60 @@ castle_db: (
MapName: "prtg_cas01"
CastleName: "Kriemhild" // kRO : Creamhilt
OnGuildBreakEventName: "Agit#prtg_cas01"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (107, 180)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 2
MapName: "prtg_cas02"
CastleName: "Swanhild" // kRO : Sbanhealt
OnGuildBreakEventName: "Agit#prtg_cas02"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (94, 56)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 3
MapName: "prtg_cas03"
CastleName: "Fadhgridh" // kRO : Lazrigees
OnGuildBreakEventName: "Agit#prtg_cas03"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (46, 97)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 4
MapName: "prtg_cas04"
CastleName: "Skoegul" // kRO : Squagul
OnGuildBreakEventName: "Agit#prtg_cas04"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (260, 262)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 5
MapName: "prtg_cas05"
CastleName: "Gondul" // kRO : Guindull
OnGuildBreakEventName: "Agit#prtg_cas05"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (26, 38)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
//================
// Al De Baran
@@ -82,30 +120,60 @@ castle_db: (
MapName: "aldeg_cas01"
CastleName: "Neuschwanstein" // kRO : Noisyubantian
OnGuildBreakEventName: "Agit#aldeg_cas01"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (212, 175)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 7
MapName: "aldeg_cas02"
CastleName: "Hohenschwangau" // kRO : Hohensyubangawoo
OnGuildBreakEventName: "Agit#aldeg_cas02"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (82, 71)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 8
MapName: "aldeg_cas03"
CastleName: "Nuernberg" // kRO : Nyirenverk
OnGuildBreakEventName: "Agit#aldeg_cas03"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (109, 112)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 9
MapName: "aldeg_cas04"
CastleName: "Wuerzburg" // kRO : Byirtsburi
OnGuildBreakEventName: "Agit#aldeg_cas04"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (60, 116)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 10
MapName: "aldeg_cas05"
CastleName: "Rothenburg" // kRO : Rotenburk
OnGuildBreakEventName: "Agit#aldeg_cas05"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (61, 185)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
//================
// Geffen
@@ -115,30 +183,60 @@ castle_db: (
MapName: "gefg_cas01"
CastleName: "Repherion" // kRO : Reprion
OnGuildBreakEventName: "Agit#gefg_cas01"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (40, 43)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 12
MapName: "gefg_cas02"
CastleName: "Eeyolbriggar" // kRO : Yolbriger
OnGuildBreakEventName: "Agit#gefg_cas02"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (22, 66)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 13
MapName: "gefg_cas03"
CastleName: "Yesnelph" // kRO : Isinlife
OnGuildBreakEventName: "Agit#gefg_cas03"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (112, 23)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 14
MapName: "gefg_cas04"
CastleName: "Bergel" // kRO : Berigel
OnGuildBreakEventName: "Agit#gefg_cas04"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (58, 46)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 15
MapName: "gefg_cas05"
CastleName: "Mersetzdeitz" // kRO : Melsedetsu
OnGuildBreakEventName: "Agit#gefg_cas05"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (66, 48)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
//================
// Payon
@@ -148,30 +246,60 @@ castle_db: (
MapName: "payg_cas01"
CastleName: "Bright Arbor" // kRO : Mingting
OnGuildBreakEventName: "Agit#payg_cas01"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (115, 57)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 17
MapName: "payg_cas02"
CastleName: "Scarlet Palace" // kRO : Tiantan
OnGuildBreakEventName: "Agit#payg_cas02"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (26, 265)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 18
MapName: "payg_cas03"
CastleName: "Holy Shadow" // kRO : Fuying
OnGuildBreakEventName: "Agit#payg_cas03"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (43, 264)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 19
MapName: "payg_cas04"
CastleName: "Sacred Altar" // kRO : Honglou
OnGuildBreakEventName: "Agit#payg_cas04"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (36, 272)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 20
MapName: "payg_cas05"
CastleName: "Bamboo Grove Hill" // kRO : Zhulinxian
OnGuildBreakEventName: "Agit#payg_cas05"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (274, 246)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
//================
// Rachel
@@ -181,30 +309,65 @@ castle_db: (
MapName: "arug_cas01"
CastleName: "Mardol" // kRO : Mardol
OnGuildBreakEventName: "Manager#arug_cas01"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (77, 371)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 22
MapName: "arug_cas02"
CastleName: "Cyr" // kRO : Cyr
OnGuildBreakEventName: "Manager#arug_cas02"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (301, 332)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 23
MapName: "arug_cas03"
CastleName: "Horn" // kRO : Horn
OnGuildBreakEventName: "Manager#arug_cas03"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (322, 91)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 24
MapName: "arug_cas04"
CastleName: "Gefn" // kRO : Gefn
OnGuildBreakEventName: "Manager#arug_cas04"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (322, 91)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 25
MapName: "arug_cas05"
CastleName: "Bandis" // kRO : Bandis
OnGuildBreakEventName: "Manager#arug_cas05"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (322, 91)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
//================
// Yuno
@@ -214,30 +377,65 @@ castle_db: (
MapName: "schg_cas01"
CastleName: "Himinn" // kRO : Himinn
OnGuildBreakEventName: "Manager#schg_cas01"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (233, 300)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 27
MapName: "schg_cas02"
CastleName: "Andlangr" // kRO : Andlangr
OnGuildBreakEventName: "Manager#schg_cas02"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (101, 372)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 28
MapName: "schg_cas03"
CastleName: "Viblainn" // kRO : Viblainn
OnGuildBreakEventName: "Manager#schg_cas03"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (81, 94)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 29
MapName: "schg_cas04"
CastleName: "Hljod" // kRO : Hljod
OnGuildBreakEventName: "Manager#schg_cas04"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (233, 300)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
{
CastleID: 30
MapName: "schg_cas05"
CastleName: "Skidbladnir" // kRO : Skidbladnir
OnGuildBreakEventName: "Manager#schg_cas05"
+ SiegeType: "SIEGE_TYPE_SE"
+ EnableClientWarp: true
+ ClientWarp: {
+ Position: (233, 300)
+ ZenyCost: 100
+ ZenyCostSiegeTime: 100000
+ }
},
//================
// Novice Guilds
@@ -247,23 +445,27 @@ castle_db: (
MapName: "nguild_prt"
CastleName: "Fire"
OnGuildBreakEventName: "Agit_N04"
+ SiegeType: "SIEGE_TYPE_TE"
},
{
CastleID: 32
MapName: "nguild_alde"
CastleName: "Earth"
OnGuildBreakEventName: "Agit_N01"
+ SiegeType: "SIEGE_TYPE_TE"
},
{
CastleID: 33
MapName: "nguild_gef"
CastleName: "Air"
OnGuildBreakEventName: "Agit_N02"
+ SiegeType: "SIEGE_TYPE_TE"
},
{
CastleID: 34
MapName: "nguild_pay"
CastleName: "Water"
OnGuildBreakEventName: "Agit_N03"
+ SiegeType: "SIEGE_TYPE_TE"
},
)
diff --git a/sql-files/upgrades/2019-08-08--19-43.sql b/sql-files/upgrades/2019-08-08--19-43.sql
index 8105cb967..35faf4ace 100644
--- a/sql-files/upgrades/2019-08-08--19-43.sql
+++ b/sql-files/upgrades/2019-08-08--19-43.sql
@@ -91,5 +91,5 @@ UPDATE `guild_castle` SET `castle_id` = 32 WHERE castle_name = 'nguild_alde';
UPDATE `guild_castle` SET `castle_id` = 33 WHERE castle_name = 'nguild_gef';
UPDATE `guild_castle` SET `castle_id` = 34 WHERE castle_name = 'nguild_pay';
ALTER TABLE `guild_castle` ADD PRIMARY KEY (`castle_id`);
-ALTER TABLE "guild_castle" DROP COLUMN "castle_name";
+ALTER TABLE `guild_castle` DROP COLUMN `castle_name`;
INSERT INTO `sql_updates` (`timestamp`) VALUES (1565293394);
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 1fa6fadc8..66736bff0 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -907,6 +907,14 @@ struct guild_castle {
int mapindex;
char castle_name[NAME_LENGTH];
char castle_event[NAME_LENGTH];
+ int siege_type;
+ bool enable_client_warp;
+ struct {
+ int x;
+ int y;
+ int zeny;
+ int zeny_siege;
+ } client_warp;
int guild_id;
int economy;
int defense;
diff --git a/src/map/clif.c b/src/map/clif.c
index c7f81a471..33c003321 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -8106,6 +8106,54 @@ static void clif_guild_allianceinfo(struct map_session_data *sd)
WFIFOSET(fd,WFIFOW(fd,2));
}
+static void clif_guild_castlelist(struct map_session_data *sd)
+{
+#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190717 || PACKETVER_ZERO_NUM >= 20190814
+ nullpo_retv(sd);
+
+ struct guild *g = sd->guild;
+ if (g == NULL)
+ return;
+
+ int castle_count = guild->checkcastles(g);
+ if (castle_count > 0) {
+ int len = sizeof(struct PACKET_ZC_GUILD_CASTLE_LIST) + castle_count;
+ struct PACKET_ZC_GUILD_CASTLE_LIST *p = aMalloc(len);
+ p->packetType = HEADER_ZC_GUILD_CASTLE_LIST;
+ p->packetLength = len;
+
+ int i = 0;
+ struct DBIterator *iter = db_iterator(guild->castle_db);
+ for (struct guild_castle *gc = dbi_first(iter); dbi_exists(iter); gc = dbi_next(iter)) {
+ if (gc->guild_id == g->guild_id) {
+ p->castle_list[i] = gc->castle_id;
+ ++i;
+ }
+ }
+ dbi_destroy(iter);
+
+ clif->send(p, len, &sd->bl, SELF);
+ aFree(p);
+ }
+#endif
+}
+
+static void clif_guild_castleinfo(struct map_session_data *sd, struct guild_castle *gc)
+{
+#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190717 || PACKETVER_ZERO_NUM >= 20190814
+
+ nullpo_retv(sd);
+ nullpo_retv(gc);
+
+ struct PACKET_ZC_CASTLE_INFO p = { 0 };
+ p.packetType = HEADER_ZC_CASTLE_INFO;
+ p.castle_id = gc->castle_id;
+ p.economy = gc->economy;
+ p.defense = gc->defense;
+ clif->send(&p, sizeof(p), &sd->bl, SELF);
+#endif
+}
+
/// Guild member manager information (ZC_MEMBERMGR_INFO).
/// 0154 <packet len>.W { <account>.L <char id>.L <hair style>.W <hair color>.W <gender>.W <class>.W <level>.W <contrib exp>.L <state>.L <position>.L <memo>.50B <name>.24B }*
/// state:
@@ -14407,6 +14455,7 @@ static void clif_parse_GuildRequestInfo(int fd, struct map_session_data *sd)
case 0: // Basic Information Guild, hostile alliance information
clif->guild_basicinfo(sd);
clif->guild_allianceinfo(sd);
+ clif->guild_castlelist(sd);
break;
case 1: // Members list, list job title
clif->guild_positionnamelist(sd);
@@ -23211,6 +23260,78 @@ static void clif_announce_refine_status(struct map_session_data *sd, int item_id
#endif
}
+static void clif_parse_GuildCastleTeleportRequest(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
+static void clif_parse_GuildCastleTeleportRequest(int fd, struct map_session_data *sd)
+{
+#if PACKETVER_MAIN_NUM >= 20190522 || PACKETVER_RE_NUM >= 20190522 || PACKETVER_ZERO_NUM >= 20190515
+ const struct PACKET_CZ_CASTLE_TELEPORT_REQUEST *p = RFIFO2PTR(fd);
+ struct guild *g = sd->guild;
+
+ if (g == NULL)
+ return;
+
+ struct guild_castle *gc = guild->castle_search(p->castle_id);
+ if (gc == NULL)
+ return;
+ if (gc->enable_client_warp == false)
+ return;
+ if (gc->guild_id != g->guild_id)
+ return;
+
+ if (map->list[sd->bl.m].flag.gvg_castle == 1)
+ return;
+
+ int zeny = gc->client_warp.zeny;
+ if (gc->siege_type == SIEGE_TYPE_FE && map->agit_flag == 1) {
+ zeny = gc->client_warp.zeny_siege;
+ } else if (gc->siege_type == SIEGE_TYPE_SE && map->agit2_flag == 1) {
+ zeny = gc->client_warp.zeny_siege;
+ } else if (gc->siege_type == SIEGE_TYPE_TE) {
+ clif->guild_castleteleport_res(sd, SIEGE_TP_INVALID_MODE);
+ return;
+ }
+
+ if (sd->status.zeny < zeny) {
+ clif->guild_castleteleport_res(sd, SIEGE_TP_NOT_ENOUGH_ZENY);
+ return;
+ }
+ sd->status.zeny -= zeny;
+ clif->updatestatus(sd, SP_ZENY);
+ pc->setpos(sd, gc->mapindex, gc->client_warp.x, gc->client_warp.y, CLR_OUTSIGHT);
+#endif
+}
+
+static void clif_guild_castleteleport_res(struct map_session_data *sd, enum siege_teleport_result result)
+{
+#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190717 || PACKETVER_ZERO_NUM >= 20190814
+
+ nullpo_retv(sd);
+
+ struct PACKET_ZC_CASTLE_TELEPORT_RESPONSE p = { 0 };
+ p.packetType = HEADER_ZC_CASTLE_TELEPORT_RESPONSE;
+ p.result = (int16)result;
+ clif->send(&p, sizeof(p), &sd->bl, SELF);
+#endif
+}
+static void clif_parse_GuildCastleInfoRequest(int fd, struct map_session_data *sd) __attribute__((nonnull(2)));
+static void clif_parse_GuildCastleInfoRequest(int fd, struct map_session_data *sd)
+{
+#if PACKETVER_MAIN_NUM >= 20190522 || PACKETVER_RE_NUM >= 20190522 || PACKETVER_ZERO_NUM >= 20190515
+ const struct PACKET_CZ_CASTLE_INFO_REQUEST *p = RFIFO2PTR(fd);
+ struct guild *g = sd->guild;
+
+ if (g == NULL)
+ return;
+
+ struct guild_castle *gc = guild->castle_search(p->castle_id);
+ if (gc == NULL)
+ return;
+ if (gc->guild_id != g->guild_id)
+ return;
+ clif->guild_castleinfo(sd, gc);
+#endif
+}
+
/*==========================================
* Main client packet processing function
*------------------------------------------*/
@@ -23895,6 +24016,8 @@ void clif_defaults(void)
clif->guild_masterormember = clif_guild_masterormember;
clif->guild_basicinfo = clif_guild_basicinfo;
clif->guild_allianceinfo = clif_guild_allianceinfo;
+ clif->guild_castlelist = clif_guild_castlelist;
+ clif->guild_castleinfo = clif_guild_castleinfo;
clif->guild_memberlist = clif_guild_memberlist;
clif->guild_skillinfo = clif_guild_skillinfo;
clif->guild_send_onlineinfo = clif_guild_send_onlineinfo;
@@ -24436,4 +24559,7 @@ void clif_defaults(void)
clif->pRefineryUIClose = clif_parse_RefineryUIClose;
clif->pRefineryUIRefine = clif_parse_RefineryUIRefine;
clif->announce_refine_status = clif_announce_refine_status;
+ clif->pGuildCastleTeleportRequest = clif_parse_GuildCastleTeleportRequest;
+ clif->pGuildCastleInfoRequest = clif_parse_GuildCastleInfoRequest;
+ clif->guild_castleteleport_res = clif_guild_castleteleport_res;
}
diff --git a/src/map/clif.h b/src/map/clif.h
index f3d7c78eb..245352b9c 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -633,6 +633,13 @@ enum inventory_type {
INVTYPE_GUILD_STORAGE = 3,
};
+/** Guild Teleport Results */
+enum siege_teleport_result {
+ SIEGE_TP_SUCCESS = 0x0,
+ SIEGE_TP_NOT_ENOUGH_ZENY = 0x1,
+ SIEGE_TP_INVALID_MODE = 0x2
+};
+
/**
* Structures
**/
@@ -1114,6 +1121,8 @@ struct clif_interface {
void (*guild_masterormember) (struct map_session_data *sd);
void (*guild_basicinfo) (struct map_session_data *sd);
void (*guild_allianceinfo) (struct map_session_data *sd);
+ void (*guild_castlelist) (struct map_session_data *sd);
+ void (*guild_castleinfo) (struct map_session_data *sd, struct guild_castle *gc);
void (*guild_memberlist) (struct map_session_data *sd);
void (*guild_skillinfo) (struct map_session_data* sd);
void (*guild_send_onlineinfo) (struct map_session_data *sd); //[LuzZza]
@@ -1647,6 +1656,9 @@ struct clif_interface {
void (*pRefineryUIClose) (int fd, struct map_session_data *sd);
void (*pRefineryUIRefine) (int fd, struct map_session_data *sd);
void (*announce_refine_status) (struct map_session_data *sd, int item_id, int refine_level, bool success, enum send_target target);
+ void (*pGuildCastleTeleportRequest) (int fd, struct map_session_data *sd);
+ void (*pGuildCastleInfoRequest) (int fd, struct map_session_data *sd);
+ void (*guild_castleteleport_res) (struct map_session_data *sd, enum siege_teleport_result result);
};
#ifdef HERCULES_CORE
diff --git a/src/map/guild.c b/src/map/guild.c
index 415a46db5..3191515f7 100644
--- a/src/map/guild.c
+++ b/src/map/guild.c
@@ -169,7 +169,7 @@ static bool guild_read_castledb_libconfig(void)
}
libconfig->destroy(&castle_conf);
- ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, config_filename);
+ ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", db_size(guild->castle_db), config_filename);
return true;
}
@@ -217,10 +217,59 @@ static bool guild_read_castledb_libconfig_sub(struct config_setting_t *it, int i
}
safestrncpy(gc->castle_event, name, sizeof(gc->castle_event));
+ if (itemdb->lookup_const(it, "SiegeType", &i32) && (i32 >= SIEGE_TYPE_MAX || i32 < 0)) {
+ ShowWarning("guild_read_castledb_libconfig_sub: Invalid SiegeType in \"%s\", entry #%d, defaulting to SIEGE_TYPE_FE.\n", source, idx);
+ gc->siege_type = SIEGE_TYPE_FE;
+ } else {
+ gc->siege_type = i32;
+ }
+
+ libconfig->setting_lookup_bool_real(it, "EnableClientWarp", &gc->enable_client_warp);
+ if (gc->enable_client_warp == true) {
+ struct config_setting_t *wd = libconfig->setting_get_member(it, "ClientWarp");
+ guild->read_castledb_libconfig_sub_warp(wd, source, gc);
+ }
idb_put(guild->castle_db, gc->castle_id, gc);
return true;
}
+static bool guild_read_castledb_libconfig_sub_warp(struct config_setting_t *wd, const char *source, struct guild_castle *gc)
+{
+ nullpo_retr(false, wd);
+ nullpo_retr(false, gc);
+ nullpo_retr(false, source);
+
+ int64 i64 = 0;
+ struct config_setting_t *it = libconfig->setting_get_member(wd, "Position");
+ if (config_setting_is_list(it)) {
+ int m = map->mapindex2mapid(gc->mapindex);
+
+ gc->client_warp.x = libconfig->setting_get_int_elem(it, 0);
+ gc->client_warp.y = libconfig->setting_get_int_elem(it, 1);
+ if (gc->client_warp.x < 0 || gc->client_warp.x >= map->list[m].xs || gc->client_warp.y < 0 || gc->client_warp.y >= map->list[m].ys) {
+ ShowWarning("guild_read_castledb_libconfig_sub_warp: Invalid Position in \"%s\", for castle (%d).\n", source, gc->castle_id);
+ return false;
+ }
+ } else {
+ ShowWarning("guild_read_castledb_libconfig_sub_warp: Invalid format for Position in \"%s\", for castle (%d).\n", source, gc->castle_id);
+ return false;
+ }
+
+ if (libconfig->setting_lookup_int64(wd, "ZenyCost", &i64)) {
+ if (i64 > MAX_ZENY) {
+ ShowWarning("guild_read_castledb_libconfig_sub_warp: ZenyCost is too big in \"%s\", for castle (%d), capping to MAX_ZENY.\n", source, gc->castle_id);
+ }
+ gc->client_warp.zeny = cap_value((int)i64, 0, MAX_ZENY);
+ }
+ if (libconfig->setting_lookup_int64(wd, "ZenyCostSiegeTime", &i64)) {
+ if (i64 > MAX_ZENY) {
+ ShowWarning("guild_read_castledb_libconfig_sub_warp: ZenyCostSiegeTime is too big in \"%s\", for castle (%d), capping to MAX_ZENY.\n", source, gc->castle_id);
+ }
+ gc->client_warp.zeny_siege = cap_value((int)i64, 0, MAX_ZENY);
+ }
+ return true;
+}
+
/// lookup: guild id -> guild*
static struct guild *guild_search(int guild_id)
{
@@ -2497,6 +2546,7 @@ void guild_defaults(void)
guild->read_guildskill_tree_db = guild_read_guildskill_tree_db;
guild->read_castledb_libconfig = guild_read_castledb_libconfig;
guild->read_castledb_libconfig_sub = guild_read_castledb_libconfig_sub;
+ guild->read_castledb_libconfig_sub_warp = guild_read_castledb_libconfig_sub_warp;
guild->payexp_timer_sub = guild_payexp_timer_sub;
guild->send_xy_timer_sub = guild_send_xy_timer_sub;
guild->send_xy_timer = guild_send_xy_timer;
diff --git a/src/map/guild.h b/src/map/guild.h
index d0374103f..41f52711d 100644
--- a/src/map/guild.h
+++ b/src/map/guild.h
@@ -166,6 +166,7 @@ struct guild_interface {
bool (*read_guildskill_tree_db) (char* split[], int columns, int current);
bool (*read_castledb_libconfig) (void);
bool (*read_castledb_libconfig_sub) (struct config_setting_t *it, int idx, const char *source);
+ bool (*read_castledb_libconfig_sub_warp) (struct config_setting_t *wd, const char *source, struct guild_castle *gc);
int (*payexp_timer_sub) (union DBKey key, struct DBData *data, va_list ap);
int (*send_xy_timer_sub) (union DBKey key, struct DBData *data, va_list ap);
int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data);
diff --git a/src/map/packets.h b/src/map/packets.h
index 83a9d0322..e91421cfc 100644
--- a/src/map/packets.h
+++ b/src/map/packets.h
@@ -1954,4 +1954,9 @@ packet(0x96e,clif->ackmergeitems);
packet(0x0b22,clif->pHotkeyRowShift2); // CZ_SHORTCUTKEYBAR_ROTATE
#endif
+#if PACKETVER_MAIN_NUM >= 20190522 || PACKETVER_RE_NUM >= 20190522 || PACKETVER_ZERO_NUM >= 20190515
+ packet(0x0b28,clif->pGuildCastleTeleportRequest);
+ packet(0x0b2c,clif->pGuildCastleInfoRequest);
+#endif
+
#endif /* MAP_PACKETS_H */
diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h
index 93b4abcca..24bb718da 100644
--- a/src/map/packets_struct.h
+++ b/src/map/packets_struct.h
@@ -3626,6 +3626,49 @@ struct PACKET_ZC_TALKBOX_CHATCONTENTS {
} __attribute__((packed));
DEFINE_PACKET_HEADER(ZC_TALKBOX_CHATCONTENTS, 0x0191);
+#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190717 || PACKETVER_ZERO_NUM >= 20190814
+struct PACKET_ZC_GUILD_CASTLE_LIST {
+ int16 packetType;
+ int16 packetLength;
+ int8 castle_list[];
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(ZC_GUILD_CASTLE_LIST, 0x0b27);
+#endif
+
+#if PACKETVER_MAIN_NUM >= 20190522 || PACKETVER_RE_NUM >= 20190522 || PACKETVER_ZERO_NUM >= 20190515
+struct PACKET_CZ_CASTLE_TELEPORT_REQUEST {
+ int16 packetType;
+ int8 castle_id;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(CZ_CASTLE_TELEPORT_REQUEST, 0x0b28);
+#endif
+
+#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190717 || PACKETVER_ZERO_NUM >= 20190814
+struct PACKET_ZC_CASTLE_TELEPORT_RESPONSE {
+ int16 packetType;
+ int16 result;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(ZC_CASTLE_TELEPORT_RESPONSE, 0x0b2e);
+#endif
+
+#if PACKETVER_MAIN_NUM >= 20190731 || PACKETVER_RE_NUM >= 20190717 || PACKETVER_ZERO_NUM >= 20190814
+struct PACKET_ZC_CASTLE_INFO {
+ int16 packetType;
+ int8 castle_id;
+ int32 economy;
+ int32 defense;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(ZC_CASTLE_INFO, 0x0b2d);
+#endif
+
+#if PACKETVER_MAIN_NUM >= 20190522 || PACKETVER_RE_NUM >= 20190522 || PACKETVER_ZERO_NUM >= 20190515
+struct PACKET_CZ_CASTLE_INFO_REQUEST {
+ int16 packetType;
+ int8 castle_id;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(CZ_CASTLE_INFO_REQUEST, 0x0b2c);
+#endif
+
#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
#pragma pack(pop)
#endif // not NetBSD < 6 / Solaris
diff --git a/src/map/script.c b/src/map/script.c
index 4fc47e039..e88e8da0f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -27078,6 +27078,11 @@ static void script_hardcoded_constants(void)
script->set_constant("GUILD_ONLINE_VENDOR", GUILD_ONLINE_VENDOR, false, false);
script->set_constant("GUILD_ONLINE_NO_VENDOR", GUILD_ONLINE_NO_VENDOR, false, false);
+ script->constdb_comment("Siege Types");
+ script->set_constant("SIEGE_TYPE_FE", SIEGE_TYPE_FE, false, false);
+ script->set_constant("SIEGE_TYPE_SE", SIEGE_TYPE_SE, false, false);
+ script->set_constant("SIEGE_TYPE_TE", SIEGE_TYPE_TE, false, false);
+
script->constdb_comment("Renewal");
#ifdef RENEWAL
script->set_constant("RENEWAL", 1, false, false);
diff --git a/src/map/script.h b/src/map/script.h
index 5dc480a15..64e709a27 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -542,6 +542,16 @@ enum pcblock_action_flag {
};
/**
+ * Types of Siege (WoE)
+ */
+enum siege_type {
+ SIEGE_TYPE_FE,
+ SIEGE_TYPE_SE,
+ SIEGE_TYPE_TE,
+ SIEGE_TYPE_MAX
+};
+
+/**
* Structures
**/