PDA

View Full Version : how to create a shopkeeper / merchant npc



nietger
September 16th, 2008, 10:49 AM
Hi

I'm in the middle of creating a ragnarok online style rpg and I would like to create a merchant npc shop. I see this a many games and can't wrap my head around the code. I would really appreciate it if anyone could post a tutorial or sample code that would explain how to create a merchant npc. I added a link to a video showing the effect I'm looking for.

http://www.youtube.com/watch?v=F0Yf2cjnRi4

Thanking you in advance

marcogiannini
September 17th, 2008, 07:12 AM
I'm working on a point&click adventure with a backpack and a coinpack, so let me introduce my little experience:
I think you should figure it out as well divided in a few parts:
1) the array (or arrays) system that permits you to organize your backpack: it's really a mess, a tough task, but you could begin to read some threads searching on this forum, in ultraschock's one and all over the web searching with the keyword "inventory" - look also at gotoandplay.com
2) The money counter - especially for your graphic sakes - should be built apart, 'cause if in the first case you have to manage some single items (there will be only ONE Dragon Sword in your game, I think) that have single features, in the second case a coin will be always a coin and will count as a coin also if you use it togheter with a bunch of other coins, in a word it will be his value. This reflects in controlling instance names: with attachMovie method - in the first case - you should call from the library a MC called dragonSword_mc and develop an action table in which THAT sword will play a role, but you'll have to build a different function to manage a coin that won't be threated with a single instance name, 'cause using the same architecture first or then you'll trample in the problem that you'll be buying an item with - say - coin14_mc, and if you'll try to buy some other with the same coin you won't...
About the coin part take a look at this

http://www.kirupa.com/forum/showthread.php?t=308597

this was an attempt to build a coin counter totally thorn apart from the inventory, but failed. Actually I worked it out using a simpler system organized on variables: you have a coin icon out of the stage, and some coins scattered inside; when you pick up one of this the outer coin icon comes into your backpack and a coin variable gets ++ - you can reply it a lot of times; when you spend the coin the counter gets -- and if it's the last in your backpack, the coin icon go back outside

I hope this will be helpful. Please reply about your enhancements, I'm really interested in this argument