#include #include #include #include "../map/atcommand.h" #include "../map/itemdb.h" #include "../map/clif.h" #include "../map/pc.h" #include "../map/mob.h" #include "../map/map.h" #include "../common/HPMi.h" #include "../common/HPMDataCheck.h" // should always be the last file included! (if you don't make it last, it'll intentionally break compile time) HPExport struct hplugin_info pinfo = { "item_mob_data",// Plugin name SERVER_TYPE_MAP,// Which server types this plugin works with? "0.1", // Plugin version HPM_VERSION, // HPM Version (don't change, macro is automatically updated) }; struct item_data2 { bool deny; }; struct mob_db2 { bool deny; }; struct mob_data2 { bool invincible; }; ACMD(denyitem) { struct item_data *idata; struct item_data2 *idata2; char atcmd_output[CHAT_SIZE_MAX]; unsigned short item_id = atoi(message); if ( !message || !*message ) { clif->message( fd, "Syntax : @denyitem " ); return false; } if ( ( idata = itemdb->exists(item_id) ) == NULL ) { clif->message( fd, "Invalid item ID." ); return false; } if ( !( idata2 = getFromITEMDATA(idata,0) ) ) { CREATE( idata2, struct item_data2, 1 ); idata2->deny = 1;; addToITEMDATA( idata, idata2, 0, true ); safesnprintf( atcmd_output, CHAT_SIZE_MAX, "The item %s is now denied.", idata->jname ); clif->message( fd, atcmd_output ); } else { safesnprintf( atcmd_output, CHAT_SIZE_MAX, "The item %s has already denied.", idata->jname ); clif->message( fd, atcmd_output ); } return true; } ACMD(testitem) { struct item_data *idata; struct item_data2 *idata2; char atcmd_output[CHAT_SIZE_MAX]; if ( !message || !*message ) { clif->message( fd, "Syntax : @testitem " ); return false; } if ( ( idata = itemdb->exists( atoi(message) ) ) == NULL ) { clif->message( fd, "Invalid item ID." ); return false; } if ( idata2 = getFromITEMDATA(idata,0) ) { safesnprintf( atcmd_output, CHAT_SIZE_MAX, "You can't create %s.", idata->jname ); clif->message( fd, atcmd_output ); } else { safesnprintf( atcmd_output, CHAT_SIZE_MAX, "You can create %s.", idata->jname ); clif->message( fd, atcmd_output ); } return true; } ACMD(denymob) { struct mob_db *mdb; struct mob_db2 *mdb2; char atcmd_output[CHAT_SIZE_MAX]; unsigned short mob_id = atoi( message ); if ( !message || !*message ) { clif->message( fd, "Syntax : @testmob " ); return false; } if ( !mob->db_checkid(mob_id) ) { clif->message( fd, "Invalid mob ID." ); return false; } mdb = mob->db(mob_id); if ( !( mdb2 = getFromMOBDB(mdb,0) ) ) { CREATE( mdb2, struct mob_db2, 1 ); mdb2->deny = 1;; addToMOBDB( mdb, mdb2, 0, true ); safesnprintf( atcmd_output, CHAT_SIZE_MAX, "The monster %s is now denied.", mdb->name ); clif->message( fd, atcmd_output ); } else { safesnprintf( atcmd_output, CHAT_SIZE_MAX, "The monster %s has already denied.", mdb->name ); clif->message( fd, atcmd_output ); } return true; } ACMD(testmob) { struct mob_db *mdb; struct mob_db2 *mdb2; char atcmd_output[CHAT_SIZE_MAX]; unsigned short mob_id = atoi( message ); if ( !message || !*message ) { clif->message( fd, "Syntax : @testmob " ); return false; } if ( !mob->db_checkid(mob_id) ) { clif->message( fd, "Invalid mob ID." ); return false; } mdb = mob->db(mob_id); if ( mdb2 = getFromMOBDB(mdb,0) ) { safesnprintf( atcmd_output, CHAT_SIZE_MAX, "You can't create %s.", mdb->name ); clif->message( fd, atcmd_output ); return true; } else { int id = mob->once_spawn( sd, sd->bl.m, sd->bl.x, sd->bl.y, mdb->name, mob_id, 1, "", SZ_SMALL, AI_NONE ); struct mob_data *mdata = (TBL_MOB*)map->id2bl(id); struct mob_data2 *mdata2; mdata2 = getFromMOBDATA(mdata,0); CREATE( mdata2, struct mob_data2, 1 ); mdata2->invincible = 1; addToMOBDATA( mdata, mdata2, 0, true ); safesnprintf( atcmd_output, CHAT_SIZE_MAX, "You just create %s.", mdb->name ); clif->message( fd, atcmd_output ); } return true; } int battle_check_target_post( int retVal, struct block_list *src, struct block_list *target,int *flag ) { if ( retVal == 1 && target->type == BL_MOB ) { struct mob_data *mdata = (TBL_MOB*)target; struct mob_data2 *mdata2; if ( mdata2 = getFromMOBDATA(mdata,0) ) return -1; } return retVal; } HPExport void plugin_init (void) { clif = GET_SYMBOL("clif"); itemdb = GET_SYMBOL("itemdb"); strlib = GET_SYMBOL("strlib"); iMalloc = GET_SYMBOL("iMalloc"); mob = GET_SYMBOL("mob"); map = GET_SYMBOL("map"); addAtcommand("denyitem",denyitem); addAtcommand("testitem",testitem); addAtcommand("denymob",denymob); addAtcommand("testmob",testmob); addHookPost("battle->check_target", battle_check_target_post); }