浏览代码

* Merged changes up to eAthena 15083.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15773 54d463be-8e91-2dee-dedb-b68131a5f0ec
eathenabot 13 年之前
父节点
当前提交
a678624e64
共有 2 个文件被更改,包括 31 次插入0 次删除
  1. 11 0
      doc/script_commands.txt
  2. 20 0
      src/map/script.c

+ 11 - 0
doc/script_commands.txt

@@ -2027,6 +2027,17 @@ Whatever it returns is determined by type.
 
 ---------------------------------------
 
+*getnpcid(<type>)
+
+This function will return the GID of an NPC.
+Type can be:
+
+ 0 - The NPC that the running script is attached to.
+
+Useful for making an NPC perform an action using script commands that require a GID (e.g. unit*)
+
+---------------------------------------
+
 *getarraysize(<array name>)
 
 This function returns the number of values that are contained inside the 

+ 20 - 0
src/map/script.c

@@ -6353,6 +6353,25 @@ BUILDIN_FUNC(getcharid)
 		
 	return 0;
 }
+/*==========================================
+ * returns the GID of an NPC
+ *------------------------------------------*/
+BUILDIN_FUNC(getnpcid)
+{
+	int num;
+	
+	switch (num = script_getnum(st,2)) {
+		case 0:
+			script_pushint(st,st->oid);
+			break;
+		default:
+			ShowError("buildin_getnpcid: invalid parameter (%d).\n", num);
+			script_pushint(st,0);
+			break;
+	}
+	
+	return 0;
+}
 /*==========================================
  *Žw’èID‚ÌPT–¼Žæ“¾
  *------------------------------------------*/
@@ -15911,6 +15930,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(checkweight,"vi"),
 	BUILDIN_DEF(readparam,"i?"),
 	BUILDIN_DEF(getcharid,"i?"),
+	BUILDIN_DEF(getnpcid,"i"),
 	BUILDIN_DEF(getpartyname,"i"),
 	BUILDIN_DEF(getpartymember,"i?"),
 	BUILDIN_DEF(getpartyleader,"i?"),