0.2.1 • Published 7 months ago

hax-antibot v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Haxball Antibot

Antibot Map Plugin for checking if player is a Bot. Creates a random map challenge to be solved by chosen players. To be used with node package haxball.js

Installation

npm i hax-antibot

Documentation

Website documentation is available at jakjus.github.io/hax-antibot/

Usage

  1. Init Antibot with initAntibot(~) as early as possible on your RoomObject. It will track script's stadium changes, so that it will turn back to the correct stadium after Antibot Map.
  2. Choose which players to test
  3. Run antibot(~) on them
  4. Kick players that failed (or do something else)

Example

// room.js

const HaxballJS = require("haxball.js");
const { initAntibot, antibot } = require("hax-antibot");

const getRoom = async () => {
  const HBInit = await HaxballJS
  const room = HBInit({
    roomName: 'test',
    token: 'thr1.AAAAAGUoFkn6N1TdUatJBg.bS6fQZYprgM'
  })
  return room
}

const run = async () => {
  const room = await getRoom()

  // Call init once on your room before any stadium changing commands
  const getStadium = initAntibot(room)

  room.onPlayerJoin = (p) => {
    room.setPlayerAdmin(p.id, true)
  }
  
  room.onPlayerChat = () => {
    performAntibot()
    return true
  }

  // Script changes the map
  room.setDefaultStadium("Big")


  // Example of your antibot function
  const performAntibot = async () => {
    // Choose who to check. You may filter the players to choose only players which are not AFK.
    const playerIdsToCheck = room.getPlayerList().map(p => p.id)

    // Run Antibot
    const result = await antibot(room, getStadium, playerIdsToCheck)

    // Perform action depending on 
    // You can choose what to do with failed player
    result.filter(p => p.failed).forEach(p => room.kickPlayer(p.id, "Failed reaching the green zone.", false))

    // Map will be changed back automatically. Set up the teams from remaining players and start the game.
  }

  room.onRoomLink = link => {
    console.log(link)
  }
}

run()

This code is also in room.ts.

Build

npm run build
0.2.1

7 months ago

0.2.2

7 months ago

0.2.0

7 months ago

0.1.3

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago