Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How to Limit Your Gold With an Event. (XP)

Introduction


This is for XP, but I’m almost for certain that VX will work, but things may sound odd to VX users. So, after spending some time making a Bank for my game. I made a Tutorial. I posted it and someone commented asking, “Why use a Bank when you have almost unlimited Gold”. This is a wonderful question. The main reason I made a bank is because it was a wonderful way to have more content. You could do a lot with a Bank. When I say you can do a lot I mean things such as: an opening to a Quest(s), have one other place for your player to go and explore, add humor and character to the game, I also made a credit card system, store other things like items, or have it be apart of the game (Buying a house, taking out a loan, or heck pay taxes). But like the random person said, a Bank is kind of pointless when the player can have almost unlimited (the limit is actually 9999999) amount of Gold. I’ve searched everywhere (this site, others, and I Googled it) and I couldn’t find anything I didn’t already know. So back to the problem and the Tutorial; the player would only use and need a Bank if they HAD to store the Gold in it. Now you could go to your Script Editor, click on Game_Party, then go to about Line 132 and do some changing. Changing as in instead of having the number 9999999, put 500. This would make the Gold limit be 500 all through out your game. This to me is not what I want. I want and like to be able to have control of my game no matter where I am in it. I have a very basic understanding of Scripts, so, I’m stuck with only Events. That is where this whole mess comes in kids! You can set your Gold Limit to what ever and change it to what ever, when ever you want to. That’s a lot of evers….A good example of this is “Legend of Zelda: Ocarina of Time”. You have a limit to how much money you can carry, but you can gain bigger and bigger Wallets which enable you to hold more money.


What You Need


- Is one Common Event.
- One Event on Map.
- One Switch.
- Two Conditional Branches.
- One Loop.

The How To


Step 1: Open the Data Base. Its an Icon on your top tool bar, on the right side. It looks like a Windows window and is between The Magnify Glass and the Resource Manger. Once you click on it, you’ll need to go to the second to last tab, the Common Event Tab. Once there you’ll need to find an open space on the left side, the lists of Common Events. Click on an open space, which will give you a free spot to work on. Title the Common Event something like Gold Limit. Now you need to make a Switch (call it something like Gold Limit). To do this, Right click on the empty Command Section (big white part) and then click on insert. Now at this new window you want to look at the Right section, it’s the first one. Click on the button that reads Switch Operation. A new window will pop up. Now you need to click on the arrow on the left (this allows you to select a Switch). Another window will pop up. Now depending if you have Switches already or not, finding a open slot, at the bottom of the window type in the name of the Switch (name it something like Gold Limit). Next click on Apply, it’s a button at the bottom of the window. To exit, just click the X button on the top of the window. Do this with all your windows expect your Data Base (Common Event). Set the Common Event Trigger to Parallel Processing. Now put the Trigger Switch to the new Switch (the one you named Gold Limit or what ever you named it). If your having trouble finding where those settings are, they are at the top where the title of the Common Event is. When done, it will set you up for the next step. If your wondering what the freak you just did. That’s fine, I’ll explain. What you did was set the Common Event to Parallel Processing, which is saying that it will run Parallel to everything else in the Game. In other words what you do in the Common Event will always be in affect no matter where you Player is in the Game. The Trigger Switch is the Switch that Triggers the Common Event to happen. I’ll touch on that Switch a little later. Now on to the next Step.

Step 2: You now need to do some Eventing, (Step 2) is the heart of this all. Alright so here we go, I’ll tell you what your going to do and then explain what and why you did it. You need a Conditional Branch that reads how much Gold the player has. So on your empty space of a Common Event right click and then click on insert. On the first Tab of the window in the second set of buttons, reads a button, Conditional Branch. Click on that. A new window will come up, go to the fourth Tab. Click the circle that has Money is, then set it to >=. Next make the number 100(the number can be what ever you want. This is the new limit your setting to your Gold. In my case, the Player will only be able to have 100 Gold). Now press the ok button at the bottom. You should have something that looks like this:

<>Conditional Branch: Money is 100 or more
<>
: Else
<>
: End

If it does that’s great. It’s time for the next step!

Step 3: Now you need a Loop. A Loop does exactly what it says. It loops. So what we’re going to do is this. Right Click the Command space under the text Conditional Branch: Money is 100 or more. Then click on insert. Under the first Tab, click on the button under the Conditional Branch Button, Which reads Loop. You guessed it that’s what makes the Loop in the Event. Now your Event Commands should look like this:

<>Conditional Branch: Money is 100 or more
<> Loop
<>
: Repeat
<>
: Else
<>
: End

If it does that’s wonderful. Now we can fill it.

Step 4: Now we need something for the Loop to loop. That is where the next Event Command comes into play. This is the how the Limit stays a Limit. So what you need to do is Right Click under the Command Loop, the Command space within the Loop. Click on insert and under the first Tab, this time on the right side first section of buttons, click on the button that reads Change Money. A new window will pop up and you have a few options. The first is increase the second is decrease, then the number you can use to change the values of Gold, and lastly the reference to a variable. If you can’t guess what were going to select then this is what you do. Click on the circle for Decrease. Next click on (if its not already clicked) the constant. Change that number to 1. Lastly click on ok at the bottom. So if you are yelling, SUCKER SAY WHAT?! Let me bring you up to speed. First off this is what your Command list should look like so far:

<>Conditional Branch: Money is 100 or more
<> Loop
<> Change Money: -1
<>
: Repeat
<>
: Else
<>
: End

If it does, that is amazing! What is happening as of now is this: When the Players Gold reaches 100 Gold or more, the Game will read that and then Minus 1 Gold, which is what we want. We have to add more Commands, for this to work though, because this will freeze your game if you leave it this way. Which is why we need the next step.

Step 5: So what we need now is another Conditional Branch. So under the Change Money: -1 Command right click on the empty Command space. You know the drill, Click on Conditional Branch, same as before go to the last, fourth, Tab and click on Money is. But this time change it to <= and the number is the same, 100 after that click the ok button at the bottom. What this is going to do is run a check within the Loop, to see if the Players Gold is Less than or equal than 100. The Event Commands, at this point, should look like this:

<>Conditional Branch: Money is 100 or more
<> Loop
<> Change Money: -1
<> Conditional Branch: Money is 100 or less
<>
: Else
<>
: End
<>
: Repeat
<>
: Else
<>
: End

If it does, then that’s awesome! I’ll explain why we do this in the next step. Which is what were going to do, if you have everything right so far.

Step 6: Now the last thing we need to for this Common event is this. The first Command Space under and within the second Conditional Branch is where you need right click and then click on insert. On the first Tab, under the button Loop, is a button that reads End Loop. Click on End Loop. Which is the final thing you need to do in the common event. What you should have at the end is this:

<>Conditional Branch: Money is 100 or more
<> Loop
<> Change Money: -1
<> Conditional Branch: Money is 100 or less
<> End Loop
<>
: Else
<>
: End
<>
: Repeat
<>
: Else
<>
: End

If it does, then that’s excellent! At this point if your saying, “ SAY WHAT?! SUCKER SAY WHAT!?”. Then again, let me bring you to speed about everything that’s happening. Currently this Common Event when turned on will run Parallel, which means it will be in affect through out the game and the Commands will always be working. Working how you ask? Well here is how it all goes down (works). The First Conditional Branch Checks (always is checking) if the Player has 100 Gold or more. If this happens, and the Gold the Player has some how reaches 100 or more (like the Player opens a chest with 30 Gold and the Player already has 87 Gold) then the Conditional is met, which allows the NEXT Command to happen. The next Command is the Loop. The Loop is going to take 1 Gold away from the Player. The Change Money: -1 is the Gold being taken away from the player, and this is happening (1 Gold is being taken away) continuously, because it’s on a loop. BUT OH NOESS, you say? THAT’S GOING TO TAKES ME GOLDS, you say? Well that is why we have the second Conditional Branch. At this point it will be checking the Players Gold. When the Players Gold reaches 100 or less, the Loop ends and the Game stops taking 1 Gold from the player. Which will leave the player with 99 Gold, which is the new Limit (this is just for this Tutorial and is somewhat Based on Zelda’s Starting Money Limit. You can make your limit what ever you want). But we’re not done yet. One last step. Click the ok button on the bottom of the Data Base window to apply everything you just did and to exit the window.

