diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 785a1a43a1..e1f47bd34e 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -2371,9 +2371,9 @@ NOTE: This command is only available if the VIP System is enabled. --------------------------------------- -*addspiritball {,}; +*addspiritball ,{,}; -Adds spirit ball(s) to player. +Adds a spirit ball to player for 'duration' in second. --------------------------------------- @@ -2385,7 +2385,7 @@ Deletes the spirit ball(s) from player. *delspiritball {,}; -Counts the spirit ball that player has +Counts the spirit ball that player has. --------------------------------------- \\ diff --git a/src/map/pc.c b/src/map/pc.c index 6268b543dc..b1589c834b 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -178,6 +178,13 @@ static int pc_spiritball_timer(int tid, unsigned int tick, int id, intptr_t data return 0; } +/** +* Adds a spiritball to player for 'interval' ms +* @param sd +* @param interval +* @param max +* @return 0 +*/ int pc_addspiritball(struct map_session_data *sd,int interval,int max) { int tid, i; @@ -213,6 +220,13 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max) return 0; } +/** +* Removes number of spiritball from player +* @param sd +* @param count +* @param type 1 = gives client effect +* @return 0 +*/ int pc_delspiritball(struct map_session_data *sd,int count,int type) { int i; diff --git a/src/map/pc.h b/src/map/pc.h index 59496970a8..9b68b8e607 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -984,8 +984,8 @@ extern const struct sg_data sg_info[MAX_PC_FEELHATE]; void pc_setinvincibletimer(struct map_session_data* sd, int val); void pc_delinvincibletimer(struct map_session_data* sd); -int pc_addspiritball(struct map_session_data *sd,int,int); -int pc_delspiritball(struct map_session_data *sd,int,int); +int pc_addspiritball(struct map_session_data *sd,int interval,int max); +int pc_delspiritball(struct map_session_data *sd,int count,int type); void pc_addfame(struct map_session_data *sd,int count); unsigned char pc_famerank(int char_id, int job); int pc_set_hate_mob(struct map_session_data *sd, int pos, struct block_list *bl); diff --git a/src/map/script.c b/src/map/script.c index dc49b6566b..ee301f75b9 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -18171,20 +18171,26 @@ BUILDIN_FUNC(bonus_script) { return SCRIPT_CMD_SUCCESS; } -/** Adds spirit ball(s) to player -* addspiritball {,}; +/** Adds a spirit ball to player for 'duration' in second +* addspiritball ,{,}; */ BUILDIN_FUNC(addspiritball) { - uint8 amount = script_getnum(st,2); + uint8 i, amount = script_getnum(st,2); + uint16 tick = script_getnum(st,3); struct map_session_data *sd; - if (script_getnum(st,3)) - sd = map_charid2sd(script_getnum(st,3)); + if (script_getnum(st,4)) + sd = map_charid2sd(script_getnum(st,4)); else sd = script_rid2sd(st); if (!sd) return SCRIPT_CMD_FAILURE; - pc_addspiritball(sd,max(amount,1),10); + + if (amount == 0) + return SCRIPT_CMD_SUCCESS; + + for (i = 0; i < amount; i++) + pc_addspiritball(sd,tick*1000,10); return SCRIPT_CMD_SUCCESS; } @@ -18201,7 +18207,10 @@ BUILDIN_FUNC(delspiritball) { sd = script_rid2sd(st); if (!sd) return SCRIPT_CMD_FAILURE; - pc_delspiritball(sd,max(amount,1),10); + + if (amount == 0) + return SCRIPT_CMD_SUCCESS; + pc_delspiritball(sd,max(amount,1),1); return SCRIPT_CMD_SUCCESS; } @@ -18704,7 +18713,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(vip_time,"i?"), #endif BUILDIN_DEF(bonus_script,"si???"), - BUILDIN_DEF(addspiritball,"i?"), + BUILDIN_DEF(addspiritball,"ii?"), BUILDIN_DEF(delspiritball,"i?"), BUILDIN_DEF(countspiritball,"?"),