summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-07-09 18:45:22 +0000
committerai4rei <ai4rei@54d463be-8e91-2dee-dedb-b68131a5f0ec>2011-07-09 18:45:22 +0000
commit201d8bb6a488ad6ef7eed4c46ad14228d543b71d (patch)
treef0a95a535ed7bb1552b47f6eece77e2712f3d4f7
parentab9b60f5c4501eb8d7bec4a053d73fc723ea31b5 (diff)
downloadhercules-201d8bb6a488ad6ef7eed4c46ad14228d543b71d.tar.gz
hercules-201d8bb6a488ad6ef7eed4c46ad14228d543b71d.tar.bz2
hercules-201d8bb6a488ad6ef7eed4c46ad14228d543b71d.tar.xz
hercules-201d8bb6a488ad6ef7eed4c46ad14228d543b71d.zip
* Added script command 'getmercinfo' for retrieving information about a mercenary of an online character.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14894 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--Changelog-Trunk.txt1
-rw-r--r--doc/script_commands.txt25
-rw-r--r--src/map/script.c57
3 files changed, 82 insertions, 1 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index fe07980c3..571fbdd0a 100644
--- a/Changelog-Trunk.txt
+++ b/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
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 621438e4a..42ccbcbbe 100644
--- a/doc/script_commands.txt
+++ b/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.
diff --git a/src/map/script.c b/src/map/script.c
index 7b27581ae..632dc0e14 100644
--- a/src/map/script.c
+++ b/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?"),