Browse Source

Adjusted script command progressbar_npc behavior (#2381)

* Players are no longer detached from the script.
* Players can't walk, attack, use items, or use skills while progress bar is active.

Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Aleos 4 years ago
parent
commit
7bdf67e3d3
2 changed files with 10 additions and 5 deletions
  1. 0 3
      doc/script_commands.txt
  2. 10 2
      src/map/script.cpp

+ 0 - 3
doc/script_commands.txt

@@ -6864,9 +6864,6 @@ given amount of seconds passes, the script resumes. The color format
 is in RGB (RRGGBB). The color is currently ignored by the client and
 is in RGB (RRGGBB). The color is currently ignored by the client and
 appears always green.
 appears always green.
 
 
-Note: If a player is attached to the NPC, they are detached from the NPC
-as soon as the progress bar activates.
-
 ---------------------------------------
 ---------------------------------------
 //
 //
 5,1.- End of time-related commands
 5,1.- End of time-related commands

+ 10 - 2
src/map/script.cpp

@@ -21014,6 +21014,7 @@ BUILDIN_FUNC(progressbar)
  * progressbar_npc "<color>",<seconds>{,<"NPC Name">};
  * progressbar_npc "<color>",<seconds>{,<"NPC Name">};
  */
  */
 BUILDIN_FUNC(progressbar_npc){
 BUILDIN_FUNC(progressbar_npc){
+	map_session_data *sd = map_id2sd(st->rid);
 	struct npc_data* nd = NULL;
 	struct npc_data* nd = NULL;
 
 
 	if( script_hasdata(st, 4) ){
 	if( script_hasdata(st, 4) ){
@@ -21042,8 +21043,10 @@ BUILDIN_FUNC(progressbar_npc){
 			return SCRIPT_CMD_FAILURE;
 			return SCRIPT_CMD_FAILURE;
 		}
 		}
 
 
-		// detach the player
-		script_detach_rid(st);
+		if (sd) { // Player attached - keep them from doing other things
+			sd->state.workinprogress = WIP_DISABLE_ALL;
+			sd->state.block_action |= (PCBLOCK_MOVE | PCBLOCK_ATTACK | PCBLOCK_SKILL);
+		}
 
 
 		// sleep for the target amount of time
 		// sleep for the target amount of time
 		st->state = RERUNLINE;
 		st->state = RERUNLINE;
@@ -21055,6 +21058,11 @@ BUILDIN_FUNC(progressbar_npc){
 	// Second call(by timer after sleeping time is over)
 	// Second call(by timer after sleeping time is over)
 	} else {
 	} else {
 		// Continue the script
 		// Continue the script
+		if (sd) { // Player attached - remove restrictions
+			sd->state.workinprogress = WIP_DISABLE_NONE;
+			sd->state.block_action &= ~(PCBLOCK_MOVE | PCBLOCK_ATTACK | PCBLOCK_SKILL);
+		}
+
 		st->state = RUN;
 		st->state = RUN;
 		st->sleep.tick = 0;
 		st->sleep.tick = 0;
 		nd->progressbar.timeout = nd->progressbar.color = 0;
 		nd->progressbar.timeout = nd->progressbar.color = 0;