summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2014-01-12 17:08:46 -0200
committershennetsind <ind@henn.et>2014-01-12 17:08:46 -0200
commitff4faca9cc44e98abad50bfda849f596d7bc81c1 (patch)
tree1a6628efa72a821dc992110e568389b1d6f3374b
parente4c21279a33a810ee80c334a74c422affcdab870 (diff)
downloadhercules-ff4faca9cc44e98abad50bfda849f596d7bc81c1.tar.gz
hercules-ff4faca9cc44e98abad50bfda849f596d7bc81c1.tar.bz2
hercules-ff4faca9cc44e98abad50bfda849f596d7bc81c1.tar.xz
hercules-ff4faca9cc44e98abad50bfda849f596d7bc81c1.zip
Follow up 20bdc01fa687b174a732be4483ddea4982d67ce9
Fixed scripting deficiency of being unable to tell whether a user is assigned to a specific instance or not ( 20bdc01fa687b174a732be4483ddea4982d67ce9 removed that ability ), because users can be assigned to more than a single instance on hercules, the previous instance_id(<va>) isn't viable, so I'm introducing has_instance2("<map_name>"), returns the instance id of that map for the user (as long as the user is assigned to a instead with that map), -1 upon failure -- valid instance ids are >= 0. Signed-off-by: shennetsind <ind@henn.et>
-rw-r--r--doc/script_commands.txt8
-rw-r--r--src/map/script.c19
2 files changed, 23 insertions, 4 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 9f9dc0049..c0b848663 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -7960,6 +7960,14 @@ Returns name of the instanced map on success, otherwise an empty string.
---------------------------------------
+*has_instance2("<map name>");
+
+Same as has_instance, with exception it returns the instance id of the map,
+as long as the user is assigned to a instance containing that map.
+It will return -1 upon failure, valid instance ids are >= 0.
+
+---------------------------------------
+
*instance_id();
Retrieves the instance id of the script it is being run on.
diff --git a/src/map/script.c b/src/map/script.c
index 3bd6d033d..64943dd2a 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -16558,11 +16558,15 @@ BUILDIN(has_instance) {
const char *str;
int16 m;
int instance_id = -1;
-
+ bool type = strcmp(script->getfuncname(st),"has_instance2") == 0 ? true : false;
+
str = script_getstr(st, 2);
if( (m = map->mapname2mapid(str)) < 0 ) {
- script_pushconststr(st, "");
+ if( type )
+ script_pushint(st, -1);
+ else
+ script_pushconststr(st, "");
return true;
}
@@ -16609,11 +16613,17 @@ BUILDIN(has_instance) {
}
if( !instance->valid(instance_id) || (m = instance->map2imap(m, instance_id)) < 0 ) {
- script_pushconststr(st, "");
+ if( type )
+ script_pushint(st, -1);
+ else
+ script_pushconststr(st, "");
return true;
}
- script_pushconststr(st, map->list[m].name);
+ if( type )
+ script_pushint(st, instance_id);
+ else
+ script_pushconststr(st, map->list[m].name);
return true;
}
int buildin_instance_warpall_sub(struct block_list *bl,va_list ap) {
@@ -18921,6 +18931,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(instance_check_party,"i???"),
BUILDIN_DEF(instance_mapname,"s?"),
BUILDIN_DEF(instance_set_respawn,"sii?"),
+ BUILDIN_DEF2(has_instance,"has_instance2","s"),
/**
* 3rd-related