Просмотр исходного кода

- Added support for multi-line messages when using mes;
- Added getstatus; script command to retrieve information about a specific, active status effect

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15072 54d463be-8e91-2dee-dedb-b68131a5f0ec

epoque11 13 лет назад
Родитель
Сommit
b6d144c4c4
2 измененных файлов с 94 добавлено и 2 удалено
  1. 28 0
      doc/script_commands.txt
  2. 66 2
      src/map/script.c

+ 28 - 0
doc/script_commands.txt

@@ -1168,6 +1168,14 @@ english characters, the color codes might get screwed if they stick to letters
 with no intervening space. Separating them with spaces from the letters on 
 with no intervening space. Separating them with spaces from the letters on 
 either side solves the problem.
 either side solves the problem.
 
 
+To display multiple lines of message while only using a single mes; command,
+use the script command in the following format:
+
+    mes "Line 1", "Line 2", "Line 3";
+
+This will display 3 different lines while only consuming a single line in
+the relevant script file.
+
 ---------------------------------------
 ---------------------------------------
 
 
 *next;
 *next;
@@ -4737,6 +4745,26 @@ should be rather obvious.
 
 
 ---------------------------------------
 ---------------------------------------
 
 
+*getstatus <effect type>{,<type>};
+
+Retrieve information about a specific status effect when called. Depending on <type>
+specified the function will return different information.
+
+Possible <type> values:
+	- 0 or undefined: whether the status is active
+	- 1: the val1 of the status
+	- 2: the val2 of the status
+	- 3: the val3 of the status
+	- 4: the val4 of the status
+	- 5: the amount of time in milliseconds that the status has remaining
+
+If <type> is not defined or is set to 0, then the script function will either
+return 1 if the status is active, or 0 if the status is not active. If the status
+is not active when any of the <type> fields are provided, this script function
+will always return 0.
+
+---------------------------------------
+
 *skilleffect <skill id>,<number>;
 *skilleffect <skill id>,<number>;
 *skilleffect "<skill name>",<number>;
 *skilleffect "<skill name>",<number>;
 
 

+ 66 - 2
src/map/script.c

@@ -3874,11 +3874,24 @@ int script_reload()
 /// mes "<message>";
 /// mes "<message>";
 BUILDIN_FUNC(mes)
 BUILDIN_FUNC(mes)
 {
 {
+	int i;
 	TBL_PC* sd = script_rid2sd(st);
 	TBL_PC* sd = script_rid2sd(st);
 	if( sd == NULL )
 	if( sd == NULL )
 		return 0;
 		return 0;
 
 
-	clif_scriptmes(sd, st->oid, script_getstr(st, 2));
+	if( !script_hasdata(st, 3) )
+	{// only a single line detected in the script
+		clif_scriptmes(sd, st->oid, script_getstr(st, 2));
+	}
+	else
+	{// parse multiple lines as they exist
+		for( i = 2; script_hasdata(st, i); i++ )
+		{
+			// send the message to the client
+			clif_scriptmes(sd, st->oid, script_getstr(st, i));
+		}
+	}
+
 	return 0;
 	return 0;
 }
 }
 
 
@@ -9067,6 +9080,56 @@ BUILDIN_FUNC(getscrate)
 	return 0;
 	return 0;
 }
 }
 
 
+/*==========================================
+ * getstatus <type>{, <info>};
+ *------------------------------------------*/
+BUILDIN_FUNC(getstatus)
+{
+	int id, type;
+	struct map_session_data* sd = script_rid2sd(st);
+
+	if( sd == NULL )
+	{// no player attached
+		return 0;
+	}
+
+	id = script_getnum(st, 2);
+	type = script_hasdata(st, 3) ? script_getnum(st, 3) : 0;
+
+	if( id <= SC_NONE || id >= SC_MAX )
+	{// invalid status type given
+		ShowWarning("script.c:getstatus: Invalid status type given (%d).\n", id);
+		return 0;
+	}
+
+	if( sd->sc.count == 0 || !sd->sc.data[id] )
+	{// no status is active
+		script_pushint(st, 0);
+		return 0;
+	}
+	
+	switch( type )
+	{
+		case 1:	 script_pushint(st, sd->sc.data[id]->val1);	break;
+		case 2:  script_pushint(st, sd->sc.data[id]->val2);	break;
+		case 3:  script_pushint(st, sd->sc.data[id]->val3);	break;
+		case 4:  script_pushint(st, sd->sc.data[id]->val4);	break;
+		case 5:
+			{
+				struct TimerData* timer = (struct TimerData*)get_timer(sd->sc.data[id]->timer);
+
+				if( timer )
+				{// return the amount of time remaining
+					script_pushint(st, timer->tick - gettick());
+				}
+			}
+			break;
+		default: script_pushint(st, 1); break;
+	}
+
+	return 0;
+}
+
 /*==========================================
 /*==========================================
  *
  *
  *------------------------------------------*/
  *------------------------------------------*/
@@ -15912,7 +15975,7 @@ BUILDIN_FUNC(deletepset);
 /// for an explanation on args, see add_buildin_func
 /// for an explanation on args, see add_buildin_func
 struct script_function buildin_func[] = {
 struct script_function buildin_func[] = {
 	// NPC interaction
 	// NPC interaction
-	BUILDIN_DEF(mes,"s"),
+	BUILDIN_DEF(mes,"s*"),
 	BUILDIN_DEF(next,""),
 	BUILDIN_DEF(next,""),
 	BUILDIN_DEF(close,""),
 	BUILDIN_DEF(close,""),
 	BUILDIN_DEF(close2,""),
 	BUILDIN_DEF(close2,""),
@@ -16055,6 +16118,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(sc_start2,"iiii?"),
 	BUILDIN_DEF(sc_start2,"iiii?"),
 	BUILDIN_DEF(sc_start4,"iiiiii?"),
 	BUILDIN_DEF(sc_start4,"iiiiii?"),
 	BUILDIN_DEF(sc_end,"i?"),
 	BUILDIN_DEF(sc_end,"i?"),
+	BUILDIN_DEF(getstatus, "i?"),
 	BUILDIN_DEF(getscrate,"ii?"),
 	BUILDIN_DEF(getscrate,"ii?"),
 	BUILDIN_DEF(debugmes,"s"),
 	BUILDIN_DEF(debugmes,"s"),
 	BUILDIN_DEF2(catchpet,"pet","i"),
 	BUILDIN_DEF2(catchpet,"pet","i"),