How to: Create a shop

Discuss Chaos Strikes Back for Windows and Linux, an unofficial port of Chaos Strikes Back to PC by Paul Stevens, as well as CSBuild, an associated dungeon editor.

Moderator: Zyx

Forum rules
Please read the Forum rules and policies before posting.
User avatar
sucinum
Pal Master
Posts: 872
Joined: Wed Apr 18, 2001 1:00 am
Location: Karlsruhe, Germany
Contact:

How to: Create a shop

Post by sucinum »

i'm just looking for the easiest way to include a shop into a dungeon. it should be a rather simple one.
how about this:
part a: a pushbutton (activated by and 'consuming' the currency)
part b: a wallshooter (triggered by 'a'). on the same tile there are objects in the wall. that's the etuff to be sold
part c: a teleporter. that is, where the shooter launches the items at.
part d: a wall alcove. destination of the teleporter.

is that working? if yes - how can i know that the teleporter zooms the items into the alcove and not in the wall? anything else i should think of?

here another try:
part a: a pushbutton (activated by and 'consuming' the currency)
part b: a door (opened by a)
part c: a room with stuff to chose from
part d: several floor pads activated by the items in the room, closing the door.

that would allow to chose freely, but i don't see a way to prevent people taking all stuff at once.

this leads to:
suggestion 3 (takes the most room, but should work the best):
i start with a sketch:
XaX
b_c
XXX
X = wall, _ = floor
a: a pushbutton (activated by and 'consuming' the currency) <- i should invent a name for this ;)
b: an alcove containing the object.
c: a teleporter. this teleporter is deactivated by both a and b. if the object is in the alcove OR if you pay, you may leave. so the teleporter is only active, if you hold the object, but have not paid for it.

this 3rd version allows to chose, what you buy. of course it requires the most walking of the party, but i see no other problem there.

further suggestions? any chance to make #2 working?
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Or: Use a derivative of the Money Changer that I published.

Or: Behind a door (or pit) is one of a loop of teleporters. Press a
button and the loop shifts all the items
clockwise so that you see the next object that is for sale.
Insert coin teleports a copy of the object to your side of the door.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Or: I like this better:

Have the teleporter loop pass through an Alcove so that
the objects are there for the taking. But if you take
it without paying then the door closes behind you and
an infinite number of Dragons appears.

So press the button to see the next object. Putting
a coin in the slot duplicates the object so you can take
one without triggering the 'Police'.
User avatar
sucinum
Pal Master
Posts: 872
Joined: Wed Apr 18, 2001 1:00 am
Location: Karlsruhe, Germany
Contact:

Post by sucinum »

the teleporter loop sounds much smarter than making the party move around and it needs much less space.
but if the shop duplicates the item in the alcove, won't this allow the player to buy one item several times? and how can i prevent the player from exchanging stuff in the alcove? he could take a vorpal blade and return a dagger - or even put in the firestaff and copy it 3 times.

this problems and my inability to solve them leads me to:
idea 4 (walking around these problems ;)):
there a several rooms, each containing the following:
a. a coinslot
b. a teleporter -> will teleport you to the entry hall of the shop
c. a blue button: next -> will teleport you to the next room
d. an alcove containing the desired item.
if the item is taken out of the alcove, b and c vanish, so you can't proceed, but you can have a look at the item. if the coinslot is triggered, a copy of the item is teleported from somewhere hidden at the entry of the shop and the coinslot vanishes.
so you can have a look at the items which are sold, but you can neither steal nor replace them. for the player, it looks the same as if the item in the alcove was exchanged, he won't recognize being teleported around.
of course, this shop shouldn't sell freeze boxes or food ;)

to the money changer: i just downloaded it and wasn't able to open anything else than the supplied dm-dungeon with it. and i didn't find anything shoplike :?:
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

won't this allow the player to buy one item several times
Certainly. I thought this was like the grocery store where I could buy
three gallons of milk if I wanted. If you want only one then a simple
way is (instead of duplicating the object) to insert another object under
it so that it can be taken. More complicated is to disable the police
until the button is pressed again and fill the empty space when the
button is pressed with a worthless object like a screamer slice.


