diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 0368b48e0c..5a115455a7 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -8312,6 +8312,13 @@ Gets the reputation points for reputation group for the attached player o --------------------------------------- +*add_reputation_points(,{,}) + +Adds the reputation points via for reputation group for the attached player or the given character ID. + is the client side index as stored in the Id field of the reputation.yml database files. + +--------------------------------------- + *item_reform({{,}}) *item_reform({<"item name">{,}}) diff --git a/src/map/script.cpp b/src/map/script.cpp index b96265a8b0..48096dffec 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -26631,6 +26631,35 @@ BUILDIN_FUNC(get_reputation_points){ return SCRIPT_CMD_SUCCESS; } +BUILDIN_FUNC(add_reputation_points) +{ + struct map_session_data* sd; + + if( !script_charid2sd( 4, sd ) ){ + return SCRIPT_CMD_FAILURE; + } + + int64 type = script_getnum64( st, 2 ); + std::shared_ptr reputation = reputation_db.find( type ); + + if( reputation == nullptr ){ + ShowError( "buildin_set_reputation_points: Unknown reputation type %" PRIi64 ".\n", type ); + return SCRIPT_CMD_FAILURE; + } + + int64 points = pc_readreg2( sd, reputation->variable.c_str() ) + script_getnum64(st, 3); + + points = cap_value( points, reputation->minimum, reputation->maximum ); + + if( !pc_setreg2( sd, reputation->variable.c_str(), points ) ){ + return SCRIPT_CMD_FAILURE; + } + + clif_reputation_type( *sd, type, points ); + + return SCRIPT_CMD_SUCCESS; +} + BUILDIN_FUNC(item_reform){ #if PACKETVER < 20211103 ShowError( "buildin_item_reform: This command requires packet version 2021-11-03 or newer.\n" ); @@ -27492,6 +27521,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(set_reputation_points, "ii?"), BUILDIN_DEF(get_reputation_points, "i?"), + BUILDIN_DEF(add_reputation_points, "ii?"), BUILDIN_DEF(item_reform, "??"), BUILDIN_DEF(item_enchant, "i?"), BUILDIN_DEF(addfame, "i?"),