diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 8a6feb8d18..b7408cb8e1 100644 --- a/doc/script_commands.txt +++ b/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 diff --git a/src/map/script.cpp b/src/map/script.cpp index 25c607fff2..8e5678566a 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -21014,6 +21014,7 @@ BUILDIN_FUNC(progressbar) * progressbar_npc "",{,<"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;