From 46e3a24ef647e5be1e10ae448d6572c93fa6ddf8 Mon Sep 17 00:00:00 2001 From: Emistry Haoyan Date: Sun, 8 Mar 2020 05:18:26 +0800 Subject: [TMW2 CHERRYPICK] Add NoPet mapflag - allow to set nopet mapflag at any maps. - mapflag to disable pet, and force return to egg. Original commit d3c24f7d9ae --- npc/mapflag/nopet.txt | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/map/atcommand.c | 2 ++ src/map/battle.c | 1 - src/map/battle.h | 1 - src/map/clif.c | 14 ++++----- src/map/map.c | 13 +++++++++ src/map/map.h | 1 + src/map/npc.c | 2 ++ src/map/script.c | 3 ++ src/map/script.h | 3 +- 10 files changed, 108 insertions(+), 10 deletions(-) create mode 100644 npc/mapflag/nopet.txt diff --git a/npc/mapflag/nopet.txt b/npc/mapflag/nopet.txt new file mode 100644 index 000000000..82f9e36eb --- /dev/null +++ b/npc/mapflag/nopet.txt @@ -0,0 +1,78 @@ +//================= Hercules Script ======================================= +//= _ _ _ +//= | | | | | | +//= | |_| | ___ _ __ ___ _ _| | ___ ___ +//= | _ |/ _ \ '__/ __| | | | |/ _ \/ __| +//= | | | | __/ | | (__| |_| | | __/\__ \ +//= \_| |_/\___|_| \___|\__,_|_|\___||___/ +//================= License =============================================== +//= This file is part of Hercules. +//= http://herc.ws - http://github.com/HerculesWS/Hercules +//= +//= Copyright (C) 2012-2020 Hercules Dev Team +//= +//= Hercules is free software: you can redistribute it and/or modify +//= it under the terms of the GNU General Public License as published by +//= the Free Software Foundation, either version 3 of the License, or +//= (at your option) any later version. +//= +//= This program is distributed in the hope that it will be useful, +//= but WITHOUT ANY WARRANTY; without even the implied warranty of +//= MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//= GNU General Public License for more details. +//= +//= You should have received a copy of the GNU General Public License +//= along with this program. If not, see . +//========================================================================= +//= Mapflag: Disable pet in map. +//================= Current Version ======================================= +//= 1.0 +//================= Description =========================================== +//= Players can't hatch pet in the map, existing pet will return to egg. +//========================================================================= + +// GvG Arenas ============= +// guild_vs1 mapflag nopet +// guild_vs2 mapflag nopet +// guild_vs3 mapflag nopet +// guild_vs4 mapflag nopet +// guild_vs5 mapflag nopet + +// Guild Castles ========== +// aldeg_cas01 mapflag nopet +// aldeg_cas02 mapflag nopet +// aldeg_cas03 mapflag nopet +// aldeg_cas04 mapflag nopet +// aldeg_cas05 mapflag nopet +// gefg_cas01 mapflag nopet +// gefg_cas02 mapflag nopet +// gefg_cas03 mapflag nopet +// gefg_cas04 mapflag nopet +// gefg_cas05 mapflag nopet +// payg_cas01 mapflag nopet +// payg_cas02 mapflag nopet +// payg_cas03 mapflag nopet +// payg_cas04 mapflag nopet +// payg_cas05 mapflag nopet +// prtg_cas01 mapflag nopet +// prtg_cas02 mapflag nopet +// prtg_cas03 mapflag nopet +// prtg_cas04 mapflag nopet +// prtg_cas05 mapflag nopet +// schg_cas01 mapflag nopet +// schg_cas02 mapflag nopet +// schg_cas03 mapflag nopet +// schg_cas04 mapflag nopet +// schg_cas05 mapflag nopet +// arug_cas01 mapflag nopet +// arug_cas02 mapflag nopet +// arug_cas03 mapflag nopet +// arug_cas04 mapflag nopet +// arug_cas05 mapflag nopet + +// Novice Guild Castles === +// n_castle mapflag nopet +// nguild_alde mapflag nopet +// nguild_gef mapflag nopet +// nguild_pay mapflag nopet +// nguild_prt mapflag nopet diff --git a/src/map/atcommand.c b/src/map/atcommand.c index f57583cfc..364d84662 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -4100,6 +4100,8 @@ ACMD(mapinfo) strcat(atcmd_output, msg_fd(fd, 1292)); // PrivateAirshipStartable | if (map->list[m_id].flag.pairship_endable) strcat(atcmd_output, msg_fd(fd, 1293)); // PrivateAirshipEndable | + if (map->list[m_id].flag.nopet != 0) + strcat(atcmd_output, msg_fd(fd, 853)); // NoPet | clif->message(fd, atcmd_output); switch (list) { diff --git a/src/map/battle.c b/src/map/battle.c index 71d4bb850..2f6a1e245 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -7097,7 +7097,6 @@ static const struct battle_data { { "pet_max_stats", &battle_config.pet_max_stats, 99, 0, INT_MAX, }, { "pet_max_atk1", &battle_config.pet_max_atk1, 750, 0, INT_MAX, }, { "pet_max_atk2", &battle_config.pet_max_atk2, 1000, 0, INT_MAX, }, - { "pet_disable_in_gvg", &battle_config.pet_no_gvg, 0, 0, 1, }, { "skill_min_damage", &battle_config.skill_min_damage, 2|4, 0, 1|2|4, }, { "finger_offensive_type", &battle_config.finger_offensive_type, 0, 0, 1, }, { "heal_exp", &battle_config.heal_exp, 0, 0, INT_MAX, }, diff --git a/src/map/battle.h b/src/map/battle.h index dd6265b1e..1f87922d2 100644 --- a/src/map/battle.h +++ b/src/map/battle.h @@ -229,7 +229,6 @@ struct Battle_Config { int pet_max_stats; //[Skotlex] int pet_max_atk1; //[Skotlex] int pet_max_atk2; //[Skotlex] - int pet_no_gvg; //Disables pets in gvg. [Skotlex] int pet_equip_required; int skill_min_damage; diff --git a/src/map/clif.c b/src/map/clif.c index 9f30408e4..3289e80c5 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -7549,8 +7549,8 @@ static void clif_sendegg(struct map_session_data *sd) nullpo_retv(sd); fd = sd->fd; - if (battle_config.pet_no_gvg && map_flag_gvg2(sd->bl.m)) { //Disable pet hatching in GvG grounds during Guild Wars [Skotlex] - clif->message(fd, msg_sd(sd, 866)); // "Pets are not allowed in Guild Wars." + if (map->list[sd->bl.m].flag.nopet != 0) { + clif->message(fd, msg_sd(sd, 866)); // "Pets are disabled in this map." return; } @@ -10621,11 +10621,11 @@ static void clif_parse_LoadEndAck(int fd, struct map_session_data *sd) // must use foreachinarea (CIRCULAR_AREA interferes with foreachinrange) map->foreachinarea(clif->getareachar, sd->bl.m, sd->bl.x-AREA_SIZE, sd->bl.y-AREA_SIZE, sd->bl.x+AREA_SIZE, sd->bl.y+AREA_SIZE, BL_ALL, sd); - // pet - if( sd->pd ) { - if( battle_config.pet_no_gvg && map_flag_gvg2(sd->bl.m) ) { //Return the pet to egg. [Skotlex] - clif->message(sd->fd, msg_sd(sd,866)); // "Pets are not allowed in Guild Wars." - pet->menu(sd, 3); //Option 3 is return to egg. + // Spawn pet. + if (sd->pd != NULL) { + if (map->list[sd->bl.m].flag.nopet != 0) { // Return the pet to egg. [Skotlex] + clif->message(sd->fd, msg_sd(sd, 866)); // Pets are not allowed in Guild Wars. + pet->menu(sd, 3); // Option 3 is return to egg. } else { map->addblock(&sd->pd->bl); clif->spawn(&sd->pd->bl); diff --git a/src/map/map.c b/src/map/map.c index 50ad9a5cd..30b7a59ad 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -5403,6 +5403,19 @@ static bool map_zone_mf_cache(int m, char *flag, char *params) map_zone_mf_cache_add(m, rflag); } } + } else if (strcmpi(flag, "nopet") == 0) { + if (state == 0) { + if (map->list[m].flag.nopet != 0) { + sprintf(rflag, "nopet\t%d", map->list[m].flag.nopet); + map_zone_mf_cache_add(m, rflag); + } + } + if (sscanf(params, "%d", &state) == 1) { + if (state != map->list[m].flag.nopet) { + sprintf(rflag, "nopet\t%d", state); + map_zone_mf_cache_add(m, rflag); + } + } } return false; diff --git a/src/map/map.h b/src/map/map.h index 6b360e1bc..b9199f3bb 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -787,6 +787,7 @@ struct map_data { unsigned pairship_endable : 1; unsigned nostorage : 2; unsigned nogstorage : 2; + unsigned nopet : 1; uint32 noviewid; ///< noviewid (bitmask - @see enum equip_pos) } flag; struct point save; diff --git a/src/map/npc.c b/src/map/npc.c index 00207a745..d6b18ec9e 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -4810,6 +4810,8 @@ static const char *npc_parse_mapflag(const char *w1, const char *w2, const char map->list[m].flag.nostorage = (state) ? cap_value(atoi(w4), 1, 3) : 0; } else if (!strcmpi(w3, "nogstorage")) { map->list[m].flag.nogstorage = (state) ? cap_value(atoi(w4), 1, 3) : 0; + } else if (strcmpi(w3, "nopet") == 0) { + map->list[m].flag.nopet = (state != 0) ? 1 : 0; } else { npc->parse_unknown_mapflag(mapname, w3, w4, start, buffer, filepath, retval); } diff --git a/src/map/script.c b/src/map/script.c index 1a31631ed..1448715a7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -13361,6 +13361,7 @@ static BUILDIN(getmapflag) case MF_PAIRSHIP_ENDABLE: script_pushint(st, map->list[m].flag.pairship_endable); break; case MF_NOSTORAGE: script_pushint(st, map->list[m].flag.nostorage); break; case MF_NOGSTORAGE: script_pushint(st, map->list[m].flag.nogstorage); break; + case MF_NOPET: script_pushint(st, map->list[m].flag.nopet); break; } } @@ -13493,6 +13494,7 @@ static BUILDIN(setmapflag) case MF_PAIRSHIP_ENDABLE: map->list[m].flag.pairship_endable = 1; break; case MF_NOSTORAGE: map->list[m].flag.nostorage = cap_value(val, 0, 3); break; case MF_NOGSTORAGE: map->list[m].flag.nogstorage = cap_value(val, 0, 3); break; + case MF_NOPET: map->list[m].flag.nopet = 1; break; } } @@ -13586,6 +13588,7 @@ static BUILDIN(removemapflag) case MF_NOVIEWID: map->list[m].flag.noviewid = EQP_NONE; break; case MF_NOSTORAGE: map->list[m].flag.nostorage = 0; break; case MF_NOGSTORAGE: map->list[m].flag.nogstorage = 0; break; + case MF_NOPET: map->list[m].flag.nopet = 0; break; } } diff --git a/src/map/script.h b/src/map/script.h index 1cec02b97..654bf1374 100644 --- a/src/map/script.h +++ b/src/map/script.h @@ -345,7 +345,8 @@ enum { MF_PAIRSHIP_STARTABLE, MF_PAIRSHIP_ENDABLE, MF_NOSTORAGE, - MF_NOGSTORAGE + MF_NOGSTORAGE, + MF_NOPET, }; enum navigation_service { -- cgit v1.2.3-60-g2f50