viewing paste topic/4509- vendor_control_2.1a.c | C

Posted on the | Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
//===== 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 );
}
 
Viewed 565 times, submitted by AnnieRuru.