Has anyone coded a good way to give a player a list of items he can purchase? The list would have to be a bit randomized, containing only items that fit within the parameters of when the vendor is accessed, and which vendor it is.
My first attempt was to create the items in question, and set the .loc to the vendor mob. This is one place to store them, but I'm having a lot of trouble finding a good way for someone to view the items, including name, description, and price, then check the users bank account when he buys, moving the item if necessary.
Can anyone think of a good way to handle this both visually and programatically? Any general ideas would be of great value.
Thanks!
ID:180474
![]() Jun 4 2001, 12:17 pm
|
|
On 6/4/01 3:17 pm Skysaw wrote:
My first attempt was to create the items in question, and set the .loc to the vendor mob. This is one place to store them, but I'm having a lot of trouble finding a good way for someone to view the items, including name, description, and price, then check the users bank account when he buys, moving the item if necessary. When the user does a buy verb, you can pop up a list (or a statpanel) showing the vendor's content list, which is his inventory. That's one way, anyway. Probably one of us should do a vendor demo sometime. |
On 6/4/01 3:35 pm jobe wrote:
On 6/4/01 3:17 pm Skysaw wrote: Well I'm trying to predetermine some attributes of the items so the buyer can make a choice on what to buy. For example, the vendor might get in a gun with a certain quality level, and at a certain price. It would be available until someone bought it. I can't see any better way of keeping the item available than creating the object when the vendor's supply is updated. |
There's some shopkeepers in LexyMUD (Vitario and Vosaril) who actually do exactly what you're talking about, except that there's no way (right now) to tell what's good quality and bad quality before you buy the items, short of looking at the price and comparing that to the price of a "shelf version" of the item at another store.
Unfortunately, LexyMUD's code is not very opitimized right now and the shopkeeper procs are spread out over three files... that, and the buying interface I have right now isn't something you'd want to imitate. :) I'm thinking of doing it in the style of the Ultima 6ish games... when you talk to the shopkeeper, you can use keywords like "buy","sell","list"... list would cause him or her to tell you what's in stock, and those words would be Topic() links to the items in the store. If I get hammered out, I'll probably offer it to the public. But until then, will it help to know that what you're talking about can be done? :) To help you out, here's a very bare bones buy verb you can make. Put this verb somewhere in your shopkeepers. It won't take care of selling, or appraising, or anything like that, and you'll also have to write a restock() procedure to create a new item to replace the old. (You could also call this procedure in the mob's New(), to fill up the stock in the first place.) Anyways, it's not a pretty code, but it should work. (Change usr.gold and purchase.value to reflect whatever variables you do use to track currency and item worth.) verb/buy() set src in oview(2) //So you can talk across counters! var/purchase = input ("What can I get for you today?","The Shop") in src.contents if (usr.gold < purchase.value) usr << "You don't have enough gold!" /*an alert might be better, but I don't use alerts myself, so don't know the syntax.*/ else purchase.Move(usr) usr.gold -= purchase.value usr << "You buy \a [purchase] from [src]." src.restock() On 6/4/01 3:45 pm Skysaw wrote: On 6/4/01 3:35 pm jobe wrote: |
Thanks Lexy,
Yes, this is more or less the code I had. I wasn't satisfied because the popup buy list just showed names, and I wanted to avoid buyer's remorse when they found out what they were actually getting! LOL Anyway, I'll keep trying to solve the interface problem. That or just put this part off for now while I fix the million other things I need to do ;-) On 6/4/01 4:19 pm LexyBitch wrote: There's some shopkeepers in LexyMUD (Vitario and Vosaril) who actually do exactly what you're talking about, except that there's no way (right now) to tell what's good quality and bad quality before you buy the items, short of looking at the price and comparing that to the price of a "shelf version" of the item at another store. |
Yes, this is more or less the code I had. I wasn't satisfied because the popup buy list just showed names, and I wanted to avoid buyer's remorse when they found out what they were actually getting! LOL Well, you could create a list that uses associated values, so that the item's "ad copy" is associated with the actual object. Assume you have a list called "inStock" that contains all the items for sale... var/list/saleList[0] for(var/obj/O in inStock) var/tempName = "[O.name], $[O.price], [O.quality] shape" //or whatever saleList[tempName] = O Then prompt the user with saleList. The user will see: sword, $500, poor shape Super Duper Flutz, $20, excellent shape Then take the string that's returned from input() and get the associated object from the list. var/result = input(bla, bla) in saleList if(result) userChoice = saleList[result] Disclaimer: I haven't tested this, so beware... |
Ok, I almost have something very cool here. I could use a little help, though.
mob/vendor weapons tickle() // called periodically to give mob a chance to do something if (prob(20)) spawn_gun(src) // routine spawns a gun on vendor & sets its stats verb buy() set src in oview(1) usr.buying = TRUE usr.buy_title = "Weapons" usr.buy_content = contents Stat() Stat() if(buying) statpanel(buy_title, buy_content) ..() The above code creates a new stat panel when the player "buys" from the vendor. The panel shows a listing of everything the vendor has. The only thing missing is being able to define and activate verbs ("Examine", "Purchase"). How do I get defined verbs to show up in this panel by right-clicking the items? I tried: obj/verb purchase(mob/supplier as obj) set src in supplier.contents ..... ..... // code for attempting purchase ..... But this gives me the error "unsupported src setting." I'm looking over VERB & ARGUMENTS in the reference guide now to try to figure out how to build the verbs from sratch and attatch them to the panel somehow, but I have a feeling someone out there can offer a quick fix or suggestion. On 6/4/01 3:17 pm Skysaw wrote: Has anyone coded a good way to give a player a list of items he can purchase? The list would have to be a bit randomized, containing only items that fit within the parameters of when the vendor is accessed, and which vendor it is. |
Create the verbs as procs and add them to the item with obj.verbs.Add(), then remove them with obj.verbs.Remove(). In fact, in the shopkeepers Entered() procs, you could put the lines
obj.verbs.Add(proc/mydefinedverbs/buy) obj.verbs.Add(proc/mydefinedverbs/examine) and so on, and put .Remove in Exited(). this should automatically tag any objects the shopkeeper gets with the necessary verbs, and remove them if the item is stolen or bought. On 6/4/01 6:01 pm Skysaw wrote: Ok, I almost have something very cool here. I could use a little help, though. mob/vendorweaponstickle() // called periodically to give mob a chance to do somethingif (prob(20)) spawn_gun(src) // routine spawns a gun on vendor & sets its statsverbbuy()set src in oview(1)usr.buying = TRUEusr.buy_title = "Weapons"usr.buy_content = contentsStat()Stat()if(buying)statpanel(buy_title, buy_content)..() The above code creates a new stat panel when the player "buys" from the vendor. The panel shows a listing of everything the vendor has. The only thing missing is being able to define and activate verbs ("Examine", "Purchase"). obj/verbpurchase(mob/supplier as obj)set src in supplier.contents.......... // code for attempting purchase..... But this gives me the error "unsupported src setting." I'm looking over VERB & ARGUMENTS in the reference guide now to try to figure out how to build the verbs from sratch and attatch them to the panel somehow, but I have a feeling someone out there can offer a quick fix or suggestion. |
Thanks for your help.
I'm not sure I totally understand this, but I'll putz around with it. How would the verbs be accessible by the person standing there and not to the world? On 6/4/01 6:11 pm LexyBitch wrote: Create the verbs as procs and add them to the item with obj.verbs.Add(), then remove them with obj.verbs.Remove(). In fact, in the shopkeepers Entered() procs, you could put the lines mob/vendorweaponstickle() // called periodically to give mob a chance to do somethingif (prob(20)) spawn_gun(src) // routine spawns a gun on vendor & sets its statsverbbuy()set src in oview(1)usr.buying = TRUEusr.buy_title = "Weapons"usr.buy_content = contentsStat()Stat()if(buying)statpanel(buy_title, buy_content)..() The above code creates a new stat panel when the player "buys" from the vendor. The panel shows a listing of everything the vendor has. The only thing missing is being able to define and activate verbs ("Examine", "Purchase"). obj/verbpurchase(mob/supplier as obj)set src in supplier.contents.......... // code for attempting purchase..... But this gives me the error "unsupported src setting." I'm looking over VERB & ARGUMENTS in the reference guide now to try to figure out how to build the verbs from sratch and attatch them to the panel somehow, but I have a feeling someone out there can offer a quick fix or suggestion. |
I've been trying to think up a way, not only for NPCs to simply sell what is in their inventory, but for players to be able to sell what is in their inventory as well.
I've considered this possible solution: Much like the unequip command, a player is able to mark an object as "for sale" (which also unequips that item), and when that item is for sale and another player uses a 'list' command at that player, it will list all objects in the player's inventory that are marked with the 'for sale' tag. Then, some kind of 'buy mob obj' command that checks if the object is marked for sale, checks the set price, and if you have the money transfers that players object to your inventory, and transfers your gold to that player. Using this method, a player is also able to simply setup a shop and go for a walk (IRL) and let other players buy things from them and thus they are earning money while they're gone. Could be interesting... Anyone have any comments, suggestions, insults? |
Well I refused to give up. After many hours (and a nice nap in-between), I finally worked out something that I think is pretty cool. See the first half of the solution in my earlier post called "Half of a good solution..."
Instead of dynamically creating verbs (which I tried with varying success), I used Click() and DblClick() to get a description and to initiate a sale respectively. The end result is: 1. a "Purchase" panel that pops up when the player uses the buy() verb. 2. the panel lists all objects owned by the vendor (stuff for sale) 3. if the player clicks once, he gets a description of the item, and the price. 4. if the player double-clicks, he buys the item (if he has enough money. 5. the panel closes if the player walks away. Well it all works, but I'm at work now, and the code is at home. I'll probably test it a tiny bit more before uploading it as (drumroll, please).... my first BYOND library! Woohoo! Cheers, Skysaw On 6/4/01 3:17 pm Skysaw wrote: Has anyone coded a good way to give a player a list of items he can purchase? The list would have to be a bit randomized, containing only items that fit within the parameters of when the vendor is accessed, and which vendor it is. |
um you dont need to store the items anywhere but the code.. oh yeah and sorry i cant help. im busy. im wirteing claims of disclaimers. its alot of fun you should give it a try. read my post about BYOND 100(READ!!)