KPass XP
#1
KPass XP
Kiwi and Mango Versions

by Kyonides

Introduction

This script is supposed to be used as a means of blocking access to certain zones or maps in your games. The implemented method here is a passport! Your heroes might get one from the very beginning or never ever or after a while, that depends on you! Plus passports can be renewed as well! It only supports a single nationality via the land method.

The Mango version includes all features found in Kiwi plus losing, retaining and returning passports at any given time!

Side notes

It seems it does not need any changes to be applied to it to be able to run on VX.

The Script

Kiwi Version
Code:
# * KPass XP & VX
#   Scripter : Kyonides-Arkanthes
#   2019-01-10 - Kiwi Version

#  This script slightly tries to emulate the need to keep a passport at hand.
#  A passport includes the following features:
#    ID:   equal to the actor's ID
#    AGE:  0 as default value
#    Name: Same as the actor's name in the DB
#    Nickname:      Empty or you can set it at any given time
#    Father's name: Empty or you can set it at any given time
#    Mother's name: Empty or you can set it at any given time
#    Land:   Empty or you can set it at any given time
#    Status: Empty or you can set it at any given time

#  All passports include steps as a method to determine their expiration.

# * Script Calls *

#  $game_party.passport_status?(actor_id, allowed_status1, etc.)
#  You may include one or more allowed statuses like :vip or "nongrata"
#  It will fail if the actor's status does not match any status.

#  $game_party.has_land_permit?(actor_id, land_to_visit)
#  It will fail if the actor has not obtained any permit to enter that land.

#  $game_party.passport_expired?(actor_id)
#  It checks whether or not the passport has expired, it has no more steps left.

#  $game_party.make_passport(actor_id)
#  Use it to make or renew a new passport for any actor.

#  KPass.no_access[Land_Name] = true or false
#  Block all access to a certain land.

#  KPass.no_strangers[Land_Name] = true or false
#  Block all access to strangers or foreigners.

#  KPass.no_access[Land_Name]
#  Use it as a condition to check if that country will block all access to it.

#  KPass.no_strangers?(Land_Name, Actor_ID)
#  Checks whether or not an actor can access a country.

module KPass
  DEFAULT_EXPIRATION_STEPS = 1000
  # Passports to be issued from the very beginning
  ACTOR_DATA = ad = {} # Do Not Edit This Line!
# ad[Actor ID] = { father's name => name, mother's name => name, land => name,
# status => :vip or :wanted or :nongrata or :diplomat or you can ommit it
  ad[1] = { :father => "Unknown",
            :mother => "",
            :land => "Forgotten Land" }
  ad[2] = { :father => "Anselm",
            :mother => "Lydia",
            :land => "Jolt Kingdom" }
  def self.no_access() @no_access end
  def self.no_strangers() @no_strangers end
  def self.no_access=(new_list) @no_access = new_list end
  def self.no_strangers=(new_list) @no_strangers = new_list end
  def self.no_strangers?(land, actor_id)
    $game_party.passports[actor_id].land == land and @no_strangers[land]
  end

  def self.reset_access_data
    @no_access = {}
    @no_strangers = {}
  end

  def self.restore_access_data
    @no_access = $game_party.no_access
    @no_strangers = $game_party.no_strangers
  end
end

class KPassport
  def initialize
    @id = 1
    @age = 0
    @name = ""
    @nickname = ""
    @father_name = ""
    @mother_name = ""
    @land = ""
    @status = nil
    @permits = {}
    @rejections = {}
    set_expiration
  end
  def set_expiration() @expire_steps = KPass::DEFAULT_EXPIRATION_STEPS end
  def expired?() @expire_steps == 0 end
  def decrease_steps() @expire_steps -= 1 if @expire_steps > 0 end
  attr_accessor :id, :age, :name, :nickname, :father_name, :mother_name
  attr_accessor :land, :status
  attr_reader :permits, :rejections
end

