1st person shooter – advanced

Type: Player Brain
Level: 3 star
Pages: 3
Description:
1st person camera brain set up for players with projectile weapons. Includes the sci fi HUD and laser pistol. Also features a Left trigger focus. A more complicated version of the 1st person shooter brain, but with very little to show for it in my opinion.

Note: This brain has a bug which causes the visual and sound effect of walking to be present when the player is not moving, and not play when the player is moving. See Phantom Footsteps Bug (Work Around).

Kode

Page 1

  1. WHEN DO [call page][page:@Init]
  2. WHEN DO [call page][@Display HUD]
  3. WHEN [left stick] DO [move]
  4. WHEN [left trigger]
  5. … WHEN DO [objvar: weapon][position][equals][camera position][+][camera forward][multiplied by][0.5][+][down][multiplied by][objvar:weapon][height][+][posvar:headBob] // moves the weapon to the center of the screen instead of the crosshair.
  6. …WHEN DO [first person turn speed][=][numvar:turnSpeedBase][multiplied by][0.75]
  7. …WHEN DO[ground speed][equals][ground speed][multiplied by][0.75]
  8. …WHEN DO [depth of field][near blur amount][0.5][depth offset][0.2][near blur depth][0.475][far blur depth][50][far blur amount][0.1] // blurs the part of the weapon nearest the camera
  9. WHEN [else]
  10. …WHEN DO [objvar:weapon][position][=][camera position][+[camera forward][+][down][divided by][2.25][+][right][divided by][2][+][posvar:headBob] // places the weapon at the side of the player
  11. …WHEN DO [display][Astro Tech Crosshair][screen center][no HUD stack] // displays crosshair
  12. WHEN [Right trigger][or][button:X]
  13. …WHEN [objvar:target] DO [objvar:weapon][shoot][at speed][50][launch frequency][7.5][lifetime][1.5][at][objvar:target] // when right trigger pressed and there is a target shoot at it
  14. …/…WHEN [else] DO [objvar:weapon][shoot][at speed][50][launch frequency][7.5][lifetime][1.5][at[vectorvar: aimPosition] // if there is no target shoot at where the player is aiming
  15. …WHEN DO [objvar:weapon][power on]
  16. …WHEN [else] DO [objvar:weapon][power off]
  17. WHEN [objvar:weapon][projectiles][count][increased] // whenever the gun is fired
  18. …WHEN DO[vibrate][at speed][1][duration][0.1]
  19. …WHEN [camera shake][strength][0.75][duration][0.1][speed][10] // get a vibrate and a shake so you “feel” the laser gun firing
  20. WHEN [right stick button][pressed] DO [attack][ light]
  21. WHEN [button:A][pressed] DO [jump]
  22. WHEN [left stick button][pressed] DO [sprinting][=][true]
  23. …WHEN DO [boolvar:crouching][equals][false]
  24. WHEN [no longer][moving] DO [boolvar:sprinting][equals][false]
  25. WHEN [boolvar:sprinting] DO [ground speed][equals][ground speed][multiplied by][1.5] // when the left stick is pressed run at 1.5 times the normal speed
  26. WHEN [detect][interactable][objects in front]
  27. …WHEN DO[highlight it yellow]
  28. …WHEN [is using keyboard] DO [display][middle mouse button][ above ][ it]
  29. …WHEN[using controller][or][is using touch] DO [display][icon:B][above] [it]
  30. …WHEN [button B][pressed] DO [interact]
  31. …WHEN [else]
  32. …/…WHEN[button B][pressed] DO [toggle][boolvar:crouching]
  33. …/…/…WHEN DO [boolvar:sprinting][equals][false]
  34. WHEN [boolvar:crouching]
  35. …WHEN[numvar:crouchscale][Greater than][0.5] DO [numvar:crouchscale][decrement by][0.1]
  36. …/… WHEN DO [shrink][to scale][numvar: crouchscale]
  37. …WHEN DO [ground speed][equals][ground speed][multiplied by][0.5]
  38. …WHEN [else]
  39. …/…WHEN [numvar:crouchscale][less than][1] DO [numvar:crounchscale][increment by][0.1]
  40. …/…/…WHEN DO [grow][to scale][numvar:crouchscale] // lines 32-40 creates a crouching mechanic by shrinking and growing the player (which of course looks like he is crouching because you see through his eyes, and you do not see that he has just got smaller)

page 2 @DisplayHUD

  1. WHEN DO [1st person camera][should track socket][transition easing][ease between][transition time][0.25] // sets up camera
  2. WHEN [in air][or][attacking] DO [boolvar: bobDelay][equals][true]
  3. …WHEN[else] DO [numvar:bobDelay][increment by][1][divided by][30]
  4. WHEN [boolvar:bobDelay] DO [1stperson camera][transition easing][ease between][transition time][0.25] // sets up a camera specifically for when the player is in the air or attacking an enemy
  5. WHEN [countdown timer][0.2] DO [boolvar:bobDelay][equals][false]
  6. WHEN DO [vectorvar:hudPos][x][equals][0]
  7. WHEN DO [vectorvar:hudPos][y][equals][-0.92]
  8. WHEN DO [display][icon:HUD panel A][at screen position][vectorvar: hudPos]
  9. WHEN DO  [vectorvar:hudPos][x][equals][-0.69]
  10. WHEN DO [vectorvar:hudPos][y][equals][-0.94]
  11. WHEN DO [display][icon:HUD panel B][at screen position][vectorvar: hudPos]
  12. WHEN DO [vectorvar:hudPos][x][equals][negative][vectorvar:hudPos][x]
  13. WHEN DO [display][icon:HUD panel C][at screen position][vectorvar: hudPos]
  14. WHEN DO  [vectorvar:hudPos][x][equals][-0.59]
  15. WHEN DO [vectorvar:hudPos][y][equals][0.87]
  16. WHEN DO [display][icon:HUD panel D][at screen position][vectorvar: hudPos]
  17. WHEN DO [vectorvar:hudPos][x][equals][negative][vectorvar:hudPos][x]
  18. WHEN DO [display][icon:HUD panel E][at screen position][vectorvar: hudPos]
  19. WHEN DO  [vectorvar:hudPos][x][equals][-0.45]
  20. WHEN DO [vectorvar:hudPos][y][equals][0]
  21. WHEN DO [display][icon:HUD detail A][at screen position][vectorvar: hudPos]
  22. WHEN DO [display][icon:HUD detail B][at screen position][negative][vectorvar: hudPos]
  23. WHEN DO  [vectorvar:hudPos][x][equals][0]
  24. WHEN DO [vectorvar:hudPos][y][equals][0.805] // lines 6-24 displays the sci fi HUD on screen
  25. WHEN DO [display meter][health][max][max health][Galaxies meter][at screen position][vectorVar:hudPos]
  26. WHEN [hit by attack] DO [numvar: hitimpact time][equals][0.25]
  27. …WHEN [numvar:hitdirection][equals][angle between][it][position][minus][position][forward][signed relative to][world up]
  28. …WHEN DO [fade][red][transition time][0.1]
  29. WHEN [numvar:hitimact time][greater than][0]
  30. …WHEN DO [numvar:hitimpact time][decrement by][0.1]
  31. …WHEN [numvar:hitDirection][less than][-20] DO [display][icon:Damage left][screen bottom left][no HUD stack]
  32. …[numvar:hitDirection][greater than][20] DO [display][icon:Damage right][screen bottom right][no HUD stack]
  33. WHEN [equipment]
  34. …WHEN DO [objvar: weapon][team][equals][neutral]
  35. …WHEN DO [activate brain][objvar:weapon]
  36. …WHEN DO [pick up][weapon]
  37. …WHEN DO [objvar: weapon][equals][it]
  38. …/…WHEN DO [deactivate brain][objvar:weapon]
  39. …/…WHEN DO [objvar:weapon][power off]

Comments are closed.

Website Powered by WordPress.com.

Up ↑

%d bloggers like this: