How do I make a trader?

  • So, i've searched far and wide for the answer on the forums and youtube/google but to no avail. For the life of me, I couldn't find how to make a merchant/trader.

    So, my goal is for both him and player have 4 same items and the buy/sell prices are the same (eg. he sells "meat", "helmet", "armor" and "sword" for 1, 2, 3, 4 gold respectfully, but buys the same things from you for the same price of 1, 2, 3, 4 gold respectfully).

    I've made simple global variable to represent player's gold, items and their prices (Text object that has instance variable) and that's about it.

    What I need is :

    1) Make player's inventory (don't need picures or anything, just text saying "You have :X pieces of meat")

    2) Have the prices vary on visit after a trigger (first time you visit him prices are 1,2,3,4 but if you come to him again after a day they get to 3,4,5,6. My idea is to make a fixed variable for each of the items representing it's base value and then add random number-from A to B, to prevent cheap stuff massivly overprice the usually more expensive stuff.

    3) Have him have lmited number of each item to trade

    ty for any help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can always use random for price and amount.. like the variable MeatPrice could be Random(1,3). this would make the price be 1, 2 or 3 randomly. I made a REALLY simple space trader game that did this so different space stations would have different values each day. This way the player would have to travel each day to make a profit.

    Does this help at all or should I make a quick example?

  • That's EXACTLY what i've been looking for! But i would love it if you gave me an example because my experience in C2 is literally less then a week

  • jouzeph if you want to learn more with Construct 2 example try this link. You will learn more here

    https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0

  • ok, i need only 1 more thing.

    how can i get a random number and then add it to an existing variable?

  • jouzeph I have add this file in dropbox it's call 1 jouzeph for you

    https://www.dropbox.com/sh/eioscti86bpr ... 7YPza?dl=0

  • jouzeph I have add this file in dropbox it's call 1 jouzeph for you

    Thank you man! you're the beast!

  • jouzeph most welcome

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