Help with spawning enemies in microworld

Does anybody know how to do this? I’m testing out weapon effects and want immediately-spawned footmen and weapons, as well as goblins (preferably appearing after 10s or so).

I had a look at the latest twitch stream, and Tom seems to be running a players_vs_goblins.json world with two ‘teams’ coded in. It doesn’t look anything like the current worlds (both of which are .lua files).

Here’s the current worker spawning code:

   -- create all the workers.
local workers = {}
for x = 1,3 do
  for z = 1,2 do
     local worker = microworld:place_citizen(-5 + (x * 3), -5 + (z * 3))
     table.insert(workers, worker)

-- give some of the workers some starting items.
local player_id = microworld:get_local_player_id()
local pop = stonehearth.population:get_population(player_id)

local function pickup(who, uri)
  local item = pop:create_entity(uri)
  radiant.entities.pickup_item(who, item)

pickup(workers[6], 'stonehearth:resources:wood:oak_log')
pickup(workers[2], 'stonehearth:footman:wooden_sword_talisman')
pickup(workers[3], 'stonehearth:mason:talisman')
pickup(workers[4], 'stonehearth:blacksmith:talisman')
1 Like

Why don’t you take a look at goblin brigands dynamic scenario?
Is people afraid of looking at the lua files? :kissing:

Have not tested these things, but…

   local citizen=self._population:create_new_citizen()

local weapon=radiant.entities.create_entity('stonehearth:weapons:jagged_cleaver')

This is a fragment from candledark, for example:

local session = {
  player_id = 'candledark_undead',
  faction = 'undead',
  kingdom = 'candledark:kingdoms:undead'

      self._population = stonehearth.population:add_population(session)

 local skeleton = self._population:create_new_citizen()

something like these things :arrow_heading_up: might work.


Thanks for the suggestion! I didn’t think of looking at the scenarios

Hopefully it’ll work!

1 Like

I plan on updating my microworld branch with some useful functions (such as equipment, workshops and so forth)… and as soon as I get around to document these things properly I’ll send a pull request or something.