Initial commit
This commit is contained in:
commit
98dd5c66b6
113
.gitignore
vendored
Normal file
113
.gitignore
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
|
||||
# Created by https://www.toptal.com/developers/gitignore/api/intellij
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### Intellij Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
||||
.idea/**/sonarlint/
|
||||
|
||||
# SonarQube Plugin
|
||||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
||||
.idea/**/sonarIssues.xml
|
||||
|
||||
# Markdown Navigator plugin
|
||||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
||||
.idea/**/markdown-navigator.xml
|
||||
.idea/**/markdown-navigator-enh.xml
|
||||
.idea/**/markdown-navigator/
|
||||
|
||||
# Cache file creation bug
|
||||
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
||||
.idea/$CACHE_FILE$
|
||||
|
||||
# CodeStream plugin
|
||||
# https://plugins.jetbrains.com/plugin/12206-codestream
|
||||
.idea/codestream.xml
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/intellij
|
||||
|
||||
CDebug
|
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
9
.idea/artifacts/CBlackjack_jar.xml
generated
Normal file
9
.idea/artifacts/CBlackjack_jar.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="CBlackjack:jar">
|
||||
<output-path>$USER_HOME$/DreamBot/Scripts</output-path>
|
||||
<root id="archive" name="CBlackjack.jar">
|
||||
<element id="module-output" name="CBlackjack" />
|
||||
<element id="module-output" name="Util" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
9
.idea/artifacts/CDebug_jar.xml
generated
Normal file
9
.idea/artifacts/CDebug_jar.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="CDebug:jar">
|
||||
<output-path>$USER_HOME$/DreamBot/Scripts</output-path>
|
||||
<root id="archive" name="CDebug.jar">
|
||||
<element id="module-output" name="CDebug" />
|
||||
<element id="module-output" name="Util" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
9
.idea/artifacts/CFisher_jar.xml
generated
Normal file
9
.idea/artifacts/CFisher_jar.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="CFisher:jar">
|
||||
<output-path>$USER_HOME$/DreamBot/Scripts</output-path>
|
||||
<root id="archive" name="CFisher.jar">
|
||||
<element id="module-output" name="CFisher" />
|
||||
<element id="module-output" name="Util" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
9
.idea/artifacts/CWintertodt_jar.xml
generated
Normal file
9
.idea/artifacts/CWintertodt_jar.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="CWintertodt:jar">
|
||||
<output-path>$USER_HOME$/DreamBot/Scripts</output-path>
|
||||
<root id="archive" name="CWintertodt.jar">
|
||||
<element id="module-output" name="CWintertodt" />
|
||||
<element id="module-output" name="Util" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
13
.idea/modules.xml
generated
Normal file
13
.idea/modules.xml
generated
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/CBlackjack/CBlackjack.iml" filepath="$PROJECT_DIR$/CBlackjack/CBlackjack.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/CDebug/CDebug.iml" filepath="$PROJECT_DIR$/CDebug/CDebug.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/CFisher/CFisher.iml" filepath="$PROJECT_DIR$/CFisher/CFisher.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/CWintertodt/CWintertodt.iml" filepath="$PROJECT_DIR$/CWintertodt/CWintertodt.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/DreambotScripts.iml" filepath="$PROJECT_DIR$/DreambotScripts.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Util/Util.iml" filepath="$PROJECT_DIR$/Util/Util.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
10
.idea/runConfigurations.xml
generated
Normal file
10
.idea/runConfigurations.xml
generated
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
13
CBlackjack/CBlackjack.iml
Normal file
13
CBlackjack/CBlackjack.iml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="client" level="project" />
|
||||
<orderEntry type="module" module-name="Util" />
|
||||
</component>
|
||||
</module>
|
16
CBlackjack/src/io/reisub/dreambot/cblackjack/CBlackjack.java
Normal file
16
CBlackjack/src/io/reisub/dreambot/cblackjack/CBlackjack.java
Normal file
@ -0,0 +1,16 @@
|
||||
package io.reisub.dreambot.cblackjack;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import org.dreambot.api.script.Category;
|
||||
import org.dreambot.api.script.ScriptManifest;
|
||||
import org.dreambot.api.script.impl.TaskScript;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ScriptManifest(name = "CBlackjack", description = "Pummels and steals", author = Constants.AUTHOR,
|
||||
version = 1.0, category = Category.THIEVING, image = "")
|
||||
public class CBlackjack extends TaskScript {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package io.reisub.dreambot.cblackjack.tasks;
|
||||
|
||||
public class ExchangeNotes {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package io.reisub.dreambot.cblackjack.tasks;
|
||||
|
||||
public class KnockOut {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package io.reisub.dreambot.cblackjack.tasks;
|
||||
|
||||
public class Pickpocket {
|
||||
}
|
13
CFisher/CFisher.iml
Normal file
13
CFisher/CFisher.iml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="client" level="project" />
|
||||
<orderEntry type="module" module-name="Util" />
|
||||
</component>
|
||||
</module>
|
30
CFisher/src/io/reisub/dreambot/cfisher/CFisher.java
Normal file
30
CFisher/src/io/reisub/dreambot/cfisher/CFisher.java
Normal file
@ -0,0 +1,30 @@
|
||||
package io.reisub.dreambot.cfisher;
|
||||
|
||||
import io.reisub.dreambot.cfisher.tasks.Drop;
|
||||
import io.reisub.dreambot.cfisher.tasks.Fish;
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.randomevents.GenieSolver;
|
||||
import io.reisub.dreambot.util.tasks.kitten.KittenTask;
|
||||
import org.dreambot.api.script.Category;
|
||||
import org.dreambot.api.script.ScriptManifest;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.script.impl.TaskScript;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ScriptManifest(name = "CFisher", description = "Fisher", author = Constants.AUTHOR,
|
||||
version = 1.0, category = Category.FISHING, image = "")
|
||||
public class CFisher extends TaskScript {
|
||||
@Override
|
||||
public void onStart() {
|
||||
getRandomManager().registerSolver(new GenieSolver(GenieSolver.Skill.HERBLORE));
|
||||
|
||||
TaskNode kittenTask = KittenTask.createKittenTask();
|
||||
if (kittenTask != null) {
|
||||
addNodes(kittenTask);
|
||||
}
|
||||
|
||||
String[] fishNames = Constants.BARBARIAN_FISH_NAMES;
|
||||
|
||||
addNodes(new Drop(fishNames), new Fish(fishNames));
|
||||
}
|
||||
}
|
45
CFisher/src/io/reisub/dreambot/cfisher/tasks/Drop.java
Normal file
45
CFisher/src/io/reisub/dreambot/cfisher/tasks/Drop.java
Normal file
@ -0,0 +1,45 @@
|
||||
package io.reisub.dreambot.cfisher.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.CInventory;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
|
||||
public class Drop extends TaskNode {
|
||||
private final String[] fishNames;
|
||||
|
||||
public Drop(String[] fishNames) {
|
||||
this.fishNames = fishNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
int r = Calculations.random(100);
|
||||
|
||||
if (r < 6) {
|
||||
return Inventory.fullSlotCount() >= 27;
|
||||
} else if (r < 9) {
|
||||
return Inventory.fullSlotCount() >= 26;
|
||||
} else if (r < 10) {
|
||||
return Inventory.fullSlotCount() >= 25;
|
||||
}
|
||||
|
||||
return Inventory.isFull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
if (Inventory.isFull()) {
|
||||
MethodContext.sleep(0, 1200);
|
||||
}
|
||||
|
||||
Inventory.setDropPattern(CInventory.verticalSnakeDropPattern);
|
||||
|
||||
Inventory.dropAll(fishNames);
|
||||
|
||||
MethodContext.sleepUntil(() -> !Inventory.contains(fishNames), 1300);
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
40
CFisher/src/io/reisub/dreambot/cfisher/tasks/Fish.java
Normal file
40
CFisher/src/io/reisub/dreambot/cfisher/tasks/Fish.java
Normal file
@ -0,0 +1,40 @@
|
||||
package io.reisub.dreambot.cfisher.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.Util;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.interactive.NPCs;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.interactive.NPC;
|
||||
|
||||
public class Fish extends TaskNode {
|
||||
private final String[] fishNames;
|
||||
|
||||
public Fish(String[] fishNames) {
|
||||
this.fishNames = fishNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return Util.playerIsIdle() && !Inventory.isFull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
if (Inventory.contains(fishNames)) {
|
||||
MethodContext.sleep(0, 2400);
|
||||
}
|
||||
|
||||
NPC npc = NPCs.closest(Constants.FISHING_SPOT);
|
||||
|
||||
if (npc == null) return 0;
|
||||
|
||||
npc.interactForceLeft(Constants.USE_ROD);
|
||||
|
||||
Util.sleepUntilMovingAndAnimating();
|
||||
|
||||
return Calculations.random(80, 200);
|
||||
}
|
||||
}
|
13
CWintertodt/CWintertodt.iml
Normal file
13
CWintertodt/CWintertodt.iml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="Util" />
|
||||
<orderEntry type="library" name="client" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,23 @@
|
||||
package io.reisub.dreambot.cwintertodt;
|
||||
|
||||
import io.reisub.dreambot.cwintertodt.tasks.Wait;
|
||||
import io.reisub.dreambot.cwintertodt.tasks.WintertodtTask;
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.tasks.Eat;
|
||||
import org.dreambot.api.script.Category;
|
||||
import org.dreambot.api.script.ScriptManifest;
|
||||
import org.dreambot.api.script.impl.TaskScript;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ScriptManifest(name = "CWintertodt", description = "Wintertodt runner", author = Constants.AUTHOR,
|
||||
version = 1.0, category = Category.MINIGAME, image = "")
|
||||
public class CWintertodt extends TaskScript {
|
||||
public void onStart() {
|
||||
addNodes(
|
||||
new Eat(),
|
||||
new Wait(),
|
||||
WintertodtTask.createWintertodtTask()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
package io.reisub.dreambot.cwintertodt.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.Util;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.interactive.GameObjects;
|
||||
import org.dreambot.api.methods.interactive.Players;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.interactive.GameObject;
|
||||
|
||||
public class Burn extends TaskNode {
|
||||
|
||||
private final WintertodtTask parent;
|
||||
|
||||
public Burn(WintertodtTask parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
if (!parent.isInterrupted() && !Util.playerIsIdle(1400)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (parent.getRootCount() == 0 && parent.getKindlingCount() > 0) || parent.shouldBurnBeforeRunningOutOfTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
parent.setInterrupted(false);
|
||||
parent.setBurning(true);
|
||||
|
||||
if (!Inventory.contains(Constants.BRUMA_ROOT, Constants.BRUMA_KINDLING)) return 0;
|
||||
|
||||
GameObject burningBrazier = GameObjects.closest(Constants.BURNING_BRAZIER);
|
||||
GameObject brazier = GameObjects.closest(Constants.BRAZIER);
|
||||
|
||||
if (burningBrazier == null) return 0;
|
||||
|
||||
if (brazier != null && Players.localPlayer().distance(burningBrazier) > Players.localPlayer().distance(brazier)) {
|
||||
brazier.interact();
|
||||
|
||||
Util.sleepUntilMovingOrAnimating();
|
||||
|
||||
return Calculations.random(200, 300);
|
||||
}
|
||||
|
||||
burningBrazier.interactForceLeft(Constants.FEED);
|
||||
|
||||
Util.sleepUntilMovingAndAnimating();
|
||||
|
||||
return Calculations.random(200, 300);
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package io.reisub.dreambot.cwintertodt.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.Util;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.interactive.GameObjects;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.interactive.GameObject;
|
||||
|
||||
public class Chop extends TaskNode {
|
||||
|
||||
private final WintertodtTask parent;
|
||||
|
||||
public Chop(WintertodtTask parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return !Inventory.isFull() && parent.getKindlingCount() == 0 && !parent.shouldBurnBeforeRunningOutOfTime() && !parent.isBurning() && parent.getEnergy() >= 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
if (parent.isInterrupted()) {
|
||||
parent.setInterrupted(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
GameObject roots = GameObjects.closest(Constants.BRUMA_ROOTS);
|
||||
|
||||
if (roots == null) return 0;
|
||||
|
||||
roots.interactForceLeft(Constants.CHOP);
|
||||
|
||||
Util.sleepUntilMovingAndAnimating();
|
||||
|
||||
return Calculations.random(200, 300);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package io.reisub.dreambot.cwintertodt.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.CInventory;
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.Util;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
|
||||
public class Fletch extends TaskNode {
|
||||
|
||||
private WintertodtTask parent;
|
||||
|
||||
public Fletch(WintertodtTask parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return parent.getRootCount() > 0 && !parent.shouldBurnBeforeRunningOutOfTime() && !parent.isBurning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
parent.setInterrupted(false);
|
||||
|
||||
CInventory.useOnNearest(Constants.KNIFE, Constants.BRUMA_ROOT);
|
||||
|
||||
Util.sleepUntilAnimating();
|
||||
|
||||
return Calculations.random(200, 300);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package io.reisub.dreambot.cwintertodt.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.Util;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.interactive.GameObjects;
|
||||
import org.dreambot.api.methods.interactive.Players;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.interactive.GameObject;
|
||||
import org.dreambot.api.wrappers.interactive.Player;
|
||||
|
||||
public class LightOrFix extends TaskNode {
|
||||
|
||||
private WintertodtTask parent;
|
||||
|
||||
public LightOrFix(WintertodtTask parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
GameObject brazier = GameObjects.closest(Constants.BRAZIER);
|
||||
|
||||
if (brazier == null) return false;
|
||||
|
||||
Player player = Players.localPlayer();
|
||||
|
||||
return (player.distance(brazier) < 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
GameObject brazier = GameObjects.closest(Constants.BRAZIER);
|
||||
|
||||
if (brazier.hasAction(Constants.LIGHT)) {
|
||||
brazier.interactForceLeft(Constants.LIGHT);
|
||||
} else {
|
||||
brazier.interactForceLeft(Constants.FIX);
|
||||
}
|
||||
|
||||
Util.sleepUntilMovingOrAnimating();
|
||||
|
||||
return Calculations.random(200, 300);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package io.reisub.dreambot.cwintertodt.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.widget.Widgets;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.widgets.WidgetChild;
|
||||
|
||||
public class Wait extends TaskNode {
|
||||
@Override
|
||||
public boolean accept() {
|
||||
WidgetChild child = Widgets.getChildWidget(396, 3);
|
||||
|
||||
if (child == null) return false;
|
||||
|
||||
String text = child.getText();
|
||||
|
||||
return text.startsWith(Constants.WINTERTODT_RETURNS_IN) && !text.endsWith("0:00");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
return Calculations.random(200, 300);
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package io.reisub.dreambot.cwintertodt.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.TaskNodeParent;
|
||||
import io.reisub.dreambot.util.Util;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.widget.Widgets;
|
||||
import org.dreambot.api.script.ScriptManager;
|
||||
import org.dreambot.api.script.listener.ChatListener;
|
||||
import org.dreambot.api.script.listener.InventoryListener;
|
||||
import org.dreambot.api.wrappers.items.Item;
|
||||
import org.dreambot.api.wrappers.widgets.WidgetChild;
|
||||
import org.dreambot.api.wrappers.widgets.message.Message;
|
||||
|
||||
public class WintertodtTask extends TaskNodeParent {
|
||||
private int rootCount, kindlingCount, energy;
|
||||
private boolean burnBeforeRunningOutOfTime, interrupted, burning;
|
||||
|
||||
public static WintertodtTask createWintertodtTask() {
|
||||
WintertodtTask task = new WintertodtTask();
|
||||
|
||||
task.setChildren(
|
||||
new LightOrFix(task),
|
||||
new Chop(task),
|
||||
new Fletch(task),
|
||||
new Burn(task)
|
||||
);
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
private WintertodtTask() {
|
||||
ScriptManager.getScriptManager().addListener(new ChatListener() {
|
||||
@Override
|
||||
public void onMessage(Message message) {
|
||||
String msg = message.getMessage();
|
||||
|
||||
if (msg.startsWith(Constants.WINTERTODT_COLD) || msg.startsWith(Constants.WINTERTODT_FREEZING_ATTACK)) {
|
||||
setInterrupted(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ScriptManager.getScriptManager().addListener(new InventoryListener() {
|
||||
@Override
|
||||
public void onItemChange(Item[] items) {
|
||||
int burnableItems = Inventory.count(Constants.BRUMA_KINDLING) + Inventory.count(Constants.BRUMA_ROOT);
|
||||
|
||||
if (burnableItems >= getEnergy() && !isBurning()) {
|
||||
setInterrupted(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
rootCount = Inventory.count(Constants.BRUMA_ROOT);
|
||||
kindlingCount = Inventory.count(Constants.BRUMA_KINDLING);
|
||||
energy = getWintertodtEnergy();
|
||||
|
||||
burnBeforeRunningOutOfTime = rootCount + kindlingCount >= energy;
|
||||
|
||||
if (isBurning() && rootCount == 0 && kindlingCount == 0) {
|
||||
setBurning(false);
|
||||
}
|
||||
|
||||
return Util.playerIsIdle() || interrupted;
|
||||
}
|
||||
|
||||
private int getWintertodtEnergy() {
|
||||
WidgetChild child = Widgets.getWidgetChild(396, 21);
|
||||
|
||||
if (child == null) return -1;
|
||||
|
||||
String text = child.getText();
|
||||
return Integer.parseInt(text.replaceAll("[\\D]", ""));
|
||||
}
|
||||
|
||||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
public int getRootCount() {
|
||||
return rootCount;
|
||||
}
|
||||
|
||||
public int getKindlingCount() {
|
||||
return kindlingCount;
|
||||
}
|
||||
|
||||
public boolean isInterrupted() {
|
||||
return interrupted;
|
||||
}
|
||||
|
||||
public void setInterrupted(boolean interrupted) {
|
||||
this.interrupted = interrupted;
|
||||
}
|
||||
|
||||
public boolean isBurning() {
|
||||
return burning;
|
||||
}
|
||||
|
||||
public void setBurning(boolean burning) {
|
||||
this.burning = burning;
|
||||
}
|
||||
|
||||
public boolean shouldBurnBeforeRunningOutOfTime() {
|
||||
return burnBeforeRunningOutOfTime;
|
||||
}
|
||||
}
|
12
DreambotScripts.iml
Normal file
12
DreambotScripts.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="client" level="project" />
|
||||
</component>
|
||||
</module>
|
12
Util/Util.iml
Normal file
12
Util/Util.iml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="client" level="project" />
|
||||
</component>
|
||||
</module>
|
101
Util/src/io/reisub/dreambot/util/CInventory.java
Normal file
101
Util/src/io/reisub/dreambot/util/CInventory.java
Normal file
@ -0,0 +1,101 @@
|
||||
package io.reisub.dreambot.util;
|
||||
|
||||
import org.dreambot.api.input.Mouse;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.container.impl.DropPattern;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.filter.Filter;
|
||||
import org.dreambot.api.wrappers.items.Item;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class CInventory {
|
||||
public static final Filter<Item> foodItemFilter = item -> item.hasAction(Constants.EAT) || item.hasAction(Constants.DRINK);
|
||||
|
||||
public final static DropPattern verticalDropPattern = () -> (Comparator<Item>) (o1, o2) -> {
|
||||
int o1Col = o1.getSlot() % 4;
|
||||
int o1Row = o1.getSlot() / 4;
|
||||
|
||||
int o2Col = o2.getSlot() % 4;
|
||||
int o2Row = o2.getSlot() / 4;
|
||||
|
||||
if (o1Col == o2Col) {
|
||||
return o1Row - o2Row;
|
||||
} else {
|
||||
return o1Col - o2Col;
|
||||
}
|
||||
};
|
||||
|
||||
public final static DropPattern verticalSnakeDropPattern = () -> (Comparator<Item>) (o1, o2) -> {
|
||||
int o1Col = o1.getSlot() % 4;
|
||||
int o1Row = o1.getSlot() / 4;
|
||||
|
||||
int o2Col = o2.getSlot() % 4;
|
||||
int o2Row = o2.getSlot() / 4;
|
||||
|
||||
if (o1Col == o2Col) {
|
||||
if (o1Col == 0 || o1Col == 2) {
|
||||
return o1Row - o2Row;
|
||||
} else {
|
||||
return o2Row - o1Row;
|
||||
}
|
||||
} else {
|
||||
return o1Col - o2Col;
|
||||
}
|
||||
};
|
||||
|
||||
public static boolean useOnNearest(String source, String... targetNames) {
|
||||
Item sourceItem = Inventory.get(source);
|
||||
|
||||
List<Item> targets = Inventory.all(item -> {
|
||||
for (String targetName : targetNames) {
|
||||
if (item.getName().equals(targetName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (sourceItem == null || targets.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return useOnNearest(sourceItem, targets);
|
||||
}
|
||||
|
||||
public static boolean useOnNearest(Item source, List<Item> targets) {
|
||||
double lowestDistance = Double.MAX_VALUE;
|
||||
Item nearest = null;
|
||||
|
||||
Point sPoint = source.getDestination().getCenterPoint();
|
||||
|
||||
for (Item target : targets) {
|
||||
Point tPoint = target.getDestination().getCenterPoint();
|
||||
|
||||
double distance = sPoint.distance(tPoint);
|
||||
|
||||
if (distance < lowestDistance) {
|
||||
lowestDistance = distance;
|
||||
nearest = target;
|
||||
}
|
||||
}
|
||||
|
||||
if (nearest == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Mouse.click(source.getDestination());
|
||||
|
||||
MethodContext.sleep(200, 400);
|
||||
|
||||
return Mouse.click(nearest.getDestination());
|
||||
}
|
||||
|
||||
public static boolean hasFood() {
|
||||
return Inventory.contains(foodItemFilter);
|
||||
}
|
||||
}
|
38
Util/src/io/reisub/dreambot/util/CNPC.java
Normal file
38
Util/src/io/reisub/dreambot/util/CNPC.java
Normal file
@ -0,0 +1,38 @@
|
||||
package io.reisub.dreambot.util;
|
||||
|
||||
import org.dreambot.api.methods.interactive.NPCs;
|
||||
import org.dreambot.api.methods.interactive.Players;
|
||||
import org.dreambot.api.wrappers.interactive.Character;
|
||||
import org.dreambot.api.wrappers.interactive.NPC;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class CNPC {
|
||||
@Nullable
|
||||
public static NPC getNPCInteractingWithPlayer(String name) {
|
||||
List<NPC> npcs;
|
||||
|
||||
if (name.equals("")) {
|
||||
npcs = NPCs.all();
|
||||
} else {
|
||||
npcs = NPCs.all(name);
|
||||
}
|
||||
|
||||
for (NPC npc : npcs) {
|
||||
Character c = npc.getInteractingCharacter();
|
||||
|
||||
if (c != null && c.getName().equals(Players.localPlayer().getName())) {
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static NPC getNPCInteractingWithPlayer() {
|
||||
return getNPCInteractingWithPlayer("");
|
||||
}
|
||||
}
|
74
Util/src/io/reisub/dreambot/util/Constants.java
Normal file
74
Util/src/io/reisub/dreambot/util/Constants.java
Normal file
@ -0,0 +1,74 @@
|
||||
package io.reisub.dreambot.util;
|
||||
|
||||
public class Constants {
|
||||
public static final String AUTHOR = "ChaosEnergy";
|
||||
|
||||
// Items/GameObjects/NPCs
|
||||
public static final String KITTEN = "Kitten";
|
||||
public static final String CAT = "Cat";
|
||||
public static final String[] KITTEN_FISH_NAMES = new String[]{
|
||||
"Shrimp",
|
||||
"Sardine",
|
||||
"Karambwanji",
|
||||
"Herring",
|
||||
"Anchovies",
|
||||
"Mackerel",
|
||||
"Trout",
|
||||
"Cod",
|
||||
"Pike",
|
||||
"Slimy eel",
|
||||
"Salmon",
|
||||
"Tuna",
|
||||
"Rainbow fish",
|
||||
"Cave eel",
|
||||
"Lobster",
|
||||
"Fish chunks",
|
||||
"Bass",
|
||||
"Roe",
|
||||
"Caviar",
|
||||
"Swordfish",
|
||||
"Lava eel",
|
||||
"Monkfish",
|
||||
"Karambwan",
|
||||
"Shark",
|
||||
"Manta ray",
|
||||
"Anglerfish",
|
||||
"Dark crab"
|
||||
};
|
||||
public static final String[] BARBARIAN_FISH_NAMES = new String[]{
|
||||
"Leaping sturgeon",
|
||||
"Leaping salmon",
|
||||
"Leaping trout",
|
||||
};
|
||||
public static final String FISHING_SPOT = "Fishing spot";
|
||||
public static final String KNIFE = "Knife";
|
||||
public static final String BRUMA_ROOT = "Bruma root";
|
||||
public static final String BRUMA_KINDLING = "Bruma kindling";
|
||||
public static final String BRUMA_ROOTS = "Bruma roots";
|
||||
public static final String BRAZIER = "Brazier";
|
||||
public static final String BURNING_BRAZIER = "Burning brazier";
|
||||
|
||||
// Actions
|
||||
public static final String USE = "Use";
|
||||
public static final String USE_ROD = "Use-rod";
|
||||
public static final String INTERACT = "Interact";
|
||||
public static final String PICK_UP = "Pick-up";
|
||||
public static final String FEED = "Feed";
|
||||
public static final String CHOP = "Chop";
|
||||
public static final String EAT = "Eat";
|
||||
public static final String DRINK = "Drink";
|
||||
public static final String LIGHT = "Light";
|
||||
public static final String FIX = "Fix";
|
||||
|
||||
// Messages
|
||||
public static final String KITTEN_WANTS_ATTENTION_MSG = "Your kitten wants attention.";
|
||||
public static final String KITTEN_IS_HUNGRY_MSG = "Your kitten is hungry.";
|
||||
public static final String KITTEN_WAS_STROKED_MSG = "You softly stroke your cat.";
|
||||
public static final String KITTEN_HAS_EATEN_MSG = "The kitten gobbles up the fish.";
|
||||
public static final String WINTERTODT_COLD = "The cold of the Wintertodt";
|
||||
public static final String WINTERTODT_FREEZING_ATTACK = "The freezing cold attack";
|
||||
public static final String WINTERTODT_RETURNS_IN = "The Wintertodt returns in";
|
||||
|
||||
// Dialog options
|
||||
public static final String STROKE = "Stroke";
|
||||
}
|
33
Util/src/io/reisub/dreambot/util/TaskNodeParent.java
Normal file
33
Util/src/io/reisub/dreambot/util/TaskNodeParent.java
Normal file
@ -0,0 +1,33 @@
|
||||
package io.reisub.dreambot.util;
|
||||
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
|
||||
public abstract class TaskNodeParent extends TaskNode {
|
||||
private TaskNode[] children;
|
||||
|
||||
public void setChildren(TaskNode... children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public boolean accept() {
|
||||
for (TaskNode n : children) {
|
||||
if (n.accept()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
for (TaskNode n : children) {
|
||||
if (n.accept()) {
|
||||
return n.execute();
|
||||
}
|
||||
}
|
||||
|
||||
return Calculations.random(40, 80);
|
||||
}
|
||||
}
|
92
Util/src/io/reisub/dreambot/util/Util.java
Normal file
92
Util/src/io/reisub/dreambot/util/Util.java
Normal file
@ -0,0 +1,92 @@
|
||||
package io.reisub.dreambot.util;
|
||||
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.interactive.Players;
|
||||
import org.dreambot.api.methods.skills.Skill;
|
||||
import org.dreambot.api.methods.skills.Skills;
|
||||
import org.dreambot.api.wrappers.interactive.Player;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class Util {
|
||||
public static boolean playerIsIdle() {
|
||||
return playerIsIdle(0);
|
||||
}
|
||||
|
||||
public static boolean playerIsIdle(long timeout) {
|
||||
Player player = Players.localPlayer();
|
||||
|
||||
MethodContext.sleepWhile(() -> !player.isMoving() && !player.isAnimating(), timeout);
|
||||
|
||||
return !player.isMoving() && !player.isAnimating();
|
||||
}
|
||||
|
||||
public static int sleepUntilMoving() {
|
||||
return sleepUntilMoving(Calculations.random(3000, 3500));
|
||||
}
|
||||
|
||||
public static int sleepUntilMoving(long timeout) {
|
||||
long start = System.currentTimeMillis();
|
||||
Player player = Players.localPlayer();
|
||||
|
||||
MethodContext.sleepUntil(() -> player.isMoving(), timeout);
|
||||
|
||||
return (int) (System.currentTimeMillis() - start);
|
||||
}
|
||||
|
||||
public static int sleepUntilAnimating() {
|
||||
return sleepUntilAnimating(Calculations.random(3000, 3500));
|
||||
}
|
||||
|
||||
public static int sleepUntilAnimating(long timeout) {
|
||||
long start = System.currentTimeMillis();
|
||||
Player player = Players.localPlayer();
|
||||
|
||||
MethodContext.sleepUntil(() -> player.isAnimating(), timeout);
|
||||
|
||||
return (int) (System.currentTimeMillis() - start);
|
||||
}
|
||||
|
||||
public static int sleepUntilMovingOrAnimating() {
|
||||
return sleepUntilMovingOrAnimating(Calculations.random(3000, 3500));
|
||||
}
|
||||
|
||||
public static int sleepUntilMovingOrAnimating(long timeout) {
|
||||
long start = System.currentTimeMillis();
|
||||
Player player = Players.localPlayer();
|
||||
|
||||
MethodContext.sleepUntil(() -> player.isMoving() || player.isAnimating(), timeout);
|
||||
|
||||
return (int) (System.currentTimeMillis() - start);
|
||||
}
|
||||
|
||||
public static int sleepUntilMovingAndAnimating() {
|
||||
return sleepUntilMovingAndAnimating(Calculations.random(5000, 5500));
|
||||
}
|
||||
|
||||
public static int sleepUntilMovingAndAnimating(long timeout) {
|
||||
int elapsed = sleepUntilMovingOrAnimating(timeout);
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
if (timeout - elapsed < 0) {
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
MethodContext.sleepWhile(() -> Players.localPlayer().isMoving(), timeout - elapsed);
|
||||
|
||||
elapsed += (System.currentTimeMillis() - start);
|
||||
|
||||
if (timeout - elapsed < 0) {
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
elapsed += sleepUntilAnimating(timeout - elapsed);
|
||||
|
||||
return elapsed;
|
||||
}
|
||||
|
||||
public static int getCurrentHP() {
|
||||
return Skills.getBoostedLevels(Skill.HITPOINTS);
|
||||
}
|
||||
}
|
121
Util/src/io/reisub/dreambot/util/randomevents/GenieSolver.java
Normal file
121
Util/src/io/reisub/dreambot/util/randomevents/GenieSolver.java
Normal file
@ -0,0 +1,121 @@
|
||||
package io.reisub.dreambot.util.randomevents;
|
||||
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.interactive.NPCs;
|
||||
import org.dreambot.api.methods.interactive.Players;
|
||||
import org.dreambot.api.methods.widget.Widgets;
|
||||
import org.dreambot.api.randoms.RandomEvent;
|
||||
import org.dreambot.api.randoms.RandomSolver;
|
||||
import org.dreambot.api.wrappers.interactive.NPC;
|
||||
import org.dreambot.api.wrappers.widgets.WidgetChild;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GenieSolver extends RandomSolver {
|
||||
@SuppressWarnings("unused")
|
||||
public enum Skill {
|
||||
ATTACK(2),
|
||||
STRENGTH(3),
|
||||
RANGED(4),
|
||||
MAGIC(5),
|
||||
DEFENSE(6),
|
||||
CONSTITUTION(7),
|
||||
PRAYER(8),
|
||||
AGILITY(9),
|
||||
HERBLORE(10),
|
||||
THIEVING(11),
|
||||
CRAFTING(12),
|
||||
RUNECRAFTING(13),
|
||||
SLAYER(14),
|
||||
FARMING(15),
|
||||
MINING(16),
|
||||
SMITHING(17),
|
||||
FISHING(18),
|
||||
COOKING(19),
|
||||
FIREMAKING(20),
|
||||
WOODCUTTING(21),
|
||||
FLETCHING(22),
|
||||
CONSTRUCTION(23),
|
||||
HUNTING(24);
|
||||
|
||||
private final int index;
|
||||
|
||||
Skill(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
}
|
||||
|
||||
private final Skill skill;
|
||||
|
||||
private NPC playerGenie;
|
||||
|
||||
public GenieSolver(Skill skill) {
|
||||
super(RandomEvent.GENIE);
|
||||
this.skill = skill;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldExecute() {
|
||||
List<NPC> genies = NPCs.all("Genie");
|
||||
String playerName = Players.localPlayer().getName();
|
||||
|
||||
if (playerGenie != null || Inventory.contains(2528)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (genies.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (NPC genie : genies) {
|
||||
String overheadMsg = genie.getOverhead();
|
||||
|
||||
if (overheadMsg == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (overheadMsg.contains(playerName)) {
|
||||
playerGenie = genie;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onLoop() {
|
||||
WidgetChild lampInterface = Widgets.getChildWidget(240, 0);
|
||||
|
||||
if (lampInterface != null && lampInterface.isVisible()) {
|
||||
MethodContext.log("[GenieSolver] Choosing " + skill.name());
|
||||
WidgetChild skillOption = Widgets.getChildWidget(240, skill.getIndex());
|
||||
skillOption.interact();
|
||||
|
||||
WidgetChild confirm = Widgets.getChildWidget(240, 26);
|
||||
confirm.interact();
|
||||
|
||||
MethodContext.sleepUntil(() -> Widgets.getChildWidget(240, 0) == null, 2000);
|
||||
} else if (Inventory.contains(2528)) {
|
||||
MethodContext.log("[GenieSolver] Rubbing lamp");
|
||||
playerGenie = null;
|
||||
|
||||
Inventory.interact(2528, "Rub");
|
||||
|
||||
MethodContext.sleepUntil(() -> Widgets.getChildWidget(240, 0) != null, 2000);
|
||||
} else {
|
||||
MethodContext.log("[GenieSolver] Interacting with Genie");
|
||||
playerGenie.interact();
|
||||
|
||||
MethodContext.sleepUntil(() -> Inventory.contains(2528), Calculations.random(4000, 5000));
|
||||
}
|
||||
|
||||
return Calculations.random(150, 350);
|
||||
}
|
||||
}
|
41
Util/src/io/reisub/dreambot/util/tasks/Eat.java
Normal file
41
Util/src/io/reisub/dreambot/util/tasks/Eat.java
Normal file
@ -0,0 +1,41 @@
|
||||
package io.reisub.dreambot.util.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.CInventory;
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.Util;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.skills.Skill;
|
||||
import org.dreambot.api.methods.skills.Skills;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
|
||||
public class Eat extends TaskNode {
|
||||
private final int threshold;
|
||||
|
||||
public Eat(int threshold) {
|
||||
this.threshold = threshold;
|
||||
}
|
||||
|
||||
public Eat() {
|
||||
this(Skills.getRealLevel(Skill.HITPOINTS) / 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return CInventory.hasFood() && Util.getCurrentHP() < threshold;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
int count = Inventory.count(CInventory.foodItemFilter);
|
||||
|
||||
if (!Inventory.interact(CInventory.foodItemFilter, Constants.EAT)) {
|
||||
Inventory.interact(CInventory.foodItemFilter, Constants.DRINK);
|
||||
}
|
||||
|
||||
MethodContext.sleepUntil(() -> Inventory.count(CInventory.foodItemFilter) < count, Calculations.random(2000, 2500));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package io.reisub.dreambot.util.tasks.kitten;
|
||||
|
||||
import io.reisub.dreambot.util.CInventory;
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.filter.Filter;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.items.Item;
|
||||
|
||||
public class CutFoodForKitten extends TaskNode {
|
||||
private final KittenTask parent;
|
||||
|
||||
private final Filter<Item> cutFishItemFilter = item -> {
|
||||
for (String fishName : Constants.BARBARIAN_FISH_NAMES) {
|
||||
if (item.getName().contains(fishName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
public CutFoodForKitten(KittenTask parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return parent.isHungry() &&
|
||||
!Inventory.contains(parent.fishItemFilter) &&
|
||||
Inventory.contains(cutFishItemFilter) &&
|
||||
Inventory.contains(Constants.KNIFE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
int count = Inventory.count(cutFishItemFilter);
|
||||
|
||||
CInventory.useOnNearest(Constants.KNIFE, Constants.BARBARIAN_FISH_NAMES);
|
||||
|
||||
MethodContext.sleepUntil(() -> Inventory.count(cutFishItemFilter) < count, Calculations.random(2500, 3000));
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package io.reisub.dreambot.util.tasks.kitten;
|
||||
|
||||
import io.reisub.dreambot.util.CNPC;
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.interactive.NPC;
|
||||
|
||||
public class FeedKitten extends TaskNode {
|
||||
private final KittenTask parent;
|
||||
|
||||
public FeedKitten(KittenTask parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return parent.isHungry() && Inventory.contains(parent.fishItemFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
NPC kitten = CNPC.getNPCInteractingWithPlayer(Constants.KITTEN);
|
||||
|
||||
if (kitten == null) return 0;
|
||||
|
||||
Inventory.get(parent.fishItemFilter).useOn(kitten);
|
||||
|
||||
MethodContext.sleepUntil(() -> !parent.isHungry(), Calculations.random(5000, 5500));
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package io.reisub.dreambot.util.tasks.kitten;
|
||||
|
||||
import io.reisub.dreambot.util.CNPC;
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.dialogues.Dialogues;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.interactive.NPC;
|
||||
|
||||
public class InteractKitten extends TaskNode {
|
||||
private final KittenTask parent;
|
||||
|
||||
public InteractKitten(KittenTask parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return parent.wantsAttention();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
NPC kitten = CNPC.getNPCInteractingWithPlayer(Constants.KITTEN);
|
||||
|
||||
if (kitten == null) return 0;
|
||||
|
||||
stroke(kitten);
|
||||
stroke(kitten);
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
|
||||
public void stroke(NPC kitten) {
|
||||
if (!kitten.interact(Constants.INTERACT)) {
|
||||
return;
|
||||
}
|
||||
|
||||
MethodContext.sleepUntil(Dialogues::areOptionsAvailable, Calculations.random(3000, 3500));
|
||||
|
||||
Dialogues.chooseFirstOptionContaining(Constants.STROKE);
|
||||
|
||||
MethodContext.sleep(1500, 2000);
|
||||
MethodContext.sleepUntil(Dialogues::inDialogue, Calculations.random(4000, 4500));
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package io.reisub.dreambot.util.tasks.kitten;
|
||||
|
||||
import io.reisub.dreambot.util.CNPC;
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.TaskNodeParent;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.filter.Filter;
|
||||
import org.dreambot.api.script.ScriptManager;
|
||||
import org.dreambot.api.script.listener.ChatListener;
|
||||
import org.dreambot.api.wrappers.interactive.NPC;
|
||||
import org.dreambot.api.wrappers.items.Item;
|
||||
import org.dreambot.api.wrappers.widgets.message.Message;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Locale;
|
||||
|
||||
public class KittenTask extends TaskNodeParent {
|
||||
private boolean hungry, attention;
|
||||
|
||||
public final Filter<Item> fishItemFilter = item -> {
|
||||
for (String fishName : Constants.KITTEN_FISH_NAMES) {
|
||||
String rawFishName = "Raw " + fishName.toLowerCase(Locale.ROOT);
|
||||
|
||||
if (item.getName().equals(fishName) || item.getName().equals(rawFishName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
@Nullable
|
||||
public static KittenTask createKittenTask() {
|
||||
KittenTask task = null;
|
||||
|
||||
if (Inventory.contains(Constants.KITTEN)) {
|
||||
Inventory.drop(Constants.KITTEN);
|
||||
|
||||
task = new KittenTask();
|
||||
}
|
||||
|
||||
NPC kitten = CNPC.getNPCInteractingWithPlayer(Constants.KITTEN);
|
||||
NPC cat = CNPC.getNPCInteractingWithPlayer(Constants.CAT);
|
||||
|
||||
if (kitten != null || cat != null) {
|
||||
task = new KittenTask();
|
||||
}
|
||||
|
||||
if (task != null) {
|
||||
task.setChildren(
|
||||
new CutFoodForKitten(task),
|
||||
new FeedKitten(task),
|
||||
new InteractKitten(task),
|
||||
new PickupCat()
|
||||
);
|
||||
}
|
||||
|
||||
return task;
|
||||
}
|
||||
|
||||
private KittenTask() {
|
||||
ScriptManager.getScriptManager().addListener(new ChatListener() {
|
||||
@Override
|
||||
public void onMessage(Message message) {
|
||||
if (message.getMessage().contains(Constants.KITTEN_WANTS_ATTENTION_MSG)) {
|
||||
setAttention(true);
|
||||
}
|
||||
|
||||
if (message.getMessage().contains(Constants.KITTEN_WAS_STROKED_MSG)) {
|
||||
setAttention(false);
|
||||
}
|
||||
|
||||
if (message.getMessage().contains(Constants.KITTEN_IS_HUNGRY_MSG)) {
|
||||
setHungry(true);
|
||||
}
|
||||
|
||||
if (message.getMessage().contains(Constants.KITTEN_HAS_EATEN_MSG)) {
|
||||
setHungry(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setHungry(boolean hungry) {
|
||||
this.hungry = hungry;
|
||||
}
|
||||
|
||||
public boolean isHungry() {
|
||||
return hungry;
|
||||
}
|
||||
|
||||
public void setAttention(boolean attention) {
|
||||
this.attention = attention;
|
||||
}
|
||||
|
||||
public boolean wantsAttention() {
|
||||
return attention;
|
||||
}
|
||||
}
|
31
Util/src/io/reisub/dreambot/util/tasks/kitten/PickupCat.java
Normal file
31
Util/src/io/reisub/dreambot/util/tasks/kitten/PickupCat.java
Normal file
@ -0,0 +1,31 @@
|
||||
package io.reisub.dreambot.util.tasks.kitten;
|
||||
|
||||
import io.reisub.dreambot.util.CNPC;
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.MethodContext;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.interactive.NPC;
|
||||
|
||||
public class PickupCat extends TaskNode {
|
||||
@Override
|
||||
public boolean accept() {
|
||||
NPC cat = CNPC.getNPCInteractingWithPlayer(Constants.CAT);
|
||||
|
||||
return cat != null && !Inventory.isFull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
NPC cat = CNPC.getNPCInteractingWithPlayer(Constants.CAT);
|
||||
|
||||
if (cat == null) return 0;
|
||||
|
||||
cat.interact(Constants.PICK_UP);
|
||||
|
||||
MethodContext.sleepUntil(() -> Inventory.contains(Constants.CAT), Calculations.random(3000, 3500));
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user