diff options
author | Kenpachi Developer <Kenpachi.Developer@gmx.de> | 2020-01-07 23:47:20 +0100 |
---|---|---|
committer | Kenpachi Developer <Kenpachi.Developer@gmx.de> | 2020-01-07 23:55:25 +0100 |
commit | d1438cbd7c18ab01d2baf57912c958ba8b804e6c (patch) | |
tree | 6c83a5c8a009d2c8fa1f5ab19f68a8476d34929b /src | |
parent | ced392f67b1252a052aa079b099e0eb46a4e02cf (diff) | |
download | hercules-d1438cbd7c18ab01d2baf57912c958ba8b804e6c.tar.gz hercules-d1438cbd7c18ab01d2baf57912c958ba8b804e6c.tar.bz2 hercules-d1438cbd7c18ab01d2baf57912c958ba8b804e6c.tar.xz hercules-d1438cbd7c18ab01d2baf57912c958ba8b804e6c.zip |
Re-added mapflag restrictions to warpparty() and introduced a flag to disable them as requested.
Diffstat (limited to 'src')
-rw-r--r-- | src/map/script.c | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/src/map/script.c b/src/map/script.c index 9881f8d97..f450549ff 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6757,7 +6757,7 @@ static BUILDIN(warpchar) * Warps a party to a specific/random map or save point. * * @code{.herc} - * warpparty("<to map name>", <x>, <y>, <party id>{, "<from map name>"{, <include leader>}}); + * warpparty("<to map name>", <x>, <y>, <party id>{{, <ignore mapflags>}, "<from map name>"{, <include leader>}}); * @endcode * **/ @@ -6819,23 +6819,47 @@ static BUILDIN(warpparty) } for (int i = 0; i < MAX_PARTY; i++) { - const bool include_leader = script_hasdata(st, 7) ? script_getnum(st, 7) : true; - const char *m_name_from = script_hasdata(st, 6) ? script_getstr(st, 6) : NULL; + if ((p_sd = p->data[i].sd) == NULL || p_sd->status.party_id != p_id || pc_isdead(p_sd)) + continue; + + int offset = 0; + bool ignore_mapflags = false; + + if (script_hasdata(st, 6) && script_isinttype(st, 6)) { + offset = 1; + ignore_mapflags = (script_getnum(st, 6) != 0); + } + + if (!ignore_mapflags) { + if (((type == 0 || type > 2) && map->list[p_sd->bl.m].flag.nowarp == 1) || + (type > 0 && map->list[p_sd->bl.m].flag.noreturn == 1)) + continue; + } + + const bool include_leader = script_hasdata(st, 7 + offset) ? script_getnum(st, 7 + offset) : true; if (p->party.member[i].online == 0 || (!include_leader && p->party.member[i].leader == 1)) continue; - if ((p_sd = p->data[i].sd) == NULL || p_sd->status.party_id != p_id || pc_isdead(p_sd)) - continue; + const char *m_name_from = script_hasdata(st, 6 + offset) ? script_getstr(st, 6 + offset) : NULL; + + if (m_name_from != NULL && script->mapindexname2id(st, m_name_from) == 0) { + ShowError("script:%s: Source map not found! (%s)\n", script->getfuncname(st), m_name_from); + script_pushint(st, 0); + return false; + } if (m_name_from != NULL && strcmp(m_name_from, map->list[p_sd->bl.m].name) != 0) continue; - if (type > 1) + if (type == 1) { + map_index = p_sd->status.save_point.map; + x = p_sd->status.save_point.x; + y = p_sd->status.save_point.y; + } + + if (type > 0) pc->setpos(p_sd, map_index, x, y, CLR_TELEPORT); - else if (type == 1) - pc->setpos(p_sd, p_sd->status.save_point.map, p_sd->status.save_point.x, - p_sd->status.save_point.y, CLR_TELEPORT); else pc->randomwarp(p_sd, CLR_TELEPORT); } |