Hostile Creature

Type: Enemy brain
Level: 3 star
Pages: 2
Description: Intended to be used in animal brains, such as squirrel, wolf. Unlike enemy brain, it separates the seek and attack from the wandering with a switch page, effectively giving the animal two separate behaviours.


page1 @Wander

  1. WHEN [once] DO [team][equals][team 4]

    Uses random number to determine whether to walk

  2. WHEN [duration timer][numvar:walk delay][loop]
  3. …WHEN [numvar:walk delay][greater than or equal to][4] DO [move][at speed][0.15]
  4. …WHEN [started to] DO [numvar:walk delay][equals][random number][0][to][20]

    Uses random number to determine which way to turn

  5. WHEN [moving]
  6. …WHEN [started to] DO [numvar:turn direction][equals][random number][1][to][2][as integer]
  7. …/… WHEN DO [numvar: random turn duration][equals][random number][2][to][6]
  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]

    Turns if bumps into anything

  10. WHEN [bump] DO [turn][away from][it][quickly]

    Uses random number to determine whether they will do the talk emote (in animals this is a howl etc)

  11. WHEN [countdown timer][10][loop] DO [numvar: chance to emote][equals][random number][1][to][40][as integer]
  12. …WHEN [numvar:chance to emote][equal to][1] DO [emote][talk]

    When detect enemies goes into seek and attack mode

  13. WHEN [detect][enemies]
  14. …WHEN DO [objvar:my enemy][equals][it]
  15. …WHEN DO [switch page][page@Seek & Attack]

page 2 @Seek & Attack (similar to Enemy brain kode)

  1. WHEN [detect][enemies] DO [objvar: my enemy][equals][it]
  2. WHEN [distance to][objvar:my enemy][less than][20][and][distance to][objvar:my enemy][greater than or equal to][2]
  3. …WHEN DO [move][toward][objvar:my enemy]
  4. WHEN [countdown timer][numvar:pause attack][loop]
  5. …WHEN [distance to][objvar:my enemy][less than or equal to][2] DO [attack][objvar:my enemy][with windup][end combo]
  6. …WHEN DO [numvar: pause attack][equals][random number][1][to][1.5]
  7. WHEN [objvar: my enemy][is dead] DO [switch page][page:@Wander]



Attack music
You can put a [play sound][music: Your choice] on page 2 of this brain and this will alert the player to danger. Obviously you cannot put this in multiple animal brains or you will get a cacophony of music being played. Instead add this

WHEN [page entered] DO [global][numvar:attack music][incremented by][1]
WHEN [started to][is dead] DO [global][numvar:attack music][decremented by][1]

It may be a good idea to place the [started to] [is dead] line into page 1 also.

In a logic cube put

WHEN [global][numvar:attack music][greater than][0] DO [play sound][music:Attack music][everywhere]



Comments are closed.

Website Powered by

Up ↑

%d bloggers like this: