summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Henrique <carloshlfzanon@gmail.com>2018-09-20 16:08:47 -0300
committerCarlos Henrique <carloshlfzanon@gmail.com>2018-12-04 16:32:11 -0200
commit582336dff2bffba506891a54ecd9360e4fbdd65c (patch)
tree298a860fa285a1bc1d430322373b8b776de5fa2a
parent41d370cd3308be48b4ce00a50ee46515742978b0 (diff)
downloadhercules-582336dff2bffba506891a54ecd9360e4fbdd65c.tar.gz
hercules-582336dff2bffba506891a54ecd9360e4fbdd65c.tar.bz2
hercules-582336dff2bffba506891a54ecd9360e4fbdd65c.tar.xz
hercules-582336dff2bffba506891a54ecd9360e4fbdd65c.zip
Added mapflags 'nostorage' and 'nogstorage'
nostorage 1 -- blocks only @storage nostorage 2 -- blocks only openstorage(); nostorage 3 -- blocks @storage and openstorage() nogstorage 1 -- blocks only @gstorage nogstorage 2 -- blocks only guildopenstorage(); nogstorage 3 -- blocks @gstorage and guildopenstorage()
-rw-r--r--db/constants.conf2
-rw-r--r--doc/constants.md2
-rw-r--r--doc/permissions.md1
-rw-r--r--doc/script_commands.txt9
-rw-r--r--src/map/atcommand.c15
-rw-r--r--src/map/map.c26
-rw-r--r--src/map/map.h2
-rw-r--r--src/map/npc.c4
-rw-r--r--src/map/pc_groups.c1
-rw-r--r--src/map/pc_groups.h1
-rw-r--r--src/map/script.c19
-rw-r--r--src/map/script.h4
12 files changed, 83 insertions, 3 deletions
diff --git a/db/constants.conf b/db/constants.conf
index 08dc63b40..a6c74d56d 100644
--- a/db/constants.conf
+++ b/db/constants.conf
@@ -424,6 +424,8 @@ constants_db: {
mf_noviewid: 56
mf_pairship_startable: 57
mf_pairship_endable: 58
+ mf_nostorage: 59
+ mf_nogstorage: 60
comment__: "Cell Properties"
cell_walkable: 0
diff --git a/doc/constants.md b/doc/constants.md
index 276881a43..cca12c59a 100644
--- a/doc/constants.md
+++ b/doc/constants.md
@@ -362,6 +362,8 @@
- `mf_noviewid`: 56
- `mf_pairship_startable`: 57
- `mf_pairship_endable`: 58
+- `mf_nostorage`: 59
+- `mf_nogstorage`: 60
### Cell Properties
diff --git a/doc/permissions.md b/doc/permissions.md
index 7d29b59fd..a8794ecae 100644
--- a/doc/permissions.md
+++ b/doc/permissions.md
@@ -48,4 +48,5 @@ disable_pickup | Ability to disable the player from picking up any i
disable_exp | Ability to disable the player from gaining any experience point.
disable_store | Ability to disable the player from using/openning npc and player stores.
disable_skill_usage | Ability to disable the player from using any skill.
+bypass_nostorage | Ability to bypass the nostorage and nogstorage mapflag.
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 90d4d77cc..4d2517efa 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -5693,6 +5693,10 @@ storage window, to avoid any disruption when both windows overlap.
openstorage();
end;
+The mapflag 'nostorage' when set to type '2' (or 3), will not open the
+account storage. Unless the character group has the permission 'bypass_nostorage'.
+In case blocked by mapflag, returns 0.
+
---------------------------------------
*openmail()
@@ -5754,6 +5758,10 @@ time.
This will also fail and return 2 if the attached character does not belong
to any guild.
+The mapflag 'nogstorage' when set to type '2' (or 3), will not open the
+guild storage. Unless the character group has the permission 'bypass_nostorage'.
+In case blocked by mapflag, returns 1.
+
---------------------------------------
*guildchangegm(<guild id>, <new master's name>)
@@ -8160,6 +8168,7 @@ Valid <permission> are:
PERM_DISABLE_STORE
PERM_DISABLE_EXP
PERM_DISABLE_SKILL_USAGE
+ PERM_BYPASS_NOSTORAGE
Example:
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 6cfa86163..b8a2670ec 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -871,6 +871,11 @@ ACMD(storage)
if (sd->npc_id || sd->state.vending || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
return false;
+ if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nostorage & 1)) { // mapflag nostorage already defined? can't open :c
+ clif->message(fd, msg_fd(fd, 1161)); // You currently cannot open your storage.
+ return false;
+ }
+
if (storage->open(sd) == 1) { //Already open.
clif->message(fd, msg_fd(fd,250)); // You have already opened your storage. Close it first.
return false;
@@ -904,6 +909,11 @@ ACMD(guildstorage)
return false;
}
+ if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nogstorage & 1)) { // mapflag nogstorage already defined? can't open :c
+ clif->message(fd, msg_fd(fd, 1161)); // You currently cannot open your storage. (there is no other messages...)
+ return false;
+ }
+
if( gstorage->open(sd) ) {
clif->message(fd, msg_fd(fd,1201)); // Your guild's storage has already been opened by another member, try again later.
return false;
@@ -7739,6 +7749,7 @@ ACMD(mapflag)
CHECKFLAG(nodrop); CHECKFLAG(novending); CHECKFLAG(loadevent);
CHECKFLAG(nochat); CHECKFLAG(partylock); CHECKFLAG(guildlock); CHECKFLAG(src4instance);
CHECKFLAG(notomb); CHECKFLAG(nocashshop); CHECKFLAG(noviewid); CHECKFLAG(town);
+ CHECKFLAG(nostorage); CHECKFLAG(nogstorage);
clif->message(sd->fd," ");
clif->message(sd->fd,msg_fd(fd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
clif->message(sd->fd,msg_fd(fd,1313)); // Type "@mapflag available" to list the available mapflags.
@@ -7780,7 +7791,7 @@ ACMD(mapflag)
SETFLAG(nomvploot); SETFLAG(nightenabled); SETFLAG(nodrop); SETFLAG(novending);
SETFLAG(loadevent); SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock);
SETFLAG(src4instance); SETFLAG(notomb); SETFLAG(nocashshop); SETFLAG(noviewid);
- SETFLAG(town);
+ SETFLAG(town); SETFLAG(nostorage); SETFLAG(nogstorage);
clif->message(sd->fd, msg_fd(fd, 1314)); // Invalid flag name or flag.
@@ -7793,7 +7804,7 @@ ACMD(mapflag)
clif->message(sd->fd, "nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
clif->message(sd->fd, "fog, fireworks, sakura, leaves, nobaseexp, nojobexp, nomobloot,");
clif->message(sd->fd, "nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,");
- clif->message(sd->fd, "guildlock, src4instance, notomb, nocashshop, noviewid");
+ clif->message(sd->fd, "guildlock, src4instance, notomb, nocashshop, noviewid, nostorage, nogstorage");
#undef CHECKFLAG
#undef SETFLAG
diff --git a/src/map/map.c b/src/map/map.c
index 93e86f80b..a0ac8cd95 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -5425,6 +5425,32 @@ static bool map_zone_mf_cache(int m, char *flag, char *params)
else if( map->list[m].flag.nocashshop )
map_zone_mf_cache_add(m,"nocashshop");
}
+ } else if (strcmpi(flag, "nostorage") == 0) {
+ if (!state) {
+ if (map->list[m].flag.nostorage != 0) {
+ sprintf(rflag, "nostorage\t%d", map->list[m].flag.nostorage);
+ map_zone_mf_cache_add(m, rflag);
+ }
+ }
+ if (sscanf(params, "%d", &state) == 1) {
+ if (state != map->list[m].flag.nostorage) {
+ sprintf(rflag, "nostorage\t%d", state);
+ map_zone_mf_cache_add(m, rflag);
+ }
+ }
+ } else if (strcmpi(flag, "nogstorage") == 0) {
+ if (!state) {
+ if (map->list[m].flag.nogstorage != 0) {
+ sprintf(rflag, "nogstorage\t%d", map->list[m].flag.nogstorage);
+ map_zone_mf_cache_add(m, rflag);
+ }
+ }
+ if (sscanf(params, "%d", &state) == 1) {
+ if (state != map->list[m].flag.nogstorage) {
+ sprintf(rflag, "nogstorage\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 4267c2c88..25ff63edc 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -899,6 +899,8 @@ struct map_data {
unsigned noautoloot : 1;
unsigned pairship_startable : 1;
unsigned pairship_endable : 1;
+ unsigned nostorage : 2;
+ unsigned nogstorage : 2;
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 7f57a9c50..fa277f382 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -4555,6 +4555,10 @@ static const char *npc_parse_mapflag(const char *w1, const char *w2, const char
map->list[m].flag.pairship_startable = (state) ? 1 : 0;
} else if (!strcmpi(w3, "pairship_endable")) {
map->list[m].flag.pairship_endable = (state) ? 1 : 0;
+ } else if (!strcmpi(w3, "nostorage")) {
+ 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 {
npc->parse_unknown_mapflag(mapname, w3, w4, start, buffer, filepath, retval);
}
diff --git a/src/map/pc_groups.c b/src/map/pc_groups.c
index 887c946e3..8d55897b8 100644
--- a/src/map/pc_groups.c
+++ b/src/map/pc_groups.c
@@ -449,6 +449,7 @@ static void do_init_pc_groups(void)
{ "disable_store", PC_PERM_DISABLE_STORE },
{ "disable_exp", PC_PERM_DISABLE_EXP },
{ "disable_skill_usage", PC_PERM_DISABLE_SKILL_USAGE },
+ { "bypass_nostorage", PC_PERM_BYPASS_NOSTORAGE },
};
unsigned char i, len = ARRAYLENGTH(pc_g_defaults);
diff --git a/src/map/pc_groups.h b/src/map/pc_groups.h
index 6070809e0..f3994b9c4 100644
--- a/src/map/pc_groups.h
+++ b/src/map/pc_groups.h
@@ -57,6 +57,7 @@ enum e_pc_permission {
PC_PERM_DISABLE_STORE = 0x1000000,
PC_PERM_DISABLE_EXP = 0x2000000,
PC_PERM_DISABLE_SKILL_USAGE = 0x4000000,
+ PC_PERM_BYPASS_NOSTORAGE = 0x8000000,
};
// Cached config settings for quick lookup
diff --git a/src/map/script.c b/src/map/script.c
index 41f21cd72..e92c4c227 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10561,6 +10561,12 @@ static BUILDIN(openstorage)
return false;
}
+ // Mapflag preventing from openstorage here
+ if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nostorage & 2)) {
+ script_pushint(st, 0);
+ return true;
+ }
+
storage->open(sd);
script_pushint(st, 1); // success flag.
@@ -10574,6 +10580,12 @@ static BUILDIN(guildopenstorage)
if (sd == NULL)
return true;
+ // Mapflag preventing from openstorage here
+ if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nogstorage & 2)) {
+ script_pushint(st, 1);
+ return true;
+ }
+
ret = gstorage->open(sd);
script_pushint(st,ret);
return true;
@@ -13064,6 +13076,8 @@ static BUILDIN(getmapflag)
case MF_NOVIEWID: script_pushint(st, map->list[m].flag.noviewid); break;
case MF_PAIRSHIP_STARTABLE: script_pushint(st, map->list[m].flag.pairship_startable); break;
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;
}
}
@@ -13194,6 +13208,8 @@ static BUILDIN(setmapflag)
case MF_NOVIEWID: map->list[m].flag.noviewid = (val <= 0) ? EQP_NONE : val; break;
case MF_PAIRSHIP_STARTABLE: map->list[m].flag.pairship_startable = 1; break;
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;
}
}
@@ -13285,6 +13301,8 @@ static BUILDIN(removemapflag)
case MF_NOCASHSHOP: map->list[m].flag.nocashshop = 0; break;
case MF_NOAUTOLOOT: map->list[m].flag.noautoloot = 0; break;
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;
}
}
@@ -25755,6 +25773,7 @@ static void script_hardcoded_constants(void)
script->set_constant("PERM_DISABLE_STORE", PC_PERM_DISABLE_STORE, false, false);
script->set_constant("PERM_DISABLE_EXP", PC_PERM_DISABLE_EXP, false, false);
script->set_constant("PERM_DISABLE_SKILL_USAGE", PC_PERM_DISABLE_SKILL_USAGE, false, false);
+ script->set_constant("PERM_BYPASS_NOSTORAGE", PC_PERM_BYPASS_NOSTORAGE, false, false);
script->constdb_comment("Data types");
script->set_constant("DATATYPE_NIL", DATATYPE_NIL, false, false);
diff --git a/src/map/script.h b/src/map/script.h
index 549ad3284..e577867ba 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -343,7 +343,9 @@ enum {
MF_NOAUTOLOOT,
MF_NOVIEWID,
MF_PAIRSHIP_STARTABLE,
- MF_PAIRSHIP_ENDABLE
+ MF_PAIRSHIP_ENDABLE,
+ MF_NOSTORAGE,
+ MF_NOGSTORAGE
};
enum navigation_service {