Jump to content

Better Cannon Clicker (BCC)


Recommended Posts

A script that places a cannon where you're standing and proceeds to click on it randomly every 20-30+ seconds. It's my first script under Tribot and I'm still learning the API but figured I'd release it. Give it a try and let me know what I can change, etc.

 

Download here.

Source code here.

 

9bd143fb59e9075a3277d7ac64aa1bac.png

Edited by BizarreAlex
  • Like 1
Link to post
Share on other sites
4 hours ago, Naton said:

Nice release! If you ever want feedback on your code from others you can open source your script.

Went ahead and open sourced it.
If anyone experienced with the Tribot API wants to give me a couple pointers that'd be great.

Link to post
Share on other sites
9 minutes ago, HeyImJamie said:

Looks good. My only suggestion would be to cache the cannon's position when you place it and filter for objects at that position, just in case someone sets up a cannon close to it and the script somehow moves.

 

The RSObject representing the cannon is stored to a variable at first load attempt and for future attempts referenced again to click. To my knowledge that should prevent clicking anyone else's cannon unless for whatever reason the bot deploys the cannon inside of another which I don't even think is possible.

Please correct me if I'm wrong.

4b508a43e90b4ed1a25a9c119e83dd21.png

The nearest object should always be the cannon that the player deploys because right after deployment the bot walks onto the same tile as the cannon.

Edited by BizarreAlex
Link to post
Share on other sites
1 minute ago, BizarreAlex said:

 

The RSObject representing the cannon is stored to a variable at first load attempt and for future attempts referenced again to click. To my knowledge that should prevent clicking anyone else's cannon unless for whatever reason the bot deploys the cannon inside of another which I don't even think is possible. The nearest object should always be the cannon that the player deploys because right after deployment the bot walks onto the same tile as the cannon.

 

Please correct me if I'm wrong.

4b508a43e90b4ed1a25a9c119e83dd21.png

That's correct, but you call walking once and can't guarantee it will walk to that exact tile everytime. If it missclicks and runs away, you could end up caching someone else's cannon. I know this is unlikely, but I see no reason to write code to prevent things like that happening. It's not a big deal, but just a suggestion. :) 

Link to post
Share on other sites
2 minutes ago, HeyImJamie said:

That's correct, but you call walking once and can't guarantee it will walk to that exact tile everytime. If it missclicks and runs away, you could end up caching someone else's cannon. I know this is unlikely, but I see no reason to write code to prevent things like that happening. It's not a big deal, but just a suggestion. :) 

 

The "placeCannon" method will return false if the player's location isn't on the same tile as the cannon which would stop the script and notify the user.

fa1098f7ed3e88611da1ec24eda507fb.png"x" = player's X coordinate prior to placing the cannon (which will be the cannon's position"

"y" = player's Y coordinate prior to placing the cannon (which will be the cannon's position"

Link to post
Share on other sites
7 minutes ago, BizarreAlex said:

 

The "placeCannon" method will return false if the player's location isn't on the same tile as the cannon which would stop the script and notify the user.

fa1098f7ed3e88611da1ec24eda507fb.png"x" = player's X coordinate prior to placing the cannon (which will be the cannon's position"

"y" = player's Y coordinate prior to placing the cannon (which will be the cannon's position"

Ah yeah, just re-read it. I'd still filter it out of preference, makes no sense not too. Good job anywho

Link to post
Share on other sites

Things you might want to consider improving:

 

 long timeRan = System.currentTimeMillis() - startTime;

Using Script.getRunningTime() would be ideal, because it takes into account the script's breaks. Using system time does not.

 

private int startXP = Skills.getXP(Skills.SKILLS.RANGED);
private int startLevel = Skills.getCurrentLevel(Skills.SKILLS.RANGED);

This will malfunction if the user doesn't start the script logged in. You need to initialize those variables after the player had a chance to log in and cache this data.

 

RSItem[] data = Inventory.find("Cannon base");
RSObject[] objects = Objects.findNearest(15, 5);

You might want to use more suggestive, less ambiguous names for your variables. For example, since the first array of RSItems might contain Cannon base(s), instead of data a more appropriate name would be cannonBase.

 

 if (!(started))

Will still compile and work correctly, but the inner braces are not necessary.

 

 

Thank you for your contribution.

WkqyHuJ.png  :cool:

 

Link to post
Share on other sites
14 hours ago, Einstein said:

Things you might want to consider improving:

 

 long timeRan = System.currentTimeMillis() - startTime;

Using Script.getRunningTime() would be ideal, because it takes into account the script's breaks. Using system time does not.

 

private int startXP = Skills.getXP(Skills.SKILLS.RANGED);
private int startLevel = Skills.getCurrentLevel(Skills.SKILLS.RANGED);

This will malfunction if the user doesn't start the script logged in. You need to initialize those variables after the player had a chance to log in and cache this data.

 

RSItem[] data = Inventory.find("Cannon base");
RSObject[] objects = Objects.findNearest(15, 5);

You might want to use more suggestive, less ambiguous names for your variables. For example, since the first array of RSItems might contain Cannon base(s), instead of data a more appropriate name would be cannonBase.

 

 if (!(started))

Will still compile and work correctly, but the inner braces are not necessary.

 

 

Thank you for your contribution.

WkqyHuJ.png  :cool:

 

I’ve been developing with Java for several years now and have developed my own personal style of coding which includes the inner braces when checking booleans. As for what you claim to be ambiguous naming, that’s completely preference but giving an Array a singular name such as “cannonBase” isn’t something I’d do. I’ll consiser doing the first thing you mentioned but as already stated in the script description the user should start the script at their location so they should already be logged in.

Link to post
Share on other sites
8 hours ago, BizarreAlex said:

