VXIconPasswords v1.0

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 75
What the...?
VX Icon Passwords
By: Ixfuru

Spoiler for INTRODUCTION:
I created this script as a remake of 'efeberk's VXAce script upon request from someone on a different site.  I had never ported a script before, and had a helluva time with it, so I just decided to do it a little different than the original script.  Still, I would be remiss if I didn't mention both 'efeberk' and 'new' as they were the inspiration for the script.

Pretty simple really, this script calls a new scene to your projects in which a pattern of Icons are used for a Password.  This can be really cool because it can be used for chests, doors, defusing bombs, and other such things.


Spoiler for FEATURES:
-new scene for inputting passwords
-customizable sound effects
-create unlimited passwords and call them by there IDs
-link passwords to game switches to be turned on immediately when the password is right
-link passwords to transfers, where the player warps to a new map upon correct password input
-link passwords to self switches to alter events when password is entered correctly

Spoiler for HOW TO USE THE SCRIPT:
There are plenty of instructions in the script itself.  But you basically, place this script above main, below materials in your script editor.  Then you call the scene by using the script call:

Code: [Select]
$scene = Scene_IconPassword.new(password_id)

Replacing the 'password_id' with the ID you gave the password in the settings.

Spoiler for SCREENSHOTS:


Spoiler for SCRIPT:
Code: [Select]
################################################################################
# VX Icon Passwords
#    By: Ixfuru
################################################################################
# The idea of the script was introduced to me by 'new' of RPGMakerVX.net and is
# an RGSS2 version of the Icon Passwords script written in RGSS3 by efeberk.
# Therefor, above all else, if you use this script, you must credit both the
# aforementioned people as well as me.  I took the scripts idea from them,
# but I just sort of implemented it in my own way. 
#===============================================================================
# The script creates 'passwords' that you set by entering the id icons from the
# Graphics/System/Iconset image.  When the scene is called with:
#
#   $scene = Scene_IconPassword.new(password_id)
#
# The player is shown selectable windows, each containing selectable icons (which
# you provide of course.  The object of the scene is to input the correct the
# icons (via their ids) with the correct icons of the password.  If there is a
# match, a switch (which you provide) will be turned on, allowing the creator
# to make something happen immediately when the password is correct.
#
# To set up the passwords, use this formula:
#
# password_id => {:all_icons => [icon_ids],
# :correct_icons => [icons_ids],
# :switch_id => game_switch_id,
# :header_string => display_string,
# :transfer => [map_id, x, y, direction],
# :self_switch => [map_id, event_id, switch_id]},
#
# all_icons : This is an array of icon_ids from the Iconset that contain the ids
# of all the icons the player can choose from.  I recommend keeping
# it to about 8-10 icon ids, that way the player isn't having to
# come up with a seemingly impossible mission of figuring out a code
# out of hundreds of possible icons.
#
# correct_icons : This is the array of the order in which the icons must be input
# in the scene to trigger the switch.  This IS the password.
# If you place [7, 21, 18, 19] as the :correct_icons array, the
# player will have to input those icons in that order to
# trigger the switch.  Since the scene creates a separate window
# for each correct icon and centers it on the screen, you shouldn't
# use more than about 10 icons for the password, since the windows
# will be created out of the screen if you do.  Also, it IS
# okay to repeat icon_ids within the array.
#
# [6, 7, 7, 7 , 6]
#
# That's perfectly legal! 
#
# Just keep in mind that you can't place an id in the :correct_icons
# array that doesn't appear in the :all_icons array, or you will
# render the password impossible.
#
# switch_id : This is the ID of the database switch you want to trigger if the code
# is correct.   The system automaticall turns the switch off when
# called and if the password is correct, immediately exits the scene
# and returns to the map scene where the player can 'make something
# happen.
#
# header_string : This is the string, ( or words ), which will be displayed in the
# window above the icon windows used for the code.  This should
# be one line long and used as a hint, or a simple "enter the code"
# message to the player.  You DO NOT HAVE TO have a header string.
# You can omit the header string entry in the hash if you would
# rather, and the header will display the DEFAULT_HEADER_STRING
# you provide below instead.
#
#   :header_string => "Code Entry",
#   :header_string => "Enter the Right Code",
#   :header_string => "Do you know the password?",
#
#    All of the above examples are fine.  As long as your string
#    has double-quotes and is about one line long, any message will
#    work.
#
# transfer : This is a four-element array [map_id, x, y, direction].  It's used
# to call about an instant map transfer when the code is a match.
# For 'direction' use 2 for down, 4 for left, 6 for right, 8 for up.
# This will be the direction the player is facing once he/she is
# transferred.
#
# self_switch : This allows you to set the Password to turn on a self switch
#    when it's entered correctly. Just place the map_id, the event's id and
#    the switch_id ("A", "B", "C" or "D") that you want to turn on
#    or you can leave it empty if you don't want to use it.
#
################################################################################
# Calling the Scene
#
# All you have to do is place this in the 3rd page of event commands script call:
#
#   $scene = Scene_IconPassword.new(password_id)
#
# Just exchange 'password_id' with the ID you create in the PASSWORDS hash below.
################################################################################
#   CREDITS
#
# Again, you can use this script how you like, but you MUST credit both 'new' and
# 'efeberk' along with me if you use it.
################################################################################
module Ixfuru
  module IconPasswords

