浏览代码

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 年之前
父节点
当前提交
7bdf67e3d3
共有 2 个文件被更改,包括 10 次插入5 次删除
  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
 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

+ 10 - 2
src/map/script.cpp

@@ -21014,6 +21014,7 @@ BUILDIN_FUNC(progressbar)
  * progressbar_npc "<color>",<seconds>{,<"NPC Name">};
  */
 BUILDIN_FUNC(progressbar_npc){
+	map_session_data *sd = map_id2sd(st->rid);
 	struct npc_data* nd = NULL;
 
 	if( script_hasdata(st, 4) ){
@@ -21042,8 +21043,10 @@ BUILDIN_FUNC(progressbar_npc){
 			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
 		st->state = RERUNLINE;
@@ -21055,6 +21058,11 @@ BUILDIN_FUNC(progressbar_npc){
 	// Second call(by timer after sleeping time is over)
 	} else {
 		// 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->sleep.tick = 0;
 		nd->progressbar.timeout = nd->progressbar.color = 0;