Page 1 of 3 123 LastLast
Results 1 to 15 of 37
  1. #1
    zekikez's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Posts
    14
    Reputation
    10
    Thanks
    25

    Realm Relay auto nexus/pot

    I modified the autonexus.js that I got from DeVoidCoder's ******. I added the capability to auto health pot. Nexus is still a priority. By default it is set to 25% for nexus and 35% for health potion. It only uses the health potions that you can store up to 6.

    Warning: Use at your own risk. I am not responsible if you die while using this script.
     
    Code:
    // autonexus_pot.js
    // original: autonexus.js by DeVoidCoder
    // modified by: zekikez
    
    var ID_MOVE = $.findPacketId("MOVE");
    var ID_PLAYERHIT = $.findPacketId("PLAYERHIT");
    var ID_SHOOT = $.findPacketId("SHOOT");
    var ID_SHOOT2 = $.findPacketId("SHOOT2");
    var ID_UPDATE = $.findPacketId("UPDATE");
    var ID_CREATE_SUCCESS = $.findPacketId("CREATE_SUCCESS");
    var ID_NEW_TICK = $.findPacketId("NEW_TICK");
    var ID_AOE = $.findPacketId("AOE");
    var ID_ESCAPE = $.findPacketId("ESCAPE");
    var ID_USE_ITEM = $.findPacketId("USEITEM");
    var ID_NOTIFICATION = $.findPacketId("NOTIFICATION");
    var ID_MAPINFO = $.findPacketId("MAPINFO");
    
    var STATDATA_MAXHEALTH = 0;
    var STATDATA_HEALTH = 1;
    var STATDATA_DEFENCEBONUS = 49
    
    var nexusHealthPercentage = 25; // <--- modify this to the health % you want to nexus at
    var playerObjectId = -1;
    var _allowAutoNexus = true;  // <--- set to false if you do not want it to auto nexus
    
    var health = -1;
    var maxHealth = -1;
    var defenceBonus = -1;
    var bulletIdDamageMap = {};
    var bEscapeToNexusSent = false; // true = don't confirm any more hits
    var playerLocation = null;
    
    // zekikez - auto health potion
    var SLOTDATA_HEALTHPOT = 69;
    var TIMEOUT_OFFSET = 250; // the amount of time before allowing to use the health potion again
    
    var _potHealthPercentage = 35; // <--- modify this to the health % you want to pot at
    
    var _clientTime = 0;
    var _potHealthCount = 0;
    var _skipHealthPotion = true;
    var _timeoutAt = -1; 
    var _mapName = "Nexus";
    
    function onClientPacket(event) {
    	if (bEscapeToNexusSent) {
    		event.cancel();
    		return;
    	}
    	var packet = event.getPacket();
    	if (packet.time)
    	{
    		_clientTime = packet.time;
    		if (_skipHealthPotion && _timeoutAt < _clientTime)
    			_skipHealthPotion = false;
    	}
    	switch (packet.id()) {
    		case ID_MOVE: {
    			playerLocation = packet.newPosition;
    			break;
    		}
    		case ID_PLAYERHIT: {
    			// predict what the damage will be
    			health -= getDamageEstimate(bulletIdDamageMap[packet.bulletId]);
    			if (_mapName != "Nexus" && useBestEscape())
    					event.cancel();
    			break;
    		}
    	}
    }
    
    function onServerPacket(event) {
    	var packet = event.getPacket();
    	switch (packet.id()) {
    		case ID_MAPINFO: {
    			_mapName = packet.name;
    			break;
    		}	
    		case ID_SHOOT2:
    		case ID_SHOOT: {
    			// store projectile damage...
    			bulletIdDamageMap[packet.bulletId] = packet.damage;
    			break;
    		}
    		case ID_UPDATE: {
    			for (var i = 0; i < packet.newObjs.length; i++) {
    				var objectData = packet.newObjs[i];
    				if (objectData.status.objectId == playerObjectId) {
    					for (var j = 0; j < objectData.status.data.length; j++) {
    						var statData = objectData.status.data[j];
    						// update player data...
    						if (statData.obf0 == STATDATA_MAXHEALTH) {
    							maxHealth = statData.obf1;
    						} else if (statData.obf0 == STATDATA_HEALTH) {
    							health = statData.obf1;
    						} else if (statData.obf0 == STATDATA_DEFENCEBONUS) {
    							defenceBonus = statData.obf1;
    						} else if (statData.obf0 == SLOTDATA_HEALTHPOT) {
    							_potHealthCount = statData.obf1;
    						}
    					}
    				}
    			}
    			break;
    		}
    		case ID_CREATE_SUCCESS: {
    			// keep the player's objectId
    			playerObjectId = packet.objectId;
    			break;
    		}
    		case ID_NEW_TICK: {
    			for (var i = 0; i < packet.statuses.length; i++) {
    				var status = packet.statuses[i];
    				if (status.objectId == playerObjectId) {
    					for (var j = 0; j < status.data.length; j++) {
    						var statData = status.data[j];
    						// update the player's health
    						if (statData.obf0 == STATDATA_HEALTH) {
    							health = statData.obf1;
    						} else if (statData.obf0 == STATDATA_DEFENCEBONUS) {
    							defenceBonus = statData.obf1;
    						} else if (statData.obf0 == SLOTDATA_HEALTHPOT) {
    							_potHealthCount = statData.obf1;
    							$.echo("health pot count: " + _potHealthCount);
    						}
    					}
    				}
    			}
    			break;
    		}
    		case ID_AOE: {
    			if (playerLocation != null && playerLocation.distanceTo(packet.pos) <= packet.radius) {
    				// predict what the damage will be
    				health -= getDamageEstimate(packet.damage);
    				if (_mapName != "Nexus" && useBestEscape())
    					event.cancel();
    			}
    			break;
    		}
    	}
    }
    
    function getDamageEstimate(baseDamage) {
            // not a perfect damage calculation at all, but good enough for govt work
            var damage = baseDamage - defenceBonus;
            if (damage < 0.15 * baseDamage) {
    			damage = 0.15 * baseDamage;
            }
            if (isNaN(damage)) {
    			// return 100; 
    			return 0; // if damage is undefined then just wait for next tick to health update.
            }
            return damage;
    }
    
    
    // Determines best action based on current health percentage
    // returns true if an action happens 
    function useBestEscape() {
    	// if the predicted health percentage is below nexusHealthPercentage...
    	var curPercentage = 100 * health / maxHealth;
    	//$.echo("Current Health: " + health + " / " + maxHealth + " = "  + curPercentage);
    	if (_allowAutoNexus && curPercentage <= nexusHealthPercentage) {
    		useNexus();
    		return true;
    	}
    	else if (!_skipHealthPotion && _potHealthCount > 0 && curPercentage <= _potHealthPercentage) {
    		useHealthPotion();
    		return true;
    	}
    	return false;
    }
    
    // creates ESCAPE packet and sends to server
    function useNexus() {
    	$.echo("Used Nexus");
    	var escapePacket = $.createPacket(ID_ESCAPE);
    	$.sendToServer(escapePacket);
    	bEscapeToNexusSent = true; // this prevents any additional packets from being sent
    }
    
    // creates a USE_ITEM packet with the health potion details
    function useHealthPotion() {
    	_potHealthCount--;
    	$.echo("Used Health Potion: " + _potHealthCount);
    	var useitemPacket = $.createPacket(ID_USE_ITEM);
    	useitemPacket.time = _clientTime + 50; // ? not sure if increment is needed
    	useitemPacket.slotObject = $.createSlotObject();
    	useitemPacket.slotObject.objectType = 2594; // health potion type
    	useitemPacket.slotObject.slotId = 254; // health potion slotid
    	useitemPacket.slotObject.objectId = playerObjectId; // player id
    	useitemPacket.itemUsePos = playerLocation; // should randomly offset a bit. (this should be where the cursor is pointing)
    	useitemPacket.useType = 0;
    	$.sendToServer(useitemPacket);
    	// Notify user that a potion was used and show the remaining number of pots
    	autoNexusPot_Notify("Used Health Potion! Count: " + _potHealthCount);
    	_skipHealthPotion = true;
    	_timeoutAt = _clientTime + TIMEOUT_OFFSET;
    }
    
    function autoNexusPot_Notify(text) {
    	var notificationPacket = $.createPacket(ID_NOTIFICATION);
    	notificationPacket.objectId = playerObjectId;
    	notificationPacket.message = "{\"key\":\"blank\",\"tokens\":{\"data\":\"" + text + "\"}}";
    	notificationPacke*****lor = 0x33FFFF;;
    	$.sendToClient(notificationPacket);
    }
    Last edited by zekikez; 11-14-2013 at 04:56 PM. Reason: skipped typo

  2. The Following 7 Users Say Thank You to zekikez For This Useful Post:

    059 (12-28-2013),Alde. (12-11-2013),DANWARPER (11-14-2013),enmity4 (08-16-2016),gloyee (11-24-2017),maat7043 (11-20-2013),Nisuxen (11-15-2013)

  3. #2
    apemanzilla's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    430
    Reputation
    76
    Thanks
    1,097
    My Mood
    Bored
    Would this still drink HP pots even if you're in the Nexus?

  4. #3
    zekikez's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Posts
    14
    Reputation
    10
    Thanks
    25
    this should not drink hp pots even if you're in the nexus.

  5. #4
    The richest man is not the one who has the most but the one who needs the least.
    MPGH Member
    Alde.'s Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    1,706
    Reputation
    166
    Thanks
    3,627
    My Mood
    Sleepy
    To know the amount of hp you nexused at, change the line 176 for
    Code:
    $.echo("Nexused at " + health +" HP.");
    All credits to zekikez!
    Alde is Alde is

  6. #5
    The richest man is not the one who has the most but the one who needs the least.
    MPGH Member
    Alde.'s Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    1,706
    Reputation
    166
    Thanks
    3,627
    My Mood
    Sleepy
    Hello zekikez!

    I have a question, is the function onServerPacket() is the function that handles the packet the server send? I'm trying to figure out your code and I'm not too good at reverse enginnering (if I can say it).
    Alde is Alde is

  7. #6
    HoffHorn's Avatar
    Join Date
    Sep 2012
    Gender
    male
    Posts
    411
    Reputation
    10
    Thanks
    96
    I can't find the ****** any more :/ Anyone have a link?

  8. #7
    lookbehindyou's Avatar
    Join Date
    Aug 2013
    Gender
    male
    Posts
    71
    Reputation
    10
    Thanks
    7
    does anyone know how to turn the auto hp pot into an auto priest tome?
    (sorry for the bump)

  9. #8
    The richest man is not the one who has the most but the one who needs the least.
    MPGH Member
    Alde.'s Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    1,706
    Reputation
    166
    Thanks
    3,627
    My Mood
    Sleepy
    Quote Originally Posted by lookbehindyou View Post
    does anyone know how to turn the auto hp pot into an auto priest tome?
    (sorry for the bump)
    Change the useitem (hp pot) into useitem (if character == priest, use item ability
    )
    Alde is Alde is

  10. #9
    FainTMako's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Posts
    332
    Reputation
    10
    Thanks
    244
    My Mood
    Inspired
    For me this worked a lot greater than using the autonexus from modselector no offence to anyone.

    I really like realmrelay keep pushing the scripts out sorry im such a leecher guys but i cant have 1000 professions.

    here are the values I used on my 6/8 wizard and it works very well for me


    Auto nexus 35%
    Auto HP 45%

    I'm a conservative guy

  11. #10
    059's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    California
    Posts
    3,312
    Reputation
    700
    Thanks
    92,771
    This script has saved my ass so many times. The part that calculates incoming bullet damage and nexuses off that is a lifesaver.
    My Vouches
    Having an issue with RotMG? Check for the solution here.


    Need Realm items? Come to RealmStock!

    Accepting PayPal - Bitcoin - Giftcards
    Selling ST Sets, Class Top Sets, Life Pots, and much more!


    Find it here: MPGH Sales Thread

  12. #11
    FainTMako's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Posts
    332
    Reputation
    10
    Thanks
    244
    My Mood
    Inspired
    var bEscapeToNexusSent = false; // true = don't confirm any more hits

    what exactly does that do when set to true? and i cant connect if i do set it to true.

  13. #12
    The richest man is not the one who has the most but the one who needs the least.
    MPGH Member
    Alde.'s Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    1,706
    Reputation
    166
    Thanks
    3,627
    My Mood
    Sleepy
    Quote Originally Posted by FainTMako View Post
    var bEscapeToNexusSent = false; // true = don't confirm any more hits

    what exactly does that do when set to true? and i cant connect if i do set it to true.
    I'm wondering too.
    Alde is Alde is

  14. #13
    FainTMako's Avatar
    Join Date
    Nov 2013
    Gender
    male
    Posts
    332
    Reputation
    10
    Thanks
    244
    My Mood
    Inspired
    it does not work in devoids original example autonexus as well.

  15. #14
    infern000's Avatar
    Join Date
    Jul 2012
    Gender
    male
    Posts
    294
    Reputation
    10
    Thanks
    74
    Quote Originally Posted by FainTMako View Post
    var bEscapeToNexusSent = false; // true = don't confirm any more hits
    do not change that line. it is just written there to declare i.e. initialize the variable as a boolean type (yes no), not for u to edit.


    if look further down in the code you'll see:

    bEscapeToNexusSent = true; // this prevents any additional packets from being sent

    getting set to true after it sends the nexus command.

    now idk the exact workings, but i can imagine that if we would still receive, compute and send packets after nexussing, one of them could basically be like, "here's another projectile that hit us, oh wait, this kills you, let me tell that to the server".
    again, im no expert, and i have my doubts (since the bEscapeToNexusSent is only used for client packets), but in theory this should prevent all deaths, assuming that the server needs a death confirmation from the client, which might not be true.

  16. #15
    The_En|D's Avatar
    Join Date
    Jun 2012
    Gender
    male
    Location
    Stark Industries
    Posts
    856
    Reputation
    18
    Thanks
    468
    My Mood
    Innocent
    Quote Originally Posted by 059 View Post
    This script has saved my ass so many times. The part that calculates incoming bullet damage and nexuses off that is a lifesaver.
    If i understood that right, if u are at O2 and theres his shotgun directly coming to you and would kill you this script nexuses before it hits?

    "They say the best weapon is one you never have to fire.
    I respectfully disagree.
    I prefer the weapon you only have to fire once."

    ~ Tony Stark

  17. The Following User Says Thank You to The_En|D For This Useful Post:

    Alde. (12-29-2013)

Page 1 of 3 123 LastLast

Similar Threads

  1. Realm Relay Updates + Ability Auto Aim
    By Nisuxen in forum Realm of the Mad God Tutorials & Source Code
    Replies: 157
    Last Post: 03-19-2015, 04:18 AM
  2. Nilly's - Auto-pot / Auto-Special if Priest / Auto-Nexus - Code
    By nilly in forum Realm of the Mad God Tutorials & Source Code
    Replies: 55
    Last Post: 05-02-2014, 11:08 PM
  3. Hacked Client 123.5.1 No Auto Nexus
    By theweedman in forum Realm of the Mad God Help & Requests
    Replies: 2
    Last Post: 09-07-2012, 12:12 AM
  4. 123.3.1 Auto-aim, Auto-nexus, No-clip (Toggled)
    By un0rth0d0x in forum Realm of the Mad God Hacks & Cheats
    Replies: 19
    Last Post: 07-03-2012, 03:05 AM
  5. [Release] Auto Nexus
    By sportukr23 in forum Realm of the Mad God Hacks & Cheats
    Replies: 10
    Last Post: 07-02-2012, 03:02 PM