How did Jagex implement the middle mouse camera movement in revision 667 (See update: http://runescape.wikia.com/wiki/Upda...amera_Controls)? I will be answering this here.
What is Middle Mouse Camera Movement?
Instead of using the arrow keys to adjust your camera, we can use the middle button of our mouse to do it.
Related Client Scripts
There is only 1 script that was added and this is what controls the middle mouse camera movement:
Revision 667, Script 4731:
Code:
void script_4731(int arg0, int arg1) {
int int2;
int int3;
int int4;
int int5;
int int6;
int2 = 0;
int3 = 0;
int4 = 0;
int2, int3, int4 = getPressedMouseButtons();
int5 = cameraGetHrot() + (VARC[1653] - arg0) * 2;
int6 = cameraGetVrot() - (VARC[1654] - arg1);
if (int3 == 1 && VARC[173] != 1 && VARPBIT[542] != 1 && minimapSettingIs1()) {
cameraForceAngle(int6, int5);
}
VARC[1653] = arg0;
VARC[1654] = arg1;
return;
}
- arg0 - mouse_x
- arg1 - mouse_y
- int2 - if the primary mouse button is pressed (1 if pressed, 0 if not pressed)
- int3 - if the middle mouse button is pressed (1 if pressed, 0 if not pressed)
- int4 - if the secondary mouse button is pressed (1 if pressed, 0 if not pressed)
- cameraForceAngle - this is what changes the camera's angle (thanks to Scu11 for the naming)
- VARC[173] - when set to 1, you cannot rotate the camera at all (through arrow keys AND middle mouse)
- VARPBIT[542] - when set to 1, you cannot rotate the camera using middle mouse. However, arrow keys still work.
Script 4731 is registered as a mouse motion trigger for the fixed and resizable gameframe for the following highlighted in red:
Fixed mode: interface 548, child 5
Resizable mode: interface 746, child 4
A mouse motion trigger means that when the mouse is moving inside the areas highlighted in red, script 4731 will be executed using the mouse positions x and y as its arguments.
Code:
Call found[interface id 548, child: 5]:[4731, args: -2147483647, -2147483646]
Call found[interface id 746, child: 4]:[4731, args: -2147483647, -2147483646]
Note that the values -2147483647 and -2147483646 are client script constants. In this case, script 4731 will be given the mouse positions x and y as arg0 and arg1.
Conclusions
With this knowledge, you will be able to implement middle mouse camera movement the same way jagex did it in revisions 667+. I have personally implemented this on a 647 and it works perfectly fine.
I hope this was an interesting read.
Credits
Vincent - decompiled client scripts
Admiral Slee - Online Cache Editor for the images of the gameframe