GithubHelp home page GithubHelp logo

botbits's Introduction

BotBits

Focus on your ideas, forget PlayerIOClient.

BotBits is the most popular bot library made specifically for Everybody Edits. Maintained by Yonom (Processor).

Usage

Step 1: Download and extract the DLL-File

You can find the latest release Here.
Click on BotBits.zip, and Download. Then extract the files.

Step 2: Import references

Rightclick on References in your tool. Then click Add references.
Select the BotBit's DLL-File. Then go to next step.

Step 3: Import BotBits' namespaces

using BotBits;
using BotBits.Events;
using BotBits.SendMessages;

Step 4: Create a new BotBitsClient instance

BotBitsClient bot = new BotBitsClient();

Connecting to EE

Using the Login class, you can login. Email, Guest, Facebook, Kongregate and Armorgames are supported login methods.

Login.Of(bot)
    .WithEmail("email", "pass")
    .CreateJoinRoom("roomId");

Please note that BotBits automatically sends "init" and "init2" messages and waits for their responses to be received before CreateJoinRoom finishes running.

Receiving Messages

You can load event listeners (which will be called automatically when a message is received) using the EventLoader class.

EventLoader.Of(bot)
    .LoadStatic<Program>();

// Or for non-static handlers

EventLoader.Of(bot)
    .Load(this);

You can define an event listener in the following way:

[EventListener]
static void On(JoinCompleteEvent e) 
{
    // Code to be executed when the bot joins the room
}

There are many other events in the BotBits.Events namespace: InitEvent, JoinEvent, LeaveEvent, CoinEvent, ForegroundPlaceEvent, BackgroundPlaceEvent, and so on...

Interacting with the game

Lots of things your player can do are in the Actions class:

Actions.Of(bot).GodMode(true);
Actions.Of(bot).Move(10 * 16, 10 * 16); // Move to 10x10
Actions.Of(bot).ChangeSmiley(SmileyShape.Regular, SmileyColour.Yellow, SmileyBorder.White, SmileyEyes.Coy,
SmileyMouth.Smile, SmileyAddon.Nothing, SmileyAbove.Nothing, SmileyBelow.Nothing, SmileyWings.Nothing);

You can chat and use chat commands with the Chat class:

Chat.Of(bot).Say("Hi");
Chat.Of(bot).LoadLevel();

Room settings can be viewed or changed in the Room class:

string roomOwner = Room.Of(bot).Owner;
Room.Of(bot).Save();

Managing players

BotBits automatically maintains a list of active players in the room.

You can loop through this list and access the stored variables of players:

[EventListener]
static void On(JoinCompleteEvent e) 
{
    foreach (Player p in Players.Of(bot)) 
    {
        Console.WriteLine(p.Username + " has smiley " + p.SmileyShape);
    }
}

You can also store your own variables:

var player = Players.Of(bot).FromUsername("processor").FirstOrDefault();
if (player != null) 
{
    player.Set("IsBanned", true); // variables can have any type (int, bool, string, custom type, ...)
}

And retrieve them later:

if (player.Get<bool>("IsBanned"))
{
    player.Kick("Sorry but you are too not allowed to play this level!");
}

Working with blocks

First, let's take a look at the way BotBits handles block ids:

Every block is given a name in BotBits, so you don't have to remember confusing ids in your code.
For example, to access the "air" block (ID: 0), you just have to type Foreground.Empty!
To get a blue coin, you type Foreground.Coin.Blue.
An invisible portal? Foreground.Portal.Invisible!

The same applies to backgrounds: Background.Empty, Background.Basic.Blue, etc.


Just like players, BotBits takes care of maintaining a live preview of the world.

Here's how you can get info about a block in a certain location:

Foreground.Id id = Blocks.Of(bot).Foreground[0, 0].Block.Id;
Player placer = Blocks.Of(bot).Foreground[0, 0].Placer;

You can also loop through every block (although it is not recommended to do this very frequently!)

foreach (var location in Blocks.Of(bot))
{
    if (location.Foreground.Block.Type == ForegroundType.Portal)
    {
        Console.WriteLine("Found portal with id: {0}, target: {1}",
            location.Foreground.Block.PortalId,
            location.Foreground.Block.PortalTarget);
    }
}

Placing blocks

As you would expect, BotBits automatically slows down the sending speed of block packets so that they are not dropped by the server.

In worlds you do not own, EE servers only accept one message every ~10 milliseconds, and BotBits is able to send around 96 blocks per second without dropping any packets. Blocks that get dropped are automatically resent, so you don't have to worry about that either!

In your own world, sending messages too fast results in you or your players being kicked from the server. By default, BotBits sends 400 messages per second. This speed can be changed in MessageSender:

MessageSender.Of(bot).SendTimerFrequency = newFrequency;

Important: For worlds you do not own, the SendTimerFrequency should be kept at MessageSender.DefaultSendTimerFrequency!

Let's place a block:

Blocks.Of(bot).Place(1, 1, Foreground.Basic.Gray);

Let's fill the whole world with that block:

Blocks.Of(bot).Set(Foreground.Basic.Gray);

Or maybe just a section of it?

Blocks.Of(bot).In(new Rectangle(10, 10, 10, 10)).Set(Foreground.Basic.Gray);

Checker the world!

Blocks.Of(bot).Where((x, i) => i % 2 == 0).Set(Foreground.Basic.Gray);

Or only a part of it

Blocks.Of(bot).In(10, 10, 10, 10).Where((x, i) => i % 2 == 0).Set(Foreground.Basic.Gray);

The possibilities are endless!

Oh and special blocks are supported too:

Blocks.Of(bot).Place(x, y, Foregrounds.Portal.Normal, 0, 1, Morph.Portal.Left);
Blocks.Of(bot).Place(x, y, Foregrounds.Portal.World, "PW01", 0);
Blocks.Of(bot).Place(x, y, Foregrounds.Coin.GoldDoor, 10);
Blocks.Of(bot).Place(x, y, Foregrounds.OneWay.Pink, Morph.OneWay.Down);
Blocks.Of(bot).Place(x, y, Foregrounds.SciFi.BlueSlope, Morph.SciFiSlope.InSouthEastPart);

Examples

Take a look at this custom ban list, snake bot or a speed run bot.

Extensions

Anyone can code extensions to make BotBits more awesome!

Here are some existing extensions:

botbits's People

Contributors

yonom avatar capashaa avatar emalton avatar tunous avatar eejesse avatar kylerm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.