Thread: Realm Relay /tq

Results 1 to 11 of 11
  1. #1
    Nisuxen's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    164
    Reputation
    10
    Thanks
    95

    Realm Relay /tq

    People seemed interested and I had a spare 30 minutes. On a side note, anyone know how to manipulate quiver or shuriken shots? They use both the use item packet and the player shoot packet. Changing the location in the former and the angle in the latter doesn't seem to do anything.

     
    Code:
    // tq.js
    
    var ID_CREATE_SUCCESS = 47;
    var ID_PLAYER_TEXT = 80;
    var ID_UPDATE = 66;
    var ID_TELEPORT = 67;
    var ID_NEW_TICK = 50;
    var ID_QUEST_OBJECTID = 48;
    
    var questObjectId = -1;
    var questLoc = null;
    var playerLocs = {};
    var myId = -1;
    
    function onClientPacket(event) {
    	var packet = event.getPacket();
    	switch (packet.id()) {
    		case ID_PLAYER_TEXT: {
    			var text = packet.text.toLowerCase();
    			if(text == "/tq"){
    				event.cancel();
    
    				if(questObjectId == -1 || questLoc == null){
    					break;
    				}
    				var minDist = questLoc.distanceSquaredTo(playerLocs[myId]);
    				var toTp = myId;
    				for(var player in playerLocs){
    					var distToQuest = questLoc.distanceSquaredTo(playerLocs[player]);
    					
    					if(distToQuest < minDist){
    						minDist = distToQuest;
    						toTp = player;
    					}
    				}
    				if (toTp != myId){
    					//send tp packet
    					var tp_packet = event.createPacket(ID_TELEPORT);
    					tp_packet.objectId = toTp;
    					event.sendToServer(tp_packet);
    					break;
    				}
    			}
    			break;
    		}
    	}
    }
    
    function onServerPacket(event) {
    	var packet = event.getPacket();
    	switch (packet.id()) {
    		case ID_CREATE_SUCCESS: {
    			myId = packet.objectId;
    			break;
    		}
    		case ID_UPDATE: {
    			// New objects
    			for (var i = 0; i < packet.newObjs.length; i++) {
    				var objectData = packet.newObjs[i];
    
    				var type = objectData.objectType;
    				if(type == 768 || type == 775 || type == 782 || type == 784 || (type >= 797 && type <= 806)){ // player classes
    					playerLocs[objectData.status.objectId] = objectData.status.pos;
    				}else{
    					if(objectData.status.objectId == questObjectId){
    						questLoc = objectData.status.pos;
    					}
    				}
    			}
    
    			// Removed objects
    			for (var i = 0; i < packet.drops.length; i++) {
    				var droppedObjectId = packet.drops[i];
    
    				if(playerLocs[droppedObjectId] != null){
    					delete playerLocs[droppedObjectId];		
    				}
    				else if(droppedObjectId == questObjectId){
    					questObjectId = -1;
    					questLoc = null;
    				}
    			}
    			break;
    		}
    		case ID_NEW_TICK: {
    			for (var i = 0; i < packet.statuses.length; i++) {
    				var status = packet.statuses[i];
    
    				for (player in playerLocs){
    					if(status.objectId == player){
    						playerLocs[player] = status.pos;
    						break;
    					}
    				}
    			}
    			break;
    		}
    		case ID_QUEST_OBJECTID: {
    			questObjectId = packet.objectId;
    			break;
    		}
    	}
    }
    Last edited by Nisuxen; 10-17-2013 at 10:32 AM.

  2. The Following 8 Users Say Thank You to Nisuxen For This Useful Post:

    059 (12-18-2013),DANWARPER (10-17-2013),DeVoidCoder (10-17-2013),hackroj (10-17-2013),IziLife (10-17-2013),ninjalone (10-18-2013),Tignite (10-18-2013),Zasx (10-17-2013)

  3. #2
    DeVoidCoder's Avatar
    Join Date
    Oct 2013
    Gender
    male
    Posts
    105
    Reputation
    10
    Thanks
    702
    Thanks, it looks good. I have a few minor suggestions.

    This bit of code has no effect because newObjs will never be null. If there is nothing in it, it will have a length of 0.
    Code:
    if(packet.newObjs == null)
    	break;
    Instead of using distanceTo, since you don't really need to know exactly what the distance is, you could use distanceSquaredTo. The difference being that the square root operation is not performed. It is an insignificant optimization in this case, but I just wanted you to know for the future in case you do some heavier processing to do with distance.

  4. #3
    Nisuxen's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    164
    Reputation
    10
    Thanks
    95
    Quote Originally Posted by DeVoidCoder View Post
    Instead of using distanceTo, since you don't really need to know exactly what the distance is, you could use distanceSquaredTo. The difference being that the square root operation is not performed. It is an insignificant optimization in this case, but I just wanted you to know for the future in case you do some heavier processing to do with distance.
    I appreciate the insight. It's a nasty habit of mine to null check incessantly due to other javascript projects I've worked on. I suspected it was unnecessary but didn't bother checking.

  5. #4
    Drowlys's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    The Crawling Depths
    Posts
    196
    Reputation
    10
    Thanks
    2,675
    Can you help me for Realm Relay i got a big problem : cdgvulcain on skype ! Thanks !

  6. #5
    Zasx's Avatar
    Join Date
    Mar 2013
    Gender
    male
    Location
    Northern Italy
    Posts
    1,379
    Reputation
    10
    Thanks
    442
    My Mood
    Yeehaw
    I don't always start to worship coders, but when I do, it's because they do really useful stuff.
    "First get me some porn accounts"
    . . . . . . . . . . . . . . .-Trapped

  7. The Following User Says Thank You to Zasx For This Useful Post:

    Trapped (10-17-2013)

  8. #6
    DANWARPER's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Posts
    19
    Reputation
    10
    Thanks
    0
    My Mood
    Blah
    Thanks this worked the first time i used it. Unfortunately after that it stoped working and i was all upset

  9. #7
    Nisuxen's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    164
    Reputation
    10
    Thanks
    95
    Quote Originally Posted by DANWARPER View Post
    Thanks this worked the first time i used it. Unfortunately after that it stoped working and i was all upset
    I've yet to see it not work consistently. Do you not have the no quest delays hack active? That might be it.

  10. #8
    ilovejohncena's Avatar
    Join Date
    Jul 2013
    Gender
    male
    Posts
    24
    Reputation
    10
    Thanks
    1
    umm.... What is this??? Sorry not really a programmer. Though am fluent in html and css

  11. #9
    Dante-sama's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Pandemonium
    Posts
    108
    Reputation
    15
    Thanks
    12
    My Mood
    Devilish
    Sadly... it doesn't work anymore

    At least not for me and i don't know/want to update it manually xD
    If i helped you press "THANKS"

    ¤»ÐλNξ¤SλM뫤


  12. #10
    Nisuxen's Avatar
    Join Date
    May 2012
    Gender
    male
    Posts
    164
    Reputation
    10
    Thanks
    95
    Quote Originally Posted by Dante-sama View Post
    At least not for me and i don't know/want to update it manually xD
    Updated code is here.

  13. #11
    Dante-sama's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Pandemonium
    Posts
    108
    Reputation
    15
    Thanks
    12
    My Mood
    Devilish
    Quote Originally Posted by Nisuxen View Post
    Updated code is here.
    Thanks for the answer, but i noticed that even updating manually the js, it don't show the text in screen for the WC js. Maybe doing it wrong?
    If i helped you press "THANKS"

    ¤»ÐλNξ¤SλM뫤


Similar Threads

  1. PLEASE NEED HELP WITH REALM RElAY
    By DANWARPER in forum Realm of the Mad God Help & Requests
    Replies: 18
    Last Post: 01-04-2014, 05:38 AM
  2. Realm Relay /con
    By Nisuxen in forum Realm of the Mad God Tutorials & Source Code
    Replies: 5
    Last Post: 12-15-2013, 12:10 PM
  3. Realm Relay /wc
    By Nisuxen in forum Realm of the Mad God Tutorials & Source Code
    Replies: 5
    Last Post: 10-27-2013, 11:32 PM
  4. [Release] Realm Relay Command Script!
    By angelofsilence123 in forum Realm of the Mad God Hacks & Cheats
    Replies: 7
    Last Post: 10-21-2013, 02:06 AM
  5. [Outdated] Realm Relay v1.0.0 - Proxy for RotMG 17.2
    By DeVoidCoder in forum Realm of the Mad God Hacks & Cheats
    Replies: 126
    Last Post: 10-17-2013, 10:23 PM