The object for sale is the only object in the alcove. And no matter
what the player does, it will be the bottom object. If he takes the
last object, the police arrive. So he can add things and take things
but he cannot take the valuable object without being caught.
put in the firestaff and copy it 3 times
Only the bottom object gets duplicated when you pay the coin.
You cannot make the bottom object be the firestaff because you
would have to have emptied the alcove first. And that summoned
the police. In the case where you slip a screamer under the object
instead of duplicating it there is no problem because nothing gets
duplicated. In the case where the coin disables the police then he
could take the merchandise, thereby emptying the alcove, and put the
firestaff into the alcove. But now he will have to pay to get his
firestaff back. So, no matter how you solve the problem, the player
cannot get away with anything for free and he cannot duplicate
anything you do not want duplicated.
just downloaded it and wasn't able to open anything
I just downloaded it and went around a couple of corners where
I found the place to buy things. I first had to go get a champion with
hands, then came back, put another coin on the floor, and pulled
the ring. My purchases appeared on the floor.
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

There are already a few examples of shops, not as complex as this has built up to : )

ian's test dungeon/dm2 by toni - is the walk in shop idea, where you opened the door with money, and each floor tile has items. When you walked into a tile with the items (they are all against the wall so you need to enter the tile) a teleporter activated to send you back out, the square you land on closing the door.

csb - the wall shooter. you need two alcoves for the two possible squares items can land on

team dungeon - if you have an old version zyx's grant shop is there, which used a more complex set of shooters and teleporters, and there is the current market shop. It used clones to have the items also display in the alcove, and only rotated, not a loop, but isn't much more difficult to use CSBwin's powers to improve it.
The idea was there was a simple blocking teleporter on the front of the alcove square stopping you from taking items until you paid. In this case, you can have it when you exit the alcove square, you activate the item duplicator.
No need for ploice, or complex mechanics to block the police
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

Paul, you have also slipped neatly into Archmaster rank with your post count.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

What if we specify the following:

1) The shop is a room with a door.
2) I should be able to enter the shop without any money.
3) I should be able to examine any of the items for sale
without any money. Pick them up. See how much they
weigh. Are they cursed? Put them back.
4) I can leave the shop without buying anything.
5) If I take one or more of the items then I must pay to leave the
shop. Either the door closes or I keep getting teleported
back to the coin slot when I try to leave.

How would you do this? I think I can imagine a solution.
Some sort of counter to keep track of the number of items
missing from their alcoves versus the number of coins that
have been put into the slot. As long as the number of coins
is greater or equal to the number of items missing, you can
leave. One problem is that this simple solution would allow
you to come back later and trade-in your Dexhelm for an
Executioner. Maybe fix this by closing any empty alcoves
when the party leaves the shop.
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

If everything costs the same amount, I don't see a problem with the logic of 'trading in' one item for another. It soudns liek a nice solution.

I like the count monitor idea, because it also has other uses - is it soemhting implementable just now, or something you would add

I remember a long while ago someone asked about being able to maintain a monster level in a room. So for example, if the room dropped below three monsters, then he wanted to be able to generate replacements. I could never see exactly how to do this with the original conventional mechanics. A count monitor would of course be able to trigger a monster if the population fell below a number.

It would also be a good way to control monster floods for designers that don't like the idea of putting a limit on the amount of times a generator is used before it becomes innactive (like certain CSB areas)..
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I think you can do this today with a DSA. I don't recall if
there is a function to set the A/B parameters. There should
be and if there is not it is easy to add. The counter would
be kept in one of the parameters.

All objects need not cost the same. The counters can be incremented/decremented by arbitrary numbers.

The monster business is a bit more tricky because you either
need a pressure pad in each cell that the monsters might visit
or you need a way to detect when monsters are killed. The only
other alternative is to scan the dungeon looking for and counting
monsters in a particular area. That would be possible now without
any changes but it seems kind of ugly to me. Unfortunately, I
have not thought of anything beautiful. I really want to implement
'zones' someday and provide messages when zone-related
actions occur. Like 'party enters zone', 'monster killed in zone', etc.
But that is a far-off dream.
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

Yes, I assume the monster thing would come from pressure pads in an area.

