From bc63ef1225dadcfa2ba20a9b073de801ee177992 Mon Sep 17 00:00:00 2001 From: malufett Date: Fri, 8 Mar 2013 22:51:42 +0800 Subject: Fixed Bug #7114 -revised/added 'npc_isnear' where it checks if an NPC is nearby when making chat rooms or using vending. Signed-off-by: malufett --- src/map/npc.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/map/npc.c') diff --git a/src/map/npc.c b/src/map/npc.c index e032a28a7..0c9924d46 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -113,6 +113,24 @@ struct view_data* npc_get_viewdata(int class_) return NULL; } +static int npc_isnear_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 0; + + return 1; +} + +bool npc_isnear(struct block_list * bl) { + + if( battle_config.min_npc_vendchat_distance > 0 && + map_foreachinrange(npc_isnear_sub,bl, battle_config.min_npc_vendchat_distance, BL_NPC) ) + return true; + + return false; +} + int npc_ontouch_event(struct map_session_data *sd, struct npc_data *nd) { char name[EVENT_NAME_LENGTH]; -- cgit v1.2.3-60-g2f50