* Added script commands2, rentitem2 and makeitem2, suggestion http://rathena.org/board/topic/90918-emistrys-rentitem2-be-added-to-svn/

-- *rentitem2 <item id>,<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
-- *rentitem2 "<item name>",<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
-- from http://www.eathena.ws/board/index.php?showtopic=241313&view=findpost&p=1315831
-- *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>;
-- Credits for the script author(s) & contributor(s)
-- NOTE: I didn't make the documentation yet
* Follow up 3441d4a

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
This commit is contained in:
Cydh Ramdh 2014-02-08 16:34:55 +07:00
parent 3fce137cbb
commit 339c0a8c48
6 changed files with 245 additions and 70 deletions

View File

@ -8520,7 +8520,7 @@
18573,White_Feather,White Feather,4,20,,500,,2,,1,0xFFFFFFFF,63,2,256,,30,1,741,{ if(getrefine()<5){bonus bHit,20;bonus bMaxHPrate,-10;}else if(getrefine()<7){bonus bHit,10;}else if(getrefine()<9){bonus bHit,7;bonus bMaxHPrate,3;}else{bonus bHit,4;bonus bMaxHPrate,4;} },{},{}
18574,Lord_of_Death,Lord of Death,4,20,,1000,,10,,1,0xFFFFFFFF,63,2,256,,70,1,742,{ bonus bMdef,5; bonus2 bAddClass,Class_Normal,(10+((getrefine()>4)?getrefine()-4:0)); bonus2 bSubClass,Class_Normal,-5; },{},{}
18575,Wunderkammer,Wunderkammer,4,20,,500,,10,,1,0xFFFFFFFF,63,2,769,,20,0,743,{ bonus bMdef,10; },{},{}
18576,YinYang_Earring,YinYang Earring,4,20,,100,,0,,0,0xFFFFFFFF,63,2,512,,50,0,744,{ bonus2 bSkillAtk,272,10; bonus2 bSkillAtk,263,5; bonus2 bSkillAtk,273,5; bonus2 bSkillUseSP,272,1; bonus2 bSkillUseSP,273,1; },{},{}
18576,YinYang_Earring,YinYang Earring,4,20,,100,,0,,0,0xFFFFFFFF,63,2,512,,50,0,744,{ bonus2 bSkillAtk,"MO_CHAINCOMBO",10; bonus2 bSkillAtk,"MO_TRIPLEATTACK",5; bonus2 bSkillAtk,"MO_COMBOFINISH",5; bonus2 bSkillUseSP,"MO_CHAINCOMBO",1; bonus2 bSkillUseSP,"MO_COMBOFINISH",1; },{},{}
18577,24_Bolt,24 Bolt,4,20,,200,,0,,0,0xFFFFFFFF,63,2,512,,10,0,696,{},{},{}
18578,Helm_Of_Valor,Helm Of Valor,4,0,,0,,4,,0,0xFFFFFFFF,63,2,256,,0,0,258,{},{},{}
18579,9th_Anni_Hat,9th Anni Hat,4,0,,90,,0,,0,0xFFFFFFFF,63,2,256,,0,1,745,{ bonus bMdef,9; },{},{}

View File

@ -4312,6 +4312,13 @@ This command can not be used to rent stackable items. Rental items cannot be
dropped, traded, sold to NPCs, or placed in guild storage. (i.e. trade mask 75)
Note: 'delitem' in an NPC script can still remove rental items.
---------------------------------------
*rentitem2 <item id>,<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
*rentitem2 "<item name>",<time>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>;
---------------------------------------
*makeitem <item id>,<amount>,"<map name>",<X>,<Y>;
@ -4331,6 +4338,13 @@ it also accepts an 'english name' field from the database and creates apples if
the name isn't found.
If the map name is given as "this", the map the invoking character is on will be used.
---------------------------------------
*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>;
---------------------------------------
*cleanarea "<map name>",<x1>,<y1>,<x2>,<y2>;

View File

