Wandering Villager

Type: Allies brain
Level: 3 star
Pages: 2
Description: A walking villager who has a message when interacted with. They will run away from any enemy. The problem with this brain is it lacks randomness and if you put a lot of villagers in your world with this brain they all start and stop at the same time, even though the direction they turn and walk in is randomized. See Alterations for a more randomised brain.

Kode

page 1 @Wander

  1. WHEN [once] DO [team][equals][team 1]
  2. WHEN [objects closer than][10][enemies]
  3. …WHEN DO [move][ away from][it][at speed][0.5]
  4. …WHEN [else][countdown timer][2][hold time][4][loop] DO [move][at speed][0.15]
  5. …/…WHEN [countdown timer][2][loop] DO [numvar:turn direction][equals][random number][1][to][2][as integer]
  6. …/…WHEN [moving]
  7. …/…/…WHEN [duration timer][2][loop]
  8. …/…/…/…WHEN [numvar:turn direction][equal to ][1] DO [turn][in direction][right][slowly]
  9. …/…/…/…WHEN [numvar:turn direction][equal to ][2] DO [turn][in direction][left][slowly]
  10. WHEN [bump] DO [turn][away from][it][quickly]
  11. WHEN [interacted][by][player]
  12. …WHEN DO [turn][toward][it]
  13. …WHEN DO [switch page][page:@Talk]

page 2 @Talk

  1. WHEN [page entered] DO [emote][emote:Talk]
  2. WHEN DO [say][text:Greetings Adventurer]
  3. WHEN [countdown timer][4] DO [switch page][text: @Wander]

 

Alterations

This brain is not very random, and your villagers can look robotic. The more randomised options you add to the brain the better it will be. This brain below uses the starting position of the character to add a random element to the timings. You should not get all your villagers starting and stopping at the same time with this kode.

  1. WHEN [once] DO [team][equals][team 1]
  2. WHEN [objects closer than][10][enemies]
  3. …WHEN DO [move][ away from][it][at speed][0.5]
  4. …WHEN [else] DO [numvar:random][equals][position][x][modulo][6]
  5. …/…WHEN [countdown timer][numvar:random] DO [numvar:hold][equals][random number][4][to][6][as integer]
  6. …/…WHEN [countdown timer][2][hold time][numvar:hold][loop] DO [move][at speed][0.15]
  7. …/…WHEN [countdown timer][(][numvar:random][divided by][3][)][loop] DO [numvar:turn direction][equals][random number][1][to][2][as integer]
  8. etc…

Comments are closed.

Powered by WordPress.com.

Up ↑

%d bloggers like this: