pastebin - collaborative debugging tool
kpaste.net RSS


modified_vending_system.diff
Posted by Anonymous on Mon 7th Feb 2011 08:04
raw | new post

  1. Index: conf/battle/items.conf
  2. ===================================================================
  3. --- conf/battle/items.conf      (revision 14697)
  4. +++ conf/battle/items.conf      (working copy)
  5. @@ -22,11 +22,11 @@
  6.  //--------------------------------------------------------------
  7.  
  8.  // The highest value at which an item can be sold via the merchant vend skill. (in zeny)
  9. -vending_max_value: 1000000000
  10. +vending_max_value: 30000
  11.  
  12.  // Whether to allow buying from vending chars that are at their max. zeny limit.
  13.  // If set to yes, the rest of the zeny above the char's capacity will disappear.
  14. -vending_over_max: yes
  15. +vending_over_max: no
  16.  
  17.  // Tax to apply to all vending transactions (eg: 10000 = 100%, 50 = 0.50%)
  18.  // When a tax is applied, the item's full price is charged to the buyer, but
  19. Index: src/map/vending.c
  20. ===================================================================
  21. --- src/map/vending.c   (revision 14697)
  22. +++ src/map/vending.c   (working copy)
  23. @@ -73,7 +73,9 @@
  24.  void vending_purchasereq(struct map_session_data* sd, int aid, int uid, const uint8* data, int count)
  25.  {
  26.         int i, j, cursor, w, new_ = 0, blank, vend_list[MAX_VENDING];
  27. -       double z;
  28. +       double z,price_buffer=0.;
  29. +       int currid,cost,vcurrid,new_currency = 677; //Change 677 to the Item ID of whatever you use as currency.
  30. +       struct item item_buffer;
  31.         struct s_vending vending[MAX_VENDING]; // against duplicate packets
  32.         struct map_session_data* vsd = map_id2sd(aid);
  33.  
  34. @@ -119,13 +121,15 @@
  35.                 else
  36.                         vend_list[i] = j;
  37.  
  38. -               z += ((double)vsd->vending[j].value * (double)amount);
  39. -               if( z > (double)sd->status.zeny || z < 0. || z > (double)MAX_ZENY )
  40. +               price_buffer += (((double)vsd->vending[j].value * (double)amount));
  41. +               currid = pc_search_inventory (sd, new_currency);
  42. +               if( price_buffer > (double)sd->status.inventory[currid].amount || currid < 0. || price_buffer > (double)MAX_ZENY )
  43.                 {
  44.                         clif_buyvending(sd, idx, amount, 1); // you don't have enough zeny
  45.                         return;
  46.                 }
  47. -               if( z + (double)vsd->status.zeny > (double)MAX_ZENY && !battle_config.vending_over_max )
  48. +               vcurrid = pc_search_inventory (vsd, new_currency);
  49. +               if( price_buffer + (double) vsd->status.inventory[vcurrid].amount > MAX_AMOUNT && !battle_config.vending_over_max )
  50.                 {
  51.                         clif_buyvending(sd, idx, vsd->vending[j].amount, 4); // too much zeny = overflow
  52.                         return;
  53. @@ -170,10 +174,14 @@
  54.         if( log_config.zeny > 0 )
  55.                 log_zeny(vsd, "V", sd, (int)z);
  56.  
  57. -       pc_payzeny(sd, (int)z);
  58. -       if( battle_config.vending_tax )
  59. -               z -= z * (battle_config.vending_tax/10000.);
  60. -       pc_getzeny(vsd, (int)z);
  61. +       if(price_buffer > sd->status.inventory[currid].amount)
  62. +               return;
  63. +       cost = (int) price_buffer;
  64. +       pc_delitem(sd, currid, cost, 0, 0);
  65. +       memset(&item_buffer,0,sizeof(item_buffer));
  66. +       item_buffer.nameid = new_currency;
  67. +       item_buffer.identify = 1;
  68. +       pc_additem(vsd,&item_buffer,cost);
  69.  
  70.         for( i = 0; i < count; i++ )
  71.         {

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}





All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at