summaryrefslogtreecommitdiff
path: root/src/map/vending.c
diff options
context:
space:
mode:
authorshennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-03 22:41:52 +0000
committershennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-06-03 22:41:52 +0000
commit36e4e442f21ed7193c4510a9bb4fcc733f821757 (patch)
treeda37bf7188e018d6fa150ba17d8bfdc9ee1d92fa /src/map/vending.c
parentd6087662f5c19b693a000126d02ced43aad5d2f7 (diff)
downloadhercules-36e4e442f21ed7193c4510a9bb4fcc733f821757.tar.gz
hercules-36e4e442f21ed7193c4510a9bb4fcc733f821757.tar.bz2
hercules-36e4e442f21ed7193c4510a9bb4fcc733f821757.tar.xz
hercules-36e4e442f21ed7193c4510a9bb4fcc733f821757.zip
Adding new config min_npc_vending_distance which simulates the official 'no vending near npcs' feature. super mega credits to masao
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16227 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/vending.c')
-rw-r--r--src/map/vending.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/map/vending.c b/src/map/vending.c
index 6deba0e55..e84ac488f 100644
--- a/src/map/vending.c
+++ b/src/map/vending.c
@@ -12,6 +12,7 @@
#include "chrif.h"
#include "vending.h"
#include "pc.h"
+#include "npc.h"
#include "skill.h"
#include "battle.h"
#include "log.h"
@@ -233,13 +234,27 @@ void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const ui
}
}
}
+static int vending_checknearnpc_sub(struct block_list* bl, va_list args) {
+ struct npc_data *nd = (struct npc_data*)bl;
+
+ if( nd->sc.option & (OPTION_HIDE|OPTION_INVISIBLE) )
+ return 1;
+ return 1;
+}
+bool vending_checknearnpc(struct block_list * bl) {
+
+ if( battle_config.min_npc_vending_distance > 0 &&
+ map_foreachinrange(vending_checknearnpc_sub,bl, battle_config.min_npc_vending_distance, BL_NPC) )
+ return true;
+
+ return false;
+}
/*==========================================
* Open shop
* data := {<index>.w <amount>.w <value>.l}[count]
*------------------------------------------*/
-void vending_openvending(struct map_session_data* sd, const char* message, bool flag, const uint8* data, int count)
-{
+void vending_openvending(struct map_session_data* sd, const char* message, bool flag, const uint8* data, int count) {
int i, j;
int vending_skill_lvl;
nullpo_retv(sd);
@@ -265,6 +280,15 @@ void vending_openvending(struct map_session_data* sd, const char* message, bool
return;
}
+ if( vending_checknearnpc(&sd->bl) ) {
+ char output[50];
+ sprintf(output,"You're too close to a NPC, you must be at least %d cells away from any NPC.",battle_config.min_npc_vending_distance);
+ clif_displaymessage(sd->fd, output);
+ clif_skill_fail(sd, MC_VENDING, USESKILL_FAIL_LEVEL, 0);
+ return;
+ }
+
+
// filter out invalid items
i = 0;
for( j = 0; j < count; j++ )