Difference between revisions of "RPG tutorial"

From Platinum Arts Sandbox Free 3D Game Maker
Jump to: navigation, search
(Part 2)
Line 46: Line 46:
  
 
This section of the tutorial involves spawning a neutral NPC and assigning him some dialogue
 
This section of the tutorial involves spawning a neutral NPC and assigning him some dialogue
 +
 +
 +
We can go about this in a few ways, but we'll start by first defining the NPC's script, the NPC, and then creating a place for him in the world.
 +
 +
First off, go to your definitions directory (probably data/rpg/games/tutorial) and then enter the script subdirectory. You will not want to create a new configuration file and place it at the very end of the others (eg, if the last is named 7.cfg, name yours 8.cfg). In this file, we define how any entities using it will react and interact with the surrounding world. Since we don't want to bother with that, we will simply include the default NPC script.
 +
 +
Afterwards we can start defining the dialogue. When you're done the final script should look something like this. Feel free to experiment by writing more dialogue and fleshing out your character
 +
 +
<code>
 +
  include scripts/1 //includes the default NPC script
 +
 
 +
  r_script_say "Hello, how are you doing" [ // 0 - it's good practice to number your entries
 +
    r_response "I'm well, yourself?" 1 //goes to dialogue #1
 +
    r_response "Goodbye" -1 //closes the dialogue
 +
  ]
 +
 
 +
  r_script_say "I'm glad to hear it" [ // 1
 +
    r_response "Goodbye" -1
 +
  ]
 +
</code>
 +
 +
With that taken care of, we will now define a critter to use the script. All critter configuration options are prefixed with r_char and most contain a variant with a _get suffix for retrieving the value. Now create a new cfg file in the critter sub directory, following the same steps as you did for the script to define it's name. This will probably be 0.cfg.
 +
 +
Consult the configuration reference for a full list of available configuration options, for now, copy the following into critters/0.cfg
 +
 +
<code>
 +
  r_char_name "Bob"
 +
  r_char_mdl "ogre"
 +
  r_char_script 8 //make sure this corresponds with the above script
 +
<code>
 +
 +
Finally, we need to spawn Bob, so start your game and create a critter entity that spawn a critter of type 0. Remember that F1 toggles editmode in the RPG!
 +
<code>
 +
  newent critter 0
 +
</code>
 +
 +
You're done, to test it simply exit editmode and press E while hovering the crosshair over him.
 +
 +
 +
==Addendum==
 +
 +
'''Default Scripts'''
 +
 +
The various definition types of the RPG each default to their own individual specialized script. They correspond as follows
 +
* 0 - null/empty/nothing
 +
* 1 - Default critter script; primarily initiates dialogue, will in the future control AI logic and stealth abilities
 +
* 2 - Default item script; mainly implements pickup
 +
* 3 - Default obstacle script; does nothing
 +
* 4 - Default container script; will eventually allow you to pick the lock and loot items
 +
* 5 - Default platform script; does nothing
 +
* 6 - Default trigger script; toggles triggered state (eg, switches door between open and close)
 +
 +
Note that the player defaults to script 0, and has its script explicitly set to 7. Script 7 contains some basic player logic, mainly it lets you know when you level up.
 +
 +
'''Definition numbering'''
 +
 +