An idea I thoght of was for a dungeon was a sort of 'favour of the goddess' - some magic that kept track of the character's standing in terms of good and bad deeds. Certain areas would have a 'favour test'. Using DM mechanics, this would mean trying to drain a central counter that was incremented and decremented during the game. If it could survive say five activations and still be untriggered then the character would pass, but of course any failure would make the mechanics irredemable.
With CSBwin a DSA keepign track of these events would be much easier! And it would be possible to restore your standing.

A quick and dirty version of the 'zone' thing would be a toggling DSA. Designer would have to put pressure pads at a bottleneck created at the exits of each zone. When the DSA is triggered, it puts the predetermined text 'you have entered...' and flips. When it is triggered again, it would instead put the text 'you have left...' and flip back to the previous state.

Obviously any pits and teleporters into/out of zones would have to be accounted for.
Perhaps having switches right under the destinations. These pads, through a relay, would target both the old and new zone DAS's. These pads would have a circle of relay toggling pads around then. So if you walk over the floor normally, you deactivate the relay, walk over the zone pad to no effect, then then reactivate the relay on passing.

I'm sure people playing CSB would be happy with this!
*fall*
You have left KU path part 2
You have entered DAIN path part 1
User avatar
LazyOldman
Journeyman
Posts: 61
Joined: Thu Mar 04, 2004 7:17 pm

Post by LazyOldman »

ok, i need some help here....

I've been trying to create a shop but am having a little bit of trouble. What i want is like one of pauls suggestions;

A room you can walk into with a bunch of alcoves, you can pick up anything you like but have to pay a coin for each item to get out... simple hey?

Well, i've been trying to use an and/or gate (idea to increase when an item is picked up and decrease when a coin or item is put down (alcove/slot by the door)) and opening/closing a door as necessary... looks like this;
Image

but it ain't workin' - argh!!!!

ok so how do i get this to work... i need to know how i setup the object holders and the and/or gate, i somehow managed to get the door closing, but couldn't get it to open again....

If someone can post me a dungeon with an example i can follow it'd be great!!!! cheers, ;-)
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

My idea was to use a counter to keep track of the number of missing
items minus the number of coins deposited. As long as the number is
zero or negative the door stays open.

But you will need to implement a non-standard counter for this purpose,
I believe. Incrementing/decrementing an And/Or gate is going to be
a great deal of work, I think.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I put 'shopkeeper.rar' at dianneandpaul.net/CSBwin.

It has some problems:

If you enter the shop without any coins and eat an apple then
you are a goner. There is no escape without regurgitating
the fruit.

There is no indication that the Helm costs two coins.

The shop uses an extremely simple DSA as a 4-bit counter so
the maximum number of coins it can handle is 8.
User avatar
TyGuy6
Craftsman
Posts: 140
Joined: Mon Aug 01, 2005 8:20 pm
Location: U.S.

Post by TyGuy6 »

I'm fascinated with the idea of making a nice shop, so I'm pulling up this thread from three years ago. I came up with a shop design myself, and although it may be complicated, and the explanation long, I think it will please the player best.

In the first and fourth post here Sucinum did some good thinking work. His 4th idea was an excellent one, because it improves upon simple item buying in the following ways:
1) you can pick up an object to look at it but you cannot steal it.
2) all objects in same "room"

Some improvements that I want to make:
3) purchased items can later be refunded somehow. (or perhaps exchanged for credit to buy other items)
4) no need to scroll through list of items every visit -- or in other words, items found in location rather than sequence, like a real shop.

Now, Paul's idea for #3 and #4 was to use some sort of non-standard item/coin counter. A room would have items available but not allow you to leave if more items were out of place than coins paid. The counter would be triggered by taking and returning items and by inserting coins. He eventually succeeded to make a DSA that could count up to 8.

I like the counter idea, but I'm not so hot with DSA's. So instead, I came up with a non-DSA, stack-like counter, which uses teleporters, pressure pads, and arrow shooters. This is how it works:

:arrow: There is a line of teleporters which, when activated, teleport to the next in line, with the last teleporting off to an empty square. This line should be as long as there are items in the shop. Each teleporter square has two pressure pads, in this order:
-an object removed clears the current square (the teleporter is turned off)
-an object added clears and removed sets the previous square. (whose teleporter points to the current square) The first square doesn't need this pad, of course.

