How would I make this work? Selling random items.

  • Im making a small rpg game, mostly text based, where you buy stuff and then sell it. I have made the buy screen, and the inventory, but I am struggling on making the actual selling part. I think im going to make it automatically sell when you press "start selling". (if you have a better idea on how I can do the selling part of the game, let me know). So I have global variables for each different product you can buy, how would I make it so a set number of customers come in to buy stuff, and when they do buy stuff they buy a random number of one or more different products? Thanks in advance!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • No suggestions?

  • There are so many ways to do this, it would really help to see your .capx (or preferably a simplified version of it.) To give you specific help I need to know, for example, how you are storing inventories. Are you using arrays? (I would.)

    As far as managing the purchase you might try something roughly along the lines of:

    system-> repeat NumberofCustomers times

        system-> pick each product

               QuantityPurchased = int(random(0,QuantitySellerHasOnHand))

    Then you'd deduct the quantitypurchased from the seller's inventory and add it to the buyer's inventory, and increase the seller's cash and decrease the buyers cash, etc.

    Hope that helps at least a little!

  • Ok well this is what I have so far. The selling part is in the "Game Events". Each "RandomBuy" is going to be representing a different customer (5 customers a night without the upgrade, which will then take it to 10). There needs to be a chance that the customers rob you of product, which needs to be one of the random numbers. Let me know what I can do here!

    dl.dropbox.com/u/68458825/Game.capx

  • Oh and it also needs to be able to upgrade the amount of profit if you have the upgrade... looks like this is going to take veryyyy long if I continue with how im doing it right now...

  • To me the approach you are taking seems very difficult to understand and manage. Maybe someone else will have better luck understanding what you are trying to do and what your next step would be.

    If you are willing to do some rework of your project, here is a link to a project that does some of what you want. The store starts out in a closed state and after a certain number of ticks, goes to an open state. When open it is possible to make sales of a random quantity of random products to up to a maximum number of customers by clicking a button.

    store.capx

    To upgrade the number of customers you would just change MaxCustomers.

    Do you mean increase the profit or increase the revenue? If you mean revenue (which is price * qty) then just multiply by another upgrade factor and make it price*qty*factor. For example, 3*10=30 vs 3*10*1.5=45.

    If you have questions about the capx I linked to, let me know.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)