Author Topic: [C#, ScriptSDK, XScript] Combot - responsive multi-botting  (Read 4538 times)

0 Members and 1 Guest are viewing this topic.

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
[C#, ScriptSDK, XScript] Combot - responsive multi-botting
« on: March 05, 2020, 05:02:05 AM »
0
Combot

What?
Combot is a system for handling multiple concurrent Stealth profiles capable of communicating with each other.

Why?
If you have a script that checks for information from UO and does something based on that information....  then you take that script and you multiply it by how many profiles you're running it on.  If the profiles could share information with each other, they would not all need to request information from Stealth.  This makes it more efficient by having the scripts share information with between profiles.  Combot is also capable of client cross-communication.

Examples of usage:
You have a group of profiles existing in the same space (shard, screen) and they are fighting some monster together.  If you're running the same script through Stealth for each profile to check one another's health and heal them when they need it, then all your profiles will always try and heal the same person at the same time.  If another profile was damaged, it wouldn't get a heal until all the profiles finished healing someone else.    Combot's job priority system can be used to delegate tasks, such as healing, to each profile that it's connected to.  Instead of all the profiles trying to heal the same person, the Combot hub (server) will assign each profile with a different healing job.

How?
Combot makes it so only one profile is requesting data from Stealth while the other profiles feed off that data over TCP/IP.  This system is broken down into three parts (two of which are only important) - Client, Server, Data.  First, you run the Server on the profile that you want to act as the "hub" for all other bots.  This will collect any data from Stealth that all the other bots need - such as checking player health.  That runs in something called a "Routine" which I'll talk more about later.  The Server Routine collects data and issues Jobs to the JobQueue based on that criteria.  When a new Job is added on the Server, it will notify each client that is connected - this can also be set up to only notify certain Clients based on criteria (like if it's a bandage job, don't notify clients who don't have healing.)  As the server starts notifying Clients, if a Client is not busy with another Job it will accept it and notify the Server that the Job is now assigned so that Clients aren't don't pick up the same Job.  Once the Client is finished with the Job, it notifies the Server that the Job is complete and the Server removes the Job from the JobQueue.  You can run the Client on as many Stealth profiles as you desire.

Structure:
I'm going to have to write up a lot more documentation on this, but I'm going to give you guys all the need-to-knows now.

Routines - Both the Client and the Server have Routines.

The Server Routine contains the checks to Stealth that you want to also share with the Clients.  It also assigns jobs to the JobQueue based on the checks that you have done in the Server Routine.

The Client Routine contains what you want the client to do on its own - like making sure you're staying within range of the Leader (the Server.)  You can add your own routines; right now both the Client and the Server have example routines named "Combat."  The Client also has a routine named Job - this defines how Jobs should be handled on the Client-side.  For example, the Server sends a Client a Job to bandage someone, the Client runs the JobHandler in the Job Routine to check what type of job it is and calls a method in the Routine to handle the Job.



Files:
https://github.com/unisharpUO/Combot

If you want to get this set up and running in its current state, download the entire solution and open it up in Visual Studio 2019 (free community edition can be downloaded.)

Requirements:
https://github.com/Crome696/ScriptSDK
https://github.com/unisharpUO/XScript

Server\Routine\Combat.cs
You'll see there's a GroupList - this is a list containing all the player IDs who are to be checked (for health.)  Add/Remove as many as you like and remember to change the number to whatever ID your character is.

Client\Client.cs
Line 68 - set this to your machine's local network IP.

Startup Stealth and connect with a profile that you want to act as a hub.  Compile and start the Server.  Use Stealth to connect another profile that you want to act as a client.  Compile and start the client.

This post is also a work in progress.

Added job rejection:
Jobs now have a new property - a list of clients who rejected the job. When the server receives a job rejection packet, the client is added to the Rejectors property of the Job object. The server then calls a notify. The Queue notify function has been updated, it now checks if a job has any rejectors and if so, doesn't notify them again. If all clients connected to the server reject the job, the list of rejectors is reset and the job goes back into the queue.

Clients can add jobs now too:
I have a poison check in my server routine, but I couldn't pass on having the clients add themselves when they get a buff/debuff event. So not only does the server check for poisoned characters, but clients will be adding themselves if they are poisoned.

Thread locking and Added Exception Catching for the Job Queue:
There are circumstances when the server will be notifying clients about jobs, and a job will be completed in that process. This will cause an Exception and usually cause the program to crash. We now catch the exceptions so the program can continue doing its job. I added thread locking to all the functions that deal with modifying the jobqueue in hopes that this wouldn't happen again, but it still did. So I ended up removing the locks, for now, may end up putting them back once I find a solution. The locker object still exists under the queue class, it's just not used.

Jobs moved to Server.Data:
I had to move the Job class into the data section because I wanted to serialize a job and send it through a packet and just moving the class was less work.

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: [C#, ScriptSDK, XScript] Combot - responsive multi-botting
« Reply #1 on: April 14, 2020, 09:31:20 AM »
0
4/14/2020 - Pushed update to client loot routine.

Offline Neo

  • Prime Program
  • Elite
  • *
  • *
  • Posts: 821
  • Activity:
    0%
  • Reputation Power: 13
  • Neo barely matters.Neo barely matters.
  • Respect: +155
  • Referrals: 3
    • View Profile
Re: [C#, ScriptSDK, XScript] Combot - responsive multi-botting
« Reply #2 on: July 10, 2020, 11:32:38 PM »
0
Hey, just stumbled across this. This looks like a great idea... Haven't messed around with Stealth in ages, but apparently you guys have been doing great things with it.

Thanks for sharing!
Never refuse an invitation.
Never resist the unfamiliar.
Never fail to be polite.
And never outstay your welcome.

Offline unisharpTopic starter

  • Elite
  • ***
  • *
  • Posts: 196
  • Activity:
    0%
  • Reputation Power: 4
  • unisharp has no influence.
  • Gender: Male
  • Respect: +40
  • Referrals: 0
    • View Profile
Re: [C#, ScriptSDK, XScript] Combot - responsive multi-botting
« Reply #3 on: July 14, 2020, 04:37:42 AM »
0
Hey, just stumbled across this. This looks like a great idea... Haven't messed around with Stealth in ages, but apparently you guys have been doing great things with it.

Thanks for sharing!


Tags: