[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,463
Reaction score
952
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,535
Reaction score
12,057
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

welp, the stock market went down by 7% because of corona today. Time to buy stocks?
Man, being able to edit my game WHILE testplaying it is like the most convenient thing EVER. Thank you, MV...it even makes up for the OGG thing. Well, almost.
Back in the old days, long before I was born, salted crisps - or potato chips, for you yanks - came unsalted and had a little pouch of salt to manually shake on it. Of course, things are more efficient now, but Walker's still brought back the old 'Salt 'N' Shake' style a couple years ago. Dunno why, but if I had to guess, I'd say it's because the nostalgia crowd were getting salty.
Guys I just want to sit around and work on my game! *gets lots and lots of money shoveled at him* Game, I don't recall a game. What game? :LZSexcite:

Forum statistics

Threads
94,555
Messages
921,842
Members
124,416
Latest member
zths
Top