Skip to content

Commit

Permalink
nocashshop mapflag
Browse files Browse the repository at this point in the history
As requested by the community in http://hercules.ws/board/topic/1477-mapflag-for-cash-shop/ and http://hercules.ws/board/topic/1476-disable-cashshop-in-pvp-woe/
'nocashshop' mapflag disables the usage of the cashshop button as well as any attempts to purchase (in case the flag is turned on after someone gets the shop open).

Signed-off-by: shennetsind <ind@henn.et>
  • Loading branch information
shennetsind committed Oct 25, 2013
1 parent 259fe19 commit 8629562
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 6 deletions.
2 changes: 2 additions & 0 deletions conf/messages.conf
Expand Up @@ -1532,5 +1532,7 @@
1487: Character cannot be disguised while in monster form.
1488: Transforming into monster is not allowed in Guild Wars.

//CashShop mapflag
1489: Cash Shop is disabled in this map
//Custom translations
import: conf/import/msg_conf.txt
2 changes: 2 additions & 0 deletions db/const.txt
Expand Up @@ -365,6 +365,8 @@ mf_monster_noteleport 49
mf_pvp_nocalcrank 50
mf_battleground 51
mf_reset 52
mf_notomb 53
mf_nocashshop 54

cell_walkable 0
cell_shootable 1
Expand Down
7 changes: 6 additions & 1 deletion db/pre-re/map_zone_db.conf
Expand Up @@ -87,6 +87,9 @@ zones: (
disabled_items: {
Greed_Scroll: true
}

mapflags: ( "nocashshop" )

},
{
/* PK Mode zone is only used when server is on pk_mode (battle.conf),
Expand Down Expand Up @@ -157,7 +160,9 @@ zones: (
"magic_damage_rate 60",
"misc_damage_rate 60",
"long_damage_rate 80",
"short_damage_rate 80" )
"short_damage_rate 80",
"nocashshop"
)

},
{
Expand Down
7 changes: 6 additions & 1 deletion db/re/map_zone_db.conf
Expand Up @@ -87,6 +87,9 @@ zones: (
disabled_items: {
Greed_Scroll: true
}

/* cashshop disabled in pvp maps */
mapflags: ( "nocashshop" )
},
{
/* PK Mode zone is only used when server is on pk_mode (battle.conf),
Expand Down Expand Up @@ -157,7 +160,9 @@ zones: (
"magic_damage_rate 60",
"misc_damage_rate 60",
"long_damage_rate 80",
"short_damage_rate 80" )
"short_damage_rate 80",
"nocashshop"
)

},
{
Expand Down
6 changes: 3 additions & 3 deletions src/map/atcommand.c
Expand Up @@ -7333,7 +7333,7 @@ ACMD(mapflag) {
CHECKFLAG(nojobexp); CHECKFLAG(nomobloot); CHECKFLAG(nomvploot); CHECKFLAG(nightenabled);
CHECKFLAG(nodrop); CHECKFLAG(novending); CHECKFLAG(loadevent);
CHECKFLAG(nochat); CHECKFLAG(partylock); CHECKFLAG(guildlock); CHECKFLAG(src4instance);
CHECKFLAG(notomb);
CHECKFLAG(notomb); CHECKFLAG(nocashshop);
clif->message(sd->fd," ");
clif->message(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
clif->message(sd->fd,msg_txt(1313)); // Type "@mapflag available" to list the available mapflags.
Expand Down Expand Up @@ -7370,7 +7370,7 @@ ACMD(mapflag) {
SETFLAG(nojobexp); SETFLAG(nomobloot); SETFLAG(nomvploot); SETFLAG(nightenabled);
SETFLAG(nodrop); SETFLAG(novending); SETFLAG(loadevent);
SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock); SETFLAG(src4instance);
SETFLAG(notomb);
SETFLAG(notomb); SETFLAG(nocashshop);

clif->message(sd->fd,msg_txt(1314)); // Invalid flag name or flag.
clif->message(sd->fd,msg_txt(1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
Expand All @@ -7382,7 +7382,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");
clif->message(sd->fd,"guildlock, src4instance, notomb, nocashshop");

#undef CHECKFLAG
#undef SETFLAG
Expand Down
11 changes: 11 additions & 0 deletions src/map/clif.c
Expand Up @@ -17387,6 +17387,12 @@ void __attribute__ ((unused)) clif_parse_dull(int fd,struct map_session_data *sd
return;
}
void clif_parse_CashShopOpen(int fd, struct map_session_data *sd) {

if( map->list[sd->bl.m].flag.nocashshop ) {
clif->colormes(fd,COLOR_RED,msg_txt(1489)); //Cash Shop is disabled in this map
return;
}

WFIFOHEAD(fd, 10);
WFIFOW(fd, 0) = 0x845;
WFIFOL(fd, 2) = sd->cashPoints; //[Ryuuzaki] - switched positions to reflect proper values
Expand Down Expand Up @@ -17423,6 +17429,11 @@ void clif_parse_CashShopBuy(int fd, struct map_session_data *sd) {
unsigned short limit = RFIFOW(fd, 4), i, j;
unsigned int kafra_pay = RFIFOL(fd, 6);// [Ryuuzaki] - These are free cash points (strangely #CASH = main cash curreny for us, confusing)

if( map->list[sd->bl.m].flag.nocashshop ) {
clif->colormes(fd,COLOR_RED,msg_txt(1489)); //Cash Shop is disabled in this map
return;
}

for(i = 0; i < limit; i++) {
int qty = RFIFOL(fd, 14 + ( i * 10 ));
int id = RFIFOL(fd, 10 + ( i * 10 ));
Expand Down
10 changes: 10 additions & 0 deletions src/map/map.c
Expand Up @@ -4388,7 +4388,17 @@ bool map_zone_mf_cache(int m, char *flag, char *params) {
map_zone_mf_cache_add(m,rflag);
}
}
} else if (!strcmpi(flag,"nocashshop")) {
if( state && map->list[m].flag.nocashshop )
;/* nothing to do */
else {
if( state )
map_zone_mf_cache_add(m,"nocashshop\toff");
else if( map->list[m].flag.nocashshop )
map_zone_mf_cache_add(m,"nocashshop");
}
}

