LoanSharks
#1
LoanSharks

by Kyonides-Arkanthos


Introduction


This scriptlet lets your heroes get personal loans from your "friendly" loan sharks?

Features

You may set the maximum amount of gold your heroes can get from the loan shark, the number of steps the heroes might do before they get charged a "modest fee" by the loan shark, and the interest percent itself. Now you may even make good use of invisible timers and game switches to create interesting bone-breaking events! Laughing + Tongue sticking out

Script Calls

Total Amount
$game_party.loans

Get a New Loan!
$game_party.new_loan(loanshark_id, amount)

Make a payment!
$game_party.pay_loan(loanshark_id, amount)

Get extra money!
$game_party.increase_loan(loanshark_id, amount)

Disable Loans!
Loans.freeze_loans

Enable Loans!
Loans.thaw_loans

The Script Itself

Code:
# * LoanSharks
#   Scripter : Kyonides-Arkanthos
#   2017-12-24

module Loans
  MAX = { 1 => 99999999, 2 => 99999 }
  TIME_LIMIT = { 1 => 300, 2 => 120 }
  SWITCH_IDS = { 1 => 10, 2 => 11 }
  INTEREST_STEPS = 100
  INTEREST_PERCENT = 10
  @disable_loans = nil
  def self.disable_loans?() @disable_loans end
  def self.disable_loans=(bool) @disable_loans = bool end
  def self.freeze_loans() @disable_loans = true end
  def self.thaw_loans() @disable_loans = nil end
end

class Game_System
  alias loans_gm_sys_up update
  def update
    loans_gm_sys_up
    timers = $game_party.loans_timer
    timers.keys.each do |ls_id|
      timers[ls_id] -= 1
      next if timers[ls_id] > 0
      sid = Loans::SWITCH_IDS[ls_id]
      $game_switches[sid] = true
      timers.delete(ls_id)
    end
  end
end

class Game_Party
  attr_reader :loans
  alias loans_gm_party_init initialize
  alias loans_gm_party_increase_steps increase_steps
  def initialize
    @loans = {}
    @loans_steps = {}
    @loans_timer = {}
    @loans.default = 0
    @loans_steps.default = 0
    @loans_timer.default = 0
    Loans.thaw_loans
    loans_gm_party_init
  end

  def new_loan(ls_id, amount)
    return if Loans.disable_loans
    @loans[ls_id] = amount
    @loans_steps[ls_id] = @steps
    @loans_timer[ls_id] = Loans::TIME_LIMIT[ls_id] * Graphics.frame_rate
  end

  def pay_loan(ls_id, amount)
    old_loans = @loans[ls_id]
    @loans[ls_id] = [old_loans - amount, 0].max
    lose_gold(old_loans - @loans[ls_id])
    return unless @loans[ls_id] == 0
    @loans.delete(ls_id)
    @loans_steps.delete(ls_id)
    @loans_timer.delete(ls_id)
  end

  def increase_loan(ls_id, amount)
    return if Loans.disable_loans
    old_loans = @loans[ls_id]
    @loans = [old_loans + amount, Loans::MAX[ls_id]].min
    gain_gold(@loans[ls_id] - old_loans)
  end

  def increase_steps
    loans_gm_party_increase_steps
    return unless @loans_steps.size == 0
    i_steps = Loans::INTEREST_STEPS
    i_perc = Loans::INTEREST_PERCENT
    @loans_steps.each do |k,v|
      next unless (@steps - v) % i_steps == 0
      @loans[k] += @loans[k] * i_perc / 100
    end
  end
end

Terms & Conditions

You got to credit me for making this scriptlet! Laughing + Tongue sticking out
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }
#2
Sneezing a Bump out of my reddish nose!

I was just hanging around when I came up with a way to implement a suggestion made by some boring people in the last couple of days. The results were a new version of my scriptlet, and I had to post it here obviously... Let's see if anyone really includes some bad ass mafioso or dozens of thugs in their videogames!
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }




Users browsing this thread: 1 Guest(s)