• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

PokéUnion Bank System Script

thor348

That's Oak to You
137
Posts
11
Years
Hello everyone, I have spent the past few hours developing this bank system script for my new project. I was contemplating releasing it or not because of the depth of possible detail based upon the developer discretion. When you examine the script, there are a few things I could have done to shorten it and still have it's level of functionality, but I script different than most and i'm fine with that.

*Credit Required if Used/Changed

Version 1.0
Spoiler:

Version1.1
Modified by Laureolus with help from Maruno
To be more "Plug and Play"
Spoiler:
 
Last edited:

Wootius

Glah
300
Posts
11
Years
  • Seen May 31, 2022
Are you sure your interest methods work? I had to rework the step counter myself. Otherwise thank you for sharing this, I'm going to use it myself!

I also removed the reliance on switches.

Bank script

Spoiler:

Game_Player
Spoiler:
 

Nickalooose

--------------------
1,309
Posts
15
Years
  • Seen Dec 28, 2023
Interesting.

Nice script, better with Lauerolus' edits.

I'm not totally sure what this script does differently to using CommonEvents... Less work, less Variables...

But nevertheless, nice Interest script and using steps too, nice touch.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
There's no need to fiddle with the Game_Player scripts. You can add an event procedure instead (where the "event" is "player takes a step"), which both counts steps until the next interest addition and actually adds that interest (i.e. what pbCalcInterest does, which incidentally isn't actually called anywhere so it doesn't work). Here's an existing step procedure which makes Pokémon happier that you can copy:

Code:
Events.onStepTaken+=proc{
  $PokemonGlobal.happinessSteps=0 if !$PokemonGlobal.happinessSteps
  $PokemonGlobal.happinessSteps+=1
  if $PokemonGlobal.happinessSteps==256
    for pkmn in $Trainer.party
      if pkmn.hp>0 && !pkmn.egg?
        pkmn.changeHappiness("walking")
      end
    end
    $PokemonGlobal.happinessSteps=0
  end
}
You can include a class snippet extending PokemonGlobalMetadata so that some extra variables are included, like so:

Code:
class PokemonGlobalMetadata
  attr_accessor :bankInterestTimer
  attr_accessor :bankAccountType
  attr_accessor :bankAccountBalance

  def bankInterestTimer
    @bankInterestTimer=0 if !@bankInterestTimer
    return @bankInterestTimer
  end

  def bankAccountType
    @bankAccountType=0 if !@bankAccountType
    return @bankAccountType
  end

  def bankAccountBalance
    @bankAccountBalance=0 if !@bankAccountBalance
    return @bankAccountBalance
  end
end
And so on. This approach is better because it creates new variables to use, rather than rely on existing variables which the user could already be doing something else with, and is therefore more plug 'n' play.
 

thor348

That's Oak to You
137
Posts
11
Years
Are you sure your interest methods work? I had to rework the step counter myself. Otherwise thank you for sharing this, I'm going to use it myself!

I've tested it through and through in my game so I know it fully works. I added the += in Game_Player where you did as well.

There's no need to fiddle with the Game_Player scripts. You can add an event procedure instead (where the "event" is "player takes a step"), which both counts steps until the next interest addition and actually adds that interest (i.e. what pbCalcInterest does, which incidentally isn't actually called anywhere so it doesn't work). Here's an existing step procedure which makes Pokémon happier that you can copy:

Code:
Code:
Events.onStepTaken+=proc{
  $PokemonGlobal.happinessSteps=0 if !$PokemonGlobal.happinessSteps
  $PokemonGlobal.happinessSteps+=1
  if $PokemonGlobal.happinessSteps==256
    for pkmn in $Trainer.party
      if pkmn.hp>0 && !pkmn.egg?
        pkmn.changeHappiness("walking")
      end
    end
    $PokemonGlobal.happinessSteps=0
  end
}
You can include a class snippet extending PokemonGlobalMetadata so that some extra variables are included, like so:

Code:
Code:
class PokemonGlobalMetadata
  attr_accessor :bankInterestTimer
  attr_accessor :bankAccountType
  attr_accessor :bankAccountBalance

  def bankInterestTimer
    @bankInterestTimer=0 if !@bankInterestTimer
    return @bankInterestTimer
  end

  def bankAccountType
    @bankAccountType=0 if !@bankAccountType
    return @bankAccountType
  end

  def bankAccountBalance
    @bankAccountBalance=0 if !@bankAccountBalance
    return @bankAccountBalance
  end
end
And so on. This approach is better because it creates new variables to use, rather than rely on existing variables which the user could already be doing something else with, and is therefore more plug 'n' play.

