//===== Hercules Plugin ====================================== //= nightmap //===== By: ================================================== //= AnnieRuru //= original by Masao //===== Current Version: ===================================== //= 0.1 //===== Compatible With: ===================================== //= Hercules 2015-12-28 //===== Description: ========================================= //= turn only the one current map into day/night mode //===== Topic ================================================ //= http://herc.ws/board/topic/11584-stop-gaining-exp-at-specific-level/?p=68089 //===== Additional Comments: ================================= //= maybe I should've done this as paid release ... //============================================================ #include "common/hercules.h" #include #include #include #include "map/pc.h" #include "common/memmgr.h" #include "common/nullpo.h" #include "common/HPMDataCheck.h" HPExport struct hplugin_info pinfo = { "nightmap", SERVER_TYPE_MAP, "0.1", HPM_VERSION, }; struct mapflag_data { unsigned nightmap : 1; }; int buildin_nightmap_sub( struct block_list *bl, va_list ap ) { TBL_PC *sd = BL_CAST( BL_PC, bl ); bool flag = va_arg( ap, bool ); if ( flag == true ) clif->status_change( &sd->bl, SI_SKE, 1, 0, 0, 0, 0 ); else clif->sc_end( &sd->bl, sd->bl.id, SELF, SI_SKE ); return true; } void npc_parse_unknown_mapflag_pre( const char *name, char *w3, char *w4, const char* start, const char* buffer, const char* filepath, int *retval ) { if ( !strcmp(w3,"nightmap") ) { int16 m = map->mapname2mapid( name ); struct mapflag_data *mf = getFromMAPD( &map->list[m], 0 ); if ( !mf ) { CREATE( mf, struct mapflag_data, 1 ); addToMAPD( &map->list[m], mf, 0, true ); } mf->nightmap = true; map->foreachinmap( buildin_nightmap_sub, m, BL_PC, true ); hookStop(); } return; } // flush all nightmap mapflag back to default upon @reloadscript void map_flags_init_pre(void) { int i; for ( i = 0; i < map->count; ++i ) { struct mapflag_data *mf = getFromMAPD( &map->list[i], 0 ); if ( mf ) { removeFromMAPD( &map->list[i], 0 ); map->foreachinmap( buildin_nightmap_sub, i, BL_PC, false ); } } return; } void clif_parse_LoadEndAck_post( int fd, struct map_session_data *sd ) { struct mapflag_data *mf = getFromMAPD( &map->list[sd->bl.m], 0 ); if ( mf && mf->nightmap == true ) clif->status_change( &sd->bl, SI_SKE, 1, 0, 0, 0, 0 ); else if ( !sd->sc.data[SC_SOULLINK] ) clif->sc_end( &sd->bl, sd->bl.id, SELF, SI_SKE ); } ACMD(nightmap) { struct mapflag_data *mf = getFromMAPD( &map->list[sd->bl.m], 0 ); if ( !mf ) { CREATE( mf, struct mapflag_data, 1 ); addToMAPD( &map->list[sd->bl.m], mf, 0, true ); mf->nightmap = false; } mf->nightmap = !(mf->nightmap); map->foreachinmap( buildin_nightmap_sub, sd->bl.m, BL_PC, mf->nightmap ); if ( mf->nightmap == false ) clif->message( fd, "Daymode has activated." ); else clif->message( fd, "Nightmode has activated." ); return true; } HPExport void plugin_init (void) { addHookPre( "npc->parse_unknown_mapflag", npc_parse_unknown_mapflag_pre ); addHookPre( "map->flags_init", map_flags_init_pre ); addHookPost( "clif->pLoadEndAck", clif_parse_LoadEndAck_post ); addAtcommand( "nightmap", nightmap ); }