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;
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;
}
}
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");
}
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;
}