BSL:BFW Scripting Language: Difference between revisions

From OniGalore
Jump to navigation Jump to search
m (Iritscen moved page BSL:BungieFrameWork Scripting Language to BSL:BFW Scripting Language without leaving a redirect: It's unwieldy and unnecessary to spell out the BFW acronym in the page name.)
m (no need to expand acronym here; user can read about BFW on Modding Oni if he wants)
Line 1: Line 1:
'''BungieFrameWork Scripting Language (or BSL)''' is what Oni scripts are written in. Being a scripting language, it is far more limited in scope and usage than a "real" programming language, as it was designed only to move events forward in the game, not to build programs.
'''[[Modding_Oni#Introduction_to_the_Oni_engine|BFW]] Scripting Language (or BSL)''' is what Oni scripts are written in. Being a scripting language, it is far more limited in scope and usage than a "real" programming language, as it was designed only to move events forward in the game, not to build programs.


==What Are Scripts?==
==What Are Scripts?==

Revision as of 16:12, 2 December 2015

BFW Scripting Language (or BSL) is what Oni scripts are written in. Being a scripting language, it is far more limited in scope and usage than a "real" programming language, as it was designed only to move events forward in the game, not to build programs.

What Are Scripts?

Scripts are the files that drive level logic, environment effects, and cutscenes. Physically speaking, they are the .bsl files inside the folder Oni/GameDataFolder/IGMD/. By editing scripts, you can alter how the game plays.

Editing Scripts

Scripts can be edited with the simplest of word-processing programs, such as the built-in WordPad (Windows) or TextEdit (Mac). They can be edited simply by typing inside the file. When saving, you must either ensure that the suffix is .bsl or that you use the suffix .txt and afterwards change it to .bsl. In Windows, you may have to turn on the displaying of file extensions to see the suffix.

- To learn BSL by example, you can read the .bsl files in Oni's IGMD folder and draw connections to the events in the game that were produced by those scripts.
- For a primer in writing BSL, see the Tutorials section below.
- For a thorough listing of what's possible in BSL (a reference, not a primer), see the Knowledge Database below.
- Typing dump_docs in the game console will generate the file script_commands.txt listing all BSL commands & variables.

Scripted Mods

Scripted mods are great examples of what can be accomplished by editing scripts. They replace or add to Oni's .bsl files to create interesting and often amusing results. They can change everything from the fog to how the characters and level interact. However, they cannot add new characters or change the level layout, as that data is fixed by the Binaries. They are great examples of what can be achieved simply by typing into a text file. The possibilities are simply endless.

Probably the best specimens of scripted mods are the Oni Team Arena scripts. Based on the desire for a multi-player mode in Oni, and inspired by Unreal Tournament, they augment Oni's hand-to-hand combat and gunplay with a scoring system much like Unreal Tournament's DeathMatch.

Other scripted mods range from free-for-all arenas to objective-based missions and enhancements of the original levels. They can spice up the gameplay and provide a more exciting experience to those who have finished the game. They keep the game alive, outside of its original levels.

Downloads

Downloads of OTA Mods are available at the Oni Team Arena page.

Downloads for other scripted mods can be gathered here, here and here.

Tutorials

For the practical minds who don't care (too much) about theory, the BSL:Tutorial page offers the following paths for you to explore:

  • Wanna make minor (yet cool-looking) changes to the original level logic? Read this.
  • Wanna script a "patch" that's effective in every level but doesn't change the original logic? Then go here.
  • Wanna create completely new level logic from scratch? Here you are.

Knowledge Database

Documentation that describes the locations that BSL scripts reside in:

Syntax Overview

BSL syntax overview table
BSL separators
; , # "
{ } ( )

Click on a separator for details

BSL operators
+ - = !
and or eq ne
< > <= >=

Click on an operator for details

BSL keywords
at float if repeat string
bool for int return using
else fork iterate schedule var
every func over sleep void

Click on a keyword for details

Code pieces

Character setup

# an old but useful character setup function by geyser
func SpawnNameFlagHealthReset(string n, int f, int h, int r){
    ai2_spawn(n); chr_teleport(n, f)
    if(h) chr_set_health(n, h)
    if(r) chr_inv_reset(n)
}

# can be like this ...
func wave_setup {
    # note that missing arguments are taken to be 0
    SpawnNameFlagHealthReset Griffin 23 600
    SpawnNameFlagHealthReset Muro 22 2500
    SpawnNameFlagHealthReset F_Er89 22 80 1
    SpawnNameFlagHealthReset A_S1 24
} 


Follow me

var bool follow_me = 1;


### begin of the journey
func follow_me_TV
{
	# ai2_spawn charname # or somewhere else
	chr_lock_active charname

	fork follow
}

func follow
{
	if (follow_me eq 1)
	{
		ai2_followme charname
		ai2_setmovementmode charname run
		sleep 180
		fork follow
	}
}


### events
func dont_follow_me_TV_enter
{
	follow_me = 0
}

func dont_follow_me_TV_extit
{
	follow_me = 1
	fork follow
}


### player orders
func main
{
	# ...
	fork do_follow_me
	fork dont_follow_me
}

func do_follow_me
{
	chr_wait_animation 0 ORDERbk_fw_kick
	follow_me = 1
	follow
	# for the case he/she is passive right now
	ai2_passive charname 0

	# sleep until anim finished
	sleep 60
	fork do_follow_me
}

func dont_follow_me
{
	chr_wait_animation 0 ORDERbk_fw_punch
	follow_me = 0
	ai2_idle charname

	# sleep until anim finished
	sleep 60
	fork dont_follow_me
}