Step 7: Now what we’re going to do is add an Event to your Map. Just one, because that’s all it takes. But what you need to understand is the Event has to be put on the beginning Map of your Game. You could actually do this other ways, but this is the easiest way to do for a Tutorial. Alright so go to your beginning Map (the Map where your Player starts on). I suggest a place that’s off to the side and at the same time easy to remember and Right click. Click on New Event. This will open an Event window. At the top, I suggest you title the Event (something like Gold Limit). This event needs no graphic. Now you what need to do, is set this Event to Parallel Processing. To find the Parallel Process on the Event, just look at the bottom of the window to the left, under the Trigger Section. Now the difference between this Parallel Process and the one in the Common Event is that one (Common Event) affects the whole game all the time, to where (Event on Map) only affects the one Map. The last thing you need to do is Right click on the empty Command Space and then click on insert. Again on the first Tab of the Command window were looking for Switch Operation. Its on the right first section. Click on the Button that reads Switch Operation. This brings up another window. You should click on (if its not already selected) Specific Switch. Next click on the arrow that opens the switch window. Find and click on the Switch you made earlier (the Gold Limit Switch). Lastly you need to make it turn on, or click on the circle for ON (if its not already selected). Then click ok at the bottom. Lastly…I really mean lastly, press ok at the bottom of the Command window. And your done. When you start your game the switch will turn on, which turns on the Common Event you’ve made and your Gold is at a limit you set! GREAT JOB! This is the end of the Tutorial, thank you for your time. I hope everything works out and that this is useful! May God Bless. Oh and if there are any problems or questions please ask. I’m refining my Banking system and will be rewriting the Tutorial. When I do, I’ll post it. This is my First post on this site. I hope it helps people.


Tips/Suggestions


- When doing this, if something isn’t working right, try checking the <= or the >=. You might of switched the two, which could make things kinda screwy.

- When doing this, if the game freezes, most likely the Loop Command is the problem. Take a breather and try to redo some steps and really pay attention to see where you’ve might of done something wrong.

- You could set the limit of gold, low and make it apart of the game to make the limit higher. This gives the Player something to work for and a little reward to ease the flow of game play.

- Please, unless you are confident in your skill and know what you want, do not mess with the order or the way things are done (meaning my system). This is the easiest and simplest way in doing what I set out to do.

- When doing this, and things aren’t working out, try checking to make sure the Conditional Branches are in the right places. This could cause a number of problems depending on where they are.

- You could do this with more than Gold. Such as some item your Player is to collect or something else. Example, would be chips in a poker game (there is normally a minimal and a limit to what you can bet) or something to that affect. But you may have to use a Variable. Again, may have to use a Variable, but you could limit the amount of Bread the Player can have…as an example.

- A thought I had, would be setting a weight limit on the things your Player carries. I saw a system where (at he end of the Eventing) your items had weight and your Player had a weight limit to what he could carry. You’d see something like that in Fall Out 3. I think my system could improve that system (in XP, not Fall Out 3...) if applied in the right way. But to do so would be complex and would use a lot more Eventing and Commands.

- When doing this, and something isn’t going right, try checking where you put the Change Money Command, it may be in the wrong place. Where it is now, is where it has to be.

- This has a lot of possibilities due to the fact you have complete control over what the limit is and when it can change. This is a great advantage and so use it wisely. This system may seem simple and small, but it could be used in so many ways.
 
Kidfox70":165ekz6i said:
<>Conditional Branch: Money is 100 or more
<> Loop
<> Change Money: -1
<> Conditional Branch: Money is 100 or more
<> End Loop
<>
: Else
<>
: End
<>
: Repeat
<>
: Else
<>
: End
Mistake noted. This manner will deplete money, what you should have said is:
<>Conditional Branch: Money is 100 or more
<> Loop
<> Change Money: -1
<> Conditional Branch: Money is 100 or more
<>
<>
: Else
<> End Loop
: End
<>
: Repeat
<>
: Else
<>
: End
 
Mistake noted. This manner will deplete money, what you should have said is:

Well after looking at it, I've found that there is no mistake and what you did only freezes the game. What I've done is the right way. The Point is take money from the Player until it reaches the Limit, then it stops. So if the limit is 100. The Player has 87 Gold on hand and then the Player gets an adward (this is an example) that is 50 Gold for killing a wolf. 87+50 is 137. So the game will read that the play now has 137 Gold, which will trigger the Commands and it will then minus 1 Gold until its to 99 Gold on hand. The game does all of this so fast that its impossible for the player to ever catch on what just happened. so the Player will always have 99 Gold as it's limit. I hope that cleared up some stuff, other wise try it again. Cause i've worked along time with this testing it in alot of ways and really refining the Events, the way I have it is the best.
 

opaj

Member

I hope it's not a faux pas to mention this, but your system doesn't seem to allow the maker to easily change the gold max mid-game (since it compares current gold to a set amount). So, in essence, it is a much more complex/inefficient way of achieving the same thing with a single line of script. Of course, perhaps the point of the tutorial is to teach the logic of eventing? Sorry if I'm misunderstanding. ^^

Code:
  def gain_gold(n)

    @gold = [[@gold + n, 0].max, $game_variables[1]].min

  end

Changing lines 130-132 of Game_Party to this will set the maximum amount of gold you can carry to game variable 1 (change $game_variables[1] to $game_variables[VARIABLE NUMBER] to choose your own game variable). Of course, you'll need to set your variable to 500 (or whatever) or else the player will be eternally broke, but this would allow you to increase/decrease the player's max gold at any time without constantly running an extra parallel process in the background.