PASSWORDS = { # <<<Don't delete this!

 
0 => {:all_icons => [96, 97, 98, 99, 100, 101, 102, 103],
  :correct_icons => [101, 96, 100], #green, white, blue
  :switch_id => 25,
  :header_string => "Unlock the Chest",
  :transfer => [],
  :self_switch => [1, 4, "A"]},
 
 
}

NO_MATCH_SE = ["Buzzer2", 80, 100] # Sound played when code doesn't match
MATCH_SE = ["Chime2", 80, 100] # Sound played when code matches
WINDOW_CONTROL_SE = ["Switch1", 80, 100] # Sound played when moving from icon to icon
DEFAULT_HEADER_STRING = "Enter the Password" # Default string to display over password


  end
end

#===============================================================================
#   ICON PASSWORD
#===============================================================================
class IconPassword
 
  attr_accessor :icons
  attr_accessor :password_id
  attr_reader :all_icons
  attr_reader :code
  attr_accessor :header_string
  attr_reader :transfer
 
  def initialize(password_id)
@password_id = password_id
@all_icons = Ixfuru::IconPasswords::PASSWORDS[@password_id][:all_icons]
@code = Ixfuru::IconPasswords::PASSWORDS[@password_id][:correct_icons]
if Ixfuru::IconPasswords::PASSWORDS[@password_id].has_key?(:header_string)
  @header_string = Ixfuru::IconPasswords::PASSWORDS[@password_id][:header_string]
else
  @header_string = Ixfuru::IconPasswords::DEFAULT_HEADER_STRING
end
@transfer = Ixfuru::IconPasswords::PASSWORDS[@password_id][:transfer]
@icons = []
  end
 
  #-----------------------------------------------------------------------------
  # Get All Icons
  #-----------------------------------------------------------------------------
  def get_all_icons
return @all_icons
  end
 
  #-----------------------------------------------------------------------------
  # Match?
  #-----------------------------------------------------------------------------
  def match?
return true if @icons == @code
return false
  end
 
end

#===============================================================================
# WINDOW PASSWORD HEADER
#===============================================================================
class Window_PasswordHeader < Window_Base
 
  attr_accessor :string
 
  def initialize(string)
super(100, 108, 344, 56)
@string = string
refresh
  end
 
  def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, self.width - 32, WLH, @string, 1)
  end
 
end

#===============================================================================
#   WINDOW PASSWORD INSTRUCTIONS
#===============================================================================
class Window_PasswordInstructions < Window_Base
 
  def initialize
super(100, 220, 344, 56)
@instructions = "< > : Next Window, SPC : Try, X : Exit"
refresh
  end
 
  def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, self.width - 32, WLH, @instructions, 1)
  end
 
end


#===============================================================================
# WINDOW ICON
#===============================================================================
class Window_Icon < Window_Selectable
 
  attr_accessor :icons
 
  def initialize(password_id, x)
super(x, 164, 56, 56)
@icons = Ixfuru::IconPasswords::PASSWORDS[password_id][:all_icons]
@item_max = @icons.size
refresh
self.active = false
self.index = 0
  end
 
  def icon_id
return @icons[self.index]
  end
 
  def refresh
create_contents
for i in 0...@item_max
  draw_each(i)
end
  end
 
  def draw_each(index)
rect = item_rect(index)
draw_icon(@icons[index], rect.x, rect.y, activated?)
  end
 
  def activated?
self.active
  end
 
end

#===============================================================================
#   SCENE ICON PASSWORD
#===============================================================================
class Scene_IconPassword < Scene_Base
 
  def initialize(password_id)
$game_switches[Ixfuru::IconPasswords::PASSWORDS[password_id][:switch_id]] = false
@password_id = password_id
@comparitor = IconPassword.new(@password_id)
@win_index = 0
@win_max = @comparitor.code.size
@windows = []
  end
 
  #-----------------------------------------------------------------------------
  # Start
  #-----------------------------------------------------------------------------
  def start
super
create_menu_background
@win_header = Window_PasswordHeader.new(@comparitor.header_string)
@win_instructions = Window_PasswordInstructions.new
start_x = window_start_x
for i in 0...@win_max
  window = Window_Icon.new(@password_id, start_x + (i * 56))
  @windows.push(window)
end
  end
 
  #-----------------------------------------------------------------------------
  # Window Start X
  #-----------------------------------------------------------------------------
  def window_start_x
x = 272 - (@win_max * 28)
return x
  end
 
  #-----------------------------------------------------------------------------
  # Return Scene
  #-----------------------------------------------------------------------------
  def return_scene
$scene = Scene_Map.new
  end
 
  #-----------------------------------------------------------------------------
  # Update Code
  #-----------------------------------------------------------------------------
  def update_code
icons = []
for window in @windows
  icons.push(window.icon_id)
