Type: Animal Brain
Level: 3 star
Pages: 1
Description: This brain is designed for flying creatures. It creates a constantly flying bird which is supposed to circle a patrol area. However, the bird generally flies off very high and completely disappears from view within a few seconds, only coming into view occasionally.
Kode
- WHEN [once] DO [team][equals][team 4] // not sure why it is set at 4
- …WHEN DO [vectorvar: patrol center][equals][position]
Set up speed variable - WHEN DO [move][with flying][at speed][numvar:speed]
- WHEN [countdown timer][5][loop][trigger on start] DO [numvar:speed][equals][random number][0.5][to][2]
- …WHEN DO [numvar:turn time][equals][random number][1.5][to][3] // time between turns
- WHEN [moving]
- …WHEN [duration timer][numvar:turn time][loop]
Set up random turn direction - …/…WHEN [started to] DO [numvar:turn direction][equals][random number][1][to][2][as integer]
- …/…/…WHEN DO [altitude direction][equals][random number][1][to][2][as integer]
Set up patrolling area
- …/…WHEN [(][position][x][plus][100][less than][vectorvar:patrol center][x][)][or][(][position][x][minus][100][greater than][vectorvar:patrol center][x][)]
- …/…/…WHEN [duration timer][0.75] DO [turn][toward][vectorvar: Patrol center]
- …/…/…/…WHEN DO [numvar: turn direction][equals][0]
- …/…WHEN {(][position][z][plus][100][less than][vectorvar:patrol center][z][)][or][(][position][z][minus][100][greater than][vectorvar:patrol center][x][)]
- …/…/…WHEN [duration timer][0.75] DO [turn][toward][vectorvar: Patrol center]
- …/…/…/…WHEN DO [numvar: turn direction][equals][0]
- …/…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]
- …/…WHEN [numvar: altitude direction][equal to][1]
- …/…/…WHEN [duration timer][1] DO [move][with flying][in direction][forward][plus][up][at speed][numvar: speed]
- …/…WHEN [numvar: Altitude direction][equal to][2]
- …/…/…WHEN {(][raycast hit][direction][down][terrain only][length][10][)][or][position][y][minus][world water level][less than][10]
- …/…/…/…WHEN [else]
- …/…/…/…/…WHEN [duration timer][1] DO [move][with flying][in direction][forward][plus][down][at speed][numvar:speed]
- WHEN [bump] DO [turn][away from it][quickly]
Alterations
Have bird fly at lower altitude
WHEN DO [numvar:height][equals][clamp][min][11][max][15][height] // you can change the numbers to higher (I do not recommend a number lower than 11)
WHEN DO [position][y][equals][numvar:height]
Use this kode for a non flying animal
Remove the [with flying] tiles from lines 3.19 and 23. Change the speed in line 4 as it will be a bit fast (0.1 to 1 is quite good)