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.
Kode
page1 @Wander
- WHEN [once] DO [team][equals][team 4]
Uses random number to determine whether to walk
- WHEN [duration timer][numvar:walk delay][loop]
- …WHEN [numvar:walk delay][greater than or equal to][4] DO [move][at speed][0.15]
- …WHEN [started to] DO [numvar:walk delay][equals][random number][0][to][20]
Uses random number to determine which way to turn
- WHEN [moving]
- …WHEN [started to] DO [numvar:turn direction][equals][random number][1][to][2][as integer]
- …/… WHEN DO [numvar: random turn duration][equals][random number][2][to][6]
- …WHEN [numvar: turn direction][equal to][1] DO [turn][in direction][right][slowly]
- …WHEN [numvar: turn direction][equal to][2] DO [turn][in direction][left][slowly]
Turns if bumps into anything
- 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)
- WHEN [countdown timer][10][loop] DO [numvar: chance to emote][equals][random number][1][to][40][as integer]
- …WHEN [numvar:chance to emote][equal to][1] DO [emote][talk]
When detect enemies goes into seek and attack mode
- WHEN [detect][enemies]
- …WHEN DO [objvar:my enemy][equals][it]
- …WHEN DO [switch page][page@Seek & Attack]
page 2 @Seek & Attack (similar to Enemy brain kode)
- WHEN [detect][enemies] DO [objvar: my enemy][equals][it]
- WHEN [distance to][objvar:my enemy][less than][20][and][distance to][objvar:my enemy][greater than or equal to][2]
- …WHEN DO [move][toward][objvar:my enemy]
- WHEN [countdown timer][numvar:pause attack][loop]
- …WHEN [distance to][objvar:my enemy][less than or equal to][2] DO [attack][objvar:my enemy][with windup][end combo]
- …WHEN DO [numvar: pause attack][equals][random number][1][to][1.5]
- WHEN [objvar: my enemy][is dead] DO [switch page][page:@Wander]
Alterations
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]