From 4539d557e2a1af824ba0cb176d16f649d1c074ab Mon Sep 17 00:00:00 2001 From: Aleos Date: Fri, 25 Aug 2017 13:26:22 -0400 Subject: [PATCH] Added script command sc_end_class (#2368) * Added a new script command sc_end_class to remove status changes from any learned skills. * Adjusted the custom Reset NPC to make use of this behavior. Thanks to @sader1992! * Follow up to f93680b * Adjusted documentation. * Follow up to f93680b * Removed the check from script command resetskill. * Added a new script command sc_end_class. * Fixed a compile error * Corrected the define of the script command. * Adjusted some documentation. * Reverted some formatting from the original commit. Thanks to @sader1992 and @Lemongrass3110! --- doc/script_commands.txt | 12 ++++++++---- npc/custom/resetnpc.txt | 9 ++------- src/map/script.c | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 6046c5a0ea..78cd0961d7 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -5316,10 +5316,11 @@ Used in reset NPC's (duh!) --------------------------------------- -*sc_start ,,{,,{,}}; -*sc_start2 ,,,{,,{,}}; -*sc_start4 ,,,,,{,,{,}}; -*sc_end {,}; +*sc_start ,,{,,{,}}; +*sc_start2 ,,,{,,{,}}; +*sc_start4 ,,,,,{,,{,}}; +*sc_end {,}; +*sc_end_class {}; These commands will bestow a status effect on a character. @@ -5357,6 +5358,9 @@ and theirs val1, val2, val3, and val4 usage in source. 'sc_end' will remove a specified status effect. If SC_ALL (-1) is given, it will perform a complete removal of all statuses (although permanent ones will re-apply). +'sc_end_class' works like 'sc_end' but will remove all status effects from any learned +skill on the invoking character. + Examples: // This will poison the invoking character for 10 minutes at 50% chance. sc_start SC_POISON,600000,0,5000; diff --git a/npc/custom/resetnpc.txt b/npc/custom/resetnpc.txt index aa6bc14b2d..e3c902cb0a 100644 --- a/npc/custom/resetnpc.txt +++ b/npc/custom/resetnpc.txt @@ -1,11 +1,5 @@ //===== rAthena Script ======================================= //= Reset NPC -//===== By: ================================================== -//= rAthena Dev Team -//===== Current Version: ===================================== -//= 1.4 -//===== Compatible With: ===================================== -//= rAthena Project //===== Description: ========================================= //= Resets skills, stats, or both. //===== Additional Comments: ================================= @@ -15,6 +9,7 @@ //= 1.3 All statuses removed upon skill reset. [Euphy] //= 1.4 Compressed Script, Added limit use option [Stolao] //= Changed set -> setarray, Improved text with F_InsertPlural +//= 1.5 Added sc_end_class to reset related status changes [sader1992] //============================================================ prontera,150,193,4 script Reset Girl 124,{ // Skills, Stats, Both, Limit @@ -44,7 +39,7 @@ prontera,150,193,4 script Reset Girl 124,{ } set Zeny, Zeny-.@Reset[.@i-1]; if(.@i&1){ - sc_end SC_ALL;// TODO make a sc_end current classes sc only + sc_end_class; ResetSkill; } if(.@i&2) ResetStatus; diff --git a/src/map/script.c b/src/map/script.c index 419c7e7e07..6a588cb6db 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -11319,6 +11319,29 @@ BUILDIN_FUNC(sc_end) return SCRIPT_CMD_SUCCESS; } +/** + * Ends all status effects from any learned skill on the attached player. + * sc_end_class {}; + */ +BUILDIN_FUNC(sc_end_class) +{ + struct map_session_data *sd; + uint16 skill_id; + int i; + + if (!script_charid2sd(2, sd)) + return SCRIPT_CMD_FAILURE; + + for (i = 0; i < MAX_SKILL_TREE && (skill_id = skill_tree[pc_class2idx(sd->status.class_)][i].skill_id) > 0; i++) { // Remove status specific to your current tree skills. + enum sc_type sc = status_skill2sc(skill_id); + + if (sc > SC_COMMON_MAX && sd->sc.data[sc]) + status_change_end(&sd->bl, sc, INVALID_TIMER); + } + + return SCRIPT_CMD_SUCCESS; +} + /*========================================== * @FIXME atm will return reduced tick, 0 immune, 1 no tick *------------------------------------------*/ @@ -23747,6 +23770,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF2(sc_start,"sc_start2","iiii???"), BUILDIN_DEF2(sc_start,"sc_start4","iiiiii???"), BUILDIN_DEF(sc_end,"i?"), + BUILDIN_DEF(sc_end_class,"?"), BUILDIN_DEF(getstatus, "i??"), BUILDIN_DEF(getscrate,"ii?"), BUILDIN_DEF(debugmes,"s"),