Advertisement

# Optimize Equipment Problem

Jun 28th, 2022
1,364
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. var pieces = ["right", "left", "head", "body", "legs", "accessory"]
2. for piece in pieces:
3.     print(piece)
4.     var best_piece = []
5.     var stat = ""
6.
7.     for item in PlayerStuff.pms[selected_pm].inv.size():
8.         if (PlayerStuff.pms[selected_pm].inv[item] is Weapon and piece in ["right", "left"]) or (ImportantStuff.var_type_in_array(PlayerStuff.pms[selected_pm].inv[item], [Head, Body, Legs, Accessory]) and piece in ["head", "body", "legs", "accessory"]):
9.             best_piece.append(item)
10.
11.     match piece:
12.         "right", "left":
13.             stat = "atk"
14.             best_piece.sort_custom(self, "sort_hands")
15.         _:
16.             stat = "def"
17.             best_piece.sort_custom(self, "sort_armor")
18.
19.     if best_piece.size() >= 1:
20.         if PlayerStuff.pms[selected_pm].equipment[piece] != null and PlayerStuff.pms[selected_pm].inv[best_piece[0]].get(stat) > PlayerStuff.pms[selected_pm].equipment[piece].get(stat):
21.             if piece != "left" and !PlayerStuff.pms[selected_pm].equipment.right.two_handed:
22.                     PlayerStuff.pms[selected_pm].inv.append(PlayerStuff.pms[selected_pm].equipment[piece])
23.                     PlayerStuff.pms[selected_pm].equipment[piece] = PlayerStuff.pms[selected_pm].inv[best_piece[0]]
24.                     PlayerStuff.pms[selected_pm].equipment[piece] = PlayerStuff.pms[selected_pm].inv[best_piece[0]]
25.                     PlayerStuff.pms[selected_pm].inv.remove(best_piece[0])
26.             else:
27.                 PlayerStuff.pms[selected_pm].inv.append(PlayerStuff.pms[selected_pm].equipment[piece])
28.                 PlayerStuff.pms[selected_pm].equipment[piece] = PlayerStuff.pms[selected_pm].inv[best_piece[0]]
29.                 PlayerStuff.pms[selected_pm].equipment[piece] = PlayerStuff.pms[selected_pm].inv[best_piece[0]]
30.                 PlayerStuff.pms[selected_pm].inv.remove(best_piece[0])
31.         else:
32.             if piece != "left":
33.                 if !PlayerStuff.pms[selected_pm].equipment.right != null and !PlayerStuff.pms[selected_pm].equipment.right.two_handed:
34.                     PlayerStuff.pms[selected_pm].equipment[piece] = PlayerStuff.pms[selected_pm].inv[best_piece[0]]
35.                         PlayerStuff.pms[selected_pm].inv.remove(best_piece[0])
Advertisement
RAW Paste Data Copied
Advertisement