@ -8551,7 +8551,7 @@ REPLACE INTO `item_db_re` VALUES (18572,'Korean_Judge_Hat','Korean Judge Hat',4,
REPLACE INTO `item_db_re` VALUES (18573,'White_Feather','White Feather',4,20,NULL,500,NULL,2,NULL,1,0xFFFFFFFF,63,2,256,NULL,'30',1,741,'if(getrefine()<5){bonus bHit,20;bonus bMaxHPrate,-10;}else if(getrefine()<7){bonus bHit,10;}else if(getrefine()<9){bonus bHit,7;bonus bMaxHPrate,3;}else{bonus bHit,4;bonus bMaxHPrate,4;}',NULL,NULL);
REPLACE INTO `item_db_re` VALUES (18574,'Lord_of_Death','Lord of Death',4,20,NULL,1000,NULL,10,NULL,1,0xFFFFFFFF,63,2,256,NULL,'70',1,742,'bonus bMdef,5; bonus2 bAddClass,Class_Normal,(10+((getrefine()>4)?getrefine()-4:0)); bonus2 bSubClass,Class_Normal,-5;',NULL,NULL);
REPLACE INTO `item_db_re` VALUES (18575,'Wunderkammer','Wunderkammer',4,20,NULL,500,NULL,10,NULL,1,0xFFFFFFFF,63,2,769,NULL,'20',0,743,'bonus bMdef,10;',NULL,NULL);
REPLACE INTO `item_db_re` VALUES (18576,'YinYang_Earring','YinYang Earring',4,20,NULL,100,NULL,0,NULL,0,0xFFFFFFFF,63,2,512,NULL,'50',0,744,'bonus2 bSkillAtk,272,10; bonus2 bSkillAtk,263,5; bonus2 bSkillAtk,273,5; bonus2 bSkillUseSP,272,1; bonus2 bSkillUseSP,273,1;',NULL,NULL);
REPLACE INTO `item_db_re` VALUES (18576,'YinYang_Earring','YinYang Earring',4,20,NULL,100,NULL,0,NULL,0,0xFFFFFFFF,63,2,512,NULL,'50',0,744,'bonus2 bSkillAtk,"MO_CHAINCOMBO",10; bonus2 bSkillAtk,"MO_TRIPLEATTACK",5; bonus2 bSkillAtk,"MO_COMBOFINISH",5; bonus2 bSkillUseSP,"MO_CHAINCOMBO",1; bonus2 bSkillUseSP,"MO_COMBOFINISH",1;',NULL,NULL);
REPLACE INTO `item_db_re` VALUES (18577,'24_Bolt','24 Bolt',4,20,NULL,200,NULL,0,NULL,0,0xFFFFFFFF,63,2,512,NULL,'10',0,696,NULL,NULL,NULL);
REPLACE INTO `item_db_re` VALUES (18578,'Helm_Of_Valor','Helm Of Valor',4,0,NULL,0,NULL,4,NULL,0,0xFFFFFFFF,63,2,256,NULL,'0',0,258,NULL,NULL,NULL);
REPLACE INTO `item_db_re` VALUES (18579,'9th_Anni_Hat','9th Anni Hat',4,0,NULL,90,NULL,0,NULL,0,0xFFFFFFFF,63,2,256,NULL,'0',1,745,'bonus bMdef,9;',NULL,NULL);

View File

@ -4011,52 +4011,54 @@ int pc_search_inventory(struct map_session_data *sd,int item_id)
return ( i < MAX_INVENTORY ) ? i : -1;
}
/*==========================================
* Attempt to add a new item to inventory.
* Return:
0 = success
1 = invalid itemid not found or negative amount
2 = overweight
3 = ?
4 = no free place found
5 = max amount reached
6 = ?
7 = stack limitation
*------------------------------------------*/
int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_log_pick_type log_type)
{
struct item_data *data;
int i;
/** Attempt to add a new item to player inventory
* @param sd
* @param item_data
* @param amount
* @param log_type
* @return
* 0 = success
* 1 = invalid itemid not found or negative amount
* 2 = overweight
* 3 = ?
* 4 = no free place found
* 5 = max amount reached
* 6 = ?
* 7 = stack limitation
*/
char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_pick_type log_type) {
struct item_data *id;
uint16 i;
unsigned int w;
nullpo_retr(1, sd);
nullpo_retr(1, item_data);
nullpo_retr(1, item);
if( item_data->nameid <= 0 || amount <= 0 )
if( item->nameid <= 0 || amount <= 0 )
return ADDITEM_INVALID;
if( amount > MAX_AMOUNT )
return ADDITEM_OVERAMOUNT;
data = itemdb_search(item_data->nameid);
id = itemdb_search(item->nameid);
if( data->stack.inventory && amount > data->stack.amount )
if( id->stack.inventory && amount > id->stack.amount )
{// item stack limitation
return ADDITEM_STACKLIMIT;
}
w = data->weight*amount;
w = id->weight*amount;
if(sd->weight + w > sd->max_weight)
return ADDITEM_OVERWEIGHT;
i = MAX_INVENTORY;
if( itemdb_isstackable2(data) && item_data->expire_time == 0 )
if( itemdb_isstackable2(id) && item->expire_time == 0 )
{ // Stackable | Non Rental
for( i = 0; i < MAX_INVENTORY; i++ )
{
if( sd->status.inventory[i].nameid == item_data->nameid && sd->status.inventory[i].bound == item_data->bound && memcmp(&sd->status.inventory[i].card, &item_data->card, sizeof(item_data->card)) == 0 )
if( sd->status.inventory[i].nameid == item->nameid && sd->status.inventory[i].bound == item->bound && memcmp(&sd->status.inventory[i].card, &item->card, sizeof(item->card)) == 0 )
{
if( amount > MAX_AMOUNT - sd->status.inventory[i].amount || ( data->stack.inventory && amount > data->stack.amount - sd->status.inventory[i].amount ) )
if( amount > MAX_AMOUNT - sd->status.inventory[i].amount || ( id->stack.inventory && amount > id->stack.amount - sd->status.inventory[i].amount ) )
return 5;
sd->status.inventory[i].amount += amount;
clif_additem(sd,i,amount,0);
@ -4071,17 +4073,17 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
if( i < 0 )
return ADDITEM_OVERITEM;
memcpy(&sd->status.inventory[i], item_data, sizeof(sd->status.inventory[0]));
memcpy(&sd->status.inventory[i], item, sizeof(sd->status.inventory[0]));
// clear equips field first, just in case
if( item_data->equip )
if( item->equip )
sd->status.inventory[i].equip = 0;
sd->status.inventory[i].amount = amount;
sd->inventory_data[i] = data;
sd->inventory_data[i] = id;
clif_additem(sd,i,amount,0);
}
#ifdef NSI_UNIQUE_ID
if( !itemdb_isstackable2(data) && !item_data->unique_id )
if( !itemdb_isstackable2(id) && !item->unique_id )
sd->status.inventory[i].unique_id = itemdb_unique_id(0,0);
#endif
log_pick_pc(sd, log_type, amount, &sd->status.inventory[i]);
@ -4089,16 +4091,16 @@ int pc_additem(struct map_session_data *sd,struct item *item_data,int amount,e_l
sd->weight += w;
clif_updatestatus(sd,SP_WEIGHT);
//Auto-equip
if(data->flag.autoequip)
pc_equipitem(sd, i, data->equip);
if(id->flag.autoequip)
pc_equipitem(sd, i, id->equip);
/* rental item check */
if( item_data->expire_time ) {
if( time(NULL) > item_data->expire_time ) {
if( item->expire_time ) {
if( time(NULL) > item->expire_time ) {
clif_rental_expired(sd->fd, i, sd->status.inventory[i].nameid);
pc_delitem(sd, i, sd->status.inventory[i].amount, 1, 0, LOG_TYPE_OTHER);
} else {
int seconds = (int)( item_data->expire_time - time(NULL) );
int seconds = (int)( item->expire_time - time(NULL) );
clif_rental_time(sd->fd, sd->status.inventory[i].nameid, seconds);
pc_inventory_rental_add(sd, seconds);
}

View File

@ -847,7 +847,7 @@ int pc_checkadditem(struct map_session_data*,int,int);
int pc_inventoryblank(struct map_session_data*);
int pc_search_inventory(struct map_session_data *sd,int item_id);
int pc_payzeny(struct map_session_data*,int, enum e_log_pick_type type, struct map_session_data*);
int pc_additem(struct map_session_data*,struct item*,int,e_log_pick_type);
char pc_additem(struct map_session_data *sd,struct item *item,int amount,e_log_pick_type log_type);
int pc_getzeny(struct map_session_data*,int, enum e_log_pick_type, struct map_session_data*);
int pc_delitem(struct map_session_data *sd,int n,int amount,int type, short reason, e_log_pick_type log_type);

View File

@ -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",""),