BSL:Tutorial/Console: Difference between revisions
(rewrote/completed the tutorial) |
m (fixed AI name label on Konoko) |
||
(One intermediate revision by the same user not shown) | |||
Line 34: | Line 34: | ||
---- | ---- | ||
{|style="float:right" | {|style="float:right" | ||
|+<tt>''' | |+<tt>'''char_0'''</tt> | ||
|[[Image:Konoko 1.gif]] | |[[Image:Konoko 1.gif]] | ||
|} | |} | ||
Line 86: | Line 86: | ||
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]]. | 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 | 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" 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.
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.
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.