I’ve been developing with Java for several years now and have developed my own personal style of coding

 

If you can't even comprehend a different opinion, stop asking for feedback.

 

Good luck with your own personal special style.

 

Edited by Einstein
Link to post
Share on other sites
5 hours ago, Einstein said:

 

If you can't even comprehend a different opinion, stop asking for feedback.

 

Good luck with your own personal special style.

 

I asked for tips regarding the API, not for irrelevant information about how I choose to negative check booleans. I thank you for the other suggestions you made but it seemed to me like you were nitpicking.

Link to post
Share on other sites
9 hours ago, Einstein said:

Then follow the first two suggestions that are 100% API related.

As for the code suggestions, I took some of my time to read your source and tried to be helpful towards a new member, so you have no reason to get aggressive, unless you are hysterical.

I don't give a shit about your years of coding experience. Bad practices are still bad practices. If you want to call them "style preferences" then go ahead, you can do whatever you want. But don't expect others not to point them out when you publish them.

 

Also, as a side note. Your logic is complete garbage and the code structure is the ugliest thing I've seen in a long time. So instead of focusing on your special magic unique style preferences, you might want to try and adhere at least partially to some real code preferences, or at least remove the profanity from your source code because this is funny only for kids with down syndrome.

 

 

Haha, I'm not the one being aggressive. I'm not sure where you learned Java, but how I check booleans is not bad practice and (imho) looks cleaner. However, at the end of the day they both compile down to the same thing so your point is irrelevant.

I spent five minutes looking at the API before I wrote this script, so I apologize if the structure is not to your liking, but you've been a member of these forums for a over year whereas I joined less than two weeks ago.

I asked for pointers regarding the API, and as I've already stated, thank you for the advice you gave pertaining to that. However, again, as stated previously, you seem to be nitpicking quite a bit (I mean seriously, you're bitching about profanity in my SOURCE code?).

Despite your name, you're anything but a genius my dude, so calm down.

 

Link to post
Share on other sites
  • 4 months later...
  • 1 month later...

@BizarreAlex

Script seems to be broken. I'll provide the crash debug below. 

 

  • [19:15:21] Starting base functions...
  • [19:15:21] Checking for cannon base..
  • [19:15:31] Failed to place cannon, script stopping.
  • [19:15:31] Exception in thread "pool-7-thread-5"
  • [19:15:31] java.lang.IllegalMonitorStateException
  • [19:15:31] at java.util.concurrent.locks.ReentrantLock$Sync.tryRelease(Unknown Source)
  • [19:15:31] at java.util.concurrent.locks.AbstractQueuedSynchronizer.release(Unknown Source)
  • [19:15:31] at java.util.concurrent.locks.ReentrantLock.unlock(Unknown Source)
  • [19:15:31] at java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
  • [19:15:31] at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
  • [19:15:31] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  • [19:15:31] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  • [19:15:31] at java.lang.Thread.run(Unknown Source)

 

 

Link to post
Share on other sites
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Our picks

    • What to expect from TRiBot moving forward.
        • Thanks
        • Like
      • 10 replies
    • TRiBot 12 Release Candidate

      The TRiBot team has been hard at work creating the last major version of TRiBot before the TRiBot X release. We've noticed many problems with TRiBot 11 with a lot of users preferring TRiBot 10 over 11. We've heard you, so we took TRiBot 10, added the new features introduced with 11, introduced some other new things, and created TRiBot 12. So without further adieu, here's TRiBot 12.
        • Sad
        • Like
      • 39 replies
    • Gradle is a build tool used to accelerate developer productivity.

      We recently setup a Maven repository (TRiBot Central) to make it easier for scripters to create scripts. Check it out here: https://gitlab.com/trilez-software/tribot/tribot-central/-/packages

      Furthermore, we've released a simple Gradle project to make it easy to run TRiBot and develop scripts for it. Check it out here: https://gitlab.com/trilez-software/tribot/tribot-gradle-launcher

      The goals of TRiBot Central are to:

      Deliver updates to TRiBot faster


      Better organize TRiBot's dependencies (AKA dependancies)


      Make it easier to develop scripts for TRiBot


      Make it easier to use and run TRiBot


      Note: TRiBot won't be able to run scripts from within this project until TRiBot's next release.
        • Like
      • 13 replies
    • Hi everyone,

      I'd like to thank everyone for their patience in this transition period. Since last week, we've worked out the remaining bugs with this integration.

      Some users have still been having issues with connecting their forums account to their Auth0 account. To resolve this, we've imported all forums accounts into Auth0.

      Unfortunately, the accounts which were imported today were using an unsupported password hashing algorithm. Hence, random passwords were set during the import.

      What does this mean for me?

      If you've previously linked your forums account to your Auth0 account, you don't have to do anything. Nothing changes for you.


      If you haven't logged in via our new login yet,

      Try logging in with your forums email address and the last password you used


      If you are unable to login, please use the "Forgot password" tool on the login page:
      Follow the instructions to reset your password
       
        • thonking
        • Like
      • 17 replies
    • Hello everyone,

      Last week we tried to roll out Auth0 Login, but we lost that battle. Now it's time to win the war!

      Important changes

      When logging into the client, you'll now have to enter your Auth0 account credentials instead of your forums credentials

      Note: 2FA is still handled through your forums account (for the time being)



      Changes for existing users

      You'll have to link your Auth0 account to your forums account here: https://tribot.org/forums/settings/login/?service=11


      Auth0 accounts have been created for most existing users. Please use your forums email address and password to login.



      Important notes

      Make sure to verify your email address upon creating a new Auth0 account


      When we mention your Auth0 account, we mean your account used for auth.tribot.org as displayed below
      • 81 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...