Thread: Middle Mouse Camera Movement

Results 1 to 4 of 4
  1. #1 Middle Mouse Camera Movement 
    Registered Member

    Join Date
    Apr 2016
    Posts
    45
    Thanks given
    20
    Thanks received
    127
    Rep Power
    232
    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.


    Attached image


    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

    Attached image


    Resizable mode: interface 746, child 4


    Attached image


    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
    Reply With Quote  
     


  2. #2  
    Registered Member

    Join Date
    Dec 2009
    Posts
    774
    Thanks given
    367
    Thanks received
    455
    Rep Power
    927
    Note that in higher revs like 718, there are different checks:

    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 || VARPBIT[542] == 1 && VARPBIT[10196] == 1) && cs2method5516() == 1) {
    		cameraMethod5504(int6, int5);
    	}
    	VARC[1653] = arg0;
    	VARC[1654] = arg1;
    	return;
    }
    link removed
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    🎬 Video Editor


    Join Date
    Jun 2015
    Posts
    407
    Thanks given
    393
    Thanks received
    155
    Rep Power
    567
    Cool

    Reply With Quote  
     

  5. #4  
    Middle Mouse Camera Movement



    Scu11's Avatar
    Join Date
    Aug 2007
    Age
    30
    Posts
    16,307
    Thanks given
    7,215
    Thanks received
    12,308
    Rep Power
    5000
    5504 is CAM_FORCEANGLE btw

    great explanation look forward to more

    Attached image
    Reply With Quote  
     

  6. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. middle mouse movement
    By Snijder in forum Tutorials
    Replies: 85
    Last Post: 06-13-2020, 10:52 AM
  2. Middle mouse camera movement
    By Jens. in forum Help
    Replies: 2
    Last Post: 03-31-2018, 12:21 PM
  3. Middle Mouse Camera Movement
    By C00l Kid in forum Help
    Replies: 1
    Last Post: 10-09-2017, 06:14 PM
  4. Replies: 0
    Last Post: 07-21-2017, 03:36 PM
  5. Middle mouse button to move camera
    By FaintView in forum Requests
    Replies: 8
    Last Post: 05-22-2014, 12:14 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •