KExpire XP
#1
KExpire XP

by Kyonides Arkanthes


Introduction

This scriptlet exists in order to let you make your items expire either after walking a long distance or time is up just because. Laughing + Tongue sticking out That means that it will replace them with useless items automatically. Should I feel sorry for all of you players now? Laughing

Script

Code:
# * KExpire XP
#   Scripter : Kyonides-Arkanthes
#   2019-02-27

#   This scriptlet allows you to setup items that will expire because the team
#   walked a long distance or time is up. Then it will replace it with a useless
#   item to piss off the player. XD

module KExpire
  # ItemID => [NewItemID, :step or :time, steps or seconds], etc.
  ITEMS = { 32 => [33, :step, 25] }
end

class BadItem
  def initialize(new_id, data)
    @id = new_id
    @next_id = data[0]
    @kind = data[1]
    @amount = data[2]
  end
  def expired?() @amount == 0 end
  def reduce_amount() @amount -= 1 end
  attr_reader :id, :next_id, :amount, :kind
end

class Game_System
  alias kyon_kexpire_gm_sys_init initialize
  alias kyon_kexpire_gm_sys_up update
  def initialize
    kyon_kexpire_gm_sys_init
    @step_items = []
    @time_items = []
  end

  def update
    kyon_kexpire_gm_sys_up
    @time_items.each do |item|
      item.reduce_amount
      $game_party.expire_item(item.id, item.next_id) if item.expired?
    end
  end

  def trash_items(item_id, kind, number)
    if kind == :step
      stuff = @step_items.select{|item| item.id == item_id }
      number.times {|n| @step_items.delete(stuff[n]) }
    elsif kind == :time
      stuff = @time_items.select{|item| item.id == item_id }
      number.times {|n| @time_items.delete(stuff[n]) }
    end
  end
  def reduce_steps() @step_items.each {|item| item.reduce_amount } end
  attr_reader :step_items, :time_items
end

class Game_Party
  alias kyon_kexpire_gm_party_gain_item gain_item
  alias kyon_kexpire_gm_party_inc_steps increase_steps
  def gain_item(item_id, n)
    old_max = item_number(item_id)
    kyon_kexpire_gm_party_gain_item(item_id, n)
    data = KExpire::ITEMS[item_id]
    return true unless data
    new_max = item_number(item_id)
    if old_max > new_max
      trash_items(item_id, data[1], old_max - new_max)
    elsif old_max < new_max
      total = new_max - old_max
      if data[1] == :step
        total.times { $game_system.step_items << BadItem.new(item_id, data) }
      elsif data[1] == :time
        data[2] *= Graphics.frame_rate
        total.times { $game_system.time_items << BadItem.new(item_id, data) }
      end
    end
    return true
  end

  def expire_item(old_id, new_id)
    total = [item_number(old_id) - 1, 99].min
    total > 0 ? @items[old_id] = total : @items.delete(old_id)
    old_max = item_number(new_id)
    @items[new_id] = [old_max + 1, 99].min
  end

  def increase_steps
    kyon_kexpire_gm_party_inc_steps
    $game_system.reduce_steps
  end
end


Terms of Use

This will be a cheap script in case you go commercial, do not forget to include my name in your game credits!
"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 }


Messages In This Thread
KExpire XP - by kyonides - 02-27-2019, 07:15 AM



Users browsing this thread: 1 Guest(s)