[RELEASE] My makeshift shopping system, and currency.

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Sephiron
Posts: 300
Joined: Mon Jun 28, 2010 1:56 pm
Location: Michigun, pew pew!

[RELEASE] My makeshift shopping system, and currency.

Post by Sephiron »

Ok, so this is my first successful script, so criticism is very much appreciated! I'm currently using this in my HEXEN rpg, but I'm sure it'll work for doom mods too.
Also, if you see anything i did wrong here, please, PLEASE tell me how to better improve this! If you use this in your game, please give me credit or something. I don't like people claiming my work :<

The first thing you do, is make a new variable called GOLD. This is where the players currency is going to be stored, and where all the players gold will be when retrieved.

Code: Select all

#include "zcommon.acs"
int gold = 0;
Now that you have a currency created, you need things to buy. This part is somewhat a clusterfuck, so please bear with me. My final version will also use hudmessage instead of print because it looks much better.

Make a closed off area, like a counter, and place the item you want the players to buy behind it. Make the front of the counter execute the script when the use key is pressed.

Here's the script. It gives the player a description of the item, and when the use key is held, it allows them to purchase a "Health flask", which can be used any time (Only in hexen, so if you're a doom modder change the script to your liking).

Code: Select all

//Shop buy health flask?
script 5 (void)
{
print(s: "Health potion\nRecovers a portion of your health. Can be used any time.\nBuy this for 20 gold? hold use key to confirm.");
delay(10);  
  int buttons;
  while (TRUE)
  {
    buttons = GetPlayerInput(-1, INPUT_BUTTONS);
    if (buttons & BT_USE)
    if(gold >= 20)
    {SectorSound("ambient12", 127);
    gold = gold - 20;
      print(s:"Health potion bought for 20 gold.");
	GiveInventory("ArtiHealth", 1);
          delay(30);
      print(s:"gold:",d:gold);
        
      }
      else
      {
      print(s:"You do not have enough gold!");
            delay(30);
      print(s:"gold:",d:gold);
    }
    delay(10);
     terminate;
     }
     }
     
Ok, it may seem a little confusing. You activate the shop system by pressing the use key once. It will show you a description of what you're buying, how much it costs, and how much you have. It also tells you to hold the use key to purchase, or move away and the shop system will eventually deactivate.

Now you may be thinking, how would you get gold?
I have that covered. Killing a monster will give you 5 gold instantly. The reason i decided to not make their drops gold is because hexen puts a limit on how many of the same things you can hold. Here's the script you have to set to a monster to give you 5 gold when killed.

Code: Select all

     script 6 (void)
{
SectorSound("ambient12", 127);
gold = gold + 10;
print(s: "You get 10 gold");
}
Now, what if you want to add some variation to the gold pickups? What if you don't want the player to go around grinding for gold?
Well, you can make a chest and set the line in front to the script i made below.

Code: Select all

//There's 10 gold coins in chest
script 1 (void)
{
SectorSound("misc/keytry", 127);
gold = gold + 10;

}
Well, that's all I've got for you right now. I wanted my first contribution to the forums to be a big one, so i hope you guys like it. Also, again, I want you to give credit to me if used. I'm serious. I don't want to sound like a heartless and greedy fool, but It's not that hard to just say I made it.
User avatar
Caligari87
Admin
Posts: 6236
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: [RELEASE] My makeshift shopping system, and currency.

Post by Caligari87 »

Well, the monsters could still drop gold, just make the "Gold" item a custom pickup that executes the "give gold" script your dying monsters already run. Nice job on a first script, though, even if it's a little basic and could theoretically be accomplished through other means. ;)

8-)
User avatar
Sephiron
Posts: 300
Joined: Mon Jun 28, 2010 1:56 pm
Location: Michigun, pew pew!

Re: [RELEASE] My makeshift shopping system, and currency.

Post by Sephiron »

:<
I didn't really want to do that because I'm just starting to learn how to use XWE.
At least you will never EVER see my first attempt at this script. It's an embarrassment.
User avatar
Caligari87
Admin
Posts: 6236
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: [RELEASE] My makeshift shopping system, and currency.

Post by Caligari87 »

Sephiron wrote::<
Is that a frowny face? If so, there's no reason for it; I fully meant the compliment, good work.

8-)
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: [RELEASE] My makeshift shopping system, and currency.

Post by XutaWoo »

Sephiron wrote:The reason i decided to not make their drops gold is because hexen puts a limit on how many of the same things you can hold.
Not really, it just has a default maxamount, like...all of the games ZDoom supports, actually. [wiki=Actor_properties#Inventory]To change this, use the inventory.maxamount property (third down).[/wiki]

But I do like the Paper Mario vibe I get from this, so good job! :D
User avatar
Caligari87
Admin
Posts: 6236
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: [RELEASE] My makeshift shopping system, and currency.

Post by Caligari87 »

I think that's what he was saying, he doesn't know DECORATE yet, so an inventory item wouldn't work. He's using pure ACS for this, and "gold" is a global variable.

8-)
User avatar
XutaWoo
Posts: 4005
Joined: Sat Dec 30, 2006 4:25 pm
Location: beautiful hills of those who are friends
Contact:

Re: [RELEASE] My makeshift shopping system, and currency.

Post by XutaWoo »

No reason to not learn DECORATE, though. Especially since it's easier to display inventory items without having to loop a script.

Plus, multiplayer compatability without have to pool together the treasures, woo. :P
User avatar
Sephiron
Posts: 300
Joined: Mon Jun 28, 2010 1:56 pm
Location: Michigun, pew pew!

Re: [RELEASE] My makeshift shopping system, and currency.

Post by Sephiron »

I know how to use decorate >_>
Just not good at it yet.
Most i know is to set flags and add custom monsters...
ABOVE^
Multiplayer gold sharing can be a shit sometimes. I might do this. MIGHT.
Locked

Return to “Editing (Archive)”