end
@comparitor.icons = icons
  end
 
  #-----------------------------------------------------------------------------
  # Update
  #-----------------------------------------------------------------------------
  def update
super
update_code
deactivate_windows
update_comparitor
update_window
  end
 
  #-----------------------------------------------------------------------------
  # DeActivate Windows
  #-----------------------------------------------------------------------------
  def deactivate_windows
for window in @windows
  window.active = false
end
@windows[@win_index].active = true
for window in @windows
  window.refresh
end
  end
 
  #-----------------------------------------------------------------------------
  # Play Code Match
  #-----------------------------------------------------------------------------
  def play_code_match
se = Ixfuru::IconPasswords::MATCH_SE
RPG::SE.new(se[0], se[1], se[2]).play
  end
 
  #-----------------------------------------------------------------------------
  # Play No Match
  #-----------------------------------------------------------------------------
  def play_no_match
se = Ixfuru::IconPasswords::NO_MATCH_SE
RPG::SE.new(se[0], se[1], se[2]).play
  end
 
  #-----------------------------------------------------------------------------
  # Play New Window
  #-----------------------------------------------------------------------------
  def play_new_window
se = Ixfuru::IconPasswords::WINDOW_CONTROL_SE
RPG::SE.new(se[0], se[1], se[2]).play
  end
 
 
  #-----------------------------------------------------------------------------
  # Update Comparitor
  #-----------------------------------------------------------------------------
  def update_comparitor
if Input.trigger?(Input::C)
  if @comparitor.match?
play_code_match
unless $game_switches[Ixfuru::IconPasswords::PASSWORDS[@password_id][:switch_id]] == 0
  $game_switches[Ixfuru::IconPasswords::PASSWORDS[@password_id][:switch_id]] = true
end
ss_base = Ixfuru::IconPasswords::PASSWORDS[@password_id][:self_switch]
unless ss_base.empty?
  key = [ss_base[0], ss_base[1], ss_base[2]]
  $game_self_switches[key] = true
  $game_map.refresh
end
unless @comparitor.transfer.empty?
  m = @comparitor.transfer[0]
  x = @comparitor.transfer[1]
  y = @comparitor.transfer[2]
  dir = @comparitor.transfer[3]
  $game_player.reserve_transfer(m, x, y, dir)
end
return_scene
  else
play_no_match
  end
elsif Input.trigger?(Input::B)
  Sound.play_cancel
  return_scene
end
  end
 
  #-----------------------------------------------------------------------------
  # Update Window
  #-----------------------------------------------------------------------------
  def update_window
@windows[@win_index].update
if Input.trigger?(Input::LEFT)
  play_new_window
  if @win_index == 0
@win_index = @win_max - 1
  else
@win_index -= 1
  end
elsif Input.trigger?(Input::RIGHT)
  play_new_window
  if @win_index == @win_max - 1
@win_index = 0
  else
@win_index += 1
  end
end
  end
 
  #-----------------------------------------------------------------------------
  # Terminate
  #-----------------------------------------------------------------------------
  def terminate
super
dispose_menu_background
@win_header.dispose
@win_instructions.dispose
for window in @windows
  window.dispose
end
  end
 
end

Spoiler for CREDITS:
Again, you need to credit both 'efeberk' whose VXAce script was originally brought to my attention.
And you need to credit 'new', as it was he who requested the script in the first place.
Also, 'neosky', who came up with the 'self-switch' linkage idea.
You can use both commercially and non-commercially as long as you don't claim it's yours and as long as the three mentioned above and me (ixfuru) are credited in your project.

Spoiler for COMPATIBILITY:
This script works pretty well and doesn't touch anything (or not much) from the default systems.  Therefor, it's very non-intrusive.   But, that said, if you have issues with the script, just post below or contact me for help.


*
i am satin die lol
Rep:
Level 96
welcom to hel
GIAW 14: 2nd Place (Hard Mode)2013 Biggest Drama Whore2013 Zero to HeroParticipant - GIAW 11Secret Santa 2013 ParticipantFor taking arms in the name of your breakfast.
This is cool. :)

********
Rep:
Level 96
2011 Most Missed Member2010 Zero To Hero
What a neat idea. :D Nice work.

****
Rep:
Level 41
Somewhat got a project? (\รด/)
GIAW 14: ParticipantParticipant - GIAW 11
That's super cool, even I can't use it, because I have VX ACE. :(

But would definitiv use it, if I had VX. ;) (\s/)

***
Rep:
Level 75
What the...?
Quote
That's super cool, even I can't use it, because I have VX ACE.
Thank you.   I know a lot of people have went to Ace.  Sucks for me because right now, I only script VX.  But one day I'll learn RGSS3.  One day.

Quote
What a neat idea.
I can't take credit for the idea.  Like I said, it was brought to me by a fellow Rpgmaker-er.   I just kind of ran with it.

Quote
This is cool.
Thank you.

I actually use this script myself.  I usually don't use the scripts I make public for myself.  But this one is an exception.  It's quite a versatile script.  Someone else took it and created Icon numbers.  So that it looked like some sort of combination when you used it.