Jelajahi Sumber

Added optional param <char_id> for some script commands:
* getexp <base xp>,<job xp>{,<char_id>};
* equip <item id>{,<char_id>};
* unequip <equipment slot>{,<char_id>};
* delequip <equipment slot>{,<char_id>};
* breakequip <equipment slot>{,<char_id>};
* clearitem {,<char_id>};
* openmail {<char_id>};
* openauction {<char_id>};
* setquest <ID>{,<char_id>};
* completequest <ID>{,<char_id>};
* erasequest <ID>{,<char_id>};
* changequest <ID>,<ID2>{,<char_id>};
* checkquest(<ID>{,PLAYTIME|HUNTING{,<char_id>}})
* isbegin_quest(<ID>{,<char_id>})
* showevent <icon>{,<mark color>{,<char_id>}}
* setd "<variable name>",<value>{,<char_id>};

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>

Cydh Ramdh 10 tahun lalu
induk
melakukan
3b197eb76c
2 mengubah file dengan 74 tambahan dan 85 penghapusan
  1. 19 16
      doc/script_commands.txt
  2. 55 69
      src/map/script.c

+ 19 - 16
doc/script_commands.txt

@@ -1226,7 +1226,7 @@ Returns the variable reference (since trunk r12870).
 
 ---------------------------------------
 
-*setd "<variable name>",<value>;
+*setd "<variable name>",<value>{,<char_id>};
 
 Works almost identically as set, except the variable name is identified as a string 
 and can thus be constructed dynamically.
@@ -1242,6 +1242,9 @@ Examples:
   setd ".@" + .@var$ + "123$", "Poporing is cool";
   mes .@Poporing123$; // Displays "Poporing is cool".
 
+NOTE:
+  'char_id' only works for non-server variables.
+
 ---------------------------------------
 
 *getd("<variable name>")
@@ -4132,7 +4135,7 @@ they will also have their skills reset upon 'changesex'.
 
 ---------------------------------------
 
-*getexp <base xp>,<job xp>;
+*getexp <base xp>,<job xp>{,<char_id>};
 
 This command will give the invoking character a specified number of base and job 
 experience points. Can be used as a quest reward. Negative values won't work.
@@ -4846,7 +4849,7 @@ appropriate messages into their chat window.
 
 ---------------------------------------
 
-*unequip <equipment slot>;
+*unequip <equipment slot>{,<char_id>};
 
 This command will unequip whatever is currently equipped in the invoking 
 character's specified equipment slot. For a full list of possible equipment 
@@ -4857,7 +4860,7 @@ them.
 
 ---------------------------------------
 
-*delequip <equipment slot>;
+*delequip <equipment slot>{,<char_id>};
 
 This command will destroy whatever is currently equipped in the invoking
 character's specified equipment slot. For a full list of possible equipment 
@@ -4867,7 +4870,7 @@ This command will return 1 if an item was deleted and 0 otherwise.
 
 ---------------------------------------
 
-*breakequip <equipment slot>;
+*breakequip <equipment slot>{,<char_id>};
 
 This command will break and unequip whatever is currently equipped in the
 invoking character's specified equipment slot. For a full list of possible
@@ -4877,7 +4880,7 @@ This command will return 1 if an item was broken and 0 otherwise.
 
 ---------------------------------------
 
-*clearitem;
+*clearitem {,<char_id>};
 
 This command will destroy all items the invoking character has in their 
 inventory (including equipped items). It will not affect anything else, like 
@@ -4885,7 +4888,7 @@ storage or cart.
 
 ---------------------------------------
 
-*equip <item id>;
+*equip <item id>{,<char_id>};
 *autoequip <item id>,<option>;
 
 These commands are to equip a equipment on the attached character. 
@@ -4968,7 +4971,7 @@ window, to avoid any disruption when both windows overlap.
 
 ---------------------------------------
 
