From 54dc915661bdb63e52eb399cfc8b5cb15c3ad15f Mon Sep 17 00:00:00 2001 From: eppc0330 <47050704+eppc0330@users.noreply.github.com> Date: Thu, 1 Aug 2024 22:05:54 +0900 Subject: [PATCH] Add mapflag specialpopup (#8365) * Add packet ZC_SPECIALPOPUP. * Add mapflag and script command specialpopup. Co-authored-by: Lemongrass3110 Co-authored-by: Atemo Co-authored-by: Aleos --- doc/mapflags.txt | 6 ++++ doc/script_commands.txt | 9 ++++++ npc/re/mapflag/specialpopup.txt | 50 +++++++++++++++++++++++++++++++++ npc/re/scripts_mapflags.conf | 1 + src/map/clif.cpp | 20 +++++++++++++ src/map/clif.hpp | 2 ++ src/map/map.cpp | 8 ++++++ src/map/map.hpp | 1 + src/map/npc.cpp | 10 +++++++ src/map/script.cpp | 17 +++++++++++ src/map/script_constants.hpp | 1 + 11 files changed, 125 insertions(+) create mode 100644 npc/re/mapflag/specialpopup.txt diff --git a/doc/mapflags.txt b/doc/mapflags.txt index 8f1d9c459e..d49e82cadc 100644 --- a/doc/mapflags.txt +++ b/doc/mapflags.txt @@ -474,3 +474,9 @@ Hides monster's HP bar on a map. Ignores config value of 'monster_hp_bars_info'. --------------------------------------- + +*specialpopup + +Displays a special popup when a player enters the map. See script command "specialpopup" for details on different popup types. + +--------------------------------------- diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 36ffd3c48a..1671e36b4d 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -8508,6 +8508,15 @@ Opens the tip box UI for the attached player or the given character ID. This command requires packet version 2017-11-22 or newer. +--------------------------------------- + +*specialpopup(); + +Open popup and/or show text by ID from list defined in the client spopup.lub file. +Popup and text is only visible if the player warped from one map to another map. + +This command requires packet version 2022-10-05 or newer. + --------------------------------------- \\ 6,1.- Unit-related commands diff --git a/npc/re/mapflag/specialpopup.txt b/npc/re/mapflag/specialpopup.txt new file mode 100644 index 0000000000..9f74ae16a0 --- /dev/null +++ b/npc/re/mapflag/specialpopup.txt @@ -0,0 +1,50 @@ +//===== rAthena Script ======================================= +//= Mapflag: special popup map setting. +//===== Description: ========================================= +//= Displays a special popup when a player enters the map. +//===== Additional Comments: ================================= +//= 1.0 Initial script. [eppc0330] +//============================================================ + +herosria mapflag specialpopup 1 +hero_in1 mapflag specialpopup 1 +hero_in2 mapflag specialpopup 1 +hero_in3 mapflag specialpopup 1 +hero_in4 mapflag specialpopup 1 +hero_out1 mapflag specialpopup 1 +hero_out2 mapflag specialpopup 1 +hero_out3 mapflag specialpopup 1 +hero_out4 mapflag specialpopup 1 +hero_ent1 mapflag specialpopup 1 +hero_ent2 mapflag specialpopup 1 +hero_ent3 mapflag specialpopup 1 + +hero_tra mapflag specialpopup 2 +hero_dun1 mapflag specialpopup 2 + +bl_ice mapflag specialpopup 3 +bl_lava mapflag specialpopup 3 +bl_grass mapflag specialpopup 3 +bl_death mapflag specialpopup 3 +bl_soul mapflag specialpopup 3 +bl_venom mapflag specialpopup 3 +bl_temple mapflag specialpopup 3 + +thana_step mapflag specialpopup 4 +tha_t07 mapflag specialpopup 4 +tha_t08 mapflag specialpopup 4 +tha_t09 mapflag specialpopup 4 +tha_t10 mapflag specialpopup 4 +tha_t11 mapflag specialpopup 4 +tha_t12 mapflag specialpopup 4 + +ama_dun01 mapflag specialpopup 5 + +lhz_dun_n mapflag specialpopup 6 + +bl_depth1 mapflag specialpopup 7 + +for_dun01 mapflag specialpopup 8 +for_dun02 mapflag specialpopup 8 + +bl_depth2 mapflag specialpopup 9 diff --git a/npc/re/scripts_mapflags.conf b/npc/re/scripts_mapflags.conf index 1320b6576e..cc5769c1bb 100644 --- a/npc/re/scripts_mapflags.conf +++ b/npc/re/scripts_mapflags.conf @@ -22,3 +22,4 @@ npc: npc/re/mapflag/town.txt npc: npc/re/mapflag/reset.txt npc: npc/re/mapflag/skill_duration.txt npc: npc/re/mapflag/nodynamicnpc.txt +npc: npc/re/mapflag/specialpopup.txt diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 93454915d1..c7533d3dc1 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -19713,6 +19713,12 @@ static void clif_loadConfirm( map_session_data *sd ){ /// 0447 void clif_parse_blocking_playcancel( int fd, map_session_data *sd ){ clif_loadConfirm( sd ); + + int32 mf = map_getmapflag(sd->bl.m, MF_SPECIALPOPUP); + + if (mf > 0) { + clif_specialpopup(*sd, mf); + } } /// req world info (CZ_CLIENT_VERSION) @@ -25119,6 +25125,20 @@ void clif_set_npc_window_pos_percent(map_session_data& sd, int x, int y) #endif // PACKETVER_MAIN_NUM >= 20220504 } +/// Displays a special popup. +/// Works only if player moved from one map to another. +/// 0bbe .L (ZC_SPECIALPOPUP) +void clif_specialpopup(map_session_data& sd, int32 id ){ +#if PACKETVER >= 20221005 + PACKET_ZC_SPECIALPOPUP p = {}; + + p.PacketType = HEADER_ZC_SPECIALPOPUP; + p.ppId = id; + + clif_send( &p, sizeof( p ), &sd.bl, SELF); +#endif +} + /*========================================== * Main client packet processing function *------------------------------------------*/ diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 7ef89d1703..6e347bcda3 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -1456,4 +1456,6 @@ void clif_set_npc_window_pos_percent(map_session_data& sd, int x, int y); void clif_noask_sub( map_session_data& sd, map_session_data& tsd, int type ); +void clif_specialpopup(map_session_data& sd, int32 id); + #endif /* CLIF_HPP */ diff --git a/src/map/map.cpp b/src/map/map.cpp index 62b27096d8..87af7b76bf 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -4785,6 +4785,14 @@ bool map_setmapflag_sub(int16 m, enum e_mapflag mapflag, bool status, union u_ma mapdata->setMapFlag(MF_NOBASEEXP, false); ShowWarning("map_setmapflag: Unable to set No Base EXP and BEXP flags for the same map! Removing No Base EXP flag from %s.\n", mapdata->name); } + mapdata->setMapFlag(mapflag, args->flag_val); + } else + mapdata->setMapFlag(mapflag, false); + break; + case MF_SPECIALPOPUP: + if (status) { + nullpo_retr(false, args); + mapdata->setMapFlag(mapflag, args->flag_val); } else mapdata->setMapFlag(mapflag, false); diff --git a/src/map/map.hpp b/src/map/map.hpp index c684b1e28d..2a1a3cb670 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -676,6 +676,7 @@ enum e_mapflag : int16 { MF_NOBUYINGSTORE, MF_NODYNAMICNPC, MF_NOBANK, + MF_SPECIALPOPUP, MF_MAX }; diff --git a/src/map/npc.cpp b/src/map/npc.cpp index fd49689f2e..bca76d1a38 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -5507,6 +5507,16 @@ static const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, con map_setmapflag_sub(m, mapflag, state, &args); } break; + + case MF_SPECIALPOPUP: { + union u_mapflag_args args = {}; + + if (sscanf(w4, "%11d", &args.flag_val) < 1) + args.flag_val = 0; + + map_setmapflag_sub(m, mapflag, state, &args); + } + break; case MF_SKILL_DAMAGE: { char skill_name[SKILL_NAME_LENGTH]; diff --git a/src/map/script.cpp b/src/map/script.cpp index a98128c5b5..e23c4fd45e 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -27234,6 +27234,22 @@ BUILDIN_FUNC(opentips){ #endif } +/** + * Displays a special popup. + * specialpopup(); + */ +BUILDIN_FUNC(specialpopup) { + map_session_data* sd; + + if( !script_rid2sd(sd) ) + return SCRIPT_CMD_FAILURE; + + int32 id = script_getnum(st,2); + clif_specialpopup(*sd, id); + + return SCRIPT_CMD_SUCCESS; +} + BUILDIN_FUNC(setdialogalign){ map_session_data *sd; @@ -28143,6 +28159,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(has_autoloot,"?"), BUILDIN_DEF(autoloot,"??"), BUILDIN_DEF(opentips, "i?"), + BUILDIN_DEF(specialpopup,"i"), BUILDIN_DEF(setdialogalign, "i"), BUILDIN_DEF(setdialogsize, "ii"), diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp index c060b151e4..c9c0a6fa58 100644 --- a/src/map/script_constants.hpp +++ b/src/map/script_constants.hpp @@ -538,6 +538,7 @@ export_constant(MF_NOBUYINGSTORE); export_constant(MF_NODYNAMICNPC); export_constant(MF_NOBANK); + export_constant(MF_SPECIALPOPUP); /* setcell types */ export_constant(CELL_WALKABLE);