diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 06ef888159..62b70f04e6 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -9697,12 +9697,18 @@ Examples: --------------------------------------- -*instance_warpall "",,{,}; +*instance_warpall "",,{,,{}}; Warps all players in the to to the given coordinates. If no ID is specified, the IM_PARTY instance the invoking player is attached to is used. If that fails, the script will come to a halt. + bitmask allows to add restrictions. + +Available values for the bitmask: + IWA_NONE No restriction. (default) + IWA_NOTDEAD If dead players are warped or not + --------------------------------------- *instance_announce ,"",{,{,{,{,{,}}}}}; diff --git a/src/map/script.cpp b/src/map/script.cpp index 2446043033..7a4f4cebba 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -21528,6 +21528,7 @@ static int buildin_instance_warpall_sub(struct block_list *bl, va_list ap) int x = va_arg(ap,int); int y = va_arg(ap,int); int instance_id = va_arg(ap, int); + int flag = va_arg(ap, int); map_session_data *sd; nullpo_retr(0, bl); @@ -21537,6 +21538,9 @@ static int buildin_instance_warpall_sub(struct block_list *bl, va_list ap) sd = (TBL_PC *)bl; + if ((flag & IWA_NOTDEAD) != 0 && pc_isdead(sd)) + return 0; + std::shared_ptr idata = util::umap_find(instances, instance_id); if (!idata) @@ -21572,19 +21576,18 @@ BUILDIN_FUNC(instance_warpall) { int16 m; int instance_id; - const char *mapn; - int x, y; - mapn = script_getstr(st,2); - x = script_getnum(st,3); - y = script_getnum(st,4); + const char *mapn = script_getstr(st,2); + if( script_hasdata(st,5) ) instance_id = script_getnum(st,5); else instance_id = script_instancegetid(st, IM_PARTY); - if( instance_id <= 0 || (m = map_mapname2mapid(mapn)) < 0 || (m = instance_mapid(m, instance_id)) < 0) + if( instance_id <= 0 || (m = map_mapname2mapid(mapn)) < 0 || (m = instance_mapid(m, instance_id)) < 0) { + ShowError("buildin_instance_warpall: Instance map for instance ID %d is not found.\n", instance_id); return SCRIPT_CMD_FAILURE; + } std::shared_ptr idata = util::umap_find(instances, instance_id); @@ -21593,8 +21596,15 @@ BUILDIN_FUNC(instance_warpall) return SCRIPT_CMD_FAILURE; } + int flag = IWA_NONE; + int x = script_getnum(st,3); + int y = script_getnum(st,4); + + if( script_hasdata(st, 6) ) + flag = script_getnum(st, 6); + for(const auto &it : idata->map) - map_foreachinmap(buildin_instance_warpall_sub, it.m, BL_PC, map_id2index(m), x, y, instance_id); + map_foreachinmap(buildin_instance_warpall_sub, it.m, BL_PC, map_id2index(m), x, y, instance_id, flag); return SCRIPT_CMD_SUCCESS; } @@ -27447,7 +27457,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(instance_enter,"s????"), BUILDIN_DEF(instance_npcname,"s?"), BUILDIN_DEF(instance_mapname,"s?"), - BUILDIN_DEF(instance_warpall,"sii?"), + BUILDIN_DEF(instance_warpall,"sii??"), BUILDIN_DEF(instance_announce,"isi?????"), BUILDIN_DEF(instance_check_party,"i???"), BUILDIN_DEF(instance_check_guild,"i???"), diff --git a/src/map/script.hpp b/src/map/script.hpp index 4c1082044a..f000f6906c 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -2090,6 +2090,11 @@ enum e_convertpcinfo_type : uint8 { CPC_ACCOUNT = 2 }; +enum e_instance_warpall_flag{ + IWA_NONE = 0x00, + IWA_NOTDEAD = 0x01, +}; + /** * Player blocking actions related flags. */ diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp index 44a5205626..36f22c3e21 100644 --- a/src/map/script_constants.hpp +++ b/src/map/script_constants.hpp @@ -9489,6 +9489,10 @@ export_constant(CPC_CHAR); export_constant(CPC_ACCOUNT); + /* instance_warpall flags */ + export_constant(IWA_NONE); + export_constant(IWA_NOTDEAD); + /* skill hit */ export_constant(DMG_SINGLE); export_constant(DMG_MULTI_HIT);