Upon going through the modifications I have to make for my scripts and ideas to work with Herc, I encountered different kinds of shops and other features.
However, stubborn as I am, I wonder if it is possible to modify clif.c to add/modify the current currencies for an item from our item database?
Taking the source for the Cash/Point shop, I see that currency is being declared, but due to my lack of programming skills I can't think of a way to point it to a new value, namely one from the item database.
Is anyone able to push me in the right direction? I've already located the most likely point of origin to modify for this to be possible, the spoiler below contains the cash shop code from clif.c.
Note: I have done my search and did find this as an option, however I like to expand my horizon and get things done how I have them in mind. Potentially providing a change for others to use. I'm not too lazy to search, just too stubborn to accept workaround to be a valid solution.
Greetings,
Upon going through the modifications I have to make for my scripts and ideas to work with Herc, I encountered different kinds of shops and other features.
However, stubborn as I am, I wonder if it is possible to modify clif.c to add/modify the current currencies for an item from our item database?
Taking the source for the Cash/Point shop, I see that currency is being declared, but due to my lack of programming skills I can't think of a way to point it to a new value, namely one from the item database.
Is anyone able to push me in the right direction? I've already located the most likely point of origin to modify for this to be possible, the spoiler below contains the cash shop code from clif.c.
/// CASH/POINT SHOP////// List of items offered in a cash shop (ZC_PC_CASH_POINT_ITEMLIST)./// 0287 <packet len>.W <cash point>.L { <sell price>.L <discount price>.L <item type>.B <name id>.W }*/// 0287 <packet len>.W <cash point>.L <kafra point>.L { <sell price>.L <discount price>.L <item type>.B <name id>.W }* (PACKETVER >= 20070711)void clif_cashshop_show(struct map_session_data *sd, struct npc_data *nd) { struct npc_item_list *shop = NULL; unsigned short shop_size = 0; int fd,i, c = 0; int currency[2] = { 0,0 };#if PACKETVER < 20070711 const int offset = 8;#else const int offset = 12;#endif nullpo_retv(sd); nullpo_retv(nd); if( nd->subtype == SCRIPT ) { shop = nd->u.scr.shop->item; shop_size = nd->u.scr.shop->items; npc->trader_count_funds(nd, sd); currency[0] = npc->trader_funds[0]; currency[1] = npc->trader_funds[1]; } else { shop = nd->u.shop.shop_item; shop_size = nd->u.shop.count; currency[0] = sd->cashPoints; currency[1] = sd->kafraPoints; } fd = sd->fd; sd->npc_shopid = nd->bl.id; WFIFOHEAD(fd,offset+shop_size*11); WFIFOW(fd,0) = 0x287; /* 0x2 = length, set after parsing */ WFIFOL(fd,4) = currency[0]; // Cash Points#if PACKETVER >= 20070711 WFIFOL(fd,8) = currency[1]; // Kafra Points#endif for( i = 0; i < shop_size; i++ ) { if( shop[i].nameid ) { struct item_data* id = itemdb->search(shop[i].nameid); WFIFOL(fd,offset+0+i*11) = shop[i].value; WFIFOL(fd,offset+4+i*11) = shop[i].value; // Discount Price WFIFOB(fd,offset+8+i*11) = itemtype(id->type); WFIFOW(fd,offset+9+i*11) = ( id->view_id > 0 ) ? id->view_id : id->nameid; c++; } } WFIFOW(fd,2) = offset+c*11; WFIFOSET(fd,WFIFOW(fd,2));}/// Cashshop Buy Ack (ZC_PC_CASH_POINT_UPDATE)./// 0289 <cash point>.L <error>.W/// 0289 <cash point>.L <kafra point>.L <error>.W (PACKETVER >= 20070711)/// For error return codes see enum [email protected] clif_cashshop_ack(struct map_session_data* sd, int error) { struct npc_data *nd; int fd; int currency[2] = { 0,0 }; nullpo_retv(sd); fd = sd->fd; if( (nd = map->id2nd(sd->npc_shopid)) && nd->subtype == SCRIPT ) { npc->trader_count_funds(nd,sd); currency[0] = npc->trader_funds[0]; currency[1] = npc->trader_funds[1]; } else { currency[0] = sd->cashPoints; currency[1] = sd->kafraPoints; } WFIFOHEAD(fd, packet_len(0x289)); WFIFOW(fd,0) = 0x289; WFIFOL(fd,2) = currency[0];#if PACKETVER < 20070711 WFIFOW(fd,6) = TOW(error);#else WFIFOL(fd,6) = currency[1]; WFIFOW(fd,10) = TOW(error);#endif WFIFOSET(fd, packet_len(0x289));}void clif_parse_cashshop_buy(int fd, struct map_session_data *sd) __attribute__((nonnull (2)));/// Request to buy item(s) from cash shop (CZ_PC_BUY_CASH_POINT_ITEM)./// 0288 <name id>.W <amount>.W/// 0288 <name id>.W <amount>.W <kafra points>.L (PACKETVER >= 20070711)/// 0288 <packet len>.W <kafra points>.L <count>.W { <amount>.W <name id>.W }.4B*count (PACKETVER >= 20100803)void clif_parse_cashshop_buy(int fd, struct map_session_data *sd){ int fail = 0; if( sd->state.trading || !sd->npc_shopid || pc_has_permission(sd,PC_PERM_DISABLE_STORE) ) fail = 1; else {#if PACKETVER < 20101116 short nameid = RFIFOW(fd,2); short amount = RFIFOW(fd,4); int points = RFIFOL(fd,6); fail = npc->cashshop_buy(sd, nameid, amount, points);#else int len = RFIFOW(fd,2); int points = RFIFOL(fd,4); int count = RFIFOW(fd,8); unsigned short* item_list = (unsigned short*)RFIFOP(fd,10); if( len < 10 || len != 10 + count * 4) { ShowWarning("Player %u sent incorrect cash shop buy packet (len %u:%u)!n", sd->status.char_id, len, 10 + count * 4); return; } fail = npc->cashshop_buylist(sd,points,count,item_list);#endif } clif->cashshop_ack(sd,fail);}Thanks in advance.
Note: I have done my search and did find this as an option, however I like to expand my horizon and get things done how I have them in mind. Potentially providing a change for others to use.
Edited by TranquilityI'm not too lazy to search, just too stubborn to accept workaround to be a valid solution.
Share this post
Link to post
Share on other sites