Skip to content

Commit 6038886

Browse files
authored
refactor: clarify failsafe logic in DemoAgilityScript (#58)
Separate mark of grace handling from walking to reset tile for clarity.
1 parent 0f412fb commit 6038886

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
---
1717

18-
ChromaScape is a colour-based automation framework designed for Old School RuneScape. Inspired by Kelltom's [OSBC](https://github.com/kelltom/OS-Bot-COLOR/tree/main), [SRL-dev](https://github.com/Villavu/SRL-Development/tree/master), Nick Cemenenkoff's [RuneDark](https://github.com/cemenenkoff/runedark-public) and [SlyAutomation](https://github.com/slyautomation/), it focuses on education, iterative prototyping, human like interaction using solely pixel based logic.
18+
ChromaScape is a colour-based automation framework designed for Old School RuneScape. Inspired by Kelltom's [OSBC](https://github.com/kelltom/OS-Bot-COLOR/tree/main), [SRL-dev](https://github.com/Villavu/SRL-Development/tree/master), Nick Cemenenkoff's [RuneDark](https://github.com/cemenenkoff/runedark-public) and [SlyAutomation](https://github.com/slyautomation/), it focuses on education, iterative prototyping and human like interaction using solely pixel based logic.
1919

2020
Whether you're just starting out or building advanced automation systems, ChromaScape provides a modular, structured framework to help you create robust bots and learn by doing.
2121

src/main/java/com/chromascape/scripts/DemoAgilityScript.java

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,12 @@ protected void cycle() {
111111

112112
// Check the state of the course
113113
if (!isObstacleVisible()) {
114-
if (handleMarkOrLost()) {
115-
// If we clicked a mark, wait for the course to reset and the Green highlight to appear
114+
if (clickMarkOfGraceIfPresent()) {
116115
waitForObstacleToAppear();
117-
return;
116+
} else {
117+
recoverToResetTile();
118118
}
119+
return;
119120
}
120121

121122
// Interact with the detected obstacle
@@ -144,30 +145,24 @@ protected void cycle() {
144145
}
145146

146147
/**
147-
* Manages the scenario when the agility obstacle is not visible. It first tries to find a Mark of
148-
* Grace. If no mark is found, it enters a fail-safe check to confirm the player is truly lost
149-
* before finally attempting to walk to the RESET tile.
150-
*
151-
* @return true if a Mark of Grace was successfully clicked, false otherwise
148+
* Manages the scenario when nothing is visible.
149+
* Firstly, confirms that it's really lost, if so -> uses the walker to path back to the reset tile.
150+
* Finally, waits for the player's animation to settle after reaching the true tile.
152151
*/
153-
private boolean handleMarkOrLost() {
154-
if (clickMarkOfGraceIfPresent()) {
155-
return true;
156-
}
157-
152+
private void recoverToResetTile() {
158153
// Double check we are actually lost to protect against lag or rendering delays
159154
waitRandomMillis(600, 800);
160155
if (!isObstacleVisible()) {
161156
try {
162157
logger.info("We are lost. Walking to reset tile.");
163158
controller().walker().pathTo(RESET_TILE, true);
159+
// wait for camera to stabilise and walking animation to finish at true tile.
164160
waitRandomMillis(4000, 6000);
165161
} catch (Exception e) {
166162
logger.error("Walker error {}", e.getMessage());
167163
stop();
168164
}
169165
}
170-
return false;
171166
}
172167

173168
/**

0 commit comments

Comments
 (0)