pastebin - collaborative debugging tool
eathena.kpaste.net RSS


alootid_array_r14697.diff
Posted by Anonymous on Mon 7th Feb 2011 23:27
raw | new post
modification of post by Anonymous (view diff)

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