-*openmail;
+*openmail {<char_id>};
 
 This will open a character's Mail window on the client connected to the 
 invoking character.
@@ -4980,7 +4983,7 @@ invoking character.
 
 ---------------------------------------
 
-*openauction;
+*openauction {<char_id>};
 
 This will open the Auction window on the client connected to the invoking character.
 
@@ -7767,7 +7770,7 @@ izlude,100,100,4	script	Test	844,{
 
 ---------------------------------------
 
-*setquest <ID>;
+*setquest <ID>{,<char_id>};
 
 Place quest of <ID> in the users quest log, the state of which is "active".
 
@@ -7775,26 +7778,26 @@ If *questinfo is set, and the same ID is specified here, the icon will be cleare
 
 ---------------------------------------
 
-*completequest <ID>;
+*completequest <ID>{,<char_id>};
 
 Change the state for the given quest <ID> to "complete" and remove from the users quest log.
 
 ---------------------------------------
 
-*erasequest <ID>;
+*erasequest <ID>{,<char_id>};
 
 Remove the quest of the given <ID> from the user's quest log.
 
 ---------------------------------------
 
-*changequest <ID>,<ID2>;
+*changequest <ID>,<ID2>{,<char_id>};
 
 Remove quest of the given <ID> from the user's quest log.
 Add quest of the <ID2> to the the quest log, and the state is "active".
 
 ---------------------------------------
 
-*checkquest(<ID>{,PLAYTIME|HUNTING})
+*checkquest(<ID>{,PLAYTIME|HUNTING{,<char_id>}})
 
 If no additional argument supplied, return the state of the quest: 
 	-1 = Quest not started (not in quest log)
@@ -7816,7 +7819,7 @@ If parameter "HUNTING" is supplied:
 
 ---------------------------------------
 
-*isbegin_quest(<ID>)
+*isbegin_quest(<ID>{,<char_id>})
 
 Return the state of the quest: 
 	0  = Quest not started (not in quest log)
@@ -7825,7 +7828,7 @@ Return the state of the quest:
 
 ---------------------------------------
 
-*showevent <icon>{,<mark color>}
+*showevent <icon>{,<mark color>{,<char_id>}}
 
 Show an emotion on top of a NPC, and optionally,
 a colored mark in the mini-map like "viewpoint".

+ 55 - 69
src/map/script.c

@@ -204,11 +204,9 @@ enum { LABEL_NEXTLINE=1,LABEL_START };
 			return SCRIPT_CMD_FAILURE;\
 		}\
 	}\
-	else {\
-		if (!((sd) = script_rid2sd(st))) {\
-			(ret);\
-			return SCRIPT_CMD_FAILURE;\
-		}\
+	else if (!((sd) = script_rid2sd(st))) {\
+		(ret);\
+		return SCRIPT_CMD_FAILURE;\
 	}\
 }
 
@@ -226,11 +224,9 @@ enum { LABEL_NEXTLINE=1,LABEL_START };
 			return SCRIPT_CMD_FAILURE;\
 		}\
 	}\
-	else {\
-		if (!((sd) = script_rid2sd(st))) {\
-			(ret);\
-			return SCRIPT_CMD_FAILURE;\
-		}\
+	else if (!((sd) = script_rid2sd(st))) {\
+		(ret);\
+		return SCRIPT_CMD_FAILURE;\
 	}\
 }
 
