Skip to content

Commit f01da2e

Browse files
Project layout refactor v2
Adjusted classes
1 parent a81738c commit f01da2e

File tree

5 files changed

+77
-25
lines changed

5 files changed

+77
-25
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
*.xml
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
<orderEntry type="library" name="TRiBot" level="project" />
11+
</component>
12+
</module>

TRILEZ SOFTWARE INC [TRiBot.org]/Projects/TribotMetalDragons/src/org/chris/script/md/Main.java

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@
1919
@ScriptManifest(authors = "AliveInMe", name = "CMetalDragons", category = "Combat")
2020
public class Main extends Script implements Starting, Painting, Ending, MessageListening07{
2121

22-
private ABCUtil abc;
23-
2422
@Override
2523
public void onStart() {
2624
//Start AntibanCompliance instance
2725
General.useAntiBanCompliance(true);
28-
abc = new ABCUtil();
26+
Variables.get().abc = new ABCUtil();
2927
//Drink when the script first starts inside the dragon room.
3028
Variables.get().shouldDrinkAntifire = true;
3129
//Generate our eatAt from the abc instance
32-
Variables.get().eatAt = abc.generateEatAtHP();
30+
Variables.get().eatAt = Variables.get().abc.generateEatAtHP();
3331
//Set to use ranged potions if the inventory contains them
3432
Variables.get().shouldDrinkRangingPotion = Inventory.find(Constants.Filters.ITEM.POTION_RANGING).length > 0;
3533
}
@@ -38,9 +36,11 @@ public void onStart() {
3836
public void run() {
3937
while (true) {
4038
if (Constants.METAL_DRAGONS_ROOM.contains(Player.getPosition())){
39+
/* checks if it should leave the area due to certain conditions */
40+
if (Variables.get().shouldLeave)
41+
leave();
4142
/* Check item consumables food & potions*/
4243
consumables();
43-
4444
if (!isAttacking()){
4545
/* checks for loot if shouldLoot */
4646
loot();
@@ -68,7 +68,7 @@ public void onPaint(Graphics graphics) {
6868
@Override
6969
public void onEnd() {
7070
//Close the abcl instance.
71-
abc.close();
71+
Variables.get().abc.close();
7272
}
7373

7474
@Override
@@ -97,6 +97,8 @@ public void serverMessageReceived(String s) {
9797
Variables.get().shouldDrinkAntifire = true;
9898
else if (s.contains("You drink some of your antifire") || s.equals("You drink some of your extended antifire potion."))
9999
Variables.get().shouldDrinkAntifire = false;
100+
else if (s.contains("There is no ammo left in your quiver.") || s.contains("You can’t use that ammo with your crossbow."))
101+
Variables.get().shouldLeave = true;
100102
}
101103

102104
@Override
@@ -157,29 +159,29 @@ private RSNPC[] getAvailableValidNPCS() {
157159
* Tribot Antiban Compliance Methods
158160
*/
159161
private void antibanCompliance(){
160-
if (this.abc.shouldCheckTabs())
161-
this.abc.checkTabs();
162+
if (Variables.get().abc.shouldCheckTabs())
163+
Variables.get().abc.checkTabs();
162164

163-
if (this.abc.shouldCheckXP())
164-
this.abc.checkXP();
165+
if (Variables.get().abc.shouldCheckXP())
166+
Variables.get().abc.checkXP();
165167

166-
if (this.abc.shouldExamineEntity())
167-
this.abc.examineEntity();
168+
if (Variables.get().abc.shouldExamineEntity())
169+
Variables.get().abc.examineEntity();
168170

169-
if (this.abc.shouldMoveMouse())
170-
this.abc.moveMouse();
171+
if (Variables.get().abc.shouldMoveMouse())
172+
Variables.get().abc.moveMouse();
171173

172-
if (this.abc.shouldPickupMouse())
173-
this.abc.pickupMouse();
174+
if (Variables.get().abc.shouldPickupMouse())
175+
Variables.get().abc.pickupMouse();
174176

175-
if (this.abc.shouldRightClick())
176-
this.abc.rightClick();
177+
if (Variables.get().abc.shouldRightClick())
178+
Variables.get().abc.rightClick();
177179

178-
if (this.abc.shouldRotateCamera())
179-
this.abc.rotateCamera();
180+
if (Variables.get().abc.shouldRotateCamera())
181+
Variables.get().abc.rotateCamera();
180182

181-
if (this.abc.shouldLeaveGame())
182-
this.abc.leaveGame();
183+
if (Variables.get().abc.shouldLeaveGame())
184+
Variables.get().abc.leaveGame();
183185
}
184186

185187
/**
@@ -305,4 +307,13 @@ private void walkAwayFromDanger(){
305307
}
306308
}
307309

310+
private void leave(){
311+
RSItem[] teleport = Inventory.find(Constants.Filters.ITEM.TELEPORT_ITEM);
312+
if (teleport.length > 0){
313+
if (teleport[0].click("Break")){
314+
Timing.waitCondition(Constants.Conditions.HAS_LEFT, 3000);
315+
}
316+
}
317+
}
318+
308319
}

TRILEZ SOFTWARE INC [TRiBot.org]/Projects/TribotMetalDragons/src/org/chris/script/md/data/Constants.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@ public final class Constants {
1313
public static final double SCRIPT_VERSION = 1.0;
1414
public static final String SCRIPT_AUTHOR = "AIM";
1515

16-
public static final String[] LOOTABLES = {};
17-
public static final String[] ALCHABLES = {};
16+
public static final String[] LOOTABLES = {"Runite limbs", "Runite bar", "Rune battleaxe", "Rune med helm", "Rune full helm", "Rune axe", "Rune mace"
17+
, "Adamantite bar", "Adamant platebody", "Rune spear" , "Rune 2h sword", "Rune sq shield", "Rune kiteshield", "Adamant 2h sword", "Adamant sq shield"
18+
, "Adamant axe", "Adamant battleaxe","Loop half of key", "Tooth half of key", "Runite bar", "Rune spear",
19+
"Rune battleaxe", "Rune 2h sword", "Uncut diamond", "Silver ore", "Rune sq shield",
20+
"Death rune", "Rune kiteshield", "Dragon med helm", "Shield left half", "Runite bolts", "Rune javelin",
21+
"Dragon spear", "Ensouled dragon head", "Death rune", "Rune longsword", "Draconic visage",
22+
"Blood rune", "Soul rune", "Dragon platelegs", "Dragon plateskirt", "Rune dart(p)", "Rune knife"
23+
, "Looting bag", "Dragon javelin heads", "Uncut dragonstone", "Dragonstone", "Dragon full helm", "Runite ore"};
24+
25+
public static final String[] ALCHABLES = {"Runite limbs", "Runite bar", "Rune battleaxe", "Rune med helm", "Rune full helm", "Rune axe", "Rune mace"
26+
, "Adamantite bar", "Adamant platebody", "Rune spear" , "Rune 2h sword", "Rune sq shield", "Rune kiteshield", "Adamant 2h sword", "Adamant sq shield"
27+
, "Adamant axe", "Adamant battleaxe"};
1828

1929
public static final RSArea METAL_DRAGONS_ROOM = new RSArea(
2030
new RSTile(2690, 9466),
@@ -49,6 +59,12 @@ public boolean active() {
4959
return Magic.isSpellSelected();
5060
}
5161
};
62+
public static final Condition HAS_LEFT = new Condition() {
63+
@Override
64+
public boolean active() {
65+
return !Constants.METAL_DRAGONS_ROOM.contains(Player.getPosition());
66+
}
67+
};
5268
}
5369

5470
public static class Filters {
@@ -97,6 +113,13 @@ public boolean accept(RSItem rsItem) {
97113
&& Arrays.stream(Constants.ALCHABLES).anyMatch(i -> i.contains(rsItem.getDefinition().getName()));
98114
}
99115
};
116+
public static final Filter<RSItem> TELEPORT_ITEM = new Filter<RSItem>() {
117+
@Override
118+
public boolean accept(RSItem rsItem) {
119+
return rsItem.getDefinition() != null && rsItem.isClickable() && rsItem.getDefinition().getActions().length > 0
120+
&& Arrays.asList(rsItem.getDefinition().getActions()).contains("Break");
121+
}
122+
};
100123
}
101124

102125
public static class GROUNDITEM {

TRILEZ SOFTWARE INC [TRiBot.org]/Projects/TribotMetalDragons/src/org/chris/script/md/data/Variables.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.chris.script.md.data;
22

3+
import org.tribot.api.util.abc.ABCUtil;
4+
35
public class Variables {
46

57
/**
@@ -11,7 +13,9 @@ public class Variables {
1113

1214
public int eatAt;
1315

14-
public boolean shouldDrinkAntifire, shouldDrinkRangingPotion, shouldLoot;
16+
public ABCUtil abc;
17+
18+
public boolean shouldDrinkAntifire, shouldDrinkRangingPotion, shouldLoot, shouldLeave;
1519

1620
public static Variables get(){
1721
return instance;

0 commit comments

Comments
 (0)