I thought of doing the step counter that way, but also wanted a way to have a Global count if I ever needed another one so I decided to do it through Game_Player. And yes, I hadn't thought of creating new variables due to I wasn't going to make this script for others, but just my game relying on my preset variables/switches.
And pbCalcInterest does work. Whenever you access your account through the bank teller, there's a script which calls it from within the event. It's not done within the script but rather the event itself.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
I thought of doing the step counter that way, but also wanted a way to have a Global count if I ever needed another one so I decided to do it through Game_Player.
Um, what? At the end of every step the player takes, def Kernel.pbOnStepTaken is called, which in turn calls the Events.onStepTaken procedure.

If you want separate interest timers for each account (for some odd reason, given that happiness gain and poisoning all uses single timers), then you can make bankInterestTimer and the other variables be arrays rather than single numbers. This requires no changes to existing scripts, which is better.

And pbCalcInterest does work. Whenever you access your account through the bank teller, there's a script which calls it from within the event. It's not done within the script but rather the event itself.
Ah, so you just didn't tell us how to use your scripts. Pretty big omission there.
 

Wootius

Glah
300
Posts
11
Years
  • Seen May 31, 2022
That's awesome Maruno. I should have thought of happiness/egg hatching counter.
 

thor348

That's Oak to You
137
Posts
11
Years
Ah, so you just didn't tell us how to use your scripts. Pretty big omission there.

My sincerest apologies. Considering you can call anything basically from an event, I wouldn't have thought that pbCalcInterest would've been excluded from that category.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
True, we know we can call (almost) any script through events. There just aren't any indications that we're supposed to, or when to do so. A screenshot of a bank teller event would help people use your scripts.
 

thor348

That's Oak to You
137
Posts
11
Years
True, we know we can call (almost) any script through events. There just aren't any indications that we're supposed to, or when to do so. A screenshot of a bank teller event would help people use your scripts.

I only posted half of the bank script. The other half has a concept that I haven't ever seen before in a fan game or franchise game. My Teller events include these "original" functions and I don't want them to be known until I release my new project.
But if anyone has any question on how to set this up to work properly, I'd be more than happy to help.
 

Wootius

Glah
300
Posts
11
Years
  • Seen May 31, 2022
All in one banking class. I've taken Maruno's advice and ran with it and also learned how to use Global variables in the process. Win/win!

Thank you again thor348 for posting this.
Spoiler:
 

thor348

That's Oak to You
137
Posts
11
Years
All in one banking class. I've taken Maruno's advice and ran with it and also learned how to use Global variables in the process. Win/win!

Thank you again thor348 for posting this.
Spoiler:

Very nice. Would you like me to edit the thread post so it shows this version one at the top?
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
There's no reason to not also put the contents of def pbCalcInterest into the onStepTaken procedure (and delete def pbCalcInterest). Like so:

Code:
Events.onStepTaken += proc{
   if $PokemonGlobal.bankInterestTimer
     $PokemonGlobal.bankInterestTimer += 1
     if $PokemonGlobal.bankInterestTimer >= 500
       a = [5, 15, 30, 50][$PokemonGlobal.bankAccountType - 1]
       $PokemonGlobal.bankAccountBalance += a
       $PokemonGlobal.bankInterestTotal += a
       $PokemonGlobal.bankInterestTimer -= 500
     end
   end
}
Way more compact, automatic addition of interest when it's earned, and a little easier to read and fiddle the numbers of.

Your code in def bankInterestTotal is wrong, by the way.
 

Wootius

Glah
300
Posts
11
Years
  • Seen May 31, 2022
Haha, I copypasta'd bankAccountBalance when I noticed I didn't have it defined while posting it and forgot to change it, sorry sorry. At least pbSetupAccount is right! But that array magic is nice !

AS for when the interest is acquired, does it matter? I'd rather do it at the teller and have a nice message then by autostep.
 

Maruno

Lead Dev of Pokémon Essentials
5,285
Posts
16
Years
Technically there wouldn't be a difference between adding the interest when it's earned and adding it in bulk just before accessing your account. However, having the code in the procedure means it's one less method to manually call in the teller event, thus making it more convenient to use and more plug 'n' play. It also makes much more sense to see that interest is gained in "real time" rather than in bulk when required.

Actually, if you change account types in the middle of a stretch of walking, then having the code in the procedure means the new interest rate applies immediately and only applies after the account type is changed. Otherwise you could run the risk of having the player walk a whole lot, then upgrade their account type and check their balance, which would cause pbCalcInterest to apply the higher interest rate to all that walking undeservedly. That's if you don't structure the bank teller's event correctly, which someone could do because there aren't any instructions.
 

Wootius

Glah
300
Posts
11
Years
  • Seen May 31, 2022
Stop being right all the time Maruno. I'll make an example bank teller(s) and move the code over later.
 
Back
Top