A shooter is aimed to shoot an arrow onto the first square. The squares initially have all the teleporters on except the last, and no objects yet. When you take an object from a shop alcove you could say you have put it in your "shopping cart," and you "set" the shooter. This adds an arrow to the last square, (or the last square without an arrow) and clears the 2nd to last teleporter. (or the teleporter before the added arrow) When you replace an object in the shop or pay a coin for the item instead, the last teleporter is "set," removing an arrow and setting off a chain reaction that moves all the arrows (in this case, there aren't any more) forward one square. Now whenever there aren't any arrows you should be allowed to leave the shop, and not otherwise, so another pad can be placed on the last square to close the door while an arrow is on it.

For simplification, I said that the line must be as long as there are shop items. Actually, the line must be twice that length, so that a person who puts back a purchased item won't break the mechanism and be able to take all the items. An arrow must start on each of these "extra" squares, and the pad to close the door should be right before the first arrow.

Also, if you are going to allow the player to pay before picking up any items, you will have to have yet another square in the line for each coin they could pay more than the number of items. My suggestion is to add pads as necessary to close the coin slot while the door is open. (I did this with two pads and an AND/OR on the coin slot, but there is probably a better way.)

:( Problems with this mechanism, and their solutions:
-adding and removing items quickly with 3 clicks allows theft: I made the alcoves close and reopen 2 frames later each time you remove their items. Kinda ugly solution and adds complexity, but it's necessary.
-complex and takes lots of time to make a big shop: This is sort of inherent. I have no solution.
-maybe more I haven't discovered.

:) Benefits:
-most user-friendly and self-explanatory, IMHO
-extendable. I've already thought of several things I will add on to it. Shopkeeper, more expensive items, statements of balance, full refunds...
-same counter idea could be used for different purposes, as mentioned in above posts

If anyone wants to try it out, I can make and send them a demo. I'm planning on incorporating it in my next dungeon also.

P.S.: Can Paul make a counter bigger than 4-bit now? Maybe I should just learn to use DSA's, huh?
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Post by Sophia »

A DSA would probably be a lot simpler than this mess. That's sort of what they were designed for. :)

<shameless self promotion>
Of course, even more straightforward for doing really complex mechanics is that you could use DSB, and then you get to script them all out in Lua. ;)
</shameless self promotion>
User avatar
beowuuf
Archmastiff
Posts: 20687
Joined: Sat Sep 16, 2000 2:00 pm
Location: Basingstoke, UK

Post by beowuuf »

Yes, DSA integer values are...well, let's just say money and objects will run out before you finish using their integer values.

Especially since each DSA can store two such values

And there are global variables usable too for all DSAs - though in olden times zyx used to manage wit monster hit points just as well!
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

A DSA is definitely written in a sub-machine
(as opposed to submachine) language. At least
a machine language is sorta symmetrical.
Getting anything complicated to work is a kind
of a work of art unto itself. Most people would
rather spend time thinking about their dungeon
design.

So I agree with Sophia. If you want to do some
complicated things and have not progressed to
the point where you would have to spend weeks
doing the conversion, then DSB would probably be
a reasonable choice.

Now, having said that, there is the possibility that
you might get me to help design such a shop.
I have the proper twists in my neurons to approach
such a problem as I would approach a difficult
Sokoban puzzle. With enthusiasm. As a
demonstration of the power of the DSA.

And perhaps, if you were to choose DSB, Sophia might
be persuaded to create some generic 'shop'
function. As a demonstration of the power of DSB.

DSA versus DSB! :oops: Sorry!
User avatar
TyGuy6
Craftsman
Posts: 140
Joined: Mon Aug 01, 2005 8:20 pm
Location: U.S.

Post by TyGuy6 »

Yes, a DSA would be perfect for this if it could do certain things, but I am not familiar enough with them to know. Here's the challenge, Paul:
-holds value initialized to a certain number
-adds or subtracts 1 or more to the value upon a command like "set"
-sends commands when value is greater to or less than a certain defined number. Multiple numbers allowed, each with a different command.

Basically, just the counter idea you were trying to do 6 posts up in this thread.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Actually, this seems pretty simple. We
examine all th objects in the room and add
up their value. If the value is less than the
initial value of all the objects, we
close the door. Various objects have various
values. Let us make an example.

