|
@@ -6514,12 +6514,11 @@ BUILDIN_FUNC(getitem2)
|
|
|
return SCRIPT_CMD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
-/*==========================================
|
|
|
+/** Gives rental item to player
|
|
|
* rentitem <item id>,<seconds>
|
|
|
* rentitem "<item name>",<seconds>
|
|
|
- *------------------------------------------*/
|
|
|
-BUILDIN_FUNC(rentitem)
|
|
|
-{
|
|
|
+ */
|
|
|
+BUILDIN_FUNC(rentitem) {
|
|
|
struct map_session_data *sd;
|
|
|
struct script_data *data;
|
|
|
struct item it;
|
|
@@ -6530,7 +6529,7 @@ BUILDIN_FUNC(rentitem)
|
|
|
get_val(st,data);
|
|
|
|
|
|
if( (sd = script_rid2sd(st)) == NULL )
|
|
|
- return 0;
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
|
|
|
if( data_isstring(data) )
|
|
|
{
|
|
@@ -6539,7 +6538,7 @@ BUILDIN_FUNC(rentitem)
|
|
|
if( itd == NULL )
|
|
|
{
|
|
|
ShowError("buildin_rentitem: Nonexistant item %s requested.\n", name);
|
|
|
- return 1;
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
}
|
|
|
nameid = itd->nameid;
|
|
|
}
|
|
@@ -6549,13 +6548,13 @@ BUILDIN_FUNC(rentitem)
|
|
|
if( nameid <= 0 || !itemdb_exists(nameid) )
|
|
|
{
|
|
|
ShowError("buildin_rentitem: Nonexistant item %d requested.\n", nameid);
|
|
|
- return 1;
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ShowError("buildin_rentitem: invalid data type for argument #1 (%d).\n", data->type);
|
|
|
- return 1;
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
}
|
|
|
|
|
|
seconds = script_getnum(st,3);
|
|
@@ -6568,11 +6567,92 @@ BUILDIN_FUNC(rentitem)
|
|
|
if( (flag = pc_additem(sd, &it, 1, LOG_TYPE_SCRIPT)) )
|
|
|
{
|
|
|
clif_additem(sd, 0, 0, flag);
|
|
|
- return 1;
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
}
|
|
|
return SCRIPT_CMD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
+/** Gives rental item to player with advanced option
|
|
|
+* rentitem2 <item id>,<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
|
|
|
+* rentitem2 "<item name>",<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
|
|
|
+*/
|
|
|
+BUILDIN_FUNC(rentitem2) {
|
|
|
+ struct map_session_data *sd;
|
|
|
+ struct script_data *data;
|
|
|
+ struct item it;
|
|
|
+ struct item_data *id;
|
|
|
+ int seconds, flag;
|
|
|
+ uint16 nameid = 0;
|
|
|
+ int iden,ref,attr,c1,c2,c3,c4;
|
|
|
+
|
|
|
+ data = script_getdata(st,2);
|
|
|
+ get_val(st,data);
|
|
|
+
|
|
|
+ if( (sd = script_rid2sd(st)) == NULL )
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
+
|
|
|
+ if( data_isstring(data) ) {
|
|
|
+ const char *name = conv_str(st,data);
|
|
|
+ id = itemdb_searchname(name);
|
|
|
+ if( id == NULL ) {
|
|
|
+ ShowError("buildin_rentitem2: Nonexistant item %s requested.\n", name);
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
+ }
|
|
|
+ nameid = id->nameid;
|
|
|
+ }
|
|
|
+ else if( data_isint(data) ) {
|
|
|
+ nameid = conv_num(st,data);
|
|
|
+ if( !(id = itemdb_search(nameid))) {
|
|
|
+ ShowError("buildin_rentitem2: Nonexistant item %d requested.\n", nameid);
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ ShowError("buildin_rentitem2: invalid data type for argument #1 (%d).\n", data->type);
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ seconds = script_getnum(st,3);
|
|
|
+ iden = script_getnum(st,4);
|
|
|
+ ref = script_getnum(st,5);
|
|
|
+ attr = script_getnum(st,6);
|
|
|
+
|
|
|
+ if (id->type==IT_WEAPON || id->type==IT_ARMOR || id->type==IT_SHADOWGEAR) {
|
|
|
+ if(ref > MAX_REFINE) ref = MAX_REFINE;
|
|
|
+ }
|
|
|
+ else if (id->type==IT_PETEGG) {
|
|
|
+ iden = 1;
|
|
|
+ ref = 0;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ iden = 1;
|
|
|
+ ref = attr = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ c1 = (short)script_getnum(st,7);
|
|
|
+ c2 = (short)script_getnum(st,8);
|
|
|
+ c3 = (short)script_getnum(st,9);
|
|
|
+ c4 = (short)script_getnum(st,10);
|
|
|
+
|
|
|
+ memset(&it, 0, sizeof(it));
|
|
|
+ it.nameid = nameid;
|
|
|
+ it.identify = iden;
|
|
|
+ it.refine = ref;
|
|
|
+ it.attribute = attr;
|
|
|
+ it.card[0] = (short)c1;
|
|
|
+ it.card[1] = (short)c2;
|
|
|
+ it.card[2] = (short)c3;
|
|
|
+ it.card[3] = (short)c4;
|
|
|
+ it.expire_time = (unsigned int)(time(NULL) + seconds);
|
|
|
+
|
|
|
+ if( (flag = pc_additem(sd, &it, 1, LOG_TYPE_SCRIPT)) ) {
|
|
|
+ clif_additem(sd, 0, 0, flag);
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
+ }
|
|
|
+
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
+}
|
|
|
+
|
|
|
/*==========================================
|
|
|
* gets an item with someone's name inscribed [Skotlex]
|
|
|
* getinscribeditem item_num, character_name
|
|
@@ -6652,42 +6732,44 @@ BUILDIN_FUNC(grouprandomitem)
|
|
|
return SCRIPT_CMD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
-/*==========================================
|
|
|
- *
|
|
|
- *------------------------------------------*/
|
|
|
-BUILDIN_FUNC(makeitem)
|
|
|
-{
|
|
|
- int nameid,amount,flag = 0;
|
|
|
- int x,y,m;
|
|
|
+/**
|
|
|
+* makeitem <item id>,<amount>,"<map name>",<X>,<Y>;
|
|
|
+* makeitem "<item name>",<amount>,"<map name>",<X>,<Y>;
|
|
|
+*/
|
|
|
+BUILDIN_FUNC(makeitem) {
|
|
|
+ int16 nameid;
|
|
|
+ uint16 amount, flag = 0, x, y;
|
|
|
const char *mapname;
|
|
|
+ int m;
|
|
|
struct item item_tmp;
|
|
|
struct script_data *data;
|
|
|
|
|
|
- data=script_getdata(st,2);
|
|
|
+ data = script_getdata(st,2);
|
|
|
get_val(st,data);
|
|
|
if( data_isstring(data) ){
|
|
|
- const char *name=conv_str(st,data);
|
|
|
+ const char *name = conv_str(st,data);
|
|
|
struct item_data *item_data = itemdb_searchname(name);
|
|
|
if( item_data )
|
|
|
- nameid=item_data->nameid;
|
|
|
+ nameid = item_data->nameid;
|
|
|
else
|
|
|
- nameid=UNKNOWN_ITEM_ID;
|
|
|
- }else
|
|
|
- nameid=conv_num(st,data);
|
|
|
+ nameid = UNKNOWN_ITEM_ID;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ nameid = conv_num(st,data);
|
|
|
|
|
|
- amount=script_getnum(st,3);
|
|
|
- mapname =script_getstr(st,4);
|
|
|
- x =script_getnum(st,5);
|
|
|
- y =script_getnum(st,6);
|
|
|
+ amount = script_getnum(st,3);
|
|
|
+ mapname = script_getstr(st,4);
|
|
|
+ x = script_getnum(st,5);
|
|
|
+ y = script_getnum(st,6);
|
|
|
|
|
|
- if(strcmp(mapname,"this")==0)
|
|
|
- {
|
|
|
+ if(strcmp(mapname,"this")==0) {
|
|
|
TBL_PC *sd;
|
|
|
sd = script_rid2sd(st);
|
|
|
- if (!sd) return 0; //Failed...
|
|
|
- m=sd->bl.m;
|
|
|
+ if (!sd)
|
|
|
+ return SCRIPT_CMD_SUCCESS; //Failed...
|
|
|
+ m = sd->bl.m;
|
|
|
} else
|
|
|
- m=map_mapname2mapid(mapname);
|
|
|
+ m = map_mapname2mapid(mapname);
|
|
|
|
|
|
if(nameid<0) {
|
|
|
nameid = -nameid;
|
|
@@ -6696,17 +6778,92 @@ BUILDIN_FUNC(makeitem)
|
|
|
|
|
|
if(nameid > 0) {
|
|
|
memset(&item_tmp,0,sizeof(item_tmp));
|
|
|
- item_tmp.nameid=nameid;
|
|
|
+ item_tmp.nameid = nameid;
|
|
|
if(!flag)
|
|
|
- item_tmp.identify=1;
|
|
|
+ item_tmp.identify = 1;
|
|
|
else
|
|
|
- item_tmp.identify=itemdb_isidentified(nameid);
|
|
|
+ item_tmp.identify = itemdb_isidentified(nameid);
|
|
|
|
|
|
map_addflooritem(&item_tmp,amount,m,x,y,0,0,0,4);
|
|
|
}
|
|
|
return SCRIPT_CMD_SUCCESS;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+* makeitem2 <item id>,<amount>,"<map name>",<X>,<Y>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
|
|
|
+* makeitem2 "<item name>",<amount>,"<map name>",<X>,<Y>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
|
|
|
+*/
|
|
|
+BUILDIN_FUNC(makeitem2) {
|
|
|
+ uint16 nameid, amount, x, y;
|
|
|
+ const char *mapname;
|
|
|
+ int m;
|
|
|
+ struct item item_tmp;
|
|
|
+ struct script_data *data;
|
|
|
+ struct item_data *id;
|
|
|
+
|
|
|
+ data = script_getdata(st,2);
|
|
|
+ get_val(st,data);
|
|
|
+ if( data_isstring(data) ){
|
|
|
+ const char *name = conv_str(st,data);
|
|
|
+ struct item_data *item_data = itemdb_searchname(name);
|
|
|
+ if( item_data )
|
|
|
+ nameid = item_data->nameid;
|
|
|
+ else
|
|
|
+ nameid = UNKNOWN_ITEM_ID;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ nameid = conv_num(st,data);
|
|
|
+
|
|
|
+ amount = script_getnum(st,3);
|
|
|
+ mapname = script_getstr(st,4);
|
|
|
+ x = script_getnum(st,5);
|
|
|
+ y = script_getnum(st,6);
|
|
|
+
|
|
|
+ if (strcmp(mapname,"this")==0) {
|
|
|
+ TBL_PC *sd;
|
|
|
+ sd = script_rid2sd(st);
|
|
|
+ if (!sd)
|
|
|
+ return SCRIPT_CMD_SUCCESS; //Failed...
|
|
|
+ m = sd->bl.m;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ m = map_mapname2mapid(mapname);
|
|
|
+
|
|
|
+ if ((id = itemdb_search(nameid))) {
|
|
|
+ char iden, ref, attr;
|
|
|
+ memset(&item_tmp,0,sizeof(item_tmp));
|
|
|
+ item_tmp.nameid = nameid;
|
|
|
+
|
|
|
+ iden = (char)script_getnum(st,7);
|
|
|
+ ref = (char)script_getnum(st,8);
|
|
|
+ attr = (char)script_getnum(st,9);
|
|
|
+
|
|
|
+ if (id->type==IT_WEAPON || id->type==IT_ARMOR || id->type==IT_SHADOWGEAR) {
|
|
|
+ if(ref > MAX_REFINE) ref = MAX_REFINE;
|
|
|
+ }
|
|
|
+ else if (id->type==IT_PETEGG) {
|
|
|
+ iden = 1;
|
|
|
+ ref = 0;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ iden = 1;
|
|
|
+ ref = attr = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ item_tmp.identify = iden;
|
|
|
+ item_tmp.refine = ref;
|
|
|
+ item_tmp.attribute = attr;
|
|
|
+ item_tmp.card[0] = script_getnum(st,10);
|
|
|
+ item_tmp.card[1] = script_getnum(st,11);
|
|
|
+ item_tmp.card[2] = script_getnum(st,12);
|
|
|
+ item_tmp.card[3] = script_getnum(st,13);
|
|
|
+
|
|
|
+ map_addflooritem(&item_tmp,amount,m,x,y,0,0,0,4);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ return SCRIPT_CMD_FAILURE;
|
|
|
+ return SCRIPT_CMD_SUCCESS;
|
|
|
+}
|
|
|
|
|
|
/// Counts / deletes the current item given by idx.
|
|
|
/// Used by buildin_delitem_search
|
|
@@ -18437,10 +18594,12 @@ struct script_function buildin_func[] = {
|
|
|
BUILDIN_DEF(getelementofarray,"ri"),
|
|
|
BUILDIN_DEF(getitem,"vi?"),
|
|
|
BUILDIN_DEF(rentitem,"vi"),
|
|
|
+ BUILDIN_DEF(rentitem2,"viiiiiiii"),
|
|
|
BUILDIN_DEF(getitem2,"viiiiiiii?"),
|
|
|
BUILDIN_DEF(getnameditem,"vv"),
|
|
|
BUILDIN_DEF2(grouprandomitem,"groupranditem","i?"),
|
|
|
BUILDIN_DEF(makeitem,"visii"),
|
|
|
+ BUILDIN_DEF(makeitem2,"visiiiiiiiii"),
|
|
|
BUILDIN_DEF(delitem,"vi?"),
|
|
|
BUILDIN_DEF(delitem2,"viiiiiiii?"),
|
|
|
BUILDIN_DEF2(enableitemuse,"enable_items",""),
|