// Copyright (c) Hercules Dev Team, licensed under GNU GPL.
// See the LICENSE file
// Sample Hercules Plugin
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../common/HPMi.h"
#include "../map/script.h"
#include "../map/pc.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 = {
"equip2", // 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)
};
BUILDIN(equip2) {
int i,nameid,ref,attr,c0,c1,c2,c3;
struct item_data *item_data;
TBL_PC *sd;
if( script_hasdata(st,9) )
sd = map->id2sd(script_getnum(st,9));
else
sd = script->rid2sd(st);
if( sd == NULL )
{
script_pushint(st,0);
return 0;
}
nameid = script_getnum(st,2);
if( (item_data = itemdb->exists(nameid)) == NULL )
{
ShowError("Wrong item ID : equipitem2(%i)\n",nameid);
script_pushint(st,0);
return 1;
}
ref = script_getnum(st,3);
attr = script_getnum(st,4);
c0 = (short)script_getnum(st,5);
c1 = (short)script_getnum(st,6);
c2 = (short)script_getnum(st,7);
c3 = (short)script_getnum(st,8);
ARR_FIND( 0, MAX_INVENTORY, i,( sd->status.inventory[i].nameid == nameid &&
sd->status.inventory[i].refine == ref &&
sd->status.inventory[i].attribute == attr &&
sd->status.inventory[i].card[0] == c0 &&
sd->status.inventory[i].card[1] == c1 &&
sd->status.inventory[i].card[2] == c2 &&
sd->status.inventory[i].card[3] == c3 ) );
if( i < MAX_INVENTORY ) {
script_pushint(st,1);
pc->equipitem(sd,i,item_data->equip);
}
else
script_pushint(st,0);
return true;
}
HPExport void plugin_init (void) {
script = GET_SYMBOL("script");
pc = GET_SYMBOL("pc");
map = GET_SYMBOL("map");
itemdb = GET_SYMBOL("itemdb");
addScriptCommand( "equip2", "viiiiii?", equip2);
}