1 Silver coin
3 Gold coin
1 Apple
2 Dagger

The room starts with two daggers and an apple.
So the initial value is 5. If the player comes in
and takes a dagger and leaves a silver coin then
the total will be Apple+dagger+silver = 1+2+1 = 4.
4 is less than the initial value of 5 so the door
remains closed. If he drops another silver or
gold coin (or an apple!!!!) then the total will be
5 and the door will open.

This allows exchanges as you specified. We could
also check for the number of apples or daggers
not greater than the initial number if it was necessary
to avoid paying with objects found elsewhere in the
dungeon. We could even make sure that the apple
returned was exactly the same apple that was
purchased earlier, if you so desire.

Then we need to arrange the dungeon so that
the player cannot thow things through the open door
or otherwise cheat the game or create a dead-end
in the play.
User avatar
TyGuy6
Craftsman
Posts: 140
Joined: Mon Aug 01, 2005 8:20 pm
Location: U.S.

Post by TyGuy6 »

How would a coin slot work? It seems like the coins would just disappear when you insert them?
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

I was not going to use a 'Slot'. Simply
leave the coins lying on the floor. This
makes your refunds easy.
User avatar
TyGuy6
Craftsman
Posts: 140
Joined: Mon Aug 01, 2005 8:20 pm
Location: U.S.

Post by TyGuy6 »

Aah, well. Sorry to be picky, but I was kinda hoping for a shopkeeper "slot." I already can replace an item with a coin in an alcove just fine, using AND/OR.

Then again, I haven't worked out anything for more valuable coins and items yet, so your suggestion does improve things. Maybe I should quit while I'm ahead.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

No... Don't quit.

How about alcoves with adjacent coin slots.
And a 'Returns' alcove. Put the returned
object in the 'Returns' alcove and it is replaced
with the proper number of coins.
User avatar
TyGuy6
Craftsman
Posts: 140
Joined: Mon Aug 01, 2005 8:20 pm
Location: U.S.

Post by TyGuy6 »

But again, I would prefer a single slot. Multiple slots goes back to DM's coin room, which is not very shop-like.
User avatar
TyGuy6
Craftsman
Posts: 140
Joined: Mon Aug 01, 2005 8:20 pm
Location: U.S.

Post by TyGuy6 »

Ooh, but can you do that returns alcove? How? That would be great!
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

OK. One slot. Many Alcoves.

What about overpayment? There is really
no way to make change. Do we simply
keep track of the 'Credit'? If he overpays
for an apple today does he retain that credit
for the next time he visits the store?
User avatar
TyGuy6
Craftsman
Posts: 140
Joined: Mon Aug 01, 2005 8:20 pm
Location: U.S.

Post by TyGuy6 »

Most definitely. Credit is the idea I'm going for.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

Nothing here that sounds too difficult.
I'm outta here for an hour. See you later.
User avatar
Paul Stevens
CSBwin Guru
Posts: 4319
Joined: Sun Apr 08, 2001 6:00 pm
Location: Madison, Wisconsin, USA

Post by Paul Stevens »

OK. I'm back. Before starting we should have
everyone who is interested provide their input
as to how best to do this. Lots of details.

In general, the shop works by not allowing
exit until you have paid for the items missing
from the shop.

Should 'returns' be limited to the specific items
or should any item of the same kind suffice?

How does the player determine the price?

Should returns be limited to credit rather
than cash?

Should the items for sale be displayed in alcoves
or simply scattered about?

If there are several Mon Potions for sale should
they all be displayed in a single alcove?

What if you take a Mon Potion and put it into
the alcove meant for Daggers?

Should there be provision for multiple coin
slots?

Should the credit for returns be different
than the purchase price?

Should there be provision for multiple shops
in the dungeon?

Should there be provision for purchasing
an infinite number of apples provided you
can come up with the cash?

Should there be provision for selling items?
Perhaps an infinite number?

Should there be a way of displaying several
different types of items in a single alcove?
Perhaps by pressing a button or stepping
off and onto a pressure-pad to rotate the items.

What other things should we think about?
Post Reply

Return to “Chaos Strikes Back for Windows & Linux (CSBWin) / CSBuild”