Files
douwco_hivemind/src/spawn.cpp
2025-08-22 01:13:09 +02:00

28 lines
721 B
C++

#include <nlohmann/json.hpp>
#include <Screeps/JS.hpp>
#include <Screeps/Game.hpp>
#include <Screeps/Room.hpp>
#include <Screeps/StructureSpawn.hpp>
#include <emscripten.h>
#include "Constants.hpp"
#include "Structures/Spawn.hpp"
void DouwcoHivemind::Spawn::loop()
{
int creepcount = spawn.room().find(Screeps::FIND_MY_CREEPS).size();
if (creepcount > 10)
{
EM_ASM({ console.log('To much creeps in this room'); });
return;
}
EM_ASM({ console.log('Creating a harvester'); });
JSON opts;
opts["memory"]["role"] = Roles::HARVESTER;
int resp = spawn.spawnCreep(
{"work", "carry", "move"},
"harvester" + std::to_string(Screeps::Game.time()),
opts);
}