85
edits
Line 76: | Line 76: | ||
== Part 4: First Script == | == Part 4: First Script == | ||
This section will teach you how to write a very basic | This section will teach you how to write a very basic script (fighting script). It will start you off in the Final Training Room, where you practiced firing weapons in the original game. With this script, the room will appear very empty. | ||
Let's open up | Let's open up the "Tutorial.bsl" file and start writing the script. | ||
First, declare it the "main" portion of the script by typing "<tt>func void main(void)</tt> at the very beginning of the file. This tells the game which function it is. The "main" function is the function that the game looks at first to determine what is to be executed. | First, declare it the "main" portion of the script by typing "<tt>func void main(void)</tt> at the very beginning of the file. This tells the game which function it is. The "main" function is the function that the game looks at first to determine what is to be executed. | ||
Line 84: | Line 84: | ||
Below that line, type '''{'''. This tells the game that the function has started. | Below that line, type '''{'''. This tells the game that the function has started. | ||
. | Add a space, and then type <tt>chr_teleport 0 7010</tt>. This function teleports Konoko (her id is always 0) to the flag 7010. It is located in the final training room. | ||
. | |||
. | Finish the function "main" by typing '''}''' on the next line. | ||
It should look like this: | |||
<tt>func void main(void)<br> | |||
{<br> | |||
chr_teleport 0 7010<br> | |||
}</tt> | |||
Save the file, load up Oni, and click "New Game". You should be standing in the center of the final combat training room. | |||
You are now on your way! | |||
---- | |||
== Part 5: Adding NPCs (AI) == | |||
Before we begin, notice that there are two types of AI. AI created from character objects, and AI created from memory. AI created from character objects are created by the function call <tt>ai2_spawn (name)</tt>, where (name) is the name of the AI. AI created from memory are created by the function call <tt>chr_create (ai_number) start,</tt>. These AI do not have combat logic, and thus will not attack you physically but can still use weapons. | |||
Now, we are going to add 2 enemy AI to our script that we wrote in the last section. Open it up, and lets add some enemies for Konoko to fight. | |||
To recap, it should look like this : | |||
<tt>func void main(void)<br> | |||
{<br> | |||
chr_teleport 0 7010<br> | |||
}</tt> | |||
After the function call <tt>chr_teleport 0 7010</tt>, add the following 2 function calls on separate lines: <tt>ai2_spawn Top_Striker</tt> and <tt>ai2_spawn Top_Comguy</tt>. These two function calls tell the game to create 2 characters: Top_Striker, and Top_Comguy. | |||
Since that these characters do not spawn in the room, they must be teleported there. Using the <tt>chr_teleport</tt> function call used earlier to teleport yourself, modify it to teleport the 2 AI using their names instead of "0". Teleport them to the flags "7008" and "7009" respectively. Refer to the example above or the list of function calls above to write this in. | |||
It should now look like this : | |||
<tt>func void main(void)<br> | |||
{<br> | |||
chr_teleport 0 7010<br> | |||
ai2_spawn Top_Striker<br> | |||
ai2_spawn Top_Comguy<br> | |||
chr_teleport Top_Striker 7008<br> | |||
chr_teleport Top_Comguy 7009<br> | |||
}</tt> | |||
This script will now teleport you into the final training room and face you off against 2 Strikers. | |||
This fight too easy? In the next section, we will learn how to spice up the fight, and let you develop your own script. | |||
Why isn't it in the OSL namespace???[[User:Geyser|geyser]] 06:04, 15 Nov 2005 (CET) | Why isn't it in the OSL namespace???[[User:Geyser|geyser]] 06:04, 15 Nov 2005 (CET) | ||
Changed (?) | |||
- Your_Mom | - Your_Mom |
edits