Again, I apologize if I'm being rude. It's not my intention, just thought I'd throw this out there in case anyone wants to use it... ^^

(And of course, your tutorial actually teaches someone something... I'm just handing over an answer without much explanation. Give a man a fish and what have you...)
 

Zeriab

Sponsor

It's nice to see how much effort you have put into this tutorial Kidfox. :3
About the academic contents, that is the event itself. I would highly advice against using that method since it's so inherently inefficient.
The loop is unnecessary and give potentials for slow downs considering how XP interprets up to 4000 event commands per second. (Per interpreter)
A better way would be to simply reduce the amount of gold to 0 and increase the gold to the limit:
simplegoldlimit.png

It is both shorter, easier to understand, typically faster and never more than slightly slower. (If it ever is slower)
You did come a long way on your own and I commend you for trying :3

For easing limit change I would suggest basing the limit on variables rather than a hardcoded limit. Note that you cannot in a conditional branch check gold against a variable directly, but you can store the current amount of gold in a variable. An event implementing the idea of a variable containing the wallet size is shown below:
goldlimit.png



I would suggest using pictures from the event editor in your tutorial rather than spoilers since they show how the event looks in the editor so the readers don't have to consider that. If you find that to tedious I suggest at least using the [pre][/pre] or [code][/code] tags so you keep the indention.

I like the structure of your tutorial and also the tips and suggestions.
Good job on your tutorial! I look forward to seeing more from you :cute:

@opaj:
It's definitely not faux pas and it's good knowledge to have.
You should note the issue of the gold in hand not being reduced if the variable is reduced until gold is added or decreased.
It can be fixed by checking whether you have more gold than the limit just after you reduce the limit and in that case add 1 gold.
It's an easy fix, but it's still an issue which needs to be highlighted.

*hugs*
- Zeriab
 
Kidfox70":3bbvk0eb said:
Well after looking at it, I've found that there is no mistake and what you did only freezes the game. What I've done is the right way. The Point is take money from the Player until it reaches the Limit, then it stops. So if the limit is 100. The Player has 87 Gold on hand and then the Player gets an adward (this is an example) that is 50 Gold for killing a wolf. 87+50 is 137. So the game will read that the play now has 137 Gold, which will trigger the Commands and it will then minus 1 Gold until its to 99 Gold on hand. The game does all of this so fast that its impossible for the player to ever catch on what just happened. so the Player will always have 99 Gold as it's limit. I hope that cleared up some stuff, other wise try it again. Cause i've worked along time with this testing it in alot of ways and really refining the Events, the way I have it is the best.

let's say you had exactly 100 gold with this setup.
it will go like this:
Is gold >= 100?
:yes
Start Loop
:gold - 1 (98)
:is gold >= 100?
::No
:Return to top of loop
:gold - 1 (97)
:is gold >= 100?
::No
:return to top of loop
...
and so on. In theory, your method depletes the wallet and freezes the game.
 
and so on. In theory, your method depletes the wallet and freezes the game.

After looking it over, I think what your doing is this changing the second Conditional Branch to 100 or more. It has to be 100 or less. But the way you have it set up (^^^) does still work. What happened before when I tryed your method, is it froze up. But what I did was only move the end loop. My Conditional Branch was still 100 or less. Which is why it froze. Sorry for not paying attention, thank you and I hope I cleared things up.

As to Zeriab I have to tip my hat *tips hat*. That is a wonderful way to do it! I'm kinda jealious I didn't think of it. Thank you for your comment it has made really think and want to do better, not to mention this is only second Tutorial I've written and my First on this site. I think if we were to look on a time line (as in Exp in Eventing) that was from 1 to 100, I'd say I'm about 37. I have alot to learn, so thank you. I'll take your advice on Tutorial writting next time I go for one!

but your system doesn't seem to allow the maker to easily change the gold max mid-game

Your right. I major over sight on my part. But I guess the reason why I didn't go into detail about changing mid game, is because I figure the maker would be able to do so on his own. It would be simple enough. A Conditional Branch, maybe a Switch or two. I'd say the main point is the fact that no one really posted (Or I couldn't find one) how to limit the Gold by Eventing. To be honest I have a very Basic knowlegde of Scrpiting (I can read most of it, and understand even less, let alone write). But what you typed was very good to have here. You weren't rude and so I tip my hat again, but to you *tips hat*. I would admit my goal was to teach about certain aspects of Eventing, which is why I tryed to explain everything I did. Thanks again!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top