//===== Hercules Plugin ====================================
//= Vendor Control
//===== By: ================================================
//= Original by Emistry
//= Rewrite by AnnieRuru
//===== Current Version: ===================================
//= 2.1a
//===== Compatible With: ===================================
//= Hercules 2018-06-02
//===== Description: =======================================
//= Vendors only vend on certain coordinate, looks tidy :P
//===== Topic ==============================================
//= http://herc.ws/board/topic/4509-vendor-control-rewrite/
//===== Additional Comments: ===============================
//= maybe because of npc->isnear ... Emistry deleted his topic ?
//==========================================================
#include "common/hercules.h"
#include "map/pc.h"
#include "map/npc.h"
#include "plugins/HPMHooking.h"
#include "common/HPMDataCheck.h"
// Note down the area where your players allow to vend
// this is meant to bypass the 'min_npc_vendchat_distance' check
char mapname[MAP_NAME_LENGTH] = "prontera";
int x1 = 150; // first element of setarray .@x
int x2 = 162; // last element of setarray .@x
int y1 = 133; // first element of setarray .@y
int y2 = 175; // last element of setarray .@y
HPExport struct hplugin_info pinfo = {
"VendorControl",
SERVER_TYPE_MAP,
"2.1",
HPM_VERSION,
};
int stack_limit = 1;
bool npc_isnear_pre( struct block_list **bl ) {
struct map_session_data *sd = BL_CAST(BL_PC, *bl);
if ( !strcmp( mapindex_id2name(sd->mapindex), mapname ) && sd->bl.x >= x1 && sd->bl.x <= x2 && sd->bl.y >= y1 && sd->bl.y <= y2 )
hookStop();
return false;
}
int unit_walktoxy_timer_pre( int *tid, int64 *tick, int *id, intptr_t *data ) {
struct block_list *bl = map->id2bl(*id);
struct map_session_data *sd = BL_CAST(BL_PC, bl);
if ( !bl || !sd )
return 0;
if ( !strcmp( mapindex_id2name(sd->mapindex), mapname ) && sd->bl.x >= x1 && sd->bl.x <= x2 && sd->bl.y >= y1 && sd->bl.y <= y2 )
battle->bc->official_cell_stack_limit = 0;
return 0;
}
int unit_walktoxy_timer_post( int retVal, int tid, int64 tick, int id, intptr_t data ) {
if ( battle->bc->official_cell_stack_limit == 0 )
battle->bc->official_cell_stack_limit = stack_limit;
return 0;
}
HPExport void plugin_init (void) {
stack_limit = battle->bc->official_cell_stack_limit;
addHookPre( npc, isnear, npc_isnear_pre );
addHookPre( unit, walktoxy_timer, unit_walktoxy_timer_pre );
addHookPost( unit, walktoxy_timer, unit_walktoxy_timer_post );
}