pastebin - collaborative debugging tool
eathena.kpaste.net RSS


alootid_array_v2.diff
Posted by Anonymous on Sun 6th Feb 2011 05:15
raw | new post
view followups (newest first): alootid_array_r14697.diff by Anonymous

  1. Index: src/map/atcommand.c
  2. ===================================================================
  3. --- src/map/atcommand.c (revision 14109)
  4. +++ src/map/atcommand.c (working copy)
  5. @@ -6074,35 +6074,84 @@
  6.  }
  7.  
  8.  /*==========================================
  9. - * @autolootitem
  10. + * @autolootitem [modified version by Rad]
  11. + * modified to enable players autoloot 5
  12. + * different items. Uses array. Counter checks added :p
  13. + * Sorry if it is too lousy for you :p
  14.   *------------------------------------------*/
  15.  int atcommand_autolootitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
  16.  {
  17.         struct item_data *item_data = NULL;
  18. +       int i, slot=0;
  19. +       char item_name[100];
  20.  
  21. -       if (!message || !*message) {
  22. -               if (sd->state.autolootid) {
  23. -                       sd->state.autolootid = 0;
  24. +       memset(item_name, '\0', sizeof(item_name));
  25. +
  26. +       if (!message || !*message || (
  27. +               sscanf(message, "\"%99[^\"]\" %d", item_name, &slot) < 1 &&
  28. +               sscanf(message, "%99s %d", item_name, &slot) < 1
  29. +              
  30. +       )) {
  31. +
  32. +               if (sd->state.autolootactive) {
  33. +                       sd->state.autolootactive = 0;
  34.                         clif_displaymessage(fd, "Autolootitem have been turned OFF.");
  35. -               } else
  36. -                       clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @autolootitem <item_name_or_ID>).");
  37. +               }
  38. +               else
  39. +                       clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @alootid <item_name_or_ID> [<slot>]).");
  40. +                       clif_displaymessage(fd, "...to see autoloot list, @alootid list");
  41. +               return -1;
  42. +       }
  43.  
  44. +       if(strcmp(item_name,"list")==0)
  45. +       {
  46. +               clif_displaymessage(fd, "Autoloot items:");
  47. +               for(i=0; i < 5; i++){
  48. +                       if(sd->state.autolootid[i] <= 500)
  49. +                       sprintf(atcmd_output, "Slot %d: %s",i+1,">>> Free autoloot slot <<<");
  50. +                       else{
  51. +                       item_data = itemdb_search(sd->state.autolootid[i]);
  52. +                       sprintf(atcmd_output, "Slot %d: '%s'",i+1,item_data->name);
  53. +                       }
  54. +                       clif_displaymessage(fd, atcmd_output)
  55. +               }
  56. +               return 0;
  57. +               }
  58. +
  59. +       else if ((item_data = itemdb_searchname(item_name)) == NULL &&
  60. +           (item_data = itemdb_exists(atoi(item_name))) == NULL)
  61. +       {
  62. +               clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
  63.                 return -1;
  64.         }
  65. +      
  66. +       if(slot<1 || slot>5) slot = 1; // check
  67. +       slot = slot - 1;
  68. +      
  69. +       if (slot < 0 || slot >4){ //counter check
  70. +       clif_displaymessage(fd, "Slot # can only be 1~5");
  71. +       return -1;
  72. +       }
  73.  
  74. -       if ((item_data = itemdb_exists(atoi(message))) == NULL)
  75. -               item_data = itemdb_searchname(message);
  76. -
  77.         if (!item_data) {
  78.                 // No items founds in the DB with Id or Name
  79.                 clif_displaymessage(fd, "Item not found.");
  80.                 return -1;
  81.         }
  82. +      
  83. +       for(i=0; i < 5; i++){ //to prevent duplicate entry
  84. +                       if(item_data->nameid == sd->state.autolootid[i]){
  85. +                       sprintf(atcmd_output, "'%s' is already auto-looted in Slot %d.",item_data->name, i+1);
  86. +                       clif_displaymessage(fd, atcmd_output);
  87. +                       return -1;
  88. +                       }
  89. +               }
  90.  
  91. -       sd->state.autolootid = item_data->nameid; // Autoloot Activated
  92. +       sd->state.autolootid[slot] = item_data->nameid; // Autoloot Activated
  93. +       sd->state.autolootactive = 1;
  94.  
  95. -       sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
  96. -               item_data->name, item_data->jname, item_data->nameid);
  97. +       sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d} , Stored in slot %d",
  98. +               item_data->name, item_data->jname, item_data->nameid,slot+1);
  99.         clif_displaymessage(fd, atcmd_output);
  100.  
  101.         return 0;
  102. Index: src/map/mob.c
  103. ===================================================================
  104. --- src/map/mob.c       (revision 14109)
  105. +++ src/map/mob.c       (working copy)
  106. @@ -1719,7 +1719,7 @@
  107.         if( sd == NULL ) sd = map_charid2sd(dlist->third_charid);
  108.  
  109.         if( sd
  110. -               && (drop_rate <= sd->state.autoloot || ditem->item_data.nameid == sd->state.autolootid)
  111. +               && (drop_rate <= sd->state.autoloot || mob_processdrop( sd, ditem->item_data.nameid ))
  112.                 && (battle_config.idle_no_autoloot == 0 || DIFF_TICK(last_tick, sd->idletime) < battle_config.idle_no_autoloot)
  113.                 && (battle_config.homunculus_autoloot?1:!flag)
  114.  #ifdef AUTOLOOT_DISTANCE
  115. @@ -1738,6 +1738,17 @@
  116.         dlist->item = ditem;
  117.  }
  118.  
  119. +int mob_processdrop(struct map_session_data * sd, int nameid)
  120. +{
  121. +       int i;
  122. +       for(i=0; i < 5; i++)
  123. +       {
  124. +       if(nameid == sd->state.autolootid[i])
  125. +               return 1;
  126. +       }
  127. +       return 0;
  128. +}
  129. +
  130.  int mob_timer_delete(int tid, unsigned int tick, int id, intptr data)
  131.  {
  132.         struct block_list* bl = map_id2bl(id);
  133. Index: src/map/mob.h
  134. ===================================================================
  135. --- src/map/mob.h       (revision 14109)
  136. +++ src/map/mob.h       (working copy)
  137. @@ -230,6 +230,7 @@
  138.  int mob_dead(struct mob_data *md, struct block_list *src, int type);
  139.  void mob_revive(struct mob_data *md, unsigned int hp);
  140.  void mob_heal(struct mob_data *md,unsigned int heal);
  141. +int mob_processdrop(struct map_session_data * sd, int nameid);
  142.  
  143.  #define mob_stop_walking(md, type) unit_stop_walking(&(md)->bl, type)
  144.  #define mob_stop_attack(md) unit_stop_attack(&(md)->bl)
  145. Index: src/map/pc.h
  146. ===================================================================
  147. --- src/map/pc.h        (revision 14109)
  148. +++ src/map/pc.h        (working copy)
  149. @@ -122,7 +122,8 @@
  150.                 unsigned ignoreAll : 1;
  151.                 unsigned debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
  152.                 unsigned short autoloot;
  153. -               unsigned short autolootid; // [Zephyrus]
  154. +               unsigned short autolootid[5]; // [Zephyrus]
  155. +               unsigned short autolootactive;
  156.                 unsigned noks : 3; // [Zeph Kill Steal Protection]
  157.                 bool changemap;
  158.                 short pmap; // Previous map on Map Change

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