 |
Castle Paradox
|
View previous topic :: View next topic |
Author |
Message |
Fuel

Joined: 02 Jun 2010 Posts: 10
|
Posted: Sun Jun 06, 2010 12:29 pm Post subject: How to make a custom NPC? |
|
|
In my game I want to have an npc that you can bring different parts to and for a fee he assembles them, for instance:
3 handles
2 blade parts
And he will create the sword for a small fee. I imagine this has something to do with scripting but since this is my first game with the OHR, I have no idea where to start.
Would this be relatively simple to implement or a lot of trouble? |
|
Back to top |
|
 |
SecondThought

Joined: 27 May 2010 Posts: 4 Location: Surrey, BC
|
Posted: Sun Jun 06, 2010 2:19 pm Post subject: |
|
|
[Oops! Deleted.] _________________ Game Progress
Forgotten Lore — 0% complete (currently designing art and concept)
Last edited by SecondThought on Mon Jun 07, 2010 7:43 pm; edited 1 time in total |
|
Back to top |
|
 |
G-Wreck OHRRPGCE Game Designer

Joined: 28 Feb 2010 Posts: 32 Location: Oklahoma
|
Posted: Sun Jun 06, 2010 3:58 pm Post subject: |
|
|
Scripting shouldn't be necessary for this. See if this was what you were wanting to do:
1. Make a new shop (if you haven't already), and give it whatever name you want.
2. Got to EDIT AVAILABLE STUFF for your new shop.
3. Give the shop all of the finished products that you want your NPC to be able to assemble. For example, if the NPC was going to make a sword with a 'handle' item and a 'blade' item, then make the finished sword be the shop item.
4. Set the $ Price of the item as the fee the NPC is going to charge the player for assembling their sword.
5. Set the MUST TRADE IN # OF bitset to an item the player must trade for the finished item. For example, set it to the handle or the blade they are going to trade for the sword. You can also highlight the '(CHANGE AMOUNT)' option just below this to, you guessed it, change the amount of that particular item the player must trade for the item they are receiving, in case you also want to do something like trade in several strips of leather to be wrapped around the sword handle.
6. Repeat step 5 as necessary, but remember that you cannot trade more than four different types of items for the item the player is going to receive. This way, you can have a handle, blade, cross-guard, and pommel traded in for a complete sword.
Sorry if that was wordy, but I try to be precise since I get really confused myself if something isn't explained word-for-word to me.
Oh, and remember that you can always pres F1 while you're in CUSTOM to bring-up the HELP menu when you get stuck (I have it on constantly). _________________ Syzygy - .01% (Extremely Random Number)
Finishing the main story arcs and gameplay elements before I do anything else. |
|
Back to top |
|
 |
JSH357

Joined: 02 Feb 2003 Posts: 1705
|
Posted: Sun Jun 06, 2010 6:22 pm Post subject: |
|
|
I'm sorry, but this is pretty absurd to recommend doing in the editor. You should really learn a bit of plotscripting to do something like this, as it will make things much easier and more flexible once you have the hang of it.
For these scripts, I am assuming that:
A) You do not have any plotscripting in your game already.
B) This script is going to be activated by talking to the blacksmith NPC
First, get the item id numbers for the handles and blade parts. That's just their number in the item editor. I'm going to assume handle is 4 and blade part is 5. I'm using 6 as the sword.
Next, make three boxes. One for if you have the parts, one for if you don't. I'm going to assume "have the parts" is text box 100 and "don't have them" is text box 101.
I just assumed the fee for the item was $50, and am adding a text box 102 that is displayed when the player does not have $50.
Now you would make your HSS file and have the following. My comments are after the #s.
Code: |
include, plotscr.hsd
# You have to include this file in every HSS you make
plotscript, blacksmith, begin
suspend player
if(inventory(4) >= 3 , AND, inventory(5) >= 2)
# This is checking to see if the player has the items
then(
show text box(100)
wait for text box
# Text Box 100 says "Hey, want me to make the sword for $50?"
if(pay money(50))
# This checks to see if the player has $50
then(
delete item(4,3)
delete item(5,2)
get item(6,1)
# And if he did, then the items get exchanged
)
else(
# Otherwise...
show text box(102)
wait for text box
# This text box says "Hey bro, you don't have enough money"
)
)
else(
# This else happens if the player didn't have the right items
show text box(101)
wait for text box
# This text box might say "Hey, go hunt me down some parts, player"
)
resume player
end
|
Now, this script is very basic, and you can add things to it, but it will do what you want it to. Just change the numbers to fit with the items and text boxes in your game.
After making this hss file, which we'd name "Yourgame.hss" drag Yourgame.hss in to hspeak.exe to compile the script. If you get errors, you need to fix the code; I could have made a mistake here.
After that's done, go in to CUSTOM and go to "Script Management." Choose to import Yourgame.hs.
Once you've done that, to make the NPC use this script, you'd go and edit it in the Map Editor and have it use this script upon activation. (Don't display a text box)
[/code] |
|
Back to top |
|
 |
Fuel

Joined: 02 Jun 2010 Posts: 10
|
Posted: Sun Jun 06, 2010 10:42 pm Post subject: |
|
|
Wow, great answers from everyone...I think I'll go for the plotscripting way since that seems to be so evident and necessary in more complicated situations, but at the same time I want the simple and non-scripted way.
I'm probably getting a little ahead of myself in this because I haven't even started putting NPC's down, but for this I'm going to make a test one. The idea just seemed like something that could be a nifty feature I didn't want to forget to ask how to do.
I'll post back here later with the results from my experimentation. |
|
Back to top |
|
 |
JSH357

Joined: 02 Feb 2003 Posts: 1705
|
Posted: Mon Jun 07, 2010 7:27 am Post subject: |
|
|
Great!
The best way to learn plotscripting is to do it, and ask questiosn when you get stuck. Most of us here should be able to answer your questions. There aren't too many limits on what you can do with it at this point. |
|
Back to top |
|
 |
Fuel

Joined: 02 Jun 2010 Posts: 10
|
Posted: Sun Jun 13, 2010 9:36 pm Post subject: |
|
|
BEHOLD! IT WORKS! (I mean it should, you wrote the whole thing )
Really, thanks for the detailed post along with the comments. Made the whole thing a breeze to substitute my own numbers in and understand how the system works. I have some basic programming experience so it's a piece of cake to read basic code like that.
The next thing I have in mind for this is a menu of items he can create as well as maybe bringing the npc schematics and he can 'learn' how to make new objects. I haven't looked into either of these things yet though, since I just wanted to post an update. Thanks again! |
|
Back to top |
|
 |
chronoboy Into the past with a splash

Joined: 04 Jun 2010 Posts: 162 Location: Canada
|
Posted: Wed Oct 13, 2010 6:23 pm Post subject: |
|
|
A note if your new to plotscripting, this advise will help manage your code easier.
In the custom editor, I would highly recommend exporting an HSI file. This file will contain all the english names for game resources, like item names.
At the beginning of your HSS file, under include, plotscr.hsd place include mygame.hsi
Next, replace references to items such as inventory(4) with inventory(item:Handle)
This will make your scripts easier to read and debug in the long run, and also result in less errors. After you have lots of scripts, switching back to the editor to check what was that item there again will get rather tedious.
I would also recommend reading through parts of the Plotscript Dictionary which is in the docs folder in your OHR installation. It may give you ideas of what you may want to do with plotscripting, there are many commands in there which you may have never thought existed.
Happy hacking! _________________ Current project: Chronoboy Adventures
Website: http://www.chronoboy.com/ |
|
Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|