From 70e8518a32b7a5e97bdca450a370a9b9deee235d Mon Sep 17 00:00:00 2001 From: AoShinHo <126742159+AoShinRO@users.noreply.github.com> Date: Sat, 14 Sep 2024 14:26:49 -0300 Subject: [PATCH] Implemented /resetcooltime (#8613) Co-authored-by: Lemongrass3110 --- conf/atcommands.yml | 5 +++++ conf/msg_conf/map_msg.conf | 1 + doc/atcommands.txt | 5 +++++ src/map/atcommand.cpp | 46 ++++++++++++++++++++++++++++++++++++++ src/map/clif.cpp | 13 +++++++++++ src/map/clif_packetdb.hpp | 5 ++--- 6 files changed, 72 insertions(+), 3 deletions(-) diff --git a/conf/atcommands.yml b/conf/atcommands.yml index b034d35c9c..c9f68d80ab 100644 --- a/conf/atcommands.yml +++ b/conf/atcommands.yml @@ -1032,6 +1032,11 @@ Body: - Command: setcard Help: | Adds a card or enchant to the specific slot of the equipment. + - Command: resetcooltime + Aliases: + - resetcooldown + Help: | + Resets the cooldown of all skills of the player and if active also of the homunculus or the mercenary. Footer: Imports: diff --git a/conf/msg_conf/map_msg.conf b/conf/msg_conf/map_msg.conf index e09f88b15d..7968680bd3 100644 --- a/conf/msg_conf/map_msg.conf +++ b/conf/msg_conf/map_msg.conf @@ -1824,6 +1824,7 @@ 1535: %d items are transferred (%d skipped)! 1536: Log configuration has been reloaded. +1537: Found skill '%s', unblocking... //Custom translations import: conf/msg_conf/import/map_msg_eng_conf.txt diff --git a/doc/atcommands.txt b/doc/atcommands.txt index 077c630735..2f2abcc5d1 100644 --- a/doc/atcommands.txt +++ b/doc/atcommands.txt @@ -1250,6 +1250,11 @@ Adds a card or enchant to the specific slot of the equipment. --------------------------------------- +@resetcooltime +/resetcooltime + +Resets the cooldown of all skills of the player and if active also of the homunculus or the mercenary. + ============================== | 5. Administrative Commands | ============================== diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 4f18c3bb16..b121a967e6 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -1150,6 +1150,51 @@ ACMD_FUNC(hide) return 0; } +ACMD_FUNC(resetcooltime) +{ + nullpo_retr(-1, sd); + + for( size_t i = 0; i < ARRAYLENGTH( sd->scd ); i++ ){ + if( sd->scd[i] != nullptr ) { + sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( sd->scd[i]->skill_id )->name ); // Found skill '%s', unblocking... + clif_displaymessage( sd->fd, atcmd_output ); + + if (battle_config.display_status_timers) + clif_skill_cooldown( *sd, sd->scd[i]->skill_id, 0 ); + + delete_timer(sd->scd[i]->timer, skill_blockpc_end); + aFree(sd->scd[i]); + sd->scd[i] = nullptr; + } + } + + if( sd->hd != nullptr && hom_is_active( sd->hd ) ){ + for( const uint16& skill_id : sd->hd->blockskill ){ + sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( skill_id )->name ); // Found skill '%s', unblocking... + clif_displaymessage( sd->fd, atcmd_output ); + + if (battle_config.display_status_timers) + clif_skill_cooldown( *sd, skill_id, 0 ); + } + + sd->hd->blockskill.clear(); + } + + if( sd->md != nullptr ){ + for( const uint16& skill_id : sd->md->blockskill ){ + sprintf( atcmd_output, msg_txt( sd, 1537 ), skill_db.find( skill_id )->name ); // Found skill '%s', unblocking... + clif_displaymessage( sd->fd, atcmd_output ); + + if (battle_config.display_status_timers) + clif_skill_cooldown( *sd, skill_id, 0 ); + } + + sd->md->blockskill.clear(); + } + + return 0; +} + /*========================================== * Changes a character's class *------------------------------------------*/ @@ -11019,6 +11064,7 @@ void atcommand_basecommands(void) { ACMD_DEF(guildstorage), ACMD_DEF(option), ACMD_DEF(hide), // + /hide + ACMD_DEF(resetcooltime), // + /resetcooltime ACMD_DEFR(jobchange, ATCMD_NOCONSOLE), ACMD_DEF(kill), ACMD_DEF(alive), diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 88f9c5126c..92a3151a90 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -14752,6 +14752,19 @@ void clif_parse_GMHide(int fd, map_session_data *sd) { } +/// /resetcooltime +/// 0a88 (CZ_CMD_RESETCOOLTIME). +void clif_parse_gm_resetcooltime( int fd, map_session_data* sd ){ +#if PACKETVER_MAIN_NUM >= 20160622 || PACKETVER_RE_NUM >= 20160622 || defined(PACKETVER_ZERO) + const PACKET_CZ_CMD_RESETCOOLTIME* p = reinterpret_cast( RFIFOP( fd, 0 ) ); + char cmd[CHAT_SIZE_MAX]; + + safesnprintf(cmd,sizeof(cmd),"%cresetcooltime",atcommand_symbol); + is_atcommand(fd, sd, cmd, 1); +#endif +} + + /// Request to adjust player's manner points (CZ_REQ_GIVE_MANNER_POINT). /// 0149 .L .B .W /// type: diff --git a/src/map/clif_packetdb.hpp b/src/map/clif_packetdb.hpp index 438f4df507..2306c5b047 100644 --- a/src/map/clif_packetdb.hpp +++ b/src/map/clif_packetdb.hpp @@ -1938,9 +1938,8 @@ parseable_packet( HEADER_CZ_REQ_RANDOM_COMBINE_ITEM, -1, clif_parse_laphine_synthesis, 0 ); #endif -// 2016-06-22aRagexeRE -#if PACKETVER >= 20160622 - packet(0x0A84,94); +#if PACKETVER_MAIN_NUM >= 20160622 || PACKETVER_RE_NUM >= 20160622 || defined(PACKETVER_ZERO) + parseable_packet( HEADER_CZ_CMD_RESETCOOLTIME, sizeof( PACKET_CZ_CMD_RESETCOOLTIME ), clif_parse_gm_resetcooltime, 0 ); #endif // 2016-10-12aRagexeRE