The numbers allows the game to easily and quickly identify and order definitions, unfortunately this is inconvenient to the users since it makes identifying which definition corresponds to an item you're looking for a bit of a chore. The only thing you need to remember, is that each definition must be assigned number from 0 and up and that there cannot be '''any''' empty gaps. Duplicate numbers (eg hex or octal) and non-number names will throw a warning.
 +
 +
<code>
 +
$ ls
 +
1.cfg  2.cfg  3.cfg  4.cfg  5.cfg
 +
# the game will abort with these files
 +
</code>
 +
 +
 +
<code>
 +
$ ls
 +
0.cfg  1.cfg  2.cfg  3.cfg  4.cfg
 +
# the game will start
 +
</code>
 +
 +
'''Multiple dialogue entry points'''
 +
 +
The entry point is defined by the talk signal, by default this simply opens the dialogue at position 0 should it exist. If you'd like to change the entry point you will have to redefine the talk signal for your entity. For example...
 +
<code>
 +
  r_script_signal talk [
 +
    if $cond [
 +
      r_chat self 0
 +
    ]
 +
      r_chat self 2
 +
    ]
 +
  ]
 +
</code>
 +
 +
You can add more more conditions and variables and you are allowed the full range of cubescript commands.
 +
 +
'''Dialogue standards'''
 +
 +
There are no fixed standards, but we recommend the following conventions when writing dialogue for your characters.
 +
 +
<code>
 +
  r_script_say "Things the creatures say are simply typed like this, no surrounding quotes" []
 +
  r_script_say "[between these brackets, write what your character sees and experiences]" []
 +
  r_script_say "If you wish to put *emphasis* on a word, place *'s on both sides]" []
 +
</code>
  
 
=Part 3=
 
=Part 3=

Revision as of 00:07, 4 October 2011

The following tutorials are only meant to cover the basics of developing for the RPG. Each of the tutorials build upon the work from the previous exercises and are therefor best done in order.

Part 1

This part covers making the initial skeleton of our game.


By default the RPG detects the available games by searching data/rpg/games for cfg files, these files form the basis of what the main menu will list as the available games. In selecting a game from the menu, it will then attempt to load the definitions from an equivalently named directory.

We now know the first step to making our own tutorial game, we need a corresponding cfg and directory inside data/rpg/games'

Luckily sandbox comes with a base that can be derived to quickly get things up and running, so first up, let's make a copy of the base directory and call the copy "tutorial" and then move a file named base.cfg inside data/rpg/games/tutorial into data/rpg/games and rename it to tutorial.cfg.

We can essentially open up our game in sandbox now, but we still have a few things to do, so for now, open up tutorial.cfg in your favourite text editor. The contents should be pretty self explanatory but we do need to make a few specific changes.

Firstly, we want to set the default map and associate it with mapscript 0, for this excercise we'll name our map tutorial1.

Secondly, we want to set the version number and the compatibility number to 1.

The final version of tutorial.cfg should look similar to this

 r_reparemap tutorial1 0
 
 firstmap tutorial1
 
 gameversion 1
 compatversion 1

Save it and we have one more step to go, we need to make a map named tutorial1, so fire up sandbox and save a newmap under that name.

Congratulations! you have successfully set up the basics required to make your RPG with sandbox

Addendum

game.cfg has two explicit purposes. Firstly it identifies the existence of a game and secondly, it defines many of the important attributes of the game.

things that can and should be defined in game.cfg include

  • the script and flags to use on a maps
  • internal properties, such as the game version
  • global game properties, such as friendly fire
  • rule properties (currently not available)

Part 2

This section of the tutorial involves spawning a neutral NPC and assigning him some dialogue


We can go about this in a few ways, but we'll start by first defining the NPC's script, the NPC, and then creating a place for him in the world.

First off, go to your definitions directory (probably data/rpg/games/tutorial) and then enter the script subdirectory. You will not want to create a new configuration file and place it at the very end of the others (eg, if the last is named 7.cfg, name yours 8.cfg). In this file, we define how any entities using it will react and interact with the surrounding world. Since we don't want to bother with that, we will simply include the default NPC script.

Afterwards we can start defining the dialogue. When you're done the final script should look something like this. Feel free to experiment by writing more dialogue and fleshing out your character

 include scripts/1 //includes the default NPC script
 
 r_script_say "Hello, how are you doing" [ // 0 - it's good practice to number your entries
   r_response "I'm well, yourself?" 1 //goes to dialogue #1
   r_response "Goodbye" -1 //closes the dialogue
 ]
 
 r_script_say "I'm glad to hear it" [ // 1
   r_response "Goodbye" -1
 ]

With that taken care of, we will now define a critter to use the script. All critter configuration options are prefixed with r_char and most contain a variant with a _get suffix for retrieving the value. Now create a new cfg file in the critter sub directory, following the same steps as you did for the script to define it's name. This will probably be 0.cfg.

Consult the configuration reference for a full list of available configuration options, for now, copy the following into critters/0.cfg

 r_char_name "Bob"
 r_char_mdl "ogre"
 r_char_script 8 //make sure this corresponds with the above script

<code>

Finally, we need to spawn Bob, so start your game and create a critter entity that spawn a critter of type 0. Remember that F1 toggles editmode in the RPG! <code>

 newent critter 0

You're done, to test it simply exit editmode and press E while hovering the crosshair over him.


Addendum

Default Scripts

The various definition types of the RPG each default to their own individual specialized script. They correspond as follows

  • 0 - null/empty/nothing
  • 1 - Default critter script; primarily initiates dialogue, will in the future control AI logic and stealth abilities
  • 2 - Default item script; mainly implements pickup
  • 3 - Default obstacle script; does nothing
  • 4 - Default container script; will eventually allow you to pick the lock and loot items
  • 5 - Default platform script; does nothing
  • 6 - Default trigger script; toggles triggered state (eg, switches door between open and close)

Note that the player defaults to script 0, and has its script explicitly set to 7. Script 7 contains some basic player logic, mainly it lets you know when you level up.

Definition numbering

The numbers allows the game to easily and quickly identify and order definitions, unfortunately this is inconvenient to the users since it makes identifying which definition corresponds to an item you're looking for a bit of a chore. The only thing you need to remember, is that each definition must be assigned number from 0 and up and that there cannot be any empty gaps. Duplicate numbers (eg hex or octal) and non-number names will throw a warning.

$ ls
1.cfg  2.cfg  3.cfg  4.cfg  5.cfg
# the game will abort with these files


$ ls
0.cfg  1.cfg  2.cfg  3.cfg  4.cfg
# the game will start

Multiple dialogue entry points

The entry point is defined by the talk signal, by default this simply opens the dialogue at position 0 should it exist. If you'd like to change the entry point you will have to redefine the talk signal for your entity. For example...

 r_script_signal talk [
   if $cond [
     r_chat self 0
   ]
     r_chat self 2
   ]
 ]

You can add more more conditions and variables and you are allowed the full range of cubescript commands.

Dialogue standards

There are no fixed standards, but we recommend the following conventions when writing dialogue for your characters.

 r_script_say "Things the creatures say are simply typed like this, no surrounding quotes" []
 r_script_say "[between these brackets, write what your character sees and experiences]" []
 r_script_say "If you wish to put *emphasis* on a word, place *'s on both sides]" []

Part 3

This section of the tutorial involves basic crafting, the player will receive a weapon at the end of it

Part 4

This section of the tutorial covers creating a hostile NPC and a weapon for him

Part 5

This section of the tutorial involves creating a fetch quest and overriding the HUD

Part 6

This part of the tutorial involves the creation of a basic puzzle to open a door