瀏覽代碼

Added some script commands: addspiritball, delspiritball, and countspiritball

Signed-off-by: Cahyadi Ramadhan Togihon <house.bad@gmail.com>
Cahyadi Ramadhan Togihon 11 年之前
父節點
當前提交
a7396c7998
共有 2 個文件被更改,包括 71 次插入0 次删除
  1. 18 0
      doc/script_commands.txt
  2. 53 0
      src/map/script.c

+ 18 - 0
doc/script_commands.txt

@@ -2369,6 +2369,24 @@ negative value will decrease time.
 
 NOTE: This command is only available if the VIP System is enabled.
 
+---------------------------------------
+
+*addspiritball <amount>{,<char_id>};
+
+Adds amount of spirit ball to player.
+
+---------------------------------------
+
+*delspiritball <amount>{,<char_id>};
+
+Deletes amount of spirit ball from player.
+
+---------------------------------------
+
+*delspiritball {,<char_id>};
+
+Counts amount of spirit ball that player has.
+
 ---------------------------------------
 \\
 2,2 Item-related commands

+ 53 - 0
src/map/script.c

@@ -18171,6 +18171,56 @@ BUILDIN_FUNC(bonus_script) {
 	return SCRIPT_CMD_SUCCESS;
 }
 
+/** Adds amount of spirit ball to player
+* addspiritball <amount>{,<char_id>};
+*/
+BUILDIN_FUNC(addspiritball) {
+	uint8 amount = script_getnum(st,2);
+	struct map_session_data *sd;
+
+	if (script_getnum(st,3))
+		sd = map_charid2sd(script_getnum(st,3));
+	else
+		sd = script_rid2sd(st);
+	if (!sd)
+		return SCRIPT_CMD_FAILURE;
+	pc_addspiritball(sd,max(amount,1),10);
+	return SCRIPT_CMD_SUCCESS;
+}
+
+/** Deletes amount of spirit ball from player
+* delspiritball <amount>{,<char_id>};
+*/
+BUILDIN_FUNC(delspiritball) {
+	uint8 amount = script_getnum(st,2);
+	struct map_session_data *sd;
+
+	if (script_getnum(st,3))
+		sd = map_charid2sd(script_getnum(st,3));
+	else
+		sd = script_rid2sd(st);
+	if (!sd)
+		return SCRIPT_CMD_FAILURE;
+	pc_delspiritball(sd,max(amount,1),10);
+	return SCRIPT_CMD_SUCCESS;
+}
+
+/** Counts amount of spirit ball that player has
+* delspiritball {,<char_id>};
+*/
+BUILDIN_FUNC(countspiritball) {
+	struct map_session_data *sd;
+
+	if (script_getnum(st,2))
+		sd = map_charid2sd(script_getnum(st,2));
+	else
+		sd = script_rid2sd(st);
+	if (!sd)
+		return SCRIPT_CMD_FAILURE;
+	script_pushint(st,sd->spiritball);
+	return SCRIPT_CMD_SUCCESS;
+}
+
 #include "../custom/script.inc"
 
 // declarations that were supposed to be exported from npc_chat.c
@@ -18654,6 +18704,9 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(vip_time,"i?"),
 #endif
 	BUILDIN_DEF(bonus_script,"si???"),
+	BUILDIN_DEF(addspiritball,"??"),
+	BUILDIN_DEF(delspiritball,"??"),
+	BUILDIN_DEF(countspiritball,"?"),
 
 #include "../custom/script_def.inc"