diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 49b350dae9..0a7445f3b0 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -8660,6 +8660,12 @@ same as NPC sprite facing directions: 0=north, 1=northwest, 2=west, etc. --------------------------------------- +*checkwall ""; + +This command will return true if the wall with the given name exists, false otherwise. + +--------------------------------------- + *readbook ,; This command will open a book item at the specified page. diff --git a/npc/battleground/tierra/tierra01.txt b/npc/battleground/tierra/tierra01.txt index 22f89adcce..5ee7bbeae4 100644 --- a/npc/battleground/tierra/tierra01.txt +++ b/npc/battleground/tierra/tierra01.txt @@ -208,7 +208,8 @@ OnEnable: OnKill: killmonster "bat_a01","barricade#bat_a01_a::OnMyMobDead"; - delwall "bat_a01_c1"; + if (checkwall("bat_a01_c1") == true) + delwall "bat_a01_c1"; end; OnMyMobDead: @@ -230,7 +231,8 @@ OnEnable: OnKill: killmonster "bat_a01","barricade#bat_a01_b::OnMyMobDead"; - delwall "bat_a01_g1"; + if (checkwall("bat_a01_g1") == true) + delwall "bat_a01_g1"; end; OnMyMobDead: diff --git a/npc/battleground/tierra/tierra02.txt b/npc/battleground/tierra/tierra02.txt index 8f99ec8c30..593aca84a6 100644 --- a/npc/battleground/tierra/tierra02.txt +++ b/npc/battleground/tierra/tierra02.txt @@ -207,7 +207,8 @@ OnEnable: OnKill: killmonster "bat_a02","barricade#bat_a02_a::OnMyMobDead"; - delwall "bat_a02_c1"; + if (checkwall("bat_a02_c1") == true) + delwall "bat_a02_c1"; end; OnMyMobDead: @@ -229,7 +230,8 @@ OnEnable: OnKill: killmonster "bat_a02","barricade#bat_a02_b::OnMyMobDead"; - delwall "bat_a02_g1"; + if (checkwall("bat_a02_g1") == true) + delwall "bat_a02_g1"; end; OnMyMobDead: diff --git a/npc/custom/battleground/unofficial/bg_tierra_01.txt b/npc/custom/battleground/unofficial/bg_tierra_01.txt index c32f1db89f..3d8102b539 100644 --- a/npc/custom/battleground/unofficial/bg_tierra_01.txt +++ b/npc/custom/battleground/unofficial/bg_tierra_01.txt @@ -275,7 +275,8 @@ OnBuild: OnDestroy: killmonster "bat_a01","Guillaume_TV1B::OnWall"; - delwall "bat_a01_g1"; + if (checkwall("bat_a01_g1") == true) + delwall "bat_a01_g1"; set .MyMobCount,0; end; diff --git a/npc/custom/battleground/unofficial/bg_tierra_02.txt b/npc/custom/battleground/unofficial/bg_tierra_02.txt index 72a802b633..6aec5608f3 100644 --- a/npc/custom/battleground/unofficial/bg_tierra_02.txt +++ b/npc/custom/battleground/unofficial/bg_tierra_02.txt @@ -275,7 +275,8 @@ OnBuild: OnDestroy: killmonster "bat_a02","Guillaume_TV2B::OnWall"; - delwall "bat_a02_g1"; + if (checkwall("bat_a02_g1") == true) + delwall "bat_a02_g1"; set .MyMobCount,0; end; diff --git a/npc/guild2/agit_main_se.txt b/npc/guild2/agit_main_se.txt index 462695fc2f..eb839045d7 100644 --- a/npc/guild2/agit_main_se.txt +++ b/npc/guild2/agit_main_se.txt @@ -1700,7 +1700,9 @@ OnBarrierDestroyed: end; OnDisable: - delwall substr(strnpcinfo(2),0,1)+substr(strnpcinfo(2),8,9)+"_"+strnpcinfo(1); + .@wall_name$ = substr(strnpcinfo(2),0,1) + substr(strnpcinfo(2),8,9) + "_" + strnpcinfo(1); + if (checkwall(.@wall_name$) == true) + delwall .@wall_name$; killmonster strnpcinfo(2),strnpcinfo(0)+"::OnBarrierDestroyed"; end; } diff --git a/src/map/map.cpp b/src/map/map.cpp index a2c13d19d8..70dfa0242e 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -3228,6 +3228,11 @@ void map_setgatcell(int16 m, int16 x, int16 y, int gat) *------------------------------------------*/ static DBMap* iwall_db; +bool map_iwall_exist(const char* wall_name) +{ + return strdb_exists(iwall_db, wall_name); +} + void map_iwall_nextxy(int16 x, int16 y, int8 dir, int pos, int16 *x1, int16 *y1) { if( dir == 0 || dir == 4 ) diff --git a/src/map/map.hpp b/src/map/map.hpp index 669918aea9..45bd7e248d 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -1098,6 +1098,7 @@ int cleanup_sub(struct block_list *bl, va_list ap); int map_delmap(char* mapname); void map_flags_init(void); +bool map_iwall_exist(const char* wall_name); bool map_iwall_set(int16 m, int16 x, int16 y, int size, int8 dir, bool shootable, const char* wall_name); void map_iwall_get(struct map_session_data *sd); bool map_iwall_remove(const char *wall_name); diff --git a/src/map/script.cpp b/src/map/script.cpp index 5658d54751..e102932efc 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -13327,6 +13327,14 @@ BUILDIN_FUNC(delwall) return SCRIPT_CMD_SUCCESS; } +BUILDIN_FUNC(checkwall) +{ + const char *wall_name = script_getstr(st, 2); + + script_pushint(st, map_iwall_exist(wall_name)); + return SCRIPT_CMD_SUCCESS; +} + /// Retrieves various information about the specified guardian. /// /// guardianinfo("", , ) -> @@ -24267,6 +24275,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(getfreecell,"srr?????"), BUILDIN_DEF(setwall,"siiiiis"), BUILDIN_DEF(delwall,"s"), + BUILDIN_DEF(checkwall,"s"), BUILDIN_DEF(searchitem,"rs"), BUILDIN_DEF(mercenary_create,"ii"), BUILDIN_DEF(mercenary_heal,"ii"),