diff options
author | Haru <haru@dotalux.com> | 2018-01-14 15:20:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-14 15:20:45 +0100 |
commit | be6b748363717519019cd606d2013868ae6d9378 (patch) | |
tree | 9e1214545aa69a7806cc7bc7a7f1a284d1e6b779 /src | |
parent | 41c6f0bcfbad0de2c647dcc65af534c7f5e8fce3 (diff) | |
parent | ea8dbdb04470859abe00eabc39990ee23adb398e (diff) | |
download | hercules-be6b748363717519019cd606d2013868ae6d9378.tar.gz hercules-be6b748363717519019cd606d2013868ae6d9378.tar.bz2 hercules-be6b748363717519019cd606d2013868ae6d9378.tar.xz hercules-be6b748363717519019cd606d2013868ae6d9378.zip |
Merge pull request #1929 from Asheraf/progressbar
Add support for packet ZC_PROGRESS_ACTOR
Diffstat (limited to 'src')
-rw-r--r-- | src/map/clif.c | 26 | ||||
-rw-r--r-- | src/map/clif.h | 1 | ||||
-rw-r--r-- | src/map/packets_struct.h | 10 | ||||
-rw-r--r-- | src/map/script.c | 23 |
4 files changed, 59 insertions, 1 deletions
diff --git a/src/map/clif.c b/src/map/clif.c index 7edc1ec5a..3d125571d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9915,7 +9915,6 @@ void clif_parse_Hotkey(int fd, struct map_session_data *sd) { /// Displays cast-like progress bar (ZC_PROGRESS). /// 02f0 <color>.L <time>.L -/* TODO ZC_PROGRESS_ACTOR <account_id>.L */ void clif_progressbar(struct map_session_data * sd, unsigned int color, unsigned int second) { int fd; @@ -9944,6 +9943,30 @@ void clif_progressbar_abort(struct map_session_data * sd) WFIFOSET(fd,packet_len(0x2f2)); } +/** +* Displays cast-like progress bar on a unit. +* 09d1 <id>.L <color>.L <time>.L +* +* @param bl Source block list. +* @param color Message color (RGB format: 0xRRGGBB). +* @param time Time in seconds. +*/ +void clif_progressbar_unit(struct block_list *bl, uint32 color, uint32 time) +{ +#if PACKETVER >= 20130821 + struct ZC_PROGRESS_ACTOR p; + nullpo_retv(bl); + + p.PacketType = progressbarunit; + p.GID = bl->id; + p.color = color; + p.time = time; + clif->send(&p, sizeof(p), bl, AREA); +#else + ShowWarning("clif_progressbar_unit: Using progressbar with units available for PACKETVER >= 20130821 only."); +#endif +} + void clif_parse_progressbar(int fd, struct map_session_data * sd) __attribute__((nonnull (2))); /// Notification from the client, that the progress bar has reached 100% (CZ_PROGRESS). /// 02f1 @@ -20367,6 +20390,7 @@ void clif_defaults(void) { clif->font = clif_font; clif->progressbar = clif_progressbar; clif->progressbar_abort = clif_progressbar_abort; + clif->progressbar_unit = clif_progressbar_unit; clif->showdigit = clif_showdigit; clif->elementalconverter_list = clif_elementalconverter_list; clif->spellbook_list = clif_spellbook_list; diff --git a/src/map/clif.h b/src/map/clif.h index e348bbb08..69567cc2c 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -796,6 +796,7 @@ struct clif_interface { void (*font) (struct map_session_data *sd); void (*progressbar) (struct map_session_data * sd, unsigned int color, unsigned int second); void (*progressbar_abort) (struct map_session_data * sd); + void (*progressbar_unit) (struct block_list *bl, uint32 color, uint32 time); void (*showdigit) (struct map_session_data* sd, unsigned char type, int value); int (*elementalconverter_list) (struct map_session_data *sd); int (*spellbook_list) (struct map_session_data *sd); diff --git a/src/map/packets_struct.h b/src/map/packets_struct.h index e1395e949..e0d856986 100644 --- a/src/map/packets_struct.h +++ b/src/map/packets_struct.h @@ -333,6 +333,9 @@ enum packet_headers { #if PACKETVER >= 20151223 skillscale = 0xA41, #endif +#if PACKETVER >= 20130821 + progressbarunit = 0x09D1, +#endif }; #if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute @@ -1491,6 +1494,13 @@ struct PACKET_ZC_SKILL_SCALE { uint32 casttime; } __attribute__((packed)); +struct ZC_PROGRESS_ACTOR { + int16 PacketType; + int32 GID; + int32 color; + uint32 time; +} __attribute__((packed)); + #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 7f7aba183..44a819ec5 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21570,7 +21570,29 @@ BUILDIN(progressbar) clif->progressbar(sd, (unsigned int)strtoul(color, (char **)NULL, 0), second); return true; } +BUILDIN(progressbar_unit) +{ + const char *color = script_getstr(st, 2); + uint32 second = script_getnum(st, 3); + + if (script_hasdata(st, 4)) { + struct block_list *bl = map->id2bl(script_getnum(st, 4)); + if (bl == NULL) { + ShowWarning("buildin_progressbar_unit: Error in finding object with given GID %d!\n", script_getnum(st, 4)); + return true; + } + clif->progressbar_unit(bl, (unsigned int)strtoul(color, (char **)NULL, 0), second); + } else { + struct map_session_data *sd = script->rid2sd(st); + + if (sd == NULL) + return false; + + clif->progressbar_unit(&sd->bl, (unsigned int)strtoul(color, (char **)NULL, 0), second); + } + return true; +} BUILDIN(pushpc) { uint8 dir; @@ -24405,6 +24427,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(setfont,"i"), BUILDIN_DEF(areamobuseskill,"siiiiviiiii"), BUILDIN_DEF(progressbar,"si"), + BUILDIN_DEF(progressbar_unit,"si?"), BUILDIN_DEF(pushpc,"ii"), BUILDIN_DEF(buyingstore,"i"), BUILDIN_DEF(searchstores,"ii"), |