This is NOT the official way of making an RPG, if you like to learn the official way of doing this, take a look at Hiratos guide : http://www.sandboxgamemaker.com/wiki/in ... G_tutorial
I'm trying to create a HowTo to the RPG-mode, mostly because I want to learn more about PAS (2.7), and I'll just throw it here, in case someone else might find it useful.
Unfortunately there are some huge gaps in my basic knowledge of PlatinumArtsSandbox (PAS), so if anyone have corrections and/or something else to add, feel free to comment.
My "research" consist of several pages of unreadable scribbles on coffee-stained bits of paper in a pile next to my keyboard, so theres bound to be some errors, but I hope that I have at least covered the basics to get someone started with PAS.
I have never been one to spend hours looking through the manual myself, and I prefer to just dive in and solve the problems as they come along, so without further ado, here it is, my "Quick and dirty hands-on approach to PAS-RPG".
RPG-mode
To start PAS in RPG-mode, first you have to edit the launcher to make PAS run in RPG mode, this is done different on Linux, Mac and Windows:
Linux:
In the file sandbox_unix, line 8 should be SANDBOX_MODULE="rpg"
Mac:
TODO
Win:
TODO
Mapbuilding
When you start PAS, choose [togle editmode] and then [new map].
Default size is 10, large maps equals long load times and unless you're planning to build a large city, I recommend staying with the default option for now.
You can always enlarge the map later with the command mapenlarge (doubles the dimensions of the current map).
Mapbuilding is pretty straightforward and theres lots of great examples on youtube if you want tips on how to build the world.
You can edit the .platinumarts/packages/rpg/mapname-art.cfg to add textures and mapmodels, but if you want to add more complex things, you have to use scripts.
Scripting
PAS comes with a game called default (by Hirato), you can use this as a template for your game, just copy and then rename the folder /data/rpg/default to /data/rpg/awesomegame and the file /data/rpg/default.cfg to /data/rpg/awesomegame.cfg. Now you have a complete structure of folders to build your game in.
In the top of the file hierarchy theres the file awesomegame.cfg, Use this as a template for your own game and add your own maps like this:
Code: Select all
r_preparemap "awesomemap" 0
r_preparemap "greatmap" 1
r_preparemap "greatestmapever" 2
//variables
firstmap awesomemap
gameversion 1
compatversion 1
exec data/rpg/hud_standard.cfg
It also sets the variables firstmap, gameversion and compatversion and loads the hud, but more about that later.
If you copied and renamed the folder, you should now have the following folders in awesomegame:
ammo // TODO
containers // TODO
critters // NPC's and monsters (model, name, etc.)
cutsceenes // TODO
effects // TODO
factions // friend or foe
items // scripted items (model, name, etc.)
mapscripts // maps
obstacles // TODO
platforms // TODO
recipies // TODO
scripts // Scripts for everything
statuses // TODO
triggers // Triggers (model, name, etc.)
and the files:
player.cfg // player model, name, etc.
tips.cfg // text to display during load and gameplay
variables.cfg // game variables like quest-status
Mapscripts folder
The folder mapscripts contain every map used in the game (0.cfg being the first, 1.cfg the second and so on), the file 0.cfg (awesomemap) could look something like this:
Code: Select all
r_mapscript_signal load [
r_spawn_creature self 20 0 // NPC1
r_spawn_creature self 21 1 // NPC2
r_spawn_trigger self 10 0 // Wood door
r_spawn_item self 30 0 // Healing plant
r_spawn_item self 31 1 // Mana mushroom
r_spawn_item self 32 2 // Silverspoon
]
Critters folder
Now we have NPC1 on our map (don't forget to save), as you can see in the mapscript, the creature NPC1 points to a script 0, you'll find it in the folder critters called 0.cfg.
Code: Select all
r_char_mdl "rpg/characters/npcman"
r_char_name "NPC1 name"
r_char_base_level 5
r_char_script 1
r_char_faction 0
Scripts folder
Here is an example of the NPC1 script (1.cfg in the folder scripts):
Code: Select all
// NPC1
r_script_signal interact [ // When you interact with someone/something using the "e"-key, you invoke r_script_signal interact
if (r_matchref player actor) [
if (= (r_get_state self) $CS_DEAD) [ // Is the player dead?
r_loop_inv self item [ // If dead, then loop through the inventory
r_select_item (r_get_base item) [ //select the item's definition based on its index
echo (format "You found %1 x %2" (r_get_amount item) (r_item_name_get)) //prints the amount and the item's name
]
r_additem player (r_get_base item) (r_get_amount item) // add to player inventory
r_remove self (r_get_base item) (r_get_amount item) // remove from npc inventory
]
] [
r_chat self 0 // If not dead, then invoke r_script_say to start the chat
]
]
]
r_script_signal spawn [ // What items and/or spells do NPC1 have
r_additem self 8 25 // 25 Silver - defined in awesomegame/items/8.cfg
]
r_script_say "NPC1 greating" [ // invoked by r_script_signal interact // 0
r_response "Player ask a question?" 1 // go to 1
r_response "Player ends chat" -1 // end
]
r_script_say "NPC1 answer question" [ //1
r_response "Player ask another a question?" 2 // go to 2
r_response "Player ends chat" -1 // end
]
r_script_say "NPC1 answer another question" [ //2
r_response "Player ends chat" -1 // end
]
So if we wanted to add a spell or just some money to the player inventory, we just add the apropriate items in the script, which in this case is scripts/0.cfg
And this line in your playerscript lets you know when you have earned enough experience to level up:
r_script_signal level [
echo (format "You have reached level %1 and have %2 point(s) to spend" (r_get_level player) (r_get_points player))
]
If you want your player or an npc to have a spell equipped when spawned:
r_equip self 1 0 // this will equip the item 1 in slot 0
Items folder
All spawnable items have a file in this folder. In our NPC1 script above, the npc have 25 item 8 (items/8.cfg)
Code: Select all
// Silver
r_item_name "Silver"
r_item_icon "silver.png" // the inventory icon (looks for the file in /data/rpg/hud/)
r_item_description "Silver" // description in inventory
r_item_mdl "rpg/objects/coin/silver"
r_item_worth 1
r_item_weight 0.1
r_item_script 7
Script 7.cfg is a default pickup script for when you interact with an item using the "e"-key.
Code: Select all
r_script_signal interact [ //
r_signal "touch" actor self 0 //executes this item's touch slot on whoever tried to pick up this item
if (!= (r_get_state actor) $CS_DEAD) [
amnt = (r_get_amount self)
r_pickup actor self
if (!= $amnt (r_get_amount self)) [
r_signal "pickup" actor self 0 //amount mismatch, actor picked up a few items
]
]
]
Placing a trigger on the map is just like placing an npc, and if you look at the mapscript for awesomemap (0.cfg), it contain this line:
r_spawn_trigger self 10 0 // Wood door
So every time you place a spawn with tag 10, you get a wood door that is controlled by triggers/0.cfg
Code: Select all
r_trigger_name "Heavy Wooden Door" // The name of the trigger
r_trigger_mdl dan/door // model (packages/models/dan/door)
r_trigger_script 3 // the file that controls this trigger (in this case scripts/3.cfg)
Code: Select all
r_script_signal interact [ // Just like critters and items
r_trigger self // trigger self (self being the door)
]
The file variables.cfg contain game variables like quest-status and is read with r_global_get, and can easily be used inside an if-else loop like this:
Code: Select all
if ( = (r_global_get $awesome_quest) 0) [ // is the value 0?
r_response "The awesome quest is not started yet" -1 // Yes the value is 0
] [
r_response "The awesome quest is started" -1 // No the value is not 0
]
HUD/GUI
There are a lot of cool skins for the hud in PAS, and in the folder data/rpg/hud/ you can place your own icons for items and such.
If you want to hack your GUI or just make small changes to the data shown, the nice stuff is in data/rpg/menus.cfg.