Moparscape - RSPS Community

RuneScape 2 Development => RS Client Hacking => Topic started by: Ambokile on January 31, 2015, 07:00:15 AM

Title: [317refactor] Adding the shift-click focus to your client
Post by: Ambokile on January 31, 2015, 07:00:15 AM
Hi all. A short guide here on adding the shift-click focusing (https://forum.moparscape.org/index.php/topic,668438.0.html/) to your 317refactor-based client.

Head over to the RSApplet class. You want to declare a new boolean called shiftClick with the other global variables.
Code: Java
  1. boolean shiftClick;

You now want to head to the mousePressed method and add the following code above the isMetaDown() check.
Code: Java
  1. if(mouseEvent.isShiftDown()){
  2.         shiftClick =true;
  3. }else{
  4.         shiftClick =false;
  5. }

This uses the isShiftDown() method from the MouseEvent class to check whether the user is holding shift whilst clicking the mouse and, if so, stores that in the boolean.

We're done in the RSApplet class, head over to the Client class. At the top of the class, declare a boolean called shiftClickWarning with a default value of false.
Code: Java
  1. boolean shiftClickWarning =false;

Search for the following line of code, there is only one occurrence in the class.
Code: Java
  1. if(WorldController.clickedTileX!=-1){

Now, replace everything inside that if-statement with the following code:
Code: Java
  1. if(super.shiftClick){
  2.         if(!shiftClickWarning){
  3.                 pushMessage("Walking disabled due to shift-click.", 0, "");
  4.                 shiftClickWarning =true;
  5.         }
  6. }else{
  7.         int x = WorldController.clickedTileX;
  8.         int y = WorldController.clickedTileY;
  9.         boolean walkable = doWalkTo(0, 0, 0, 0, localPlayer.waypointY[0],
  10.                         0, 0, y, localPlayer.waypointX[0], true, x);
  11.         WorldController.clickedTileX=-1;
  12.         if(walkable){
  13.                 crossX =super.clickX;
  14.                 crossY =super.clickY;
  15.                 crossType =1;
  16.                 crossIndex =0;
  17.         }
  18. }

As you can see, the code checks whether the player is holding shift. If they're not, click on the tile as usual. If they are, the code then checks whether they've already received the warning message. If they haven't, the code sends the message and records the fact that they've received the message.