summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorsevenzz23 <sevenzz23@yahoo.com>2013-10-31 12:07:06 +0700
committersevenzz23 <sevenzz23@yahoo.com>2013-10-31 12:42:05 +0700
commitc47d8e4b8f9d63ab6b4e7e286e91cd50a5bdd151 (patch)
tree4df1018ccbb52543c4e97409764b4381714ba2f8 /src/map/script.c
parent566529c819bcf9aeb1bd3a4a691c443c2b88d076 (diff)
downloadhercules-c47d8e4b8f9d63ab6b4e7e286e91cd50a5bdd151.tar.gz
hercules-c47d8e4b8f9d63ab6b4e7e286e91cd50a5bdd151.tar.bz2
hercules-c47d8e4b8f9d63ab6b4e7e286e91cd50a5bdd151.tar.xz
hercules-c47d8e4b8f9d63ab6b4e7e286e91cd50a5bdd151.zip
No error after compilation, but when logging in at map server it will crash.
Im pretty sure its on the clif.c Signed-off-by: sevenzz23 <sevenzz23@yahoo.com>
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c229
1 files changed, 226 insertions, 3 deletions
diff --git a/src/map/script.c b/src/map/script.c
index d51f27ce9..174d12316 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -5946,6 +5946,7 @@ BUILDIN(rentitem)
it.nameid = nameid;
it.identify = 1;
it.expire_time = (unsigned int)(time(NULL) + seconds);
+ it.bound = 0;
if( (flag = pc->additem(sd, &it, 1, LOG_TYPE_SCRIPT)) )
{
@@ -10850,6 +10851,7 @@ BUILDIN(successremovecards) {
item_tmp.refine = sd->status.inventory[i].refine;
item_tmp.attribute = sd->status.inventory[i].attribute;
item_tmp.expire_time = sd->status.inventory[i].expire_time;
+ item_tmp.bound = sd->status.inventory[i].bound;
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
@@ -10923,7 +10925,8 @@ BUILDIN(failedremovecards) {
item_tmp.refine = sd->status.inventory[i].refine;
item_tmp.attribute = sd->status.inventory[i].attribute;
item_tmp.expire_time = sd->status.inventory[i].expire_time;
-
+ item_tmp.bound = sd->status.inventory[i].bound;
+
for (j = sd->inventory_data[i]->slot; j < MAX_SLOTS; j++)
item_tmp.card[j]=sd->status.inventory[i].card[j];
@@ -11573,7 +11576,8 @@ BUILDIN(getinventorylist)
pc->setreg(sd,reference_uid(script->add_str(card_var), j),sd->status.inventory[i].card[k]);
}
pc->setreg(sd,reference_uid(script->add_str("@inventorylist_expire"), j),sd->status.inventory[i].expire_time);
- j++;
+ pc->setreg(sd,reference_uid(script->add_str("@inventorylist_bound"), j),sd->status.inventory[i].bound);
+ j++;
}
}
pc->setreg(sd,script->add_str("@inventorylist_count"),j);
@@ -17529,6 +17533,219 @@ BUILDIN(bg_join_team) {
return true;
}
+
+/*==============[Mhalicot]==================
+ * getitembound <item id>,<amount>,<type>{,<account ID>};
+ * getitembound "<item id>",<amount>,<type>{,<account ID>};
+ * Type:
+ * 1 - Account Bound
+ * 2 - Guild Bound
+ * 3 - Party Bound
+ * 4 - Character Bound
+ *------------------------------------------*/
+BUILDIN(getitembound)
+{
+ int nameid, amount, i, flag;
+ struct item it;
+ struct script_data *data;
+ char bound = script_getnum(st,4);
+ TBL_PC *sd;
+
+ data = script_getdata(st,2);
+ get_val(st,data);
+ if( data_isstring(data) ) { // "<item name>"
+ const char *name = script->conv_str(st,data);
+ struct item_data *item_data = itemdb->search_name(name);
+ if( item_data == NULL ) {
+ ShowError("buildin_getitembound: Nonexistant item %s requested.\n", name);
+ return 1; //No item created.
+ }
+ nameid = item_data->nameid;
+ } else if( data_isint(data) ) { // <item id>
+ nameid = script->conv_num(st,data);
+ if( nameid <= 0 || !itemdb->exists(nameid) ) {
+ ShowError("buildin_getitembound: Nonexistant item %d requested.\n", nameid);
+ return 1; //No item created.
+ }
+ } else {
+ ShowError("buildin_getitembound: invalid data type for argument #1 (%d).", data->type);
+ return 1;
+ }
+
+ if( itemdb->isstackable(nameid) || itemdb_type(nameid) == IT_PETEGG ) {
+ ShowError("buildin_getitembound: invalid item type. Bound only work for non stackeable items (Item %d).", nameid);
+ return 1;
+ }
+
+ if( (amount = script_getnum(st,3)) <= 0)
+ return 0; //return if amount <=0, skip the useless iteration
+
+ memset(&it,0,sizeof(it));
+ it.nameid = nameid;
+ it.identify = 1;
+ it.bound = bound;
+
+ if( bound < 1 || bound > 4) { //Not a correct bound type
+ ShowError("script_getitembound: Not a correct bound type! Type=%d\n",bound);
+ return 1;
+ }
+
+ if( script_hasdata(st,5) )
+ sd=map->id2sd(script_getnum(st,5)); // Account ID
+ else
+ sd=script->rid2sd(st); // Attached player
+
+ if( sd == NULL ) // no target
+ return 0;
+
+ for( i = 0; i < amount; i++ ) {
+ if( (flag = pc->additem(sd, &it, 1, LOG_TYPE_SCRIPT)) ) {
+ clif->additem(sd, 0, 0, flag);
+ if( pc->candrop(sd,&it) )
+ map->addflooritem(&it,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0);
+ }
+ }
+
+ return 0;
+}
+
+/*==============[Mhalicot]==================
+ * getitembound2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<bound type>;
+ * getitembound2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,<bound type>;
+ *------------------------------------------*/
+BUILDIN(getitembound2)
+{
+ int nameid,amount,get_count,i,flag = 0;
+ int iden,ref,attr,c1,c2,c3,c4;
+ char bound=0;
+ struct item_data *item_data;
+ struct item item_tmp;
+ TBL_PC *sd;
+ struct script_data *data;
+
+ bound = script_getnum(st,11);
+ if( bound < 1 || bound > 4) { //Not a correct bound type
+ ShowError("script_getitembound2: Not a correct bound type! Type=%d\n",bound);
+ return 1;
+ }
+ if( script_hasdata(st,12) )
+ sd=map->id2sd(script_getnum(st,12));
+ else
+ sd=script->rid2sd(st); // Attached player
+
+ if( sd == NULL ) // no target
+ return true;
+
+ data=script_getdata(st,2);
+ script->get_val(st,data);
+ if( data_isstring(data) ){
+ const char *name=script->conv_str(st,data);
+ struct item_data *item_data = itemdb->search_name(name);
+ if( item_data )
+ nameid=item_data->nameid;
+ else
+ nameid=UNKNOWN_ITEM_ID;
+ }else
+ nameid=script->conv_num(st,data);
+
+ amount=script_getnum(st,3);
+ iden=script_getnum(st,4);
+ ref=script_getnum(st,5);
+ attr=script_getnum(st,6);
+ c1=(short)script_getnum(st,7);
+ c2=(short)script_getnum(st,8);
+ c3=(short)script_getnum(st,9);
+ c4=(short)script_getnum(st,10);
+
+ if(nameid<0) { // Invalide nameid
+ nameid = -nameid;
+ flag = 1;
+ }
+
+ if(nameid > 0) {
+ memset(&item_tmp,0,sizeof(item_tmp));
+ item_data=itemdb->exists(nameid);
+ if (item_data == NULL)
+ return -1;
+ if(item_data->type==IT_WEAPON || item_data->type==IT_ARMOR){
+ if(ref > MAX_REFINE) ref = MAX_REFINE;
+ }
+ else if(item_data->type==IT_PETEGG) {
+ iden = 1;
+ ref = 0;
+ }
+ else {
+ iden = 1;
+ ref = attr = 0;
+ }
+
+ item_tmp.nameid=nameid;
+ if(!flag)
+ item_tmp.identify=iden;
+ else if(item_data->type==IT_WEAPON || item_data->type==IT_ARMOR)
+ item_tmp.identify=0;
+ item_tmp.refine=ref;
+ item_tmp.attribute=attr;
+ item_tmp.card[0]=(short)c1;
+ item_tmp.card[1]=(short)c2;
+ item_tmp.card[2]=(short)c3;
+ item_tmp.card[3]=(short)c4;
+ item_tmp.bound=bound;
+
+ //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, LOG_TYPE_SCRIPT))) {
+ 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);
+ }
+ }
+ }
+ }
+
+ return true;
+}
+/*==============[Mhalicot]==================
+ * countbound {<type>};
+ * Creates an array of bounded item IDs
+ * Returns amount of items found
+ * Type:
+ * 1 - Account Bound
+ * 2 - Guild Bound
+ * 3 - Party Bound
+ *------------------------------------------*/
+BUILDIN(countbound)
+{
+ int i, type, j=0, k=0;
+ TBL_PC *sd;
+
+ if( (sd = script->rid2sd(st)) == NULL )
+ return false;
+
+ type = script_hasdata(st,2)?script_getnum(st,2):0;
+
+ for(i=0;i<MAX_INVENTORY;i++){
+ if(sd->status.inventory[i].nameid > 0 && (
+ (!type && sd->status.inventory[i].bound > 0) ||
+ (type && sd->status.inventory[i].bound == type)
+ )) {
+ pc->setreg(sd,reference_uid(script->add_str("@bound_items"), k),sd->status.inventory[i].nameid);
+ k++;
+ j += sd->status.inventory[i].amount;
+ }
+ }
+
+ script_pushint(st,j);
+ return 0;
+}
+
/* bg_match_over( arena_name {, optional canceled } ) */
/* returns 0 when successful, 1 otherwise */
BUILDIN(bg_match_over) {
@@ -18109,7 +18326,13 @@ void script_parse_builtin(void) {
BUILDIN_DEF(bindatcmd, "ss???"),
BUILDIN_DEF(unbindatcmd, "s"),
BUILDIN_DEF(useatcmd, "s"),
-
+ /**
+ * Item bound [Mhalicot\Hercules]
+ **/
+ BUILDIN_DEF(getitembound,"vii?"),
+ BUILDIN_DEF(getitembound2,"viiiiiiiii?"),
+ BUILDIN_DEF(countbound, "?"),
+
//Quest Log System [Inkfish]
BUILDIN_DEF(questinfo, "ii??"),
BUILDIN_DEF(setquest, "i"),