class Game_Party
  attr_reader :passports, :no_access, :no_strangers
  alias kyon_kpass_gm_party_init initialize
  alias kyon_kpass_gm_party_steps increase_steps
  def initialize
    kyon_kpass_gm_party_init
    KPass.reset_access_data
    @passports = {}
    @no_access = KPass.no_access
    @no_strangers = KPasss.no_strangers
    make_passports
  end

  def make_passports
    data = KPass::ACTOR_DATA
    ids = data.keys.sort
    ids.each do |n|
      ad = data[n]
      @passports[n] = pass = KPassport.new
      pass.id = n
      pass.name = $game_actors[n].name
      pass.father_name = ad[:father] || ""
      pass.mother_name = ad[:mother] || ""
      pass.land = ad[:land] || ""
      pass.status = ad[:status]
      pass.age = ad[:age] || 0
    end
  end

  def make_passport(aid)
    unless (pass = @passports[aid])
      @passports[aid] = pass = KPassport.new
      pass.id = aid
      pass.name = $game_actors[aid].name
    end
    pass.set_expiration
  end

  def increase_steps
    @passports.each {|pass| pass.decrease_steps }
    kyon_kpass_gm_party_steps
  end

  def passport_status?(aid, *statuses)
    return unless (pass = @passports[aid])
    statuses.include?(pass.status)
  end

  def has_land_permit?(aid, land)
    return unless (pass = @passports[aid])
    pass.permits[land]
  end

  def passport_expired?(aid)
    return true unless (pass = @passports[aid])
    pass.expired?
  end
end

class Scene_Load
  alias kyon_kpass_scn_load_on_decision on_decision
  def on_decision(filename)
    kyon_kpass_scn_load_on_decision(filename)
    KPass.restore_access_data
  end
end


Mango Version
Code:
# * KPass XP & VX
#   Scripter : Kyonides-Arkanthes
#   2019-01-10 - Mango Version

#  This script slightly tries to emulate the need to keep a passport at hand.
#  A passport includes the following features:
#    ID:   equal to the actor's ID
#    AGE:  0 as default value
#    Name: Same as the actor's name in the DB
#    Nickname:      Empty or you can set it at any given time
#    Father's name: Empty or you can set it at any given time
#    Mother's name: Empty or you can set it at any given time
#    Land:   Empty or you can set it at any given time
#    Status: Empty or you can set it at any given time

#  All passports include steps as a method to determine their expiration.

# * Script Calls *

#  $game_party.passport_status?(actor_id, allowed_status1, etc.)
#  You may include one or more allowed statuses like :vip or "nongrata"
#  It will fail if the actor's status does not match any status.

#  $game_party.has_land_permit?(actor_id, land_to_visit)
#  It will fail if the actor has not obtained any permit to enter that land.

#  $game_party.passport_expired?(actor_id)
#  It checks whether or not the passport has expired, it has no more steps left.

#  $game_party.lose_passport(actor_id)
#  Lose the passport forever! (You'd need to issue a new passport later on...)

#  $game_party.retain_passport(actor_id)
#  Let Customs Agents retain the actor's passport!

#  $game_party.return_passport(actor_id)
#  Let Customs Agents return the actor's passport!

#  $game_party.retained_passport?(actor_id)
#  Is the actor's passport retained right now?

#  $game_party.make_passport(actor_id)
#  Use it to make or renew a new passport for any actor.

#  KPass.no_access[Land_Name] = true or false
#  Block all access to a certain land.

#  KPass.no_strangers[Land_Name] = true or false
#  Block all access to strangers or foreigners.

#  KPass.no_access[Land_Name]
#  Use it as a condition to check if that country will block all access to it.

#  KPass.no_strangers?(Land_Name, Actor_ID)
#  Checks whether or not an actor can access a country.

module KPass
 DEFAULT_EXPIRATION_STEPS = 1000
 # Passports to be issued from the very beginning
 ACTOR_DATA = ad = {} # Do Not Edit This Line!
