소스 검색

* Added script command 'getmercinfo' for retrieving information about a mercenary of an online character.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14894 54d463be-8e91-2dee-dedb-b68131a5f0ec
ai4rei 14 년 전
부모
커밋
4d6e77c875
3개의 변경된 파일82개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 0
      Changelog-Trunk.txt
  2. 24 1
      doc/script_commands.txt
  3. 57 0
      src/map/script.c

+ 1 - 0
Changelog-Trunk.txt

@@ -1,6 +1,7 @@
 Date	Added
 
 2011/07/09
+	* Added script command 'getmercinfo' for retrieving information about a mercenary of an online character. [Ai4rei]
 	* CMake: added search for math library, made CPack existence optional, updated the search for mysqlclient and corrected misspelled variables (tested with FreeBSD-8.2-i386) [FlavioJS]
 	* Removed duplicate entries for Gunslinger and Ninja in msg_athena.conf (since r5506). [Ai4rei]
 2011/07/07

+ 24 - 1
doc/script_commands.txt

@@ -4,7 +4,7 @@
 //= A reference manual for the eAthena scripting language.
 //= Commands are sorted depending on their functionality.
 //===== Version ===========================================
-//= 3.44.20110530
+//= 3.45.20110709
 //=========================================================
 //= 1.0 - First release, filled will as much info as I could
 //=       remember or figure out, most likely there are errors,
@@ -179,6 +179,8 @@
 //=       cashshops as well. [Ai4rei]
 //= 3.44.20110530
 //=       Documented special map names recognized by 'warpguild'. [Ai4rei]
+//= 3.45.20110709
+//=       Added 'getmercinfo' command. [Ai4rei]
 //=========================================================
 
 This document is a reference manual for all the scripting commands and functions 
@@ -7172,5 +7174,26 @@ attached character. Guild can be one or the following constants:
 
 ---------------------------------------
 
+*getmercinfo(<type>{,<char id>});
+
+Retrieves information about mercenary of the currently attached
+character. If char id is given, the information of that character is
+retrieved instead. Type specifies what information to retrieve and
+can be one of the following:
+
+    0 - Database ID
+    1 - Class
+    2 - Name
+    3 - Faith value for this mercenary's guild, if any
+    4 - Calls value for this mercenary's guild, if any
+    5 - Kill count
+    6 - Remaining life time in msec
+    7 - Level
+
+If the character does not have a mercenary, the command returns ""
+for name and 0 for all other types.
+
+----------------------------------------
+
 Whew.
 That's about all of them.

+ 57 - 0
src/map/script.c

@@ -11684,6 +11684,62 @@ BUILDIN_FUNC(gethominfo)
 	return 0;
 }
 
+/// Retrieves information about character's mercenary
+/// getmercinfo <type>[,<char id>];
+BUILDIN_FUNC(getmercinfo)
+{
+	int type, char_id;
+	struct map_session_data* sd;
+	struct mercenary_data* md;
+
+	type = script_getnum(st,2);
+
+	if( script_hasdata(st,3) )
+	{
+		char_id = script_getnum(st,3);
+
+		if( ( sd = map_charid2sd(char_id) ) == NULL )
+		{
+			ShowError("buildin_getmercinfo: No such character (char_id=%d).\n", char_id);
+			script_pushnil(st);
+			return 1;
+		}
+	}
+	else
+	{
+		if( ( sd = script_rid2sd(st) ) == NULL )
+		{
+			script_pushnil(st);
+			return 0;
+		}
+	}
+
+	md = ( sd->status.mer_id && sd->md ) ? sd->md : NULL;
+
+	switch( type )
+	{
+		case 0: script_pushint(st,md ? md->mercenary.mercenary_id : 0); break;
+		case 1: script_pushint(st,md ? md->mercenary.class_ : 0); break;
+		case 2:
+			if( md )
+				script_pushstrcopy(st,md->db->name);
+			else
+				script_pushconststr(st,"");
+			break;
+		case 3: script_pushint(st,md ? mercenary_get_faith(md) : 0); break;
+		case 4: script_pushint(st,md ? mercenary_get_calls(md) : 0); break;
+		case 5: script_pushint(st,md ? md->mercenary.kill_count : 0); break;
+		case 6: script_pushint(st,md ? mercenary_get_lifetime(md) : 0); break;
+		case 7: script_pushint(st,md ? md->db->lv : 0); break;
+		default:
+			ShowError("buildin_getmercinfo: Invalid type %d (char_id=%d).\n", type, sd->status.char_id);
+			script_pushnil(st);
+			return 1;
+	}
+
+	return 0;
+}
+
 /*==========================================
  * Shows wether your inventory(and equips) contain
    selected card or not.
@@ -15143,6 +15199,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(recovery,""),
 	BUILDIN_DEF(getpetinfo,"i"),
 	BUILDIN_DEF(gethominfo,"i"),
+	BUILDIN_DEF(getmercinfo,"i?"),
 	BUILDIN_DEF(checkequipedcard,"i"),
 	BUILDIN_DEF(jump_zero,"il"), //for future jA script compatibility
 	BUILDIN_DEF(globalmes,"s?"),