Browse Source

Implemented /resetcooltime (#8613)

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
AoShinHo 8 months ago
parent
commit
70e8518a32
6 changed files with 72 additions and 3 deletions
  1. 5 0
      conf/atcommands.yml
  2. 1 0
      conf/msg_conf/map_msg.conf
  3. 5 0
      doc/atcommands.txt
  4. 46 0
      src/map/atcommand.cpp
  5. 13 0
      src/map/clif.cpp
  6. 2 3
      src/map/clif_packetdb.hpp

+ 5 - 0
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:

+ 1 - 0
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

+ 5 - 0
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 |
 ==============================

+ 46 - 0
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),

+ 13 - 0
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<const PACKET_CZ_CMD_RESETCOOLTIME*>( 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 <account id>.L <type>.B <value>.W
 /// type:

+ 2 - 3
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