Allow pickup custom items

This commit is contained in:
RedSparr0w
2019-10-21 12:32:03 +13:00
parent cb7d83666d
commit 861d24c8a5
5 changed files with 53 additions and 0 deletions
+3
View File
@@ -3,7 +3,10 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3ab8e8a0-ccfd-4b0b-9547-98173085dc38" name="Default Changelist" comment=""> <list default="true" id="3ab8e8a0-ccfd-4b0b-9547-98173085dc38" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/ParaScript/Methods.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ParaScript/Methods.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/ParaScript/data/Variables.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ParaScript/data/Variables.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/ParaScript/strategies/PickupItems.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ParaScript/strategies/PickupItems.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/main/java/ParaScript/strategies/PickupItems.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ParaScript/strategies/PickupItems.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/ParaScript/ui/UI.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ParaScript/ui/UI.java" afterDir="false" />
</list> </list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
+17
View File
@@ -14,4 +14,21 @@ public class Methods {
} }
return "" + number; return "" + number;
} }
public static int[] combineIntArrays(int[] array1, int[] array2){
int[] array1and2 = new int[array1.length + array2.length];
int currentPosition = 0;
for( int i = 0; i < array1.length; i++) {
array1and2[currentPosition] = array1[i];
currentPosition++;
}
for( int j = 0; j < array2.length; j++) {
array1and2[currentPosition] = array2[j];
currentPosition++;
}
return array1and2;
}
} }
@@ -33,6 +33,7 @@ public class Variables {
// Fighting // Fighting
public static FightingNpcs fighting_npc_selected = FightingNpcs.MAN_WOMAN; public static FightingNpcs fighting_npc_selected = FightingNpcs.MAN_WOMAN;
public static boolean fighting_bury_bones = true; public static boolean fighting_bury_bones = true;
public static int[] fighting_item_ids = new int[]{};
// Thieving // Thieving
public static ThievingNpcs thieving_npc_selected = ThievingNpcs.MAN_WOMAN; public static ThievingNpcs thieving_npc_selected = ThievingNpcs.MAN_WOMAN;
@@ -1,5 +1,6 @@
package ParaScript.strategies; package ParaScript.strategies;
import ParaScript.Methods;
import ParaScript.data.Variables; import ParaScript.data.Variables;
import ParaScript.data.variables.Ores; import ParaScript.data.variables.Ores;
import org.parabot.environment.api.utils.Time; import org.parabot.environment.api.utils.Time;
@@ -33,6 +34,7 @@ public class PickupItems implements Strategy {
try { try {
for (GroundItem item : items) { for (GroundItem item : items) {
item.take(); item.take();
Time.sleep(500);
Time.sleep(() -> item.distanceTo() < 1, 2000); Time.sleep(() -> item.distanceTo() < 1, 2000);
if (Inventory.isFull()){ if (Inventory.isFull()){
break; break;
@@ -50,6 +52,7 @@ public class PickupItems implements Strategy {
if (Variables.fighting_bury_bones) if (Variables.fighting_bury_bones)
itemIDs = new int[]{526}; itemIDs = new int[]{526};
} }
itemIDs = Methods.combineIntArrays(Variables.fighting_item_ids, itemIDs);
return GroundItems.getNearest(itemIDs); return GroundItems.getNearest(itemIDs);
} }
} }
+29
View File
@@ -41,6 +41,8 @@ public class UI extends JFrame {
private JLabel lblFightingNpcCustomID = new JLabel("Custom NPC IDs"); private JLabel lblFightingNpcCustomID = new JLabel("Custom NPC IDs");
private JTextField fightingNpcCustomID = new JTextField(); private JTextField fightingNpcCustomID = new JTextField();
private JCheckBox fightingBuryBones = new JCheckBox(); private JCheckBox fightingBuryBones = new JCheckBox();
private JLabel lblFightingItemCustomID = new JLabel("Pickup Item IDs");
private JTextField fightingItemCustomID = new JTextField();
// Thieving // Thieving
private JComboBox thievingNpcSelect = new JComboBox(); private JComboBox thievingNpcSelect = new JComboBox();
@@ -349,6 +351,33 @@ public class UI extends JFrame {
}); });
fightingPanel.add(fightingBuryBones); fightingPanel.add(fightingBuryBones);
// Custom items to pickup
lblFightingItemCustomID.setForeground(Color_WhiteSmoke);
lblFightingItemCustomID.setBounds(20, 120, 150, 20);
fightingPanel.add(lblFightingItemCustomID);
fightingItemCustomID.setBounds(20, 140, 150, 20);
fightingItemCustomID.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
// we don't need to do anything here
}
@Override
public void focusLost(FocusEvent e) {
try {
String[] sample = fightingItemCustomID.getText().split("(,|;)\\s*");
int[] customIDs = new int[sample.length];
for (int i = 0; i < sample.length; i++)
customIDs[i] = Integer.parseInt(sample[i]);
Variables.fighting_item_ids = customIDs;
} catch (Exception err) {
Variables.fighting_item_ids = new int[]{};
}
}
});
fightingPanel.add(fightingItemCustomID);
/* /*
* Thieving Panel * Thieving Panel
*/ */