Updated instance_warpall script command (#7591)

* Added a parameter to the instance_warpall script command to prevent dead players from being warped

Thanks to @aleos89, @Lemongrass3110 and @vstumpf for the reviews!
This commit is contained in:
Atemo
2023-02-12 16:09:20 +01:00
committed by GitHub
parent 36bcfaecee
commit bc7b9cdd2e
4 changed files with 34 additions and 9 deletions

View File

@@ -9697,12 +9697,18 @@ Examples:
---------------------------------------
*instance_warpall "<map name>",<x>,<y>{,<instance id>};
*instance_warpall "<map name>",<x>,<y>{,<instance id>,{<flag>}};
Warps all players in the <instance id> to <map name> 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.
<flag> bitmask allows to add restrictions.
Available values for the <flag> bitmask:
IWA_NONE No restriction. (default)
IWA_NOTDEAD If dead players are warped or not
---------------------------------------
*instance_announce <instance id>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};

View File

@@ -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<s_instance_data> 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<s_instance_data> 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???"),

View File

@@ -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.
*/

View File

@@ -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);