return false;
}
void map_zone_apply(int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath) {
Expand Down
1 change: 1 addition & 0 deletions src/map/map.h
Expand Up @@ -632,6 +632,7 @@ struct map_data {
unsigned chsysnolocalaj : 1;
unsigned noknockback : 1;
unsigned notomb : 1;
unsigned nocashshop : 1;
} flag;
struct point save;
struct npc_data *npc[MAX_NPC_PER_MAP];
Expand Down
2 changes: 2 additions & 0 deletions src/map/npc.c
Expand Up @@ -3441,6 +3441,8 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
map->list[m].long_damage_rate = (state) ? atoi(w4) : 100;
} else if ( !strcmpi(w3,"src4instance") ) {
map->list[m].flag.src4instance = (state) ? 1 : 0;
} else if ( !strcmpi(w3,"nocashshop") ) {
map->list[m].flag.nocashshop = (state) ? 1 : 0;
} else
ShowError("npc_parse_mapflag: unrecognized mapflag '%s' (file '%s', line '%d').\n", w3, filepath, strline(buffer,start-buffer));

Expand Down
3 changes: 3 additions & 0 deletions src/map/script.c
Expand Up @@ -10201,6 +10201,7 @@ BUILDIN(getmapflag)
case MF_BATTLEGROUND: script_pushint(st,map->list[m].flag.battleground); break;
case MF_RESET: script_pushint(st,map->list[m].flag.reset); break;
case MF_NOTOMB: script_pushint(st,map->list[m].flag.notomb); break;
case MF_NOCASHSHOP: script_pushint(st,map->list[m].flag.nocashshop); break;
}
}

Expand Down Expand Up @@ -10317,6 +10318,7 @@ BUILDIN(setmapflag) {
case MF_BATTLEGROUND: map->list[m].flag.battleground = (val <= 0 || val > 2) ? 1 : val; break;
case MF_RESET: map->list[m].flag.reset = 1; break;
case MF_NOTOMB: map->list[m].flag.notomb = 1; break;
case MF_NOCASHSHOP: map->list[m].flag.nocashshop = 1; break;
}
}

Expand Down Expand Up @@ -10402,6 +10404,7 @@ BUILDIN(removemapflag) {
case MF_BATTLEGROUND: map->list[m].flag.battleground = 0; break;
case MF_RESET: map->list[m].flag.reset = 0; break;
case MF_NOTOMB: map->list[m].flag.notomb = 0; break;
case MF_NOCASHSHOP: map->list[m].flag.nocashshop = 0; break;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/map/script.h
Expand Up @@ -287,7 +287,8 @@ enum {
MF_PVP_NOCALCRANK, //50
MF_BATTLEGROUND,
MF_RESET,
MF_NOTOMB
MF_NOTOMB,
MF_NOCASHSHOP
};

/**
Expand Down

1 comment on commit 8629562

@mmanlapat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GREAT!!!!

Please sign in to comment.