SRL Archive - First Scripts

[RS3][SRL-6] Akarigar's first script - LumbridgeCrayfisher


akarigar

2014-11-05 23:15:30

Hey guys, a little bit about me. I used to play before RS3 was released and I'm getting back into it. This time around though, I'll mostly be scripting and letting the bots do most of the work! Since this is my first script, I really need a lot of feedback so I can improve this and my next scripts. I hope to contribute a lot to this community. I also have a few questions. Runescape used to have randoms to try and detect bots, do they still have them in RS3? If yes, what is the best practice to detect and deal with them in scripts? Do you guys have any reflection hooks that you use in your RS3 scripts or are they 100% color based? Last but not least, how much of the OSR tutorials section can I look at and still be able to use it in SRL-6/RS3? Thanks in advance.

LumbridgeCrayfisher

Features
  • Bank or drop the crayfish.
  • Multiple players.
  • Ability to take breaks.
  • Runs for specified time.
  • Antiban.

Setup
  • Put lumbridge_crayfish_map.png into the {SIMBA}/Includes/SPS/img/runescape_other/ directory.
  • Ensure your characters are either in the Al Kharid bank or at the Crayfish spot in Lumbridge.
  • Run the script and fill the player form.

Camel

2014-11-05 23:55:37

No, randoms were removed in RS3.

There is no reflection for RS3. There is reflection for OSRS but I don't know anything about that. RS3 is color based. There are OGL hooks but I don't really know much about that either.

OSRS tutorial's concepts could probably be used in RS3, the include usage will obviously be different but you could definitely learn a thing or two from them and apply them to RS3 scripting.

As for your script, it is very well written for a first script.

I didn't look at this in a lot of depth but a few things I noticed glancing through

This
if (bankScreen.open(BANK_NPC_GREEN)) or (pinScreen.isOpen(RandomRange(500, 1500))) or (bankScreen.isOpen()) then
Exit(True);
Could just be this. Bankscreen.open automatically checks if either the pinscreen or bankscreen is already open
if (bankScreen.open(BANK_NPC_GREEN)) then
Exit(True);


In your main method you have this
  exitSquealOfFortune();
exitTreasure();
That just calls the same procedure twice, Squeal Of Fortune was removed and replaced with treasure hunter. The exitSqueal procedure just calls exitTreasure. ExitSqueal will be removed eventually.

These are both really minor things, but I figured I'd just go ahead and mention them.

Another thing, in your fish() procedure, you have this loop to check if its fishing

 repeat
backpackCount := tabBackpack.count();
doAntiBan();
Wait(RandomRange(6000, 10500));
until (not isLoggedIn()) or (tabBackpack.isFull()) or (backpackCount = tabBackpack.count());

While this works, if for some reason it takes a while to catch a fish, the script will click the spot again. Another way to this to counter clicking multiple times would be using
function TRSTabBackpack.waitForShift(waitTime: integer): boolean;  
This will wait for the count in the backpack to shift, it returns true it a shift occurs within the wait time specified.

so your loop could look something like this

 repeat
doAntiBan();
until (not isLoggedIn()) or (tabBackpack.isFull()) or (not tabBackpack.waitForShift(randomRange(15000,17000));

This way the script will start waiting for the next fish again right after one is caught. Again, this is really minor and just a suggestion.

Overall though, great job. This is a quality first post.

The Mayor

2014-11-06 01:43:40

Nice script! Where did you learn to code ;)

akarigar

2014-11-06 04:01:38

From: Camel

No, randoms were removed in RS3.

There is no reflection for RS3. There is reflection for OSRS but I don't know anything about that. RS3 is color based. There are OGL hooks but I don't really know much about that either.

OSRS tutorial's concepts could probably be used in RS3, the include usage will obviously be different but you could definitely learn a thing or two from them and apply them to RS3 scripting.

As for your script, it is very well written for a first script.

I didn't look at this in a lot of depth but a few things I noticed glancing through


Thanks for the answers and the quick reply! You caught a lot of things for a quick glance! Thank you for the feedback, I appreciate it.

From: Camel

Could just be this. Bankscreen.open automatically checks if either the pinscreen or bankscreen is already open

From: Camel

That just calls the same procedure twice, Squeal Of Fortune was removed and replaced with treasure hunter. The exitSqueal procedure just calls exitTreasure. ExitSqueal will be removed eventually.


Awesome, I didn't know about those. I have edited those and updated the attachment.

From: Camel

Another thing, in your fish() procedure, you have this loop to check if its fishing

 repeat
backpackCount := tabBackpack.count();
doAntiBan();
Wait(RandomRange(6000, 10500));
until (not isLoggedIn()) or (tabBackpack.isFull()) or (backpackCount = tabBackpack.count());

While this works, if for some reason it takes a while to catch a fish, the script will click the spot again. Another way to this to counter clicking multiple times would be using
function TRSTabBackpack.waitForShift(waitTime: integer): boolean;  
This will wait for the count in the backpack to shift, it returns true it a shift occurs within the wait time specified.

so your loop could look something like this

 repeat
