Sparring Knights

Type: Assembly Brain
Level: not in gallery
Pages: 7
Description: Found in the Sparring Knights Assembly. This brain creates AI for two fighting knight NPCs. They try to remain within a circular arena (though they occasionally get out of it).

Knight 1

  1. WHEN [once] DO [equip][prop:Knights Practice sword]
  2. …WHEN DO [objvar:target][equals][iwp:Knight 2]
  3. …WHEN DO [push brain][iwp:Knight Brain]

Knight 2

  1. WHEN [once] DO [equip][prop:Knights Practice sword]
  2. …WHEN DO [objvar:target][equals][iwp:Knight 1]
  3. …WHEN DO [push brain][iwp:Knight Brain]

Knight Brain

page 1 @Move Randomly

  1. WHEN [once] DO [vectorvar:center of ring][equals][(][position][plus][objvar:target][position][)][divided by][2]
  2. WHEN DO [#distance to target][equals][distance to][objvar:target]
  3. WHEN DO [turn][toward][objvar:target][quickly]
  4. WHEN DO [move][in direction][right][at speed][#move speed]
  5. WHEN DO [move][toward][vectorvar:center of ring][at speed][0.4][with strafing]
  6. WHEN [#distance to target][less than or equal to][#spacing]
  7. …WHEN [countdown timer][1] DO [call page][page::@Random Dodge]
  8. WHEN [countdown timer][5][loop] DO [#move speed][equals][random number][0.1][to][0.4]
  9. WHEN [countdown timer][1][loop]
  10. …WHEN [(][random number][as integer][1][to][5][)][equal to][1] DO [switch page][page: @Random Attack]
  11. …WHEN [(][random number][as integer][1][to][10][equal to][1] DO [call page][page:@Random Dodge]
  12. …WHEN [(][random number][as integer][1][to][50][)][equal to][1] DO [switch page][page: @Taunt]
  13. …WHEN [(][random number][as integer][1][to][50][)][equal to][1] DO [switch page][page: @Compliment]

page 2 @Random Dodge

  1. WHEN [page entered] DO [#distance to target][equals][distance to][objvar:target]
  2. WHEN DO [turn][toward][objvar:target][quickly]
  3. WHEN [#distance to target][greater than][3] DO [dodge][in direction][forward][distance][(][#distance to target][minus][#spacing][)]
  4. …WHEN [else] DO [dodge][in direction][backward][distance][#minimum dodge distance][with strafing]
  5. WHEN DO [#attack hits][equals][0]

page 3 @Random Attack

  1. WHEN [not][moving]
  2. …WHEN [countdown timer][1.5] DO [switch page][page:@Move Randomly]
  3. WHEN DO [turn][toward][objvar:target][quickly]
  4. WHEN DO [#attack type][equals][random number][as integer][1][to][3]
  5. WHEN [#attack type][equal to][1] DO [attack][objvar:target][light]
  6. WHEN [attack type][equal to][2] DO [attack][objvar:target]
  7. WHEN [attack type][equal to][3] DO [attack][objvar:target][heavy]
  8. WHEN [attack hit] DO [#attack hits][increment by][1]
  9. WHEN [#attack hits][greater than or equal to][ransom number][as integer][1][to][4] DO [switch page][page: @Move Randomly]

page 4 @Taunt

  1. WHEN [page entered] DO [#random number][equals][random number][as integer][1][to][4]
  2. WHEN DO [turn][toward][objvar:target][quickly]
  3. WHEN DO [emote][Taunt]
  4. WHEN [detect][player]
  5. …WHEN [#random number][equal to][1] DO [say][text: You call yourself…]
  6. …WHEN [#random number][equal to][2] DO [say][text: Let me know…]
  7. …WHEN [#random number][equal to][3] DO [say][text: Are you gonna…]
  8. …WHEN [#random number][equal to][1] DO [say][text: You you trying to…]
  9. WHEN DO [objvar:target][switch page][page:@cry]
  10. WHEN DO [objvar:target][turn][toward][me]
  11. WHEN [countdown timer][3]
  12. …WHEN DO [objvar:target][switch page][page:@Move Randomly]
  13. …WHEN DO [switch page][page:@Move Randomly]

page 5 @Compliment

  1. WHEN [page entered] DO [#random number][equals][random number][as integer][1][to][4]
  2. WHEN DO [turn][toward][objvar:target][quickly]
  3. WHEN DO [emote][Talk]
  4. WHEN [detect][player]
  5. …WHEN [#random number][equal to][1] DO [say][text: Impressive…]
  6. …WHEN [#random number][equal to][2] DO [say][text:Now weve got…]
  7. …WHEN [#random number][equal to][3] DO [say][text: Has anyone…]
  8. …WHEN [#random number][equal to][1] DO [say][text: Nicely done…]
  9. WHEN DO [objvar:target][switch page][page:@Celebrate]
  10. WHEN DO [objvar:target][turn][toward][me]
  11. WHEN [countdown timer][3]
  12. …WHEN DO [objvar:target][switch page][page:@Move Randomly]
  13. …WHEN DO [switch page][page:@Move Randomly]

page 6 @Cry

  1. WHEN DO [emote][cry]

page 7 @Celebrate

  1. WHEN DO [emote][Cheer]

Comments are closed.

Website Powered by WordPress.com.

Up ↑

%d bloggers like this: