Results 1 to 14 of 14
  1. #1
    ReeceDaBeast's Avatar
    Join Date
    May 2013
    Gender
    male
    Posts
    340
    Reputation
    10
    Thanks
    778
    My Mood
    Stressed

    smh i will never understand

    So I am new to the ROTMG coding realm and so I don't really understand what some peoples code means but Auto Ability has NEVER worked for me so I was trying to recode it to work for me.

    I noticed this in the code: I am assuming ROTMG has a update every x amount of seconds which sends packets to and fro and that this is what that is. So I don't know why the cooldown is 20 because item cooldown would be 6500 but I am just leaving it.
    Code:
     private void OnUpdate(Client client, Packet packet)
            {
                if (_cooldown > 0) _cooldown--;
                if (_cooldown != 0) return;
                if (!_enabled) return;
                if (_useItemMap[client] == null) return;
    This is what I have so far and it works.. sorta it DCs me after x amount of time. It looks like I am cloaking way to soon after the cooldown but I don't really know how the cooldown works in this code so if someone could help that would be great.

    Code:
    using Lib_K_Relay;
    using Lib_K_Relay.Interface;
    using Lib_K_Relay.Networking;
    using Lib_K_Relay.Networking.Packets;
    using Lib_K_Relay.Networking.Packets.Client;
    using Lib_K_Relay.Networking.Packets.DataObjects;
    using Lib_K_Relay.Networking.Packets.Server;
    using Lib_K_Relay.Utilities;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace AutoAbility
    {
        public class AutoAbility : IPlugin
        {
            private bool _enabled;
            private int _cooldown = 20;
            private Dictionary<Client, UseItemPacket> _useItemMap = new Dictionary<Client, UseItemPacket>();
            private Classes[] _validClasses = { Classes****gue, Classes.Priest, Classes.Paladin, Classes.Warrior };
    
            public string GetAuthor()
            { return "KrazyShank / Kronks"; }
    
            public string GetName()
            { return "Auto Ability"; }
    
            public string GetDescription()
            {
                return "Automatically uses your abilities based on your class and your specified conditions:\n" +
                       "Paladin: Automatically Seal Buff\n" +
                       "Priest: Automatically Tome Buff and/or Heal\n" +
                       "Warrior: Automatically Helm Buff";
            }
    
            public string[] GetCommands()
            { return new string[] { "/aa on", "/aa off", "/aa settings" }; }
    
            public void Initialize(Proxy proxy)
            {
                _enabled = true;
    
                proxy.ClientConnected += (c) => _useItemMap.Add(c, null);
                proxy.ClientDisconnected += (c) => _useItemMap.Remove(c);
    
                proxy.HookPacket(PacketType.CREATESUCCESS, OnCreateSuccess);
                proxy.HookPacket(PacketType.USEITEM, OnUseItem);
                proxy.HookPacket(PacketType.UPDATE, OnUpdate);
                proxy.HookPacket(PacketType.NEWTICK, OnUpdate);
                proxy.HookCommand("aaa", OnAAACommand);
            }
    
            private void OnCreateSuccess(Client client, Packet packet)
            {
                if (_enabled)
                    PluginUtils.Delay(2100, () =>
                        client.SendToClient(PluginUtils.CreateOryxNotification(
                            "Auto Ability", "Use your ability to Activate Auto Ability")));
            }
    
            private void OnUseItem(Client client, Packet packet)
            {
                if (_useItemMap[client] == null && _validClasses.Contains(client.PlayerData.Class))
                {
                    client.SendToClient(PluginUtils.CreateNotification(
                        client.ObjectId, "Auto Ability Activated!"));
                    _useItemMap[client] = packet as UseItemPacket;
                }
            }
    
            private void OnUpdate(Client client, Packet packet)
            {
                if (_cooldown > 0) _cooldown--;
                if (_cooldown != 0) return;
                if (!_enabled) return;
                if (_useItemMap[client] == null) return;
    
                float manaPercentage = (float)client.PlayerData.Mana / (float)client.PlayerData.MaxMana;
                float healthPercentage = (float)client.PlayerData.Health / (float)client.PlayerData.MaxHealth;
    
                switch (client.PlayerData.Class)
                {
                    case Classes.Paladin:
                        {
                            if (!client.PlayerData.HasConditionEffect(ConditionEffects.Damaging))
                            {
                                SendUseItem(client);
                            }
                            break;
                        }
                    case Classes.Priest:
                        {
                            if (!client.PlayerData.HasConditionEffect(ConditionEffects.Healing))
                            {
                                SendUseItem(client);
                            }
                            break;
                        }
                    case Classes.Warrior:
                        {
                            if (!client.PlayerData.HasConditionEffect(ConditionEffects.Berserk))
                            {
                                SendUseItem(client);
                            }
                            break;
                        }
                    case Classes****gue:
                        {
                            if (!client.PlayerData.HasConditionEffect(ConditionEffects.Invisible))
                            {
                                SendUseItem(client);
                            }
                            break;
                        }
                }
            }
    
            private void OnAAACommand(Client client, string command, string[] args)
            {
                if (args.Length == 0) return;
    
                if (args[0] == "on")
                {
                    _enabled = true;
                    client.SendToClient(
                        PluginUtils.CreateNotification(
                            client.ObjectId, "Auto Ability Enabled!"));
                }
                else if (args[0] == "off")
                {
                    _enabled = false;
                    client.SendToClient(
                        PluginUtils.CreateNotification(
                            client.ObjectId, "Auto Ability Disabled!"));
                }
    
                else if (args[0] == "test")
                {
                    SendUseItem(client);
                }
            }
    
            private void SendUseItem(Client client)
            {
                _cooldown = 1;
    
                UseItemPacket useItem = _useItemMap[client];
                useItem.Time = client.Time;
                useItem.ItemUsePos = client.PlayerData.Pos;
                client.SendToServer(useItem);
    
                if (client.PlayerData.HasConditionEffect(ConditionEffects.Invisible) || 
                    client.PlayerData.HasConditionEffect(ConditionEffects.Berserk) || 
                    client.PlayerData.HasConditionEffect(ConditionEffects.Damaging) ||
                    client.PlayerData.HasConditionEffect(ConditionEffects.Healing))
                    client.SendToClient(PluginUtils.CreateNotification(
                        client.ObjectId, "Auto-Buff Triggered!"));
            }
        }
    }

  2. #2
    059's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    California
    Posts
    3,312
    Reputation
    700
    Thanks
    92,771
    Cooldown in rotmg is in milliseconds, by default it is 500, and with specific abilities it is longer +500.

    if (_cooldown > 0) _cooldown--;
    I wouldn't do it that way because UPDATE packets are not consistently sent, they're sporadic. Newtick is every 200 ms so you can do that, or make a new thread for just the timer.
    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

  3. #3
    ReeceDaBeast's Avatar
    Join Date
    May 2013
    Gender
    male
    Posts
    340
    Reputation
    10
    Thanks
    778
    My Mood
    Stressed
    Quote Originally Posted by 059 View Post
    Cooldown in rotmg is in milliseconds, by default it is 500, and with specific abilities it is longer +500.

    if (_cooldown > 0) _cooldown--;
    I wouldn't do it that way because UPDATE packets are not consistently sent, they're sporadic. Newtick is every 200 ms so you can do that, or make a new thread for just the timer.
    I learned Java so I don't know the little differences about these but whenever I delete that first thing of code I have above it breaks everything and idky

    EDIT:
    I changed the cooldown to 33 which means thats over 6.5 seconds if the tick is every 200 ms meaning i should not disconnect but I still do

  4. #4
    bluuman's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    localhost
    Posts
    629
    Reputation
    10
    Thanks
    889
    cloak Cd time is 1 second + listed ability time.

  5. #5
    toddddd's Avatar
    Join Date
    Sep 2016
    Gender
    male
    Posts
    720
    Reputation
    46
    Thanks
    6,363
    I also want to point out that the code you posted the OnUpdate() function is called for both Update and NewTick packets. I missed that when i originally looked at that plugins long long ago, but it helps you understand why the function is called so much. An Update packet doesnt go out too much, only if there are events requiring one (if you sit in your vault and dont do anything you probably wont get too many, if any, update packets after the first few). NewTick packets go out about every 200ms, give or take ~100ms.

  6. #6
    ReeceDaBeast's Avatar
    Join Date
    May 2013
    Gender
    male
    Posts
    340
    Reputation
    10
    Thanks
    778
    My Mood
    Stressed
    Quote Originally Posted by toddddd View Post
    I also want to point out that the code you posted the OnUpdate() function is called for both Update and NewTick packets. I missed that when i originally looked at that plugins long long ago, but it helps you understand why the function is called so much. An Update packet doesnt go out too much, only if there are events requiring one (if you sit in your vault and dont do anything you probably wont get too many, if any, update packets after the first few). NewTick packets go out about every 200ms, give or take ~100ms.
    So the NewTick packet is being used so if I set the cooldown to a time above the item ability cooldown it should autoability corrected yes?

    Also is there anywhere I need to restate _cooldown so that it goes back to 33 which is like 6.6 seconds because even though I have it above the cooldown timer for the ability it still cloaks before it should making me DC but im 90% sure it works the first time but after that it cloaks too soon

  7. #7
    CrazyJani's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    2,475
    Reputation
    170
    Thanks
    15,666
    Your thought process is not very logical. You should not rely on arbitrary timers but use a proper one.

    The most simple way I can think of making an auto ability is to make it activate on USEITEM if UseType is ability (value 2 IIRC). Make it call a recursive function (function that calls itself) with the desired cooldown using PluginUtils.Delay.

    Pseudo code:
    Code:
    bool enabled_ = false;
    int cooldown = 6500; //cloak cd
    
    function OnUseItemPacket //called by the packet hook
    {
        if (packet.UseType == 2) //make sure this value is correct by recording one use ability packet
        {
            enabled_ = !enabled_; //changes the boolean state on every ability use
            AutoAbil();
            packet.Send = false; //AutoAbil function sends the packet so cancel this one
        }
    }
    
    function AutoAbil
    {
        if (enabled_)
        {
            //create and send useitem packet here
            PluginUtils.Delay(cooldown, () => AutoAbil()); //recall the function after the cooldown
        }
    }

  8. The Following User Says Thank You to CrazyJani For This Useful Post:

    toddddd (02-26-2017)

  9. #8
    ReeceDaBeast's Avatar
    Join Date
    May 2013
    Gender
    male
    Posts
    340
    Reputation
    10
    Thanks
    778
    My Mood
    Stressed
    Quote Originally Posted by CrazyJani View Post
    Your thought process is not very logical. You should not rely on arbitrary timers but use a proper one.

    The most simple way I can think of making an auto ability is to make it activate on USEITEM if UseType is ability (value 2 IIRC). Make it call a recursive function (function that calls itself) with the desired cooldown using PluginUtils.Delay.

    Pseudo code:
    Code:
    bool enabled_ = false;
    int cooldown = 6500; //cloak cd
    
    function OnUseItemPacket //called by the packet hook
    {
        if (packet.UseType == 2) //make sure this value is correct by recording one use ability packet
        {
            enabled_ = !enabled_; //changes the boolean state on every ability use
            AutoAbil();
            packet.Send = false; //AutoAbil function sends the packet so cancel this one
        }
    }
    
    function AutoAbil
    {
        if (enabled_)
        {
            //create and send useitem packet here
            PluginUtils.Delay(cooldown, () => AutoAbil()); //recall the function after the cooldown
        }
    }
    How do you record one use ability packet?

  10. #9
    CrazyJani's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    2,475
    Reputation
    170
    Thanks
    15,666
    Quote Originally Posted by ReeceDaBeast View Post
    How do you record one use ability packet?
    Just print it out on the console.

    Pseudo code:
    Code:
    function OnUseItemPacket 
    {
        Console.WriteLine(packet.ToString());
    }

  11. #10
    ReeceDaBeast's Avatar
    Join Date
    May 2013
    Gender
    male
    Posts
    340
    Reputation
    10
    Thanks
    778
    My Mood
    Stressed
    Quote Originally Posted by CrazyJani View Post
    Just print it out on the console.

    Pseudo code:
    Code:
    function OnUseItemPacket 
    {
        Console.WriteLine(packet.ToString());
    }
    I dont understand how to use the UseType method. This is what I have

    Code:
    private void OnUseItem(Client client, Packet packet)
            {
                    Console.WriteLine(packet.ToString());
                UseItemPacket useItem = _useItemMap[client];
                Console.WriteLine(_useItemMap.ToString());
                if (useItem.UseType == 1)
                {
                    client.SendToClient(PluginUtils.CreateNotification(
                    client.ObjectId, "Auto Ability Activated!"));
                    _enabled = !_enabled;
                    AutoAbil();
    
                }
            }
            private void AutoAbil() { if(_enabled) PluginUtils.Delay(_cooldown, () => AutoAbil()); }

  12. #11
    CrazyJani's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    2,475
    Reputation
    170
    Thanks
    15,666
    Quote Originally Posted by ReeceDaBeast View Post
    I dont understand how to use the UseType method. This is what I have
    You should look at how other plugins are made.

    Before you can access packet specific properties (e.g. UseType of UseItemPacket) you first need to cast the packet to the correct type, in this case:

    Code:
    UseItemPacket usp = (UseItemPacket)packet;
    Console.WriteLine(usp.UseType); //or usp.ToString() as I used earlier
    Also note that your AutoAbil function doesn't in fact use the ability yet.

  13. #12
    bluuman's Avatar
    Join Date
    Nov 2011
    Gender
    male
    Location
    localhost
    Posts
    629
    Reputation
    10
    Thanks
    889
    well actually i wasnt wrong. original post said usetype was 1.
    Last edited by bluuman; 02-26-2017 at 07:48 PM.

  14. #13
    CrazyJani's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Posts
    2,475
    Reputation
    170
    Thanks
    15,666
    I decided to take the time to actually make the plugin.

    Code:
    using Lib_K_Relay;
    using Lib_K_Relay.Interface;
    using Lib_K_Relay.Networking;
    using Lib_K_Relay.Networking.Packets;
    using Lib_K_Relay.Networking.Packets.Client;
    using Lib_K_Relay.Utilities;
    using System;
    
    namespace AutoAbil
    {
        public class AutoAbil : IPlugin
        {
            private int cooldown = 6500;
            private bool enabled = false;
    
            public string GetAuthor()
            {
                return "CrazyJani";
            }
    
            public string GetName()
            {
                return "Simple Auto Ability";
            }
    
            public string GetDescription()
            {
                return "A very quick and basic auto ability.";
            }
    
            public string[] GetCommands()
            {
                return new string[0];
            }
    
            public void Initialize(Proxy proxy)
            {
                proxy.ClientDisconnected += (c) => Deactivate();
                proxy.HookPacket(PacketType.USEITEM, OnPacket);
            }
    
            private void OnPacket(Client client, Packet packet)
            {
                UseItemPacket usp = (UseItemPacket)packet;
                if (usp.SlotObject.SlotId == 1)
                {
                    enabled = !enabled;
                    Execute(client, usp);
                    packet.Send = false;
                }
            }
    
            private void Deactivate()
            {
                enabled = false;
            }
    
            private void Execute(Client c, UseItemPacket p)
            {
                if (enabled)
                {
                    p.Time = c.Time;
                    p.ItemUsePos = c.PlayerData.Pos;
                    c.SendToServer(p);
                    PluginUtils.Delay(cooldown, () => Execute(c, p));
                }
            }
        }
    }
    The correct value for UseType was 1 but as I was making the plugin I remembered that potions use that as well so it's better to use SlotObject.SlotId to confirm that it's the ability that you're using. I also added a function that deactivates it if you change map so it won't run into errors (it would try to use ability when connecting).

    It doesn't notify the player in any way when activated so you might want to add that. Also you can't change the cooldown in this version so if you want to use it with other items than cloaks make sure to add a command or make it detect your ability cooldown (latter is more difficult).

  15. #14
    ReeceDaBeast's Avatar
    Join Date
    May 2013
    Gender
    male
    Posts
    340
    Reputation
    10
    Thanks
    778
    My Mood
    Stressed
    Quote Originally Posted by CrazyJani View Post
    I decided to take the time to actually make the plugin.

    Code:
    using Lib_K_Relay;
    using Lib_K_Relay.Interface;
    using Lib_K_Relay.Networking;
    using Lib_K_Relay.Networking.Packets;
    using Lib_K_Relay.Networking.Packets.Client;
    using Lib_K_Relay.Utilities;
    using System;
    
    namespace AutoAbil
    {
        public class AutoAbil : IPlugin
        {
            private int cooldown = 6500;
            private bool enabled = false;
    
            public string GetAuthor()
            {
                return "CrazyJani";
            }
    
            public string GetName()
            {
                return "Simple Auto Ability";
            }
    
            public string GetDescription()
            {
                return "A very quick and basic auto ability.";
            }
    
            public string[] GetCommands()
            {
                return new string[0];
            }
    
            public void Initialize(Proxy proxy)
            {
                proxy.ClientDisconnected += (c) => Deactivate();
                proxy.HookPacket(PacketType.USEITEM, OnPacket);
            }
    
            private void OnPacket(Client client, Packet packet)
            {
                UseItemPacket usp = (UseItemPacket)packet;
                if (usp.SlotObject.SlotId == 1)
                {
                    enabled = !enabled;
                    Execute(client, usp);
                    packet.Send = false;
                }
            }
    
            private void Deactivate()
            {
                enabled = false;
            }
    
            private void Execute(Client c, UseItemPacket p)
            {
                if (enabled)
                {
                    p.Time = c.Time;
                    p.ItemUsePos = c.PlayerData.Pos;
                    c.SendToServer(p);
                    PluginUtils.Delay(cooldown, () => Execute(c, p));
                }
            }
        }
    }
    The correct value for UseType was 1 but as I was making the plugin I remembered that potions use that as well so it's better to use SlotObject.SlotId to confirm that it's the ability that you're using. I also added a function that deactivates it if you change map so it won't run into errors (it would try to use ability when connecting).

    It doesn't notify the player in any way when activated so you might want to add that. Also you can't change the cooldown in this version so if you want to use it with other items than cloaks make sure to add a command or make it detect your ability cooldown (latter is more difficult).
    Ok Thanks, yeah that other stuff is easy to add so its fine but this helps me understand a bit more, I haven't coded in a year and I only learned basic java like objectdraw and making things move and count and stuff so this helps

    - - - Updated - - -

    Quote Originally Posted by bluuman View Post
    edit: whoops..... i'm wrong.
    Its ok boo boo

Similar Threads

  1. Computer Hackers Will Never Stop.
    By Corndog in forum General
    Replies: 17
    Last Post: 09-03-2009, 08:01 PM
  2. I have a hack that WAS not patched, IS not patched and WILL never patched^^
    By asswadou95 in forum CrossFire Hacks & Cheats
    Replies: 5
    Last Post: 08-10-2009, 05:17 PM
  3. There will never...
    By Dave84311 in forum United States of America
    Replies: 12
    Last Post: 01-01-2009, 04:31 AM
  4. want a hack that will never be detected again?
    By zoidman in forum WarRock - International Hacks
    Replies: 2
    Last Post: 06-09-2007, 03:10 PM