BSL:Tutorial/Console: Difference between revisions

From OniGalore
Jump to navigation Jump to search
m (localized images)
m (fixed AI name label on Konoko)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Scripting from the Developer Mode console==
The quickest way to jump into learning BSL is to enter single commands into the developer console and see their effect. Once you understand what the basic commands do, you will be ready to assemble them into functions and create entire level scripts.
In this tutorial, you are supposed to enter single BSL commands in real time, from the console, and watch their effect.


Once you understand what the basic commands do, you will be ready to assemble them into [[BSL:Functions|functions]] and level logic files.
The developer console (usually just called "the console") is a feature of [[Developer Mode]]. Developer Mode was disabled for shipping builds of Oni, but it was re-enabled by the [[Daodan DLL]], so if you have the DLL or the [[Anniversary Edition]] installed, you are ready to use it.
----
 
The "console" is a feature of the [[thedayismine|Developer Mode]].
You activate Dev Mode with the cheat '''thedayismine''' or simply '''x'''. You enter the console by pressing the '''console''' key, which is the '~' key or the key between Esc and Tab (see [[Developer Mode#Using the console|HERE]] for help). The console should appear as a "CMD:" prompt in the bottom-left corner of the screen. You should be able to type and see input on the prompt line, and once you enter a command you should see output printed above the prompt. In the tutorial below, you should type the commands which are set like this:
:You enter the Dev Mode with the cheat '''thedayismine''', or '''x'''.
 
:You turn on the console by pressing the '''console''' key (between Esc and Tab).
CMD: type this


The console appears as a "CMD: " prompt in the bottom left corner.
…and then hit Enter to send them.
:Input appears in the line to the right of that prompt.
:Output is printed in the lines above that prompt.
----
If for some reason you can not do one of the following -
:enter the Dev Mode, or
:turn on the console, or
:see the output, or
:see the input
- just say so on the talk page and we will help you.


==A_t48==
==A_t48, why aren't you at your post?==
{|style="float:right"
{|style="float:right"
|+<tt>'''A_t48'''</tt>
|+<tt>'''A_t48'''</tt>
Line 25: Line 15:
|}
|}


"A_t48" is the name of the very first enemy that you encounter in Oni (training droids do not count).
"A_t48" is the name of the very first enemy that you encounter in Oni: a "thug" patrolling the first room in the Syndicate Warehouse. This exercise is going to find a new purpose for him. Load the first save point in Chapter 1.
:It's a "thug" patrolling the first room in the Syndicate Warehouse.
 
We are going to stay in this room and study him. We do '''not''' want to fight him.
First, we are going to stay in this room and study him. We do '''not''' want to fight him. So you should make yourself invisible with the '''moonshadow''' cheat. Now he can't see us. If we don't want him to hear us, either, we can creep.
:The very first thing is to become invisible, with the '''moonshadow''' cheat.
 
:Now he can't see us. If we don't want him to hear us, either, we can creep.
Now, let's do a very simple thing at the console: setting a built-in [[BSL:Variables|variable]]. First let's check its value.
:(Or we can move far away from his patrol, and use the camera from there.)
 
CMD: ai2_deaf
 
The output should be "bool: 0". This means that '''ai2_deaf''' is the name of a "boolean" variable (true/false), and that the ''value'' of the variable named '''ai2_deaf''' is currently set to "false" (0). This means the AI ''aren't'' deaf, but if '''ai2_deaf''' is "true", then they ''are''. We will now change that value to "true" (1):
 
CMD: ai2_deaf=1
 
You should get the output "int32: 1", meaning that the value was set to "true" (1). We can double-check our success:


Now, let's do a very simple thing at the console, such as setting a [[BSL:Variables|variable]].
CMD: ai2_deaf
:Type the word "ai2_deaf" at the console and press Enter. The output will be "bool: 0"
 
:This means that '''ai2_deaf''' is the name of a "boolean" variable (true/false),
You should get the output "bool: 1" instead of "bool: 0". Now all of Oni's AI will be completely deaf. That includes the A_t48 thug, so we don't have to creep any more.
:and that the ''value'' of that variable named '''ai2_deaf''' is currently set to "false" (0).
:It is actually a switch. Normally the AI ''aren't'' deaf, but if '''ai2_deaf''' is "true", then they ''are''.
:We will now change that value to "true" (1), by entering either '''ai2_deaf=1''' or '''ai2_deaf=true'''
:After we've entered that, we'll get the output "int32: 1" or "bool: 1", meaning that the value was set to "true" (1).
:We can check the success by entering '''ai2_deaf''' again, getting the output "bool: 1" instead of "bool: 0".
:Now all of Oni's AI will be completely deaf. That includes the A_t48 thug, so we don't have to creep any more.
----
----
{|style="float:right"
{|style="float:right"
Line 46: Line 37:
|[[Image:Konoko 1.gif]]
|[[Image:Konoko 1.gif]]
|}
|}
Now, we are going to set the variable named "ai2_shownames" (default value 0) to 1.
Now, we are going to turn on name tags above everyone's head. This shows a useful way to tell which AI you are looking at. As you type these commands, note that the console will offer autocomplete suggestions with names of functions and variables. Hit Tab to use the autocomplete if you see the command you desire. You can also keep pressing Tab or Shift-Tab to cycle forward or backward through the autocomplete suggestions.
:Enter '''ai2_shownames=1''' or '''ai2_shownames=true''' the console.
 
:You will see name tags appear both above "A_t48" and Konoko ("char_0").
CMD: ai2_shownames=1
:There are many other variables in Oni. You can find a full list [[BSL:Variables|HERE]].
 
You will see name tags appear both above "A_t48" and Konoko ("char_0"). These are their scripting names.
----
----
Now, we are going to give him a weapon, for example the Van de Graaff pistol (stun gun).
Now, we are going to give him a weapon, the Van de Graaff pistol (stun gun).
:At the console, type '''chr_giveweapon A_t48 w6_vdg''' or '''chr_giveweapon(A_t48,w6_vdg)''' and press Enter.
 
:What we did here is, we called the [[BSL:Functions|function]] '''chr_giveweapon''' with two parameters '''A_t48''' and '''w6_vdg'''.
CMD: chr_giveweapon A_t48 w6_vdg
:The first parameter ("A_t48") is the name of the character that we want to give a weapon to.
:The second parameter ("w6_vdg") is the name of the [[ONWC|weapon]] that we want to give to him.
:The parameters can be space-separated, or they can be comma-separated in parentheses.


Now, we are going to take that weapon away, by resetting that character's inventory.
As long as you don't get an error in the console output, you typed the command correctly and should now see the AI carrying the weapon. What we did here is call the built-in function '''chr_giveweapon''' with two parameters, '''A_t48''' and '''w6_vdg'''. The first parameter is the name of the character that we want to give a weapon to. The second parameter is the name of the weapon we want to give to him. The parameters can be space-separated, or they can be comma-separated in parentheses: "chr_giveweapon(A_t48, w6_vdg)" would also have worked.
:At the console, type '''chr_inv_reset A_t48''' or '''chr_inv_reset(A_t48)''' and press Enter.
:This is the same as above, except we are calling the function '''chr_inv_reset''',
:and that this function takes only one parameter - the name of a character.
----
----
{|style="float:right"
{|style="float:right"
Line 67: Line 53:
|[[Image:Comm Trooper 3.gif]]
|[[Image:Comm Trooper 3.gif]]
|}
|}
We can also change A_t48 into a [[Comguy]], if we like.
We'll also change A_t48 into a [[Comguy]], who has superior fighting skills.
:At the console, type '''chr_set_class 1 comguy_3''' or '''chr_set_class(1,comguy_3)''' and press Enter.
 
:Now the first parameter is the "index" of the character to be "shapeshifted". In this case, it is 1.
CMD: chr_set_class 1 comguy_3
:Konoko has index 0 because she appears first, and the thug has index 1 because he appears next.
 
:The second parameter of '''chr_set_class''' is the name of the [[ONCC|character class]] to change to.
This function's first parameter takes not the script name but the "index" of the character to be "shapeshifted". Konoko has index 0 because she spawns first in the level, and the thug has index 1 because he spawns next. The second parameter of '''chr_set_class''' is the name of the character class to which the target should be changed.
----
Now we're going to place him on our side. This will make him stop wanting to attack us.
 
CMD: chr_changeteam A_t48 Konoko
 
This function takes the name of a character and a team to place them on; the choices are Konoko, TCTF, Syndicate, Neutral, SecurityGuard, RogueKonoko, Switzerland, SyndicateAccessory, which are explained elsewhere on the wiki. You can now make yourself visible again by turning off the "moonshadow" cheat and the Comguy will not attack you when he sees you. Let's also allow AIs to hear again:
 
CMD: ai2_deaf=0
 
Now we're going to give our Comguy better mobility:
 
CMD: ai2_setmovementmode A_t48 run
 
You'll notice he is now ''very'' enthusiastic about his patrol route. We're going to give him another outlet for his energy soon. First we need to perform some housekeeping:
 
CMD: trigvolume_enable trigger_volume_64 0
CMD: door_unlock 6
CMD: door_unlock 108
CMD: ai2_spawn Bay1_Thug_1
 
What you just did was disable a trigger volume outside of the first room in Warehouse which would force A_t48 to attack you, then you unlocked two doors that were going to get in your way, and then you spawned the second enemy which players encounter in the game. Now let's get our newfound friend to help us:
 
CMD: ai2_attack A_t48 Bay1_Thug_1
 
Follow him, Konoko! The Comguy is going to seek out the Thug upstairs, and he's going to move fast. When he reaches him, he'll attack with his weapon in hand. You can take advantage of the taser hits to eliminate his target, or just let the Comguy tase the Thug repeatedly until he runs out of ammo, at which point he will close in for melee. It would be nice to have a wingman like this all the time, wouldn't it?
----
This is just a sampling of the power that BSL gives you. There are over 500 built-in variables and functions in Oni. You can find a full list of them at [[BSL:Functions]] and [[BSL:Variables]].


More, later.
P.S.: Note that there are some things you can't do on the console that are essential to scripting, such as declaring a function. The [[../Scratch|next tutorial]] will show how to write complete scripts in .bsl files.


[[Category:Modding tutorials]]
[[Category:Modding tutorials]]

Latest revision as of 17:38, 7 December 2023

The quickest way to jump into learning BSL is to enter single commands into the developer console and see their effect. Once you understand what the basic commands do, you will be ready to assemble them into functions and create entire level scripts.

The developer console (usually just called "the console") is a feature of Developer Mode. Developer Mode was disabled for shipping builds of Oni, but it was re-enabled by the Daodan DLL, so if you have the DLL or the Anniversary Edition installed, you are ready to use it.

You activate Dev Mode with the cheat thedayismine or simply x. You enter the console by pressing the console key, which is the '~' key or the key between Esc and Tab (see HERE for help). The console should appear as a "CMD:" prompt in the bottom-left corner of the screen. You should be able to type and see input on the prompt line, and once you enter a command you should see output printed above the prompt. In the tutorial below, you should type the commands which are set like this:

CMD: type this

…and then hit Enter to send them.

A_t48, why aren't you at your post?

A_t48
Thug.gif

"A_t48" is the name of the very first enemy that you encounter in Oni: a "thug" patrolling the first room in the Syndicate Warehouse. This exercise is going to find a new purpose for him. Load the first save point in Chapter 1.

First, we are going to stay in this room and study him. We do not want to fight him. So you should make yourself invisible with the moonshadow cheat. Now he can't see us. If we don't want him to hear us, either, we can creep.

Now, let's do a very simple thing at the console: setting a built-in variable. First let's check its value.

CMD: ai2_deaf

The output should be "bool: 0". This means that ai2_deaf is the name of a "boolean" variable (true/false), and that the value of the variable named ai2_deaf is currently set to "false" (0). This means the AI aren't deaf, but if ai2_deaf is "true", then they are. We will now change that value to "true" (1):

CMD: ai2_deaf=1

You should get the output "int32: 1", meaning that the value was set to "true" (1). We can double-check our success:

CMD: ai2_deaf

You should get the output "bool: 1" instead of "bool: 0". Now all of Oni's AI will be completely deaf. That includes the A_t48 thug, so we don't have to creep any more.


char_0
Konoko 1.gif

Now, we are going to turn on name tags above everyone's head. This shows a useful way to tell which AI you are looking at. As you type these commands, note that the console will offer autocomplete suggestions with names of functions and variables. Hit Tab to use the autocomplete if you see the command you desire. You can also keep pressing Tab or Shift-Tab to cycle forward or backward through the autocomplete suggestions.

CMD: ai2_shownames=1

You will see name tags appear both above "A_t48" and Konoko ("char_0"). These are their scripting names.


Now, we are going to give him a weapon, the Van de Graaff pistol (stun gun).

CMD: chr_giveweapon A_t48 w6_vdg

As long as you don't get an error in the console output, you typed the command correctly and should now see the AI carrying the weapon. What we did here is call the built-in function chr_giveweapon with two parameters, A_t48 and w6_vdg. The first parameter is the name of the character that we want to give a weapon to. The second parameter is the name of the weapon we want to give to him. The parameters can be space-separated, or they can be comma-separated in parentheses: "chr_giveweapon(A_t48, w6_vdg)" would also have worked.


A_t48
Comm Trooper 3.gif

We'll also change A_t48 into a Comguy, who has superior fighting skills.

CMD: chr_set_class 1 comguy_3

This function's first parameter takes not the script name but the "index" of the character to be "shapeshifted". Konoko has index 0 because she spawns first in the level, and the thug has index 1 because he spawns next. The second parameter of chr_set_class is the name of the character class to which the target should be changed.


Now we're going to place him on our side. This will make him stop wanting to attack us.

CMD: chr_changeteam A_t48 Konoko

This function takes the name of a character and a team to place them on; the choices are Konoko, TCTF, Syndicate, Neutral, SecurityGuard, RogueKonoko, Switzerland, SyndicateAccessory, which are explained elsewhere on the wiki. You can now make yourself visible again by turning off the "moonshadow" cheat and the Comguy will not attack you when he sees you. Let's also allow AIs to hear again:

CMD: ai2_deaf=0

Now we're going to give our Comguy better mobility:

CMD: ai2_setmovementmode A_t48 run

You'll notice he is now very enthusiastic about his patrol route. We're going to give him another outlet for his energy soon. First we need to perform some housekeeping:

CMD: trigvolume_enable trigger_volume_64 0
CMD: door_unlock 6
CMD: door_unlock 108
CMD: ai2_spawn Bay1_Thug_1

What you just did was disable a trigger volume outside of the first room in Warehouse which would force A_t48 to attack you, then you unlocked two doors that were going to get in your way, and then you spawned the second enemy which players encounter in the game. Now let's get our newfound friend to help us:

CMD: ai2_attack A_t48 Bay1_Thug_1

Follow him, Konoko! The Comguy is going to seek out the Thug upstairs, and he's going to move fast. When he reaches him, he'll attack with his weapon in hand. You can take advantage of the taser hits to eliminate his target, or just let the Comguy tase the Thug repeatedly until he runs out of ammo, at which point he will close in for melee. It would be nice to have a wingman like this all the time, wouldn't it?


This is just a sampling of the power that BSL gives you. There are over 500 built-in variables and functions in Oni. You can find a full list of them at BSL:Functions and BSL:Variables.

P.S.: Note that there are some things you can't do on the console that are essential to scripting, such as declaring a function. The next tutorial will show how to write complete scripts in .bsl files.