doAntiBan();
until (not isLoggedIn()) or (tabBackpack.isFull()) or (not tabBackpack.waitForShift(randomRange(15000,17000));

This way the script will start waiting for the next fish again right after one is caught. Again, this is really minor and just a suggestion.


I was doing exactly that before, but after observing the script I decided to change it to what it is now. The reason is simple. Let's assume doAntiBan() ends up hovering over a skill. If we immediately call TRSTabBackpack.waitForShift afterwards, then the script will switch to the backpack tab. This looks very fishy, who hovers over a skill for a fraction of a second before changing tabs? If instead, we wait for a while right after doAntiBan(), and then use TRSTabBackpack.waitForShift, it could work. However, let's say while we're waiting, the fishing spot ends. Then we have to wait the initial wait time and then wait a while longer to see a new item appear in the inventory before concluding we are no longer fishing. Seems a bit wasteful, right? I couldn't think of a more elegant way to do some sort anti ban procedure and then wait for a good chunk of time, and then somehow figure out if we're still fishing. What do you think?

From: Camel

Overall though, great job. This is a quality first post.

From: The Mayor

Nice script! Where did you learn to code ;)


Thanks a lot guys, really appreciate it! I taught myself to code, with the help of material available online. As for the SRL material, well I could not have learned that without your tutorial guides! ;)

Lipcot

2014-11-06 05:46:50

gratz on the release :)

Quentini

2014-11-06 08:58:33

From: akarigar
Thanks for the answers and the quick reply! You caught a lot of things for a quick glance! Thank you for the feedback, I appreciate it.




Awesome, I didn't know about those. I have edited those and updated the attachment.



I was doing exactly that before, but after observing the script I decided to change it to what it is now. The reason is simple. Let's assume doAntiBan() ends up hovering over a skill. If we immediately call TRSTabBackpack.waitForShift afterwards, then the script will switch to the backpack tab. This looks very fishy, who hovers over a skill for a fraction of a second before changing tabs? If instead, we wait for a while right after doAntiBan(), and then use TRSTabBackpack.waitForShift, it could work. However, let's say while we're waiting, the fishing spot ends. Then we have to wait the initial wait time and then wait a while longer to see a new item appear in the inventory before concluding we are no longer fishing. Seems a bit wasteful, right? I couldn't think of a more elegant way to do some sort anti ban procedure and then wait for a good chunk of time, and then somehow figure out if we're still fishing. What do you think?




Thanks a lot guys, really appreciate it! I taught myself to code, with the help of material available online. As for the SRL material, well I could not have learned that without your tutorial guides! ;)


I am rather new to scripting with SRL myself, but my suggestion for this fix may involve adding a random wait time right after the hover skill function in your antiban procedure, then add a isplayeranimating function to determine if the fishing spot has disappeared in the process? Anyone else think this would solve the issue?

(I apologize for the format of this post. My phone is horrible)

Camel

2014-11-06 14:12:08

From: akarigar
What do you think?


You make a good point. You have to weigh both methods worst-case and best-case scenarios. Someone mentioned the isPlayerAnimating() function. This could accurately determine if the player is fishing or not regardless of how often or not fishes are caught. So yeah, food for thought.

akarigar

2014-11-06 14:28:25

From: Quentini
I am rather new to scripting with SRL myself, but my suggestion for this fix may involve adding a random wait time right after the hover skill function in your antiban procedure, then add a isplayeranimating function to determine if the fishing spot has disappeared in the process? Anyone else think this would solve the issue?

(I apologize for the format of this post. My phone is horrible)

From: Camel
You make a good point. You have to weigh both methods worst-case and best-case scenarios. Someone mentioned the isPlayerAnimating() function. This could accurately determine if the player is fishing or not regardless of how often or not fishes are caught. So yeah, food for thought.

I looked at TRSMainscreen.isPlayerAnimating, however, the documentation gave me the feeling it wasn't the most reliable method and I don't want to put limitations such as, having the user wearing nothing, and having the mainscreen at about half zoom. It is possible I got an incorrect impression of the function. Plus, since this is fishing crayfish, I figured 6.5-10 seconds would be a long enough time to catch at least one. :p

Quentini

2014-11-06 16:12:21

From: akarigar
I looked at TRSMainscreen.isPlayerAnimating, however, the documentation gave me the feeling it wasn't the most reliable method and I don't want to put limitations such as, having the user wearing nothing, and having the mainscreen at about half zoom. It is possible I got an incorrect impression of the function. Plus, since this is fishing crayfish, I figured 6.5-10 seconds would be a long enough time to catch at least one. :p


I would like clarification on this function as well for myself. As for the wait period, it is also worth accounting for possible lag - time too that could throw things off a bit.

bonsai

2014-11-11 02:21:50

From: Quentini
I would like clarification on this function as well for myself. As for the wait period, it is also worth accounting for possible lag - time too that could throw things off a bit.


The discussion is correct, these functions are highly variable in response depending on player clothing and general motion in the area of the player.

The function is a one-liner:

result := (getPixelShiftAverage(self.playerBox, 50, 250) >= maxShift);

If collects 4-5 samples [50ms each] of the area around the player. Each sample represents the number of dots that changed in that 50ms. It averages those samples and compares them to your 'maxShift'.

You need to tune it by taking samples when you're not performing the activity but you'll always be open to random things like people running around.

It's more of a secondary check. If I'm animating it doesn't mean I am fishing. But if I'm fishing I should be animating.

Quentini

2014-11-11 17:46:21

From: bonsai
The discussion is correct, these functions are highly variable in response depending on player clothing and general motion in the area of the player.

The function is a one-liner:

result := (getPixelShiftAverage(self.playerBox, 50, 250) >= maxShift);

If collects 4-5 samples [50ms each] of the area around the player. Each sample represents the number of dots that changed in that 50ms. It averages those samples and compares them to your 'maxShift'.

You need to tune it by taking samples when you're not performing the activity but you'll always be open to random things like people running around.

It's more of a secondary check. If I'm animating it doesn't mean I am fishing. But if I'm fishing I should be animating.


Thank you Bonsai for the clarification!

TimeRiders

2014-11-12 20:56:01

not to shabby for a first script