Archer Brain (Archery Wing)

Type: Assembly Brain
Level: not in gallery
Pages: 5
Description: This Brain is part of the Archery Wing assembly. An archer stands with a selection of arrows. He fires at a target, goes to check to see how he is done, emotes either happiness or sadness depending on the result, removes the arrows, then returns to his starting position and begins again.

It requires input from the bullseye prop and the two arrow props in the assembly. As it currently stands this assembly does not work correctly and should not be used without correction – see Alterations.

Kode

Archer brain

page 1 @Shoot at Target

  1. WHEN [page entered] DO [numvar:shots fired][equals][0]
  2. …WHEN DO [turn][toward][IWP:bullseye]
  3. WHEN [once] DO [equip][Rustic Bow]
  4. …WHEN DO [team][equals][team 1]
  5. …WHEN DO [vectorvar:starting position][equals][position]
  6. WHEN [countdown timer][random number][0.7][to][1.5][loop] DO [shoot][IWP:Projectile][in direction][random vector][cone][angle][10][direction][forward][launch frequency][2]
  7. WHEN [objset: stuck arrows][count][greater than or equal to][random number][as integer][10][to][20] DO [switch page][page: @Check Hits]

page 2 @Check Hits

  1. WHEN DO [move][toward][IWP:Practice target][min distance][2]
  2. WHEN [not][duration timer][0.25]
  3. …WHEN [not][ moving]
  4. …/…WHEN [started to][countdown timer][1]
  5. …/…/…WHEN [for each of][objset:stuck arrows]
  6. …/…/…/…WHEN [it][boolvar:hit center] DO [switch page][page: @Celebrate]
  7. …/…/…WHEN DO [switch page][@Sulk]

page 3 @Clear Arrows

  1. WHEN [page entered] DO [emote][Greet]
  2. WHEN [started to][countdown timer]
  3. …WHEN [for each of][objset:stuck arrows] DO [destroy][it]
  4. WHEN [not][duration][2]
  5. …WHEN DO [move][toward][vectorvar:starting position][min distance][0]
  6. …WHEN [not][duration timer][3]
  7. …/…WHEN [not moving] DO [switch page][page@Shoot at Target]

page 4 @Celebrate

  1. WHEN [page entered] DO [emote][Cheer]
  2. WHEN [detect][player] DO [say][text: Bullseye!]
  3. WHEN [not][duration timer][5] DO [switch page][page: @Clear Arrows]

page 5 @Sulk

  1. WHEN [page entered] DO [emote][sad]
  2. WHEN [detect][player] DO [say][text: So close…]
  3. WHEN [not][duration timer][5] DO [switch page][page: @Clear Arrows]

 

Bullseye brain

  1. WHEN [detect][IWP:Squire Male (Archer)][objset: stuck arrows] DO [it][boolvar:hit center][equals][true] // this determines if any of the archers arrows have hit the bullseye

Stuck Arrow Brain

  1. WHEN [once]
  2. …WHEN DO [up][equals][right]
  3. …WHEN DO [IWP:Squire Male(archer)][objset:stuck arrows][increment by][me]
  4. WHEN DO [forward][equals][creator][vectorvar:forward]

Arrow Projectile Brain

  1. WHEN [page entered] DO [forward][equals][velocity]
  2. WHEN [is projectile]
  3. …WHEN DO [play fx][fx:Projectile trail]
  4. WHEN DO [forward][equals][vetorvar:forward]
  5. WHEN [one] DO [up][equals][right]
  6. WHEN [creator][attack hit]
  7. …WHEN [it][equal to][IWP:practice target]
  8. …/…WHEN [once] DO [create][IWP: Stuck arrow][at position][position][plus][(][forward][multiplied by][0.2][)]
  9. …WHEN [it][equal to][IWP:Glued object (haybales)]
  10. …/…WHEN [once] DO [create][IWP:stuck arrow][at position][position][plus][(][forward][multiplied by][0.5][)]
  11. …/…/…WHEN DO [play sound][sound:Impact Hay]

Alterations

Fixing the wayward archer

The problem with this archery lesson is that the kode does not work after the first time. The player does not have a chance to turn around with the frames available before he starts firing again. Because he is no longer hitting the hay bales and target he never stops firing after the first go, and in the wrong direction. It is an easy fix.

page 1@Shoot at Target

  1. WHEN [page entered] DO [numvar:shots fired][equals][0]
  2. …WHEN DO [boolvar:turn][equals][true]
  3. WHEN [boolvar:turn]
  4. …WHEN DO [turn][toward][IWP:bullseye]
  5. …WHEN [countdown timer] DO [boolvar:fire][equals][true]
  6. …/…WHEN DO [boolvar:turn][equals][false]
  7. WHEN [once] DO [equip][Rustic Bow]
  8. …WHEN DO [team][equals][team 1]
  9. …WHEN DO [vectorvar:starting position][equals][position]
  10. WHEN [boolvar:fire]
  11. …WHEN [countdown timer][random number][0.7][to][1.5][loop] DO [shoot][IWP:Projectile][in direction][random vector][cone][angle][10][direction][forward][launch frequency][2]
  12. …WHEN [objset: stuck arrows][count][greater than or equal to][random number][as integer][10][to][20] DO [switch page][page: @Check Hits]

@Check Hits

  1. WHEN [page entered] DO [boolvar:fire][equals][false]

There is also a weird koding decision in the brain as instead of using [countdown timer] the developer has used [not][duration timer]. It works just the same, but I do not recommend using two tiles when one is sufficient.

Add a missing sound fx

There is a sound effect when the arrows hit the hay but not the target. Try adding to the Projectile arrow brain

childine of line 8 (new line 9)

WHEN DO [play sound][sound: Impact Light]

Having the arrows that appear next to the archer reduce as he shoots them and reappear when he returns.

You will need to unglue the arrows from the main assembly and delete all but one.

In Arrow brain

  1. WHEN [once] DO [IWP: archer][objset: arrow stock][increment by][me]
  2. WHEN [once] DO [IWP: archer][objset:original stock][increment by][me]
  3. WHEN [not][ visible] DO [IWP: archer][objset:arrow stock][decrement by][me]
  4. WHEN [started to][visible] DO [IWP:archer][objset:arrow stock][increment by][me]
  5. WHEN [once] DO [collidable][equals][false] // it is easier to have the arrows non collidable all the time rather than toggled on visibility as it prevents a sudden issue if the player is standing in their position when they appear.

Copy and paste the amount of arrows you want the archer to fire each round. It will be  a fixed amount every time.

In Arrow Projectile brain

  1. WHEN [page entered] DO [forward][equals][velocity]
  2. WHEN [is projectile]
  3. …WHEN DO [play fx][fx:Projectile trail]
  4. WHEN DO [forward][equals][vectorvar:forward]
  5. WHEN [one] DO [up][equals][right]
  6. WHEN [creator][attack hit]
  7. …WHEN DO [numvar:random arrow][equals][random number][1][to][IWP: archer][objset:arrow stock][count][as integer]
  8. …WHEN [for each of[IWP: archer]][objset:arrow stock]
  9. …/…WHEN [current index][equal to][numvar: random arrow] DO [toggle][it][visible]
  10. …WHEN [it][equal to][IWP:practice target]
  11. …/…WHEN [once] DO [create][IWP: Stuck arrow][at position][position][plus][(][forward][multiplied by][0.2][)]
  12. …WHEN [it][equal to][IWP:Glued object (haybales)]
  13. …/…WHEN [once] DO [create][IWP:stuck arrow][at position][position][plus][(][forward][multiplied by][0.5][)]
  14. …/…/…WHEN DO [play sound][sound:Impact Hay]

Archers brain

@ Shoot at Target

line 6 as child line to line 4

…WHEN [for each of][objset:original stock] DO[it][visible][equals][true]

last line change to

…WHEN [objset: stuck arrows][count][equal to][objset:original stock][count] DO [switch page][page: @Check Hits]

Change the emote for clearing the arrows

I suggest that the give emote is better than the greet emote when he clears the arrows from the target. It can be found line 1 @Clear Arrows in the Archer brain.

 

Comments are closed.

Website Powered by WordPress.com.

Up ↑

%d bloggers like this: