Jump to content
×
×
  • Create New...

[Closed] Application for SW I


Recommended Posts

 

 

Ive been working on a smithing script to make cannonballs in Edgeville. Id like to call it Cannon-Baller.

Please check out the git page at: https://github.com/Jonesa5/Cannon-Baller

 

## Recommended for mobile only due to there being no anti-ban features included.

Very low requirements! Only 35 smithing and Dwarf Cannon quest are needed.
Low starting capital makes it easy to manage risk while still maximizing profits.

## Features

* Easy click and play running
    * Start at the login screen or somewhere in Edgeville
    * Once the start button is pressed there is no more need for more human interaction
* Supports breaks
* Calculates the amount of profit earned as the bot runs with the given inputs
* No random crashes or unintended behavior. The bot will automatically restart the smithing process if something adverse happens.
    * Walks back to Edgeville if something causes the bot to walk too far away.
* Capable of limiting how many bars to use
* Keeps track of gained experience as well as experience per hour and experience to next level
    * Also displays how many actions are left until the next level
* Smelts ~500 bars (2000 cannonballs) an hour consistently
    * ~120k profit (320k total value) an hour
* Automatically suspends the bot and logs out when there are no more steel bars available or when the bars used limit has been reached

## Future updates

* Automatic traveling to the GE to sell cannonballs and to buy steel bars.
* Automatic offloading onto a mule account

Edited by BlackMiner37
messed up the original post
Link to post
Share on other sites

  • 2 weeks later...
  • Moderators

(Just really looked at main)

Some general notes

  • Compiled code should not be checked in as its generated and generally increases repository size for no benefit
    • Out(Folder)
  • Docs(Not sure why you need to generate this?)
  • Code format kind of seems clumped, but that's my preference to have it more well spaces
  • Biggest one(Which would involve quite a bit of tidyup): Use if statements to help determine logic and error check, you are too reliant on it just working and nothing going wrong.
  • You should separate GUI logic and business logic otherwise it can get messy.

 

private void startSetUp() {
        Condition.wait(() -> ctx.game.clientState() == Constants.GAME_LOADED, 500, 20);
        if (!ctx.players.local().inViewport()) {
            Component playButton = ctx.widgets.widget(378).component(80);
            Condition.wait(() -> playButton.visible() && playButton.click(), 250, 8);
            Condition.wait(() -> ctx.players.local().inViewport(), 500, 20);
        }
    }
  • Unsure why you need to check play button as that should be handled by AutoLogin?

 

if (ctx.chat.canContinue()) { // If we have leveled up or started a dialog
                Condition.wait(() -> true, Random.nextInt(732, 3930), 1);
                updateWindow();
                Component component = ctx.widgets.widget(233).component(3);
                if (component.visible() && component.click()) // Then click continue
                    System.out.println("|Cannon-Baller| Clicked on continue");
                state = STATE.SMITH; // and go back to smithing (assumed that it will only happen during a level up)
            }

 

could be

 

if (ctx.chat.canContinue() && ctx.chat.clickContinue()) { 
	updateWindow();
	state = STATE.SMITH; // and go back to smithing (assumed that it will only happen during a level up)
}

 

 

BankGoods seems to rely on it being opened first time and it looks messy.

It really should be more structured (EG)

if (!ctx.bank.opened && !ctx.bank.open())
{
  return 
}

//Now contine assuming the bank is opened
if (ctx.bank.depositAllExcept(<MouldNameHere>) {
  // Now we know there is only the mould
  if (ctx.bank.withdraw("Steel bars", 0)) { // 0 should be all
    var result = Condition.wait({check bar count});
    if (result) { // Successfully has bar count
     	ctx.bank.close()
         state = STATE.SMITH;
      return
    } 
  }
}

 

SmithCannonballs

  • This really lacks safety logic and checking "if" statements.
  • Your widget logic is too reliant on it working first time and all shoved together. ^^ Above

 

int[] ids = {AMMO_MOULD, STEEL_BAR};

Could be final at the top of the class so its not defined each time method is called.

 

GameObject smelter = ctx.objects.toStream().within(INTERACTION_RANGE).name("Furnace").first();
smelter.interact("Smelt");

Gameobjects can't be null although they can be Nil(GameObject.Nil) this means that the object you would be interacting with is invalid. So you really should be checking it like it's a null object or invalid. Should be something like this

GameObject smelter = ctx.objects.toStream().within(INTERACTION_RANGE).name("Furnace").first();
if (smelter == GameObject.Nil){
	// Invalid smelter so I guess we need to walk to it
	state = State.WALK_TO;
	return;
}

 

 

Component all = cannonballWidget.component(COMPONENT_ALL_ID).component(COMPONENT_ALL_SUB_ID); // The ALL button on the widget

This is not used until later and should only be called if the "if" statement is successful. Gathering components is an expensive action and should only be done when needed.

 

Link to post
Share on other sites

  • Moderators

Fedback briefly over discord last night, coupled with the in depth feedback above, will place on hold till changes are made.

You clearly have a good foundation to work on, now it's just about broadening your API knowledge (using GeItem for example rather than asking the user to input prices) and getting a good scripting structure to work from and maintian.

Link to post
Share on other sites

The script has been completely reworked and is now uploaded to github.  I'm currently testing it today, and I will be doing that for around 10 hours or so. Feel free to look through the code to see if there is anything else I need to change.

Link to post
Share on other sites

  • Moderators

Hi mate,

Nice to see a task structure implemented, much easier to work out what's going on and easier to maintain.

You've taken on some feedback and made some other amendments too which is nice however a few things still irk me and I'd suggest doing before your next update.

@Pty suggested the following:

  • Quote

    This really lacks safety logic and checking "if" statements.

This section for example here: https://github.com/Jonesa5/Cannon-Baller/blob/6daab2de29261f5f294153052c93286312d4388e/src/blackminer37/cannonballer/task/TaskSmith.java#L65

Still seems unchecked. You're trying to interact with the smelter yet the only conditions for this to be activated is 

!completed
&& !ctx.players.local().interacting().valid()
&& !ctx.players.local().inMotion();

There's nothing to suggest that the smelter is in the viewport and you're actually able to click on it.

 

Also, you seem to differ your syntax partway through the code

https://github.com/Jonesa5/Cannon-Baller/blob/6daab2de29261f5f294153052c93286312d4388e/src/blackminer37/cannonballer/task/TaskSmith.java#L61

here for example you wrap your if's in curly braces

whereas here https://github.com/Jonesa5/Cannon-Baller/blob/6daab2de29261f5f294153052c93286312d4388e/src/blackminer37/cannonballer/task/TaskBank.java#L47

you don't, just seems odd to me that you don't follow a standard syntax throughout the script making it confusing and likely moreso confusing if you were to come back after 6 months to make amendments to it.

 

Other than that, it's looking much better.

Link to post
Share on other sites

That's a very good point about the activate methods! I didn't put much thought into them honestly. As for the brackets for the one line of code, I had commented out the "completed = true;" to test if it was needed and then forgot to remove it. I will remove that and then make sure the rest of the files are formatted consistently. Im also going to be reworking the readme.md file as the calculation I used to figure the profit per hour is wrong. There are still a couple things here and there that I would like to work out like reselecting the furnace right after I had already started smithing, and trying to open the bank right as it opens. Just some timing issues. Nothing that a couple more if statements cant fix.

  • Like 1
Link to post
Share on other sites

Version 2.0.13 is up and good to go. I've fixed a lot of the bugs with opening the bank and selecting the furnace. I hope that the script is to the point where it can be released as a free script. I am also prepared to add graphics to the client once v2 comes out. I'm still working on adding GE buying and selling, and that will be released soon (maybe a week or so). As for the off-loading to a mule, I have some ideas for it, but I haven't started work on that yet.

Link to post
Share on other sites

  • 2 weeks later...
  • Administrators
On 8/14/2021 at 3:28 PM, BlackMiner37 said:

Version 2.0.13 is up and good to go. I've fixed a lot of the bugs with opening the bank and selecting the furnace. I hope that the script is to the point where it can be released as a free script. I am also prepared to add graphics to the client once v2 comes out. I'm still working on adding GE buying and selling, and that will be released soon (maybe a week or so). As for the off-loading to a mule, I have some ideas for it, but I haven't started work on that yet.

v2 is out now do you mind updating to it?

Link to post
Share on other sites

  • Moderators

Yeah, real good base here and happy with your progress on the feedback.

If you're able to port to V2 and @ me when you're done, I'll review and as long as everything is all well and good, will be happy to close.

Link to post
Share on other sites

  • Dan changed the title to [On Hold] Application for SW I
  • 1 month later...
  • Dan changed the title to [Closed] Application for SW I
  • Dan locked this topic
Guest
This topic is now closed to further replies.
 Share