From 8955a37a9b25344eb75a6091b59b66e9b0a51f2e Mon Sep 17 00:00:00 2001 From: skotlex Date: Wed, 15 Mar 2006 21:07:00 +0000 Subject: [PATCH] - Added mapflag nodrop, fixed mapflag notrade. git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@5619 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 2 ++ conf-tmpl/msg_athena.conf | 2 ++ db/const.txt | 1 + src/map/atcommand.c | 2 ++ src/map/clif.c | 5 ++++- src/map/map.h | 1 + src/map/npc.c | 3 +++ src/map/pc.c | 34 ++++++++++++++++++---------------- src/map/script.c | 11 ++++++++++- src/map/trade.c | 5 +++++ 10 files changed, 48 insertions(+), 18 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 01c0bae560..178fb65508 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -5,6 +5,8 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EV GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS 2006/03/15 + * Added mapflag nodrop (prevents droping items to the ground). [Skotlex] + * Fixed mapflag notrade doing nothing. [Skotlex] * Likely fixed Gravitation not hitting except for the last hit. [Skotlex] * Removed the hardcoded duration of 30 seconds for sleep. [Skotlex] * Fixed rangecheck for pet skill usage of INF_SELF_SKILL type of skills diff --git a/conf-tmpl/msg_athena.conf b/conf-tmpl/msg_athena.conf index 5b532873ae..e41c37bd29 100644 --- a/conf-tmpl/msg_athena.conf +++ b/conf-tmpl/msg_athena.conf @@ -280,6 +280,8 @@ 269: Displaying first %d out of %d matches //@me output format 270: *%s %s* +271: You can't drop items on this map +272: You can't trade on this map // Guild Castles Number // -------------------- 299: ?? Castles diff --git a/db/const.txt b/db/const.txt index 8678f78239..e2802b2f03 100644 --- a/db/const.txt +++ b/db/const.txt @@ -124,6 +124,7 @@ mf_nowarpto 33 mf_nonightmaredrop 34 mf_restricted 35 mf_nocommand 36 +mf_nodrop 37 cell_wall 1 cell_water 3 diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 4bc9d5ec5b..dad90776ff 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5689,6 +5689,8 @@ int atcommand_mapinfo( strcat(atcmd_output, "NoBranch | "); if (map[m_id].flag.notrade) strcat(atcmd_output, "NoTrade | "); + if (map[m_id].flag.nodrop) + strcat(atcmd_output, "NoDrop | "); if (map[m_id].flag.noskill) strcat(atcmd_output, "NoSkill | "); if (map[m_id].flag.noicewall) diff --git a/src/map/clif.c b/src/map/clif.c index ac7c73ef5e..802bbea158 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -9617,7 +9617,10 @@ void clif_parse_DropItem(int fd, struct map_session_data *sd) { item_index = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[0])-2; item_amount = RFIFOW(fd,packet_db[sd->packet_ver][RFIFOW(fd,0)].pos[1]); - pc_dropitem(sd, item_index, item_amount); + if (!pc_dropitem(sd, item_index, item_amount)) + //Because the client does not likes being ignored. + clif_delitem(sd, item_index,0); + } /*========================================== diff --git a/src/map/map.h b/src/map/map.h index cb82be8a85..8f697a33b3 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1037,6 +1037,7 @@ struct map_data { unsigned nightenabled :1; //For night display. [Skotlex] unsigned restricted : 1; // [Komurka] unsigned nocommand : 1; //Blocks @/# commands for non-gms. [Skotlex] + unsigned nodrop : 1; } flag; struct point save; struct npc_data *npc[MAX_NPC_PER_MAP]; diff --git a/src/map/npc.c b/src/map/npc.c index e3abe5eaa1..1fc99de95f 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2546,6 +2546,9 @@ static int npc_parse_mapflag (char *w1, char *w2, char *w3, char *w4) else if (strcmpi(w3,"notrade")==0) { map[m].flag.notrade=1; } + else if (strcmpi(w3,"nodrop")==0) { + map[m].flag.nodrop=1; + } else if (strcmpi(w3,"noskill")==0) { map[m].flag.noskill=1; } diff --git a/src/map/pc.c b/src/map/pc.c index a467f36076..559f18677e 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -2502,35 +2502,37 @@ int pc_dropitem(struct map_session_data *sd,int n,int amount) nullpo_retr(1, sd); if(n < 0 || n >= MAX_INVENTORY) - return 1; + return 0; if(amount <= 0) - return 1; + return 0; if (sd->status.inventory[n].nameid <= 0 || sd->status.inventory[n].amount < amount || sd->trade_partner != 0 || sd->vender_id != 0 || sd->status.inventory[n].amount <= 0) - return 1; - - if (!pc_candrop(sd,sd->status.inventory[n].nameid)) - { //The client does not likes being silently ignored, so we send it a del of 0 qty - clif_delitem(sd,n,0); - clif_displaymessage (sd->fd, msg_txt(263)); - return 1; - } + return 0; + if (map[sd->bl.m].flag.nodrop) { + clif_displaymessage (sd->fd, msg_txt(271)); + return 0; //Can't drop items in nodrop mapflag maps. + } + + if (!pc_candrop(sd,sd->status.inventory[n].nameid)) { + clif_displaymessage (sd->fd, msg_txt(263)); + return 0; + } + //Logs items, dropped by (P)layers [Lupus] if(log_config.pick > 0 ) log_pick(sd, "P", 0, sd->status.inventory[n].nameid, -amount, (struct item*)&sd->status.inventory[n]); //Logs - if (map_addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, NULL, NULL, NULL, 2) != 0) - pc_delitem(sd, n, amount, 0); - else - clif_delitem(sd,n,0); - - return 0; + if (!map_addflooritem(&sd->status.inventory[n], amount, sd->bl.m, sd->bl.x, sd->bl.y, NULL, NULL, NULL, 2)) + return 0; + + pc_delitem(sd, n, amount, 0); + return 1; } /*========================================== diff --git a/src/map/script.c b/src/map/script.c index edd9b75503..33d06ddbb2 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6566,7 +6566,7 @@ enum { MF_NOMEMO,MF_NOTELEPORT,MF_NOSAVE,MF_NOBRANCH,MF_NOPENALTY,MF_NOZENYPENA MF_NOWARP,MF_NOPVP,MF_NOICEWALL,MF_SNOW,MF_FOG,MF_SAKURA,MF_LEAVES,MF_RAIN, MF_INDOORS,MF_NOGO,MF_CLOUDS,MF_CLOUDS2,MF_FIREWORKS,MF_GVG_CASTLE,MF_GVG_DUNGEON,MF_NIGHTENABLED, MF_NOBASEEXP, MF_NOJOBEXP, MF_NOMOBLOOT, MF_NOMVPLOOT, MF_NORETURN, MF_NOWARPTO, MF_NIGHTMAREDROP, - MF_RESTRICTED, MF_NOCOMMAND }; + MF_RESTRICTED, MF_NOCOMMAND, MF_NODROP }; int buildin_setmapflagnosave(struct script_state *st) { @@ -6640,6 +6640,9 @@ int buildin_setmapflag(struct script_state *st) case MF_NOTRADE: map[m].flag.notrade=1; break; + case MF_NODROP: + map[m].flag.nodrop=1; + break; case MF_NOSKILL: map[m].flag.noskill=1; break; @@ -6767,6 +6770,12 @@ int buildin_removemapflag(struct script_state *st) case MF_NOZENYPENALTY: map[m].flag.nozenypenalty=0; break; + case MF_NOTRADE: + map[m].flag.notrade=0; + break; + case MF_NODROP: + map[m].flag.nodrop=0; + break; case MF_NOSKILL: map[m].flag.noskill=0; break; diff --git a/src/map/trade.c b/src/map/trade.c index c9b9b21b0d..15f99b9c48 100644 --- a/src/map/trade.c +++ b/src/map/trade.c @@ -29,6 +29,11 @@ void trade_traderequest(struct map_session_data *sd, int target_id) { nullpo_retv(sd); + if (map[sd->bl.m].flag.notrade) { + clif_displaymessage (sd->fd, msg_txt(272)); + return; //Can't trade in notrade mapflag maps. + } + if ((target_sd = map_id2sd(target_id)) != NULL) { if (!battle_config.invite_request_check) { if (target_sd->guild_invite > 0 || target_sd->party_invite > 0) {