Need help urgently

I have made a dungeon-crawling RPG with squiffy.

I have a shop that pops up. You can play the game here. /

http://textadventures.co.uk/games/view/mraa66li40imctqqi8ob1w/infinite-dungeon-v-1-0-1

So, I have a few questions.

  1. How can I get my shop to actually charge?
    If you buy from the traveling merchant, you just lose coins and get the item, even if the item costs more than what you have.

  2. Randomisation
    Is there a way to make the merchant encounters random?

  3. Level-related loot
    I'd like to have the loot dependent on the player's level.
    E.G You get 1 gold × player level.

  4. ASCII Art
    (If you don't what this is, look it up.)
    Whenever I add ASCII art to my game (even using the <pre> html tags), squiffy squashes it into a little box.

Thanks


I'll take these down the line. Let me see if I can come close. And I'm just freewheeling the code - it might take some debugging.

For the first, how to make them charge. Howabout something like this.

cash=cash on hand. So...

[[Start]]:

@set cash=75
@set swordcost=50
@set numSwords=0

You have {cash} cash.

A sword costs {swordcost}.

{if cash>=@swordcost:[buy a sword]}

[[I'm done here]](game continues)

[buy a sword]:

@inc numSwords
{@cash-=@swordcost}

You've bought a sword!

[[game continues]]:

You have {cash} cash.

You have {numSwords} swords.

For the randomly-occuring merchant, you'll need a randomizer. I'm including it here so you'll set the function when the game starts, and it will be available everywhere. This will give you a merchant 1/3 of the time. Boost the max value to 1000 and you'll never see him. Set max to 1 and you'll always get him. Note that indentation is critical here - four spaces in each of the java sections, and they always go FIRST in their sections.


    //RANDOM NUMBER GENERATOR
    squiffy.getRndInteger = function(min,max){
        return Math.floor(Math.random() * (max - min + 1) ) + min;
    };
    
Welcome to the game. We've established a randomzier above. Make sure you use it wisely. First value is the min number, second the max.

[[Continue down the road]](event1)

[[event1]]:

    set("merch",squiffy.getRndInteger(1,3));

Hey, this place on the road looks like a place I'd find a merchant a third of the time.

{if merch=1: [[Hello, Mr Merchant!]](enc)}
{else:[[Nobody here]](no enc)}

[[enc]]:

So, what do you have to sell me...?

[[no enc]]:

So lonely....

The third (level based loot) is pretty simple. Well, simple if you know the right spells...


@set cash=100
@set level=3

...and so thus the monster is dead. Even though I have {cash} cash, I'm always hungry for more loot. Let's see what [[this monster had]](grub)

[[grub]]:

@set loot=100
{@loot*=@level}

I found {loot}!

{@cash+=@loot}

Now I have {cash} cash!


Not sure about that last one. Usually, if I'm using gifs or jpgs, I use the following command.

<img src={gGif} alt="scene" height=200 width=200>

gGif is the name (with the extension} of your file. And make sure the file is either in your folder, or give it a subfolder path and name. You can play with this. You'll have to check pixels on your art, but paint or any other program (or even file explorer) will give you this.


Just thought about what you said, this being a shop. In this case, you probably need to be able to buy multiple things. So my first example, my cute passage use (single brackets) won't work so hot. No, you'll need sections to force the code back (and recalculate cash). So what I'm showing you below would be grafted into the first example.

@set cash=100

Lets go into the [[Shop]].

[[Shop]]:

You are in a shop. You have {cash} cash.

[[Buy item 1]](item1)

[[Buy item 2]](item2)

[[Leave shop]](leave)

[[item1]]:

@dec cash 25
@inc item1

You bought item 1

[[what else?]](Shop)


[[item2]]:

@dec cash 50
@inc item2

You bought item 2

[[what else?]](Shop)

[[leave]]:

Thank you. Come again.

You have {cash} cash.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums