[MV]Shop/building buying system that then generates passive gold income.

JTK

Villager
Member
Joined
May 25, 2018
Messages
25
Reaction score
4
First Language
english
Primarily Uses
RMMV
I'm looking for a plugin that has a similar function to how Fable 3's shop and building buy system was. Lets say you buy a building for 1,000 gold then every 15 minutes you receive 75 gold back.

In a dialogue choice tree the player will have an option to purchase the shop if they have enough gold.

The Houses/Inns could be rented out to npcs that return small amounts of gold every 10 minutes similar to shops.



fable 3 income.jpg


[urchase store.png
 

Attachments

caethyril

^_^
Veteran
Joined
Feb 21, 2018
Messages
1,510
Reaction score
993
First Language
EN
Primarily Uses
RMMV
In case you're interested, I think you can do all this with eventing (and maybe a little scripting), no plugin required~

There are two concepts at play here:
  1. Store the last time gold was added, and
  2. Add gold based on how much time has elapsed since then.
Part 1 depends on how you want to measure time, here's a couple of examples:
  • Real-time:
    ...I've assigned a time value to a variable using Control Variables > Script:
    Code:
    Math.floor(Date.now() / 1000)
    Date.now() gets the milliseconds since midnight on 1 Jan 1970. More details here: the Date object (MDN).
  • Game time: Control Variables > Game Data > Other > Play Time; this is measured in seconds and will increase every frame of gameplay during that playthrough, including in menus etc.

Part 2 can be done with an event. The example below is for a Parallel-trigger event, but if you're OK with getting the gold via Action Button or something (e.g. when you next talk to the NPC) then a similar approach applies, just remove the wait time at the end. :kaophew:

Get the current time (however you're doing that), then check it against the stored time; if the difference is large enough, add the gold and update the stored time; finally, wait a little and check again later. Example with two variables (and a whole bunch of comments):
Code:
◆Comment:Just in case! Check if timestamp not yet set
:       :(Best done once, in a separate event, e.g. when you make the original investment)
◆If:Time = 0
  ◆Comment:OK, set it
  ◆Control Variables:#0020 Time = Math.floor(Date.now() / 1000)
  ◆
:End
◆Comment:Get difference between time now and stored time
◆Control Variables:#0008 Temporary = Math.floor(Date.now() / 1000)
◆Control Variables:#0008 Temporary -= Time
◆Comment:Check if difference is more than 15 minutes (900 seconds)
◆If:Temporary ≥ 900
  ◆Comment:Divide by 900 to get how many intervals have elapsed (rounds down automatically)
  ◆Control Variables:#0008 Temporary /= 900
  ◆Comment:Update timestamp~
  ◆Control Variables:#0008 Temporary *= 900
  ◆Control Variables:#0020 Time += Temporary
  ◆Control Variables:#0008 Temporary /= 900
  ◆Comment:Multiply by gold per interval
  ◆Control Variables:#0008 Temporary *= 75
  ◆Comment:Add gold!
  ◆Change Gold:+ {Temporary}
  ◆Comment:Testing message...
  ◆Text:None, Window, Bottom
  :    :You got \v[8] gold!
  ◆
:End
◆Comment:Now wait 60 frames (run event once per second)
◆Wait:60 frames
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,847
Reaction score
12,257
First Language
English
Primarily Uses
RMMV
I also have a multi-timers plugin that would work for this. IF you want the income to be passive (you get paid every 15 minutes, and you don't have to go back to the shop to collect).
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

The new intro Logo for my videos.

I speed it up, the one I use to use was to long.
The workweek is now over. Now I can work on my GamZzzzzZzzzzZzzzZzzZz....
Just watched Onward with the family. One of the best movies I've ever seen. <3
2 hours & 20 minutes remaining. :D
...trying to hurry finish up all commissions before I never put the controller down again ;)

Forum statistics

Threads
95,823
Messages
932,195
Members
126,256
Latest member
tehgreatestsam
Top