hugmeir

Untitled

Jan 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. item [string] slot_to_best;
  2. string [string, string] all_modifiers;
  3. file_to_map("data/modifiers.txt", all_modifiers);
  4.  
  5. int [item] item_to_plus_hot;
  6. boolean [item] single_equip_item;
  7. string extra_damage_re = "(Hot|Cold|Spooky|Sleaze|Stench)( Spell)? Damage: \\+([0-9]+)";
  8. string class_specific_re = 'Class: "([^"]+)"';
  9.  
  10. foreach this_item_str, enchantments in all_modifiers["Item"] {
  11. matcher class_matcher = create_matcher(class_specific_re, enchantments);
  12. if ( class_matcher.find() ) {
  13. string class_locked = class_matcher.group(1).to_lower_case();
  14. if ( class_locked != my_class().to_lower_case() )
  15. continue;
  16. }
  17. item this_item = to_item(this_item_str);
  18. if ( this_item == $item[none] )
  19. continue;
  20.  
  21. matcher enchantment_matcher = create_matcher(extra_damage_re, enchantments);
  22. while ( enchantment_matcher.find() ) {
  23. string plus_damage = enchantment_matcher.group(3);
  24. int plus_damage_int = plus_damage.to_int();
  25. item_to_plus_hot[this_item] += plus_damage_int;
  26. }
  27.  
  28. if ( this_item != $item[none] ) {
  29. single_equip_item[this_item] = enchantments.contains_text("Single Equip");
  30. }
  31. }
  32.  
  33. void handle_item(item this_item) {
  34. slot this_slot = this_item.to_slot();
  35. if ( this_slot == $slot[none] )
  36. return;
  37.  
  38. if ( !this_item.can_equip() )
  39. return;
  40.  
  41. int hot_damage = item_to_plus_hot[this_item];
  42. if ( hot_damage <= 0 )
  43. return;
  44.  
  45. if ( this_slot == $slot[weapon] && this_item.weapon_hands() != 1 )
  46. return; // no 2h
  47.  
  48. int [string] slottery;
  49.  
  50. if ( this_slot == $slot[acc1] ) {
  51. slottery["acc1"] = 1;
  52. slottery["acc2"] = 1;
  53. }
  54. else {
  55. slottery[this_slot.to_string()] = 1;
  56. }
  57.  
  58. foreach this_slot_again in slottery {
  59. item current_best = slot_to_best[this_slot_again];
  60. if ( current_best == $item[none] ) {
  61. slot_to_best[this_slot_again] = this_item;
  62. continue;
  63. }
  64.  
  65. int current_best_dmg = item_to_plus_hot[current_best];
  66. if ( current_best_dmg > hot_damage )
  67. continue;
  68.  
  69. if ( single_equip_item[this_item] && this_slot_again == "acc2" ) {
  70. item current_acc1 = slot_to_best["acc1"];
  71. if ( current_acc1 == this_item )
  72. continue;
  73. }
  74. slot_to_best[this_slot_again] = this_item;
  75. }
  76. }
  77.  
  78. foreach this_item in $items[] {
  79. if ( this_item.available_amount() < 1 )
  80. continue;
  81. handle_item(this_item);
  82. }
  83.  
  84. foreach this_slot, best_in_slot in slot_to_best {
  85. print(this_slot + " " + best_in_slot);
  86. }
Advertisement
Add Comment
Please, Sign In to add comment