@@ -8321,9 +8317,7 @@ BUILDIN_FUNC(delequip) {
 	TBL_PC *sd;
 
 	pos = script_getnum(st,2);
-	sd = script_rid2sd(st);
-	if (sd == NULL)
-		return 0;
+	script_charid2sd(3,sd,NULL);
 
 	if (pos > 0 && pos <= ARRAYLENGTH(equip))
 		i = pc_checkequip(sd,equip[pos-1]);
@@ -8350,9 +8344,7 @@ BUILDIN_FUNC(breakequip) {
 	TBL_PC *sd;
 
 	pos = script_getnum(st,2);
-	sd = script_rid2sd(st);
-	if (sd == NULL)
-		return 0;
+	script_charid2sd(3,sd,NULL);
 
 	if (pos > 0 && pos <= ARRAYLENGTH(equip))
 		i = pc_checkequip(sd,equip[pos-1]);
@@ -9342,9 +9334,7 @@ BUILDIN_FUNC(getexp)
 	int base=0,job=0;
 	double bonus;
 
-	sd = script_rid2sd(st);
-	if( sd == NULL )
-		return 0;
+	script_charid2sd(4,sd,NULL);
 
 	base=script_getnum(st,2);
 	job =script_getnum(st,3);
@@ -12856,9 +12846,11 @@ BUILDIN_FUNC(getskilllist)
 
 BUILDIN_FUNC(clearitem)
 {
-	TBL_PC *sd=script_rid2sd(st);
+	TBL_PC *sd;
 	int i;
-	if(sd==NULL) return 0;
+
+	script_charid2sd(2,sd,NULL);
+
 	for (i=0; i<MAX_INVENTORY; i++) {
 		if (sd->status.inventory[i].amount) {
 			pc_delitem(sd, i, sd->status.inventory[i].amount, 0, 0, LOG_TYPE_SCRIPT);
@@ -14367,8 +14359,7 @@ BUILDIN_FUNC(unequip) {
 	int pos;
 	TBL_PC *sd;
 
-	if (!(sd = script_rid2sd(st)))
-		return SCRIPT_CMD_SUCCESS;
+	script_charid2sd(3,sd,NULL);
 
 	pos = script_getnum(st,2);
 	if (pos >= 1 && pos <= ARRAYLENGTH(equip)) {
@@ -14389,8 +14380,7 @@ BUILDIN_FUNC(equip) {
 	TBL_PC *sd;
 	struct item_data *item_data;
 
-	if (!(sd = script_rid2sd(st)))
-		return SCRIPT_CMD_SUCCESS;
+	script_charid2sd(3,sd,NULL);
 
 	nameid = script_getnum(st,2);
 	if ((item_data = itemdb_exists(nameid))) {
@@ -15445,12 +15435,7 @@ BUILDIN_FUNC(setd)
 
 	if( not_server_variable(*varname) )
 	{
-		sd = script_rid2sd(st);
-		if( sd == NULL )
-		{
-			ShowError("script:setd: no player attached for player variable '%s'\n", buffer);
-			return 0;
-		}
+		script_charid2sd(4,sd,NULL);
 	}
 
 	if( is_string_variable(varname) ) {
@@ -16658,9 +16643,7 @@ BUILDIN_FUNC(openmail)
 {
 	TBL_PC* sd;
 
-	sd = script_rid2sd(st);
-	if( sd == NULL )
-		return 0;
+	script_charid2sd(2,sd,NULL);
 
 	mail_openmail(sd);
 
@@ -16671,9 +16654,7 @@ BUILDIN_FUNC(openauction)
 {
 	TBL_PC* sd;
 
-	sd = script_rid2sd(st);
-	if( sd == NULL )
-		return 0;
+	script_charid2sd(2,sd,NULL);
 
 	if( !battle_config.feature_auction ) {
 		clif_colormes(sd, color_table[COLOR_RED], msg_txt(sd, 517));
@@ -16978,14 +16959,14 @@ BUILDIN_FUNC(questinfo)
 
 BUILDIN_FUNC(setquest)
 {
-	struct map_session_data *sd = script_rid2sd(st);
+	struct map_session_data *sd;
 	unsigned short i;
 	int quest_id;
 
-	nullpo_retr(1, sd);
-
 	quest_id = script_getnum(st, 2);
 
+	script_charid2sd(3,sd,NULL);
+
 	quest_add(sd, quest_id);
 
 	// If questinfo is set, remove quest bubble once quest is set.
@@ -17004,8 +16985,9 @@ BUILDIN_FUNC(setquest)
 
 BUILDIN_FUNC(erasequest)
 {
-	struct map_session_data *sd = script_rid2sd(st);
-	nullpo_ret(sd);
+	struct map_session_data *sd;
+
+	script_charid2sd(3,sd,NULL);
 
 	quest_delete(sd, script_getnum(st, 2));
 	return SCRIPT_CMD_SUCCESS;
@@ -17013,8 +16995,9 @@ BUILDIN_FUNC(erasequest)
 
 BUILDIN_FUNC(completequest)
 {
-	struct map_session_data *sd = script_rid2sd(st);
-	nullpo_ret(sd);
+	struct map_session_data *sd;
+
+	script_charid2sd(3,sd,NULL);
 
 	quest_update_status(sd, script_getnum(st, 2), Q_COMPLETE);
 	return SCRIPT_CMD_SUCCESS;
@@ -17022,8 +17005,9 @@ BUILDIN_FUNC(completequest)
 
 BUILDIN_FUNC(changequest)
 {
-	struct map_session_data *sd = script_rid2sd(st);
-	nullpo_ret(sd);
+	struct map_session_data *sd;
+	
+	script_charid2sd(4,sd,NULL);
 
 	quest_change(sd, script_getnum(st, 2),script_getnum(st, 3));
 	return SCRIPT_CMD_SUCCESS;
@@ -17031,14 +17015,14 @@ BUILDIN_FUNC(changequest)
 
 BUILDIN_FUNC(checkquest)
 {
-	struct map_session_data *sd = script_rid2sd(st);
+	struct map_session_data *sd;
 	enum quest_check_type type = HAVEQUEST;
 
-	nullpo_ret(sd);
-
 	if( script_hasdata(st, 3) )
 		type = (enum quest_check_type)script_getnum(st, 3);
 
+	script_charid2sd(4,sd,NULL);
+
 	script_pushint(st, quest_check(sd, script_getnum(st, 2), type));
 
 	return SCRIPT_CMD_SUCCESS;
@@ -17046,10 +17030,10 @@ BUILDIN_FUNC(checkquest)
 
 BUILDIN_FUNC(isbegin_quest)
 {
-	struct map_session_data *sd = script_rid2sd(st);
+	struct map_session_data *sd;
 	int i;
 
-	nullpo_ret(sd);
+	script_charid2sd(3,sd,NULL);
 
 	i = quest_check(sd, script_getnum(st, 2), (enum quest_check_type) HAVEQUEST);
 	script_pushint(st, i + (i < 1));
@@ -17059,12 +17043,14 @@ BUILDIN_FUNC(isbegin_quest)
 
 BUILDIN_FUNC(showevent)
 {
-	TBL_PC *sd = script_rid2sd(st);
+	TBL_PC *sd;
 	struct npc_data *nd = map_id2nd(st->oid);
 	int icon, color = 0;
 
+	script_charid2sd(4,sd,NULL);
+
 	if( sd == NULL || nd == NULL )
-	return 0;
+		return 0;
 
 	icon = script_getnum(st, 2);
 	if( script_hasdata(st, 3) ) {
@@ -19501,10 +19487,10 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(getitemname,"v"),
 	BUILDIN_DEF(getitemslots,"i"),
 	BUILDIN_DEF(makepet,"i"),
-	BUILDIN_DEF(getexp,"ii"),
+	BUILDIN_DEF(getexp,"ii?"),
 	BUILDIN_DEF(getinventorylist,""),
 	BUILDIN_DEF(getskilllist,""),
-	BUILDIN_DEF(clearitem,""),
+	BUILDIN_DEF(clearitem,"?"),
 	BUILDIN_DEF(classchange,"ii"),
 	BUILDIN_DEF(misceffect,"i"),
 	BUILDIN_DEF(playBGM,"s"),
@@ -19568,7 +19554,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(checkequipedcard,"i"),
 	BUILDIN_DEF(jump_zero,"il"), //for future jA script compatibility
 	BUILDIN_DEF(globalmes,"s?"), //end jA addition
-	BUILDIN_DEF(unequip,"i"), // unequip command [Spectre]
+	BUILDIN_DEF(unequip,"i?"), // unequip command [Spectre]
 	BUILDIN_DEF(getstrlen,"s"), //strlen [Valaris]
 	BUILDIN_DEF(charisalpha,"si"), //isalpha [Valaris]
 	BUILDIN_DEF(charat,"si"),
@@ -19601,13 +19587,13 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(md5,"s"),
 	// [zBuffer] List of dynamic var commands --->
 	BUILDIN_DEF(getd,"s"),
-	BUILDIN_DEF(setd,"sv"),
+	BUILDIN_DEF(setd,"sv?"),
 	BUILDIN_DEF(callshop,"s?"), // [Skotlex]
 	BUILDIN_DEF(npcshopitem,"sii*"), // [Lance]
 	BUILDIN_DEF(npcshopadditem,"sii*"),
 	BUILDIN_DEF(npcshopdelitem,"si*"),
 	BUILDIN_DEF(npcshopattach,"s?"),
-	BUILDIN_DEF(equip,"i"),
+	BUILDIN_DEF(equip,"i?"),
 	BUILDIN_DEF(autoequip,"ii"),
 	BUILDIN_DEF(setbattleflag,"si"),
 	BUILDIN_DEF(getbattleflag,"s"),
@@ -19655,8 +19641,8 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(checkvending,"?"),
 	BUILDIN_DEF(checkchatting,"?"),
 	BUILDIN_DEF(checkidle,"?"),
-	BUILDIN_DEF(openmail,""),
-	BUILDIN_DEF(openauction,""),
+	BUILDIN_DEF(openmail,"?"),
+	BUILDIN_DEF(openauction,"?"),
 	BUILDIN_DEF(checkcell,"siii"),
 	BUILDIN_DEF(setcell,"siiiiii"),
 	BUILDIN_DEF(setwall,"siiiiis"),
@@ -19728,8 +19714,8 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF2(cleanmap,"cleanarea","siiii"),
 	BUILDIN_DEF(npcskill,"viii"),
 	BUILDIN_DEF(consumeitem,"v"),
-	BUILDIN_DEF(delequip,"i"),
-	BUILDIN_DEF(breakequip,"i"),
+	BUILDIN_DEF(delequip,"i?"),
+	BUILDIN_DEF(breakequip,"i?"),
 	BUILDIN_DEF(sit,"?"),
 	BUILDIN_DEF(stand,"?"),
 	//@commands (script based)
@@ -19739,13 +19725,13 @@ struct script_function buildin_func[] = {
 
 	//Quest Log System [Inkfish]
 	BUILDIN_DEF(questinfo, "ii??"),
-	BUILDIN_DEF(setquest, "i"),
-	BUILDIN_DEF(erasequest, "i"),
-	BUILDIN_DEF(completequest, "i"),
-	BUILDIN_DEF(checkquest, "i?"),
-	BUILDIN_DEF(isbegin_quest,"i"),
-	BUILDIN_DEF(changequest, "ii"),
-	BUILDIN_DEF(showevent, "i?"),
+	BUILDIN_DEF(setquest, "i?"),
+	BUILDIN_DEF(erasequest, "i?"),
+	BUILDIN_DEF(completequest, "i?"),
+	BUILDIN_DEF(checkquest, "i??"),
+	BUILDIN_DEF(isbegin_quest,"i?"),
+	BUILDIN_DEF(changequest, "ii?"),
+	BUILDIN_DEF(showevent, "i??"),
 
 	//Bound items [Xantara] & [Akinari]
 	BUILDIN_DEF2(getitem,"getitembound","vii?"),