Browse Source

Added command 'getattachedrid()' as discussion result with @aleos89

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
Cydh Ramdh 10 years ago
parent
commit
0f137f3c67
3 changed files with 21 additions and 4 deletions
  1. 9 2
      doc/script_commands.txt
  2. 11 1
      src/map/script.c
  3. 1 1
      src/map/script.h

+ 9 - 2
doc/script_commands.txt

@@ -376,7 +376,7 @@ Another way would be to right click on a mob,
 NPC or char as GM sprited char to view the GID.
 NPC or char as GM sprited char to view the GID.
 
 
 This is mostly used for the new version of skill and the mob control commands
 This is mostly used for the new version of skill and the mob control commands
-implemented (but NEVER documented by Lance. Shame on you...).
+implemented.
 
 
 Item and pet scripts
 Item and pet scripts
 --------------------
 --------------------
@@ -933,7 +933,8 @@ chosen once the triggering character leaves the area.
 
 
 OnTouchNPC:
 OnTouchNPC:
 
 
-Similar to OnTouch, but will only trigger for monsters.
+Similar to OnTouch, but will only trigger for monsters. For this case, by using
+'getattachedrid' will returns GID (ID that returned when use 'monster').
 
 
 OnPCLoginEvent:
 OnPCLoginEvent:
 OnPCLogoutEvent:
 OnPCLogoutEvent:
@@ -3360,6 +3361,12 @@ account ID.
 
 
 ---------------------------------------
 ---------------------------------------
 
 
+*getattachedrid();
+
+Returns RID from running script. Script may does not have RID.
+
+---------------------------------------
+
 *isloggedin(<account id>{,<char id>})
 *isloggedin(<account id>{,<char id>})
 
 
 This function returns 1 if the specified account is logged in and 0 if they 
 This function returns 1 if the specified account is logged in and 0 if they 

+ 11 - 1
src/map/script.c

@@ -3734,7 +3734,7 @@ int run_func(struct script_state *st)
 /*==========================================
 /*==========================================
  * script execution
  * script execution
  *------------------------------------------*/
  *------------------------------------------*/
-void run_script(struct script_code *rootscript,int pos,int rid,int oid)
+void run_script(struct script_code *rootscript, int pos, int rid, int oid)
 {
 {
 	struct script_state *st;
 	struct script_state *st;
 
 
@@ -19254,6 +19254,15 @@ BUILDIN_FUNC(mergeitem) {
 	return SCRIPT_CMD_SUCCESS;
 	return SCRIPT_CMD_SUCCESS;
 }
 }
 
 
+/**
+ * Get rid from running script.
+ * getattachedrid();
+ **/
+BUILDIN_FUNC(getattachedrid) {
+	script_pushint(st, st->rid);
+	return SCRIPT_CMD_SUCCESS;
+}
+
 #include "../custom/script.inc"
 #include "../custom/script.inc"
 
 
 // declarations that were supposed to be exported from npc_chat.c
 // declarations that were supposed to be exported from npc_chat.c
@@ -19797,6 +19806,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(delspiritball,"i?"),
 	BUILDIN_DEF(delspiritball,"i?"),
 	BUILDIN_DEF(countspiritball,"?"),
 	BUILDIN_DEF(countspiritball,"?"),
 	BUILDIN_DEF(mergeitem,"??"),
 	BUILDIN_DEF(mergeitem,"??"),
+	BUILDIN_DEF(getattachedrid,""),
 
 
 #include "../custom/script_def.inc"
 #include "../custom/script_def.inc"
 
 

+ 1 - 1
src/map/script.h

@@ -159,7 +159,7 @@ void script_warning(const char* src, const char* file, int start_line, const cha
 
 
 struct script_code* parse_script(const char* src,const char* file,int line,int options);
 struct script_code* parse_script(const char* src,const char* file,int line,int options);
 void run_script_sub(struct script_code *rootscript,int pos,int rid,int oid, char* file, int lineno);
 void run_script_sub(struct script_code *rootscript,int pos,int rid,int oid, char* file, int lineno);
-void run_script(struct script_code*,int,int,int);
+void run_script(struct script_code *rootscript,int pos,int rid,int oid);
 
 
 int set_var(struct map_session_data *sd, char *name, void *val);
 int set_var(struct map_session_data *sd, char *name, void *val);
 int conv_num(struct script_state *st,struct script_data *data);
 int conv_num(struct script_state *st,struct script_data *data);