From 1e560981e0c0dfff9cc0ae4c8cb3eb7e59438745 Mon Sep 17 00:00:00 2001 From: toms Date: Tue, 15 Apr 2008 18:37:06 +0000 Subject: Use the same code for script commands getitem & getitem2 as @item to avoid bug in bugreport:1324 (non-stackable items are stacked) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12603 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/script.c | 54 ++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 12 deletions(-) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index f5c1339cd..8af56aaa8 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5310,7 +5310,7 @@ BUILDIN_FUNC(checkweight) *------------------------------------------*/ BUILDIN_FUNC(getitem) { - int nameid,amount,flag = 0; + int nameid,amount,get_count,i,flag = 0; struct item it; TBL_PC *sd; struct script_data *data; @@ -5362,13 +5362,27 @@ BUILDIN_FUNC(getitem) } if( sd == NULL ) // no target return 0; - if( pet_create_egg(sd, nameid) ) - amount = 1; //This is a pet! - else if( (flag=pc_additem(sd,&it,amount)) ){ - clif_additem(sd,0,0,flag); - if( pc_candrop(sd,&it) ) - map_addflooritem(&it,amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); - } + + + //Check if it's stackable. + if (!itemdb_isstackable(nameid)) + get_count = 1; + else + get_count = amount; + + for (i = 0; i < amount; i += get_count) + { + // if not pet egg + if (!pet_create_egg(sd, nameid)) + { + if ((flag = pc_additem(sd, &it, get_count))) + { + clif_additem(sd, 0, 0, flag); + if( pc_candrop(sd,&it) ) + map_addflooritem(&it,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + } + } + } //Logs items, got from (N)PC scripts [Lupus] if(log_config.enable_logs&LOG_SCRIPT_TRANSACTIONS) @@ -5382,7 +5396,7 @@ BUILDIN_FUNC(getitem) *------------------------------------------*/ BUILDIN_FUNC(getitem2) { - int nameid,amount,flag = 0; + int nameid,amount,get_count,i,flag = 0; int iden,ref,attr,c1,c2,c3,c4; struct item_data *item_data; struct item item_tmp; @@ -5451,9 +5465,25 @@ BUILDIN_FUNC(getitem2) item_tmp.card[1]=c2; item_tmp.card[2]=c3; item_tmp.card[3]=c4; - if((flag = pc_additem(sd,&item_tmp,amount))) { - clif_additem(sd,0,0,flag); - map_addflooritem(&item_tmp,amount,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + + //Check if it's stackable. + if (!itemdb_isstackable(nameid)) + get_count = 1; + else + get_count = amount; + + for (i = 0; i < amount; i += get_count) + { + // if not pet egg + if (!pet_create_egg(sd, nameid)) + { + if ((flag = pc_additem(sd, &item_tmp, get_count))) + { + clif_additem(sd, 0, 0, flag); + if( pc_candrop(sd,&item_tmp) ) + map_addflooritem(&item_tmp,get_count,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); + } + } } //Logs items, got from (N)PC scripts [Lupus] -- cgit v1.2.3-60-g2f50