# ad[Actor ID] = { father's name => name, mother's name => name, land => name,
# status => :vip or :wanted or :nongrata or :diplomat or you can ommit it
 ad[1] = { :father => "Unknown",
           :mother => "",
           :land => "Forgotten Land" }
 ad[2] = { :father => "Anselm",
           :mother => "Lydia",
           :land => "Jolt Kingdom" }
 def self.no_access() @no_access end
 def self.no_strangers() @no_strangers end
 def self.no_access=(new_list) @no_access = new_list end
 def self.no_strangers=(new_list) @no_strangers = new_list end
 def self.no_strangers?(land, actor_id)
   $game_party.passports[actor_id].land == land and @no_strangers[land]
 end

 def self.reset_access_data
   @no_access = {}
   @no_strangers = {}
 end

 def self.restore_access_data
   @no_access = $game_party.no_access
   @no_strangers = $game_party.no_strangers
 end
end

class KPassport
 def initialize
   @id = 1
   @age = 0
   @name = ""
   @nickname = ""
   @father_name = ""
   @mother_name = ""
   @land = ""
   @status = nil
   @permits = {}
   @rejections = {}
   set_expiration
 end
 def set_expiration() @expire_steps = KPass::DEFAULT_EXPIRATION_STEPS end
 def expired?() @expire_steps == 0 end
 def decrease_steps() @expire_steps -= 1 if @expire_steps > 0 end
 attr_accessor :id, :age, :name, :nickname, :father_name, :mother_name
 attr_accessor :land, :status
 attr_reader :permits, :rejections
end

class Game_Party
 attr_reader :passports, :no_access, :no_strangers
 alias kyon_kpass_gm_party_init initialize
 alias kyon_kpass_gm_party_steps increase_steps
 def initialize
   kyon_kpass_gm_party_init
   KPass.reset_access_data
   @passports = {}
   @no_access = KPass.no_access
   @no_strangers = KPasss.no_strangers
   make_passports
 end

 def make_passports
   data = KPass::ACTOR_DATA
   ids = data.keys.sort
   ids.each do |n|
     ad = data[n]
     @passports[n] = pass = KPassport.new
     pass.id = n
     pass.name = $game_actors[n].name
     pass.father_name = ad[:father] || ""
     pass.mother_name = ad[:mother] || ""
     pass.land = ad[:land] || ""
     pass.status = ad[:status]
     pass.age = ad[:age] || 0
   end
 end

 def lose_passport(aid) @passports.delete(aid) end
 def retain_passport(aid) @retained_passports[aid] = @passports.delete(aid) end
 def return_passport(aid) @passports[aid] = @retained_passports.delete(aid) end
 def retained_passport?(aid) @retained_passports.keys.include?(aid) end

 def make_passport(aid)
   unless (pass = @passports[aid])
     @passports[aid] = pass = KPassport.new
     pass.id = aid
     pass.name = $game_actors[aid].name
   end
   pass.set_expiration
 end

 def increase_steps
   @passports.each {|pass| pass.decrease_steps }
   kyon_kpass_gm_party_steps
 end

 def passport_status?(aid, *statuses)
   return unless (pass = @passports[aid])
   statuses.include?(pass.status)
 end

 def has_land_permit?(aid, land)
   return unless (pass = @passports[aid])
   pass.permits[land]
 end

 def passport_expired?(aid)
   return true unless (pass = @passports[aid])
   pass.expired?
 end
end

class Scene_Load
 alias kyon_kpass_scn_load_on_decision on_decision
 def on_decision(filename)
   kyon_kpass_scn_load_on_decision(filename)
   KPass.restore_access_data
 end
end

Terms & Conditions

Free for use in any non commercial games, a single $15 fee do apply for every commercial game, no matter how many copies their game developers may sell at the end.
"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
KPass XP - by kyonides - 01-11-2019, 03:23 AM



Users browsing this thread: 1 Guest(s)