Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add bot? #46

Open
tianyma opened this issue Nov 19, 2021 · 3 comments
Open

How to add bot? #46

tianyma opened this issue Nov 19, 2021 · 3 comments

Comments

@tianyma
Copy link

tianyma commented Nov 19, 2021

I found there are four default bots inside xxscreeps, how can I add and delete the bot?

@laverdet
Copy link
Owner

There's no utility to do this right now but I'd definitely accept a player management patch.

The "scrape-world" utility is a good place to start. It collects all the information from the vanilla Screeps lokidb and dumps it into xxscreeps:
https://github.com/laverdet/xxscreeps/blob/main/src/scripts/scrape-world.ts

This is a little skeleton to get you started if you're interested.

import { RoomPosition } from 'xxscreeps/game/position';
import * as CodeSchema from 'xxscreeps/engine/db/user/code';
import * as User from 'xxscreeps/engine/db/user';
import { Database, Shard } from 'xxscreeps/engine/db';
import { Room } from 'xxscreeps/game/room/room';
import * as Spawn from 'xxscreeps/mods/spawn/spawn';

const shard = await Shard.connect(db, 'shard0');
const { data } = shard;
const userId = generateId(12);
const user = await User.create(db, userId, 'bot');
const room = await shard.loadRoom('W1N1'); 
const spawn = Spawn.create(new RoomPosition(25, 25, 'W1N1'), userId, 'Spawn1');
room['#insertObject'](spawn);
await shard.saveRoom(room);
await shard.save();
const modules = ...;
await CodeSchema.saveContent(db, userId, 'main', modules);
db.disconnect();

@tianyma
Copy link
Author

tianyma commented Nov 20, 2021

thank you, where do the bot scripts locate, can I modify them?

@thmsndk
Copy link
Contributor

thmsndk commented Dec 12, 2021

So a search in the screeps org after bot gives us the following places I think are relevant.

@laverdet I assume we would need something listening on the CLI host and an actual CLI implementation to get something in place for adding/removing bots? seems like it is backend-local that is responsible for starting both the gameserver and the cli server in vanilla screeps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants