Advertisement
Guest User

NoLootItem

a guest
Feb 27th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 5.83 KB | None | 0 0
  1. Index: map/atcommand.c
  2. ===================================================================
  3. --- map/atcommand.c (revision 15632)
  4. +++ map/atcommand.c (working copy)
  5. @@ -5789,6 +5789,111 @@
  6.     }
  7.     return 0;
  8.  }
  9. +
  10. +ACMD_FUNC(nolootitem)
  11. +{
  12. +   struct item_data *item_data = NULL;
  13. +   int i;
  14. +   int action = 3;
  15. +
  16. +   if (message && *message) {
  17. +       if (message[0] == '+') {
  18. +           message++;
  19. +           action = 1;
  20. +       }
  21. +       else if (message[0] == '-') {
  22. +           message++;
  23. +           action = 2;
  24. +       }
  25. +       else if (!strcmp(message,"reset"))
  26. +           action = 4;
  27. +   }
  28. +
  29. +   if ( sd->state.autoloot == 0 && action != 3) {
  30. +       clif_displaymessage(fd, "You must enable Autoloot to use this command.");
  31. +       return -1;
  32. +   }
  33. +
  34. +   if (action < 3)
  35. +   {
  36. +       if ((item_data = itemdb_exists(atoi(message))) == NULL)
  37. +           item_data = itemdb_searchname(message);
  38. +       if (!item_data) {
  39. +           clif_displaymessage(fd, "Item not found.");
  40. +           return -1;
  41. +       }
  42. +   }
  43. +
  44. +   switch ( action ) {
  45. +       case 1:
  46. +       ARR_FIND(i = 0, AUTOLOOTITEM_SIZE, i, sd->state.nolootid[i] == item_data->nameid);
  47. +       if ( i < AUTOLOOTITEM_SIZE ) {
  48. +           clif_displaymessage(fd, "This item is already in your nolootitem list.");
  49. +           return -1;
  50. +       }
  51. +       ARR_FIND(i = 0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
  52. +       if ( i < AUTOLOOTITEM_SIZE )
  53. +           sd->state.autolootid[i] = 0;
  54. +       ARR_FIND(i = 0, AUTOLOOTITEM_SIZE, i, sd->state.nolootid[i] == 0);
  55. +       if (i == AUTOLOOTITEM_SIZE) {
  56. +           clif_displaymessage(fd, "Your nolootitem list is full. Remove some items first with @nolootitem -<item name or ID>.");
  57. +           return -1;
  58. +       }
  59. +       sd->state.nolootid[i] = item_data->nameid;
  60. +       sprintf(atcmd_output, "Ignoring loot for item: '%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  61. +       clif_displaymessage(fd, atcmd_output);
  62. +       sd->state.nolooting = 1;
  63. +       break;
  64. +          
  65. +       case 2:
  66. +       ARR_FIND(i = 0, AUTOLOOTITEM_SIZE, i, sd->state.nolootid[i] == item_data->nameid);
  67. +       if ( i == AUTOLOOTITEM_SIZE ) {
  68. +           clif_displaymessage(fd, "This item is not in your nolootitem list.");
  69. +           return -1;
  70. +       }
  71. +       sd->state.nolootid[i] = 0;
  72. +       sprintf(atcmd_output, "Removed item: '%s'/'%s' {%d} from your nolootitem list.", item_data->name, item_data->jname, item_data->nameid);
  73. +       clif_displaymessage(fd, atcmd_output);
  74. +       ARR_FIND(i = 0, AUTOLOOTITEM_SIZE, i, sd->state.nolootid[i] == 0);
  75. +       if ( i < AUTOLOOTITEM_SIZE )
  76. +           sd->state.nolooting = 0;
  77. +       break;
  78. +
  79. +   case 3:
  80. +       sprintf(atcmd_output, "You can have %d items on your nolootitem list.", AUTOLOOTITEM_SIZE);
  81. +       clif_displaymessage(fd, atcmd_output);
  82. +       clif_displaymessage(fd, "Autoloot must be enabled to use this command.");
  83. +       clif_displaymessage(fd, "To add item to the list, use \"@nolootitem +<item name or ID>\". To remove item use \"@nolootitem -<item name or ID>\".");
  84. +       clif_displaymessage(fd, "\"@alootid reset\" will clear your autolootitem list.");
  85. +       ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.nolootid[i] != 0);
  86. +       if (i == AUTOLOOTITEM_SIZE) {
  87. +           clif_displaymessage(fd, "Your nolootitem list is empty.");
  88. +       } else {
  89. +           clif_displaymessage(fd, "Items on your nolootitem list:");
  90. +           for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
  91. +           {
  92. +               if (sd->state.nolootid[i] == 0)
  93. +                   continue;
  94. +               if (!(item_data = itemdb_exists(sd->state.nolootid[i]))) {
  95. +                   ShowDebug("Non-existant item %d on nolootitem list (account_id: %d, char_id: %d)", sd->state.nolootid[i], sd->status.account_id, sd->status.char_id);
  96. +                   continue;
  97. +               }
  98. +               sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
  99. +               clif_displaymessage(fd, atcmd_output);
  100. +           }
  101. +       }
  102. +       break;
  103. +  
  104. +       case 4:
  105. +           memset(sd->state.nolootid, 0, sizeof(sd->state.nolootid));
  106. +           clif_displaymessage(fd, "Your nolootitem list has been reset.");
  107. +           sd->state.nolooting = 0;
  108. +           break;
  109. +   }
  110. +   return 0;
  111. +}
  112. +
  113. +
  114.  /**
  115.   * No longer available, keeping here just in case it's back someday. [Ind]
  116.   **/
  117. @@ -8578,6 +8683,8 @@
  118.         ACMD_DEF(delitem),
  119.         ACMD_DEF(charcommands),
  120.         ACMD_DEF(font),
  121. +       ACMD_DEF(nolootitem),
  122. +       ACMD_DEF2("noloot", nolootitem),
  123.         /**
  124.          * For Testing Purposes, not going to be here after we're done.
  125.          **/
  126. Index: map/mob.c
  127. ===================================================================
  128. --- map/mob.c   (revision 15632)
  129. +++ map/mob.c   (working copy)
  130. @@ -1746,7 +1746,8 @@
  131.     if( sd == NULL ) sd = map_charid2sd(dlist->third_charid);
  132.  
  133.     if( sd
  134. -       && (drop_rate <= sd->state.autoloot || pc_isautolooting(sd, ditem->item_data.nameid))
  135. +//     && (drop_rate <= sd->state.autoloot || pc_isautolooting(sd, ditem->item_data.nameid))
  136. +       && ( ( drop_rate <= sd->state.autoloot && !pc_isnolooting(sd, ditem->item_data.nameid) ) || pc_isautolooting(sd, ditem->item_data.nameid))
  137.         && (battle_config.idle_no_autoloot == 0 || DIFF_TICK(last_tick, sd->idletime) < battle_config.idle_no_autoloot)
  138.         && (battle_config.homunculus_autoloot?1:!flag)
  139.  #ifdef AUTOLOOT_DISTANCE
  140. Index: map/pc.c
  141. ===================================================================
  142. --- map/pc.c    (revision 15632)
  143. +++ map/pc.c    (working copy)
  144. @@ -8263,6 +8263,15 @@
  145.     return (i != AUTOLOOTITEM_SIZE);
  146.  }
  147.  
  148. +bool pc_isnolooting(struct map_session_data *sd, int nameid)
  149. +{
  150. +   int i;
  151. +   if( !sd->state.nolooting )
  152. +       return true;
  153. +   ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.nolootid[i] == nameid);
  154. +   return (i != AUTOLOOTITEM_SIZE);
  155. +}
  156. +
  157.  /**
  158.   * Checks if player can use @/#command
  159.   * @param sd Player map session data
  160. Index: map/pc.h
  161. ===================================================================
  162. --- map/pc.h    (revision 15632)
  163. +++ map/pc.h    (working copy)
  164. @@ -869,6 +869,7 @@
  165.  int pc_read_motd(void); // [Valaris]
  166.  int pc_disguise(struct map_session_data *sd, int class_);
  167.  bool pc_isautolooting(struct map_session_data *sd, int nameid);
  168. +bool pc_isnolooting(struct map_session_data *sd, int nameid);
  169.  /**
  170.   * Mechanic (Mado Gear)
  171.   **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement