[RELEASE] My makeshift shopping system, and currency.
Posted: Mon Jun 28, 2010 2:53 pm
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.
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).
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.
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.
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.
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;
}