Difference between revisions of "BGS Doc"

From Elite Wiki
m (added player.ship.script checks)
m (Retagged!)
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{OXPNote|The documentation reflects the state up to v1.10, pre 2016. For more modern documentation see [[BGS2 Doc]]}}
 +
 
== Overview ==
 
== Overview ==
 
[[BGS|BGS-M]] is the script for ambient sounds, music and image switches.
 
[[BGS|BGS-M]] is the script for ambient sounds, music and image switches.
Line 12: Line 14:
  
 
==== Effects ====
 
==== Effects ====
On <code>startUp</code> BGS checks the shader support level. If it's switched off or no shader support is available all effects are disabled.
+
On <code>startUp</code> BGS checks the shader support level. If it's switched off or no shader support is available all effects are disabled. See also [[#Docking FX|Docking FX]].
  
 
==== BGS-XMapping ====
 
==== BGS-XMapping ====
The script ships functionality to display more infos on the LongRangeChart via overlay if the player has bought the [[Advanced_Navigational_Array|Advanced Navigational Array]]. BGS-X will (when released) add the named regions and lanes from ClymAngus vector maps (see [[Oolite_planet_list]]).
+
The script ships functionality to display more infos on the LongRangeChart via overlay if the player has bought the [[Advanced_Navigational_Array|Advanced Navigational Array]]. It adds the named regions and lanes from ClymAngus vector maps (see [[Oolite_planet_list]]).
  
 
BGS uses [[Cabal_Common_Library_Doc_2DCollision|Cabal_Common_2DCollision()]] to check if the cursor is inside a specified polygon or on a specified line. Methods for inserting the datatsets are available (see [[#addToLRCSpecial()|addToLRCSpecial()]] and [[#addToLRC()|addToLRC()]]).
 
BGS uses [[Cabal_Common_Library_Doc_2DCollision|Cabal_Common_2DCollision()]] to check if the cursor is inside a specified polygon or on a specified line. Methods for inserting the datatsets are available (see [[#addToLRCSpecial()|addToLRCSpecial()]] and [[#addToLRC()|addToLRC()]]).
Line 40: Line 42:
 
=== stationMusic ===
 
=== stationMusic ===
 
:Boolean. Switches music in stations on/off. Default is true.<sup>OXPC</sup>
 
:Boolean. Switches music in stations on/off. Default is true.<sup>OXPC</sup>
 +
 +
=== bgsChatterPause ===
 +
:Number. Max pause for chatter in game seconds. Default 24.<sup>OXPC</sup> {{AV|1.7}}
  
 
=== bgsCountOffset ===
 
=== bgsCountOffset ===
Line 55: Line 60:
 
=== bgsDisableJump ===
 
=== bgsDisableJump ===
 
:Boolean. Disables spoken jumpcountdown. Default false.<sup>OXPC</sup>
 
:Boolean. Disables spoken jumpcountdown. Default false.<sup>OXPC</sup>
 +
 +
=== bgsDockingFX ===
 +
:Boolean. Shader effect on docking/launching. Default true.<sup>OXPC</sup> {{AV|1.9}}
  
 
=== bgsHyperFX ===
 
=== bgsHyperFX ===
Line 60: Line 68:
  
 
=== bgsHyperFXWormhole ===
 
=== bgsHyperFXWormhole ===
:Boolean. Wormhole exit point effect. Default true.<sup>OXPC</sup> (New in v1.6)
+
:Boolean. Wormhole exit point effect. Default true.<sup>OXPC</sup>
  
 
=== bgsHyperMove ===
 
=== bgsHyperMove ===
:Number. Move the playership forward to get rid of the breakpattern rings. Set to 0 to disable it. Ignored if bgsHyperFX is false. Default 500.<sup>OXPC</sup> Will be removed in v1.6.
+
:Number. Move the playership forward to get rid of the breakpattern rings. Set to 0 to disable it. Ignored if bgsHyperFX is false. Default 500.<sup>OXPC</sup> Removed in v1.6.
 +
 
 +
=== bgsImageSwitch ===
 +
:Boolean. If true BGS handles 'player died while on F5', <tt>bgsDisableCrowd</tt> and script_info <tt>bgs_nocrowd</tt> and adds interface backgrounds. Default true in BGS-A, false in BGS-M. BGS-I sets it to true in <tt>startUp</tt>.
  
 
=== bgsJitterRemove ===
 
=== bgsJitterRemove ===
:Number. In case uers have problems with their Joystick deadzones for throttle (resulting in playing engine sounds even at full stop) a finetuning option is available. Default 0.<sup>OXPC</sup> (New in v1.6)
+
:Number. In case uers have problems with their Joystick deadzones for throttle (resulting in playing engine sounds even at full stop) a finetuning option is available. Default 0.<sup>OXPC</sup>
  
 
=== bgsOff ===
 
=== bgsOff ===
Line 90: Line 101:
 
'''Returns:'''
 
'''Returns:'''
 
:;bool: Boolean. True on success.
 
:;bool: Boolean. True on success.
 +
  
 
=== addToLRC() ===
 
=== addToLRC() ===
 
{{CodeEx|codeex=addToLRC( obj )}}
 
{{CodeEx|codeex=addToLRC( obj )}}
Inserts a overlay as route or region. 4 different types can be used (circle, rectangle, npoly and route). Make sure that the object is extensible and not sealed or frozen.
+
Inserts a overlay as route or region. 4 different types can be used (circle, rectangle, npoly and route). BGS creates a bounding box based on the used type and positions to speed up the processing. Make sure that the object is extensible and not sealed or frozen.
  
 
'''Parameters:'''
 
'''Parameters:'''
Line 99: Line 111:
 
::;type:Number. Required. Range 1...4.
 
::;type:Number. Required. Range 1...4.
 
::;gal:Number. Required. Galaxy number in range 0...7.
 
::;gal:Number. Required. Galaxy number in range 0...7.
 +
::;disp:String. Required. String for [[#findOnLRC()|.findOnLRC]].
 
::;ov:String. Required. Filename for the overlay with extension.
 
::;ov:String. Required. Filename for the overlay with extension.
  
Line 126: Line 139:
 
'''Type 4 (Route):'''
 
'''Type 4 (Route):'''
 
:;pos:Array. Pairs of coordinates in LY in x,y format, e.g. [[8,34.6],[...]]
 
:;pos:Array. Pairs of coordinates in LY in x,y format, e.g. [[8,34.6],[...]]
 +
 +
 +
=== findOnLRC() ===
 +
{{CodeEx|codeex=findOnLRC( pos ) {{AV|1.10}} }}
 +
Collects matching map entries <tt>.disp</tt> properties which are added through [[#addToLRC()|.addToLRC]] and returns array.
 +
 +
'''Parameters:'''
 +
:;pos: Can be a Vector3D, Array with 3 numbers, Object with properties x,y,z or a Number (system.ID) in range 0...255.
 +
 +
'''Returns:'''
 +
:;matches:Array. Format <tt>[ [areas], [lanes] ]</tt>.
  
  
Line 149: Line 173:
 
:;bgs_nocrowd:Boolean. Station - disables the crowd sounds and switches images on F5.
 
:;bgs_nocrowd:Boolean. Station - disables the crowd sounds and switches images on F5.
 
:;bgs_nomusic:Boolean. Station - disables the music.
 
:;bgs_nomusic:Boolean. Station - disables the music.
 +
:;bgs_tunnel_off:Boolean. Station - disables the tunnel effect. (New in v1.9.1)
 +
:;bgs_tunnel_shape:Number. Station - range 0.38 - 5.0. If not specified the script takes the ratio of the first found dock bounding box x/y to get the shape. See also [[#Docking FX|Docking FX]]. (New in v1.9)
 +
::0.5 - square 45 degrees rotated with aspect ratio
 +
::1 - circle with aspect ratio
 +
::>1 - squircle...rectangle (>1.1 with decreased aspect ratio to get a wider tunnel)
 +
:;bgs_tunnel_texture:String/Filename. Station. See also [[#Docking FX|Docking FX]]. (New in v1.9)
  
 
Examples:
 
Examples:
  
 
Playership (with preloaded sounds):
 
Playership (with preloaded sounds):
{{CodeEx|codeex=script_info = {"bgs_engine" = "[vector_engine]"; "bgs_engineUp" = "[vector_engineUp]"; "bgs_engineDown" = "[vector_engineDown]";};}}
+
  script_info = {bgs_engine = "[vector_engine]"; bgs_engineUp = "[vector_engineUp]"; bgs_engineDown = "[vector_engineDown]";};
  
 
Playership (without preloaded sounds):
 
Playership (without preloaded sounds):
{{CodeEx|codeex=script_info = {"bgs_engine" = "myEngine.ogg"; "bgs_engineUp" = "myEngineUp.ogg"; "bgs_engineDown" = "myEngineDown.ogg";};}}
+
  script_info = {bgs_engine = "myEngine.ogg"; bgs_engineUp = "myEngineUp.ogg"; bgs_engineDown = "myEngineDown.ogg";};
  
 
Station:
 
Station:
{{CodeEx|codeex=script_info = {"bgs_music" = "buoyRepair_music.ogg"; "bgs_nocrowd" = true;};}}
+
  script_info = {bgs_music = "buoyRepair_music.ogg"; bgs_nocrowd = true;};
  
  
Line 177: Line 207:
  
 
Example:
 
Example:
{{CodeEx|codeex="BGS-COUNT" = "5";<br>"BGS-COUNTDOWN" = "bgstest";<br>"BGS-COUNTLAYER" = "bgstest";<br>"BGS-COUNTONLY" = "No";<br>"BGS-DISABLEJUMP" = "No";<br>"BGS-STATIONMUSIC_1" = "myMusicA.ogg";<br>// Without preloading<br>"BGS-CHATTER_1" = "myChatterA.ogg";<br>// With preloading<br>"BGS-CHATTER_1" = "[myChatterA]";}}
+
  "BGS-COUNT" = "5";
 +
  "BGS-COUNTDOWN" = "bgstest";
 +
  "BGS-COUNTLAYER" = "bgstest";
 +
  "BGS-COUNTONLY" = "No";
 +
  "BGS-DISABLEJUMP" = "No";
 +
  "BGS-STATIONMUSIC_1" = "myMusicA.ogg";
 +
  // Without preloading
 +
  "BGS-CHATTER_1" = "myChatterA.ogg";
 +
  // With preloading
 +
  "BGS-CHATTER_1" = "[myChatterA]";
  
  
Line 186: Line 225:
 
:;messages:If you want to disable some onscreen messages BGS ships now a “_descriptions.plist” that cleans them out.  Rename this file to activate it. This might be useful for eSpeak users.
 
:;messages:If you want to disable some onscreen messages BGS ships now a “_descriptions.plist” that cleans them out.  Rename this file to activate it. This might be useful for eSpeak users.
 
:;silence:If you want to disable a specific customsounds sound set the value to “bgs-m_silence.ogg” in customsounds.plist.
 
:;silence:If you want to disable a specific customsounds sound set the value to “bgs-m_silence.ogg” in customsounds.plist.
[[Category:OXPDoc]]
+
 
 +
 
 +
== For artists ==
 +
=== Docking FX ===
 +
<gallery widths="100px" heights="100px" perrow="5">
 +
File:Bgs docking effect 1.jpg|1.1
 +
File:Bgs docking effect 2.jpg|1.2
 +
File:Bgs docking effect 3.jpg|1.3
 +
File:Bgs docking effect 4.jpg|1.4
 +
File:Bgs docking effect 5.jpg|1.5
 +
</gallery>
 +
The effect is done via VisualEffect entity. The model is a plane and gets scaled to fullscreen (with z = -1).
 +
 
 +
The input texture (figure 1.1) gets wrapped around via abs(atan(y,x)) (figure 1.2). You can imagine this as a cylinder with infinite length and you are looking into it, with a mirror axis along x. As the shape can be adjusted we can reach square, circle and squircle (figure 1.3).
 +
 
 +
The shader applies then some glowing lines and adds a opening door. Artists don't have to care much about it - the shaders does it on it's own. The interesting bit though is the coloring of the door. It's taken from the input image and walks counter-clockwise (figure 1.4). The shader rotates it and zooms in, so we get a gradient (figure 1.5). Finally it gets mixed with the glowing lines to some extend to get a smoother transition between tunnel and door and a standard tint gets applied (rgb: 0.5626,0.3587,0.0858).
 +
 
 +
All in all it does some computation (atan, length, pow and sin/cos and 2 texture lookups), but still runs smooth even on my old GeForce Go 7950. The compiler in 6.14.11.7948 spits out 118 instructions, 5 R-reg and 1 H-reg, so it's not really cheap - later cards drivers may cut this down, based on the optimizations they are able to do.
 +
 
 +
 
 +
[[Category:OXP API's]]

Latest revision as of 13:42, 20 September 2023

Overview

BGS-M is the script for ambient sounds, music and image switches.

Cabal Common Library

BGS checks existance of Cabal Common Library and the internal version. If the requirement is not fullfilled the script gets completely disabled.

Autoconfiguration

Countdown

The timed countdowns are using single soundfiles for the countdown. BGS checks the keys in customsounds.plist ([galactic-hyperspace-countdown-begun] and [hyperspace-countdown-begun]) to see if another soundpack is using them. If so BGS disables its own countdown.

Additionally BGS checks the duration of the countdown (declared by OXPs via hyperspace_motor_spin_time for playerships) and adjusts it's own countdown.

Effects

On startUp BGS checks the shader support level. If it's switched off or no shader support is available all effects are disabled. See also Docking FX.

BGS-XMapping

The script ships functionality to display more infos on the LongRangeChart via overlay if the player has bought the Advanced Navigational Array. It adds the named regions and lanes from ClymAngus vector maps (see Oolite_planet_list).

BGS uses Cabal_Common_2DCollision() to check if the cursor is inside a specified polygon or on a specified line. Methods for inserting the datatsets are available (see addToLRCSpecial() and addToLRC()).


Properties

OXPC - Marked properties can be configured via OXPConfig.

ambientSounds

Boolean. Switches ambientSounds on/off. This switch affects the crowd layer in stations and engine mumble inflight. Default is true.OXPC

fxSounds

Boolean. Switches fxSounds on/off. This switch affects the screen based sounds in stations and engine up/down inflight. Default is true.OXPC

logging

Boolean. Switches extended logging on/off. Default is false.OXPC

stationMusic

Boolean. Switches music in stations on/off. Default is true.OXPC

bgsChatterPause

Number. Max pause for chatter in game seconds. Default 24.OXPC Added in v1.7

bgsCountOffset

Number. Switches the nextTime for the countdown timer to clock.absoluteSeconds+offset (0...0.3). This can help to ‘correct’ the countdown if the displayed messages are not in sync with the spoken countdown. Default 0.OXPC

bgsDelay

Integer. Defines the delay in milliseconds between mission screens before BGS re-enables its features. Default 600.OXPC

bgsDisableChatter

Boolean. Disables radio chatter when in station aegis. Default false.OXPC

bgsDisableCrowd

Boolean. Disables crowd noise in stations. Default is false.OXPC

bgsDisableJump

Boolean. Disables spoken jumpcountdown. Default false.OXPC

bgsDockingFX

Boolean. Shader effect on docking/launching. Default true.OXPC Added in v1.9

bgsHyperFX

Boolean. Shader effect for hyperjumps. If no shader support available the script sets it to false. Default true.OXPC

bgsHyperFXWormhole

Boolean. Wormhole exit point effect. Default true.OXPC

bgsHyperMove

Number. Move the playership forward to get rid of the breakpattern rings. Set to 0 to disable it. Ignored if bgsHyperFX is false. Default 500.OXPC Removed in v1.6.

bgsImageSwitch

Boolean. If true BGS handles 'player died while on F5', bgsDisableCrowd and script_info bgs_nocrowd and adds interface backgrounds. Default true in BGS-A, false in BGS-M. BGS-I sets it to true in startUp.

bgsJitterRemove

Number. In case uers have problems with their Joystick deadzones for throttle (resulting in playing engine sounds even at full stop) a finetuning option is available. Default 0.OXPC

bgsOff

Boolean. Disables some BGS functions (all when docked, chatter when inflight). It is primarily meant for mission OXPs and stations where no additional functions are available or if the features would interfere. Scripts are responsible to reset it when used, but BGS resets it on its own on shipWillLaunchFromStation, playerCancelledJumpCountdown, playerJumpFailed and playerStartedAutoPilot. Default false.
worldScripts["BGS-M"].bgsOff = true;

bgsQPatch

Boolean. QMine monkeypatch. If true, implement sound for QMines. Only processed on startUp. Default false.OXPC


Methods

addToLRCSpecial()

addToLRCSpecial( obj )

Inserts a overlay for the special keys. Make sure that the object is extensible and not sealed or frozen.

Parameters:

obj
Object with the following properties
gal
Number. Required. Galaxy number in range 0...7.
ov
String. Required. Filename for the overlay with extension.
txt
String. Required. Text to be displayed.
check
String. Optional. worldScript name to be checked.

Returns:

bool
Boolean. True on success.


addToLRC()

addToLRC( obj )

Inserts a overlay as route or region. 4 different types can be used (circle, rectangle, npoly and route). BGS creates a bounding box based on the used type and positions to speed up the processing. Make sure that the object is extensible and not sealed or frozen.

Parameters:

obj
Object.
type
Number. Required. Range 1...4.
gal
Number. Required. Galaxy number in range 0...7.
disp
String. Required. String for .findOnLRC.
ov
String. Required. Filename for the overlay with extension.

Returns:

bool
Boolean. True on success.


Additional properties are required for the different types:

Type 1 (Circle):

posx
Number. Position of the center. X coordinate in LY.
posy
Number. Position of the center. Y coordinate in LY.
radi
Number. Radius.

Type 2 (Rectangle):

posx
Number. Position of the center. X coordinate in LY.
posy
Number. Position of the center. Y coordinate in LY.
w
Number. Width.
h
Number. Height.

Type 3 (nPoly):

nvert
Number. Number of points.
ax
Array. X coordinates in LY.
ay
Array. Y coordinates in LY.
con
Boolean. Optional. Concave shapes may need to set it.

Type 4 (Route):

pos
Array. Pairs of coordinates in LY in x,y format, e.g. [[8,34.6],[...]]


findOnLRC()

findOnLRC( pos ) Added in v1.10

Collects matching map entries .disp properties which are added through .addToLRC and returns array.

Parameters:

pos
Can be a Vector3D, Array with 3 numbers, Object with properties x,y,z or a Number (system.ID) in range 0...255.

Returns:

matches
Array. Format [ [areas], [lanes] ].


player.ship.script

Some properties are checked on every launch. They have priority above specified script_info entries.

Keys

bgs_engine
String/Filename. Playership - engine mumble sound.
bgs_engineUp
String/Filename. Playership - engine acceleration sound.
bgs_engineDown
String/Filename. Playership - engine deceleration sound.


shipdata.plist

Additional keys for specific entities are available and can be specified via script_info dictionary.

Keys

bgs_chatter
String. Station - Chatter sound files for mainStation. Multiple files can be separated by “|”.
bgs_countonly
Boolean. Playership - spoken countdown only.
bgs_engine
String/Filename. Playership - engine mumble sound.
bgs_engineUp
String/Filename. Playership - engine acceleration sound.
bgs_engineDown
String/Filename. Playership - engine deceleration sound.
bgs_music
String/Filename. Station - music file for specific station.
bgs_nocrowd
Boolean. Station - disables the crowd sounds and switches images on F5.
bgs_nomusic
Boolean. Station - disables the music.
bgs_tunnel_off
Boolean. Station - disables the tunnel effect. (New in v1.9.1)
bgs_tunnel_shape
Number. Station - range 0.38 - 5.0. If not specified the script takes the ratio of the first found dock bounding box x/y to get the shape. See also Docking FX. (New in v1.9)
0.5 - square 45 degrees rotated with aspect ratio
1 - circle with aspect ratio
>1 - squircle...rectangle (>1.1 with decreased aspect ratio to get a wider tunnel)
bgs_tunnel_texture
String/Filename. Station. See also Docking FX. (New in v1.9)

Examples:

Playership (with preloaded sounds):

 script_info = {bgs_engine = "[vector_engine]"; bgs_engineUp = "[vector_engineUp]"; bgs_engineDown = "[vector_engineDown]";};

Playership (without preloaded sounds):

 script_info = {bgs_engine = "myEngine.ogg"; bgs_engineUp = "myEngineUp.ogg"; bgs_engineDown = "myEngineDown.ogg";};

Station:

 script_info = {bgs_music = "buoyRepair_music.ogg"; bgs_nocrowd = true;};


missiontext.plist

Additional keys specially for other soundpacks are available.

Please note that these options have been removed in v1.6.

Keys

BGS-CHATTER_1
String. Chatter sound files to be added to the soundPool. Keys “BGS-CHATTER_1” ... “BGS-CHATTER_5” are examined. Multiple files can be separated by “|”.
BGS-COUNT
String. Defines used countdown in range 1-10.
BGS-COUNTDOWN
String. Defines names for used countdown. [BGS-COUNT] is required! The filenames will be build -> name+[BGS-COUNT]+’.ogg’ and counted down to zero! So BGS expects [BGS-COUNT] + 1 files!
BGS-COUNTLAYER
String. Defines name of ambient part for galactic and standard jump. BGS looks for name+”g.ogg” and name+”h.ogg”.
BGS-COUNTONLY
String. Bypasses ambient sounds for jumping, but leaves the countdown. Set to “No” to avoid deactivation.
BGS-DISABLEJUMP
String. Disables timed jumpcountdown (overrides this.bgsDisableJump). Set to “No” to avoid deactivation.
BGS-STATIONMUSIC_1
String. Ambient music files to be added to the musicPool. Keys “BGS-STATIONMUSIC_1” ... “BGS-STATIONMUSIC_5” are examined. Multiple files can be separated by “|”.

Example:

 "BGS-COUNT" = "5";
 "BGS-COUNTDOWN" = "bgstest";
 "BGS-COUNTLAYER" = "bgstest";
 "BGS-COUNTONLY" = "No";
 "BGS-DISABLEJUMP" = "No";
 "BGS-STATIONMUSIC_1" = "myMusicA.ogg";
 // Without preloading
 "BGS-CHATTER_1" = "myChatterA.ogg";
 // With preloading
 "BGS-CHATTER_1" = "[myChatterA]";


Additional features

BGS ships some ‘hidden’ features.

hidden sounds
The alternative trumble sounds are outcommented. To activate them remove the comment (“//”) for both keys (“[trumble-idle]” and “[trumble-squeal]”) in customsounds.plist.
messages
If you want to disable some onscreen messages BGS ships now a “_descriptions.plist” that cleans them out. Rename this file to activate it. This might be useful for eSpeak users.
silence
If you want to disable a specific customsounds sound set the value to “bgs-m_silence.ogg” in customsounds.plist.


For artists

Docking FX

The effect is done via VisualEffect entity. The model is a plane and gets scaled to fullscreen (with z = -1).

The input texture (figure 1.1) gets wrapped around via abs(atan(y,x)) (figure 1.2). You can imagine this as a cylinder with infinite length and you are looking into it, with a mirror axis along x. As the shape can be adjusted we can reach square, circle and squircle (figure 1.3).

The shader applies then some glowing lines and adds a opening door. Artists don't have to care much about it - the shaders does it on it's own. The interesting bit though is the coloring of the door. It's taken from the input image and walks counter-clockwise (figure 1.4). The shader rotates it and zooms in, so we get a gradient (figure 1.5). Finally it gets mixed with the glowing lines to some extend to get a smoother transition between tunnel and door and a standard tint gets applied (rgb: 0.5626,0.3587,0.0858).

All in all it does some computation (atan, length, pow and sin/cos and 2 texture lookups), but still runs smooth even on my old GeForce Go 7950. The compiler in 6.14.11.7948 spits out 118 instructions, 5 R-reg and 1 H-reg, so it's not really cheap - later cards drivers may cut this down, based on the optimizations they are able to do.