singulo_emitter.m 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. # This is a script to be loaded into GNU Octave.
  2. # - Notes -
  3. # + Be sure to check all parameters are up to date with game before use.
  4. # + This plots *worst-case* performance, the assumption is that it shouldn't ever randomly fail.
  5. # + The assumption is that there is one emitter per shield point.
  6. # + Keep in mind that to prevent the generator being destroyed, either shield must be above a limit.
  7. # This limit is (level*2)+1.
  8. # The timestep used for simulation is one second.
  9. global emitter_state emitter_timer shield_energy
  10. emitter_state = 0
  11. emitter_timer = 0
  12. shield_energy = 0
  13. function shield_clamp ()
  14. global shield_energy
  15. # ContainmentFieldConnection.SharedEnergyPool
  16. shield_energy = min(max(shield_energy, 0), 25)
  17. endfunction
  18. function shield_tick ()
  19. global shield_energy
  20. shield_energy -= 1
  21. shield_clamp()
  22. endfunction
  23. function shield_hit ()
  24. global shield_energy
  25. emitter_count = 2 # one per connection side
  26. receive_power = 6 # ContainmentFieldGeneratorComponent.IStartCollide.CollideWith
  27. power_per_connection = receive_power / 2 # ContainmentFieldGeneratorComponent.ReceivePower
  28. shield_energy += power_per_connection * emitter_count
  29. shield_clamp()
  30. endfunction
  31. function retval = scenario (x)
  32. global emitter_state emitter_timer shield_energy
  33. # Tick (degrade) shield
  34. shield_tick()
  35. # Timer...
  36. if emitter_timer > 0
  37. emitter_timer -= 1
  38. else
  39. # Note the logic here is written to match how EmitterComponent does it.
  40. # Fire first...
  41. shield_hit()
  42. # Then check if < fireBurstSize
  43. if emitter_state < 3
  44. # Then increment & reset
  45. emitter_state += 1
  46. # to fireInterval
  47. emitter_timer = 2
  48. else
  49. # Reset state
  50. emitter_state = 0
  51. # Worst case, fireBurstDelayMax
  52. emitter_timer = 10
  53. endif
  54. endif
  55. retval = shield_energy
  56. endfunction
  57. # x is in seconds.
  58. x = 0:1:960
  59. plot(x, arrayfun(@scenario, x))