diff options
author | toms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-04-15 18:37:06 +0000 |
---|---|---|
committer | toms <toms@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2008-04-15 18:37:06 +0000 |
commit | 1e560981e0c0dfff9cc0ae4c8cb3eb7e59438745 (patch) | |
tree | 732fe4e13b2200428e8c408dfd35953072a59a54 /src/map/script.c | |
parent | 6006bca059d0857d57892acf3dcc391d4b0ffe0d (diff) | |
download | hercules-1e560981e0c0dfff9cc0ae4c8cb3eb7e59438745.tar.gz hercules-1e560981e0c0dfff9cc0ae4c8cb3eb7e59438745.tar.bz2 hercules-1e560981e0c0dfff9cc0ae4c8cb3eb7e59438745.tar.xz hercules-1e560981e0c0dfff9cc0ae4c8cb3eb7e59438745.zip |
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
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 54 |
1 files changed, 42 insertions, 12 deletions
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] |