Skip to content

Commit

Permalink
* Added script commands2, rentitem2 and makeitem2, suggestion http://…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
cydh committed Feb 8, 2014
1 parent 3fce137 commit 339c0a8
Show file tree
Hide file tree
Showing 6 changed files with 245 additions and 70 deletions.
2 changes: 1 addition & 1 deletion db/re/item_db.txt
Expand Up @@ -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; },{},{}
Expand Down
14 changes: 14 additions & 0 deletions doc/script_commands.txt
Expand Up @@ -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>;
Expand All @@ -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>;
Expand Down
2 changes: 1 addition & 1 deletion sql-files/item_db_re.sql
Expand Up @@ -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);
Expand Down
68 changes: 35 additions & 33 deletions src/map/pc.c
Expand Up @@ -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;

This comment has been minimized.

Copy link
@cydh
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);
Expand All @@ -4071,34 +4073,34 @@ 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]);

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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/map/pc.h
Expand Up @@ -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);

Expand Down

0 comments on commit 339c0a8

Please sign in to comment.