Evidence Locker
Version: 1.1
Author: modern algebra
Date: November 11, 2010
Version History
- <Version 1.1> 11.11.2011 - Added the possibility of multiple different evidence lockers (so the function can be used for different purposes) as well as made it easier to call the scene with a simple call_evidence method. Added a demo.
- <Version 1.0> 08.02.2008 - Original Release
Description
This script allows the player to choose an evidence item from his or her inventory and set conditions depending on which item is chosen. This allows for an interactive exchange, particularly in games where the presentation of evidence is necessary, such as detective games or minigames. In addition, you can have multiple different evidence lockers, allowing for different functions. Maybe some items you'll want to use this script to create a trading features, while others you'd like to use for detective purposes. This is now possible. As well, the same item can belong to multiple different evidence lockers.
Features
- Simple way to identify items as evidence
- The scene is a subclass of Scene_Item and so should fit in with any custom Scene_Item that does not depart too heavily from the basic
- Allows your events to react to the evidence chosen
- Perfect for games where the presentation of evidence or proof is necessary or useful
Screenshots
Should look exactly the same as your Scene_Item
Instructions
Place this script into its own slot in the Script Editor (F11), somewhere above Main and below Materials.
See the instructions in the header of the script for more instruction on how to use the script in your game.
Script
#==============================================================================
# Evidence Locker
# Version 1.1
# Author: modern algebra (rmrk.net)
# Date: November 11, 2010
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Description:
#
# This script allows the player to choose an evidence item from his or her
# inventory and set conditions depending on which item is chosen. It also
# allows you to have multiple evidence lockers, in case you only want to
# choose from a limited subsection of items in your possession in one case and
# a different subsection in another case.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Instructions:
#
# To set an item so that it will show up in an evidence locker, you need
# only type the following into the note box of an item
# \evidence[locker_id]
# locker_id : the ID of the locker you want this item to be in. If
# excluded entirely (ie. just \evidence ) then it's in locker 0.
#
# To call the Evidence scene, use this code:
#
# call_evidence (locker_id)
# locker_id : the ID of the locker you want to open. If excluded, (ie.
# just call_evidence ) then it opens locker 0.
#
# To access the item the player has chosen in the scene, you have four codes:
#
# $game_temp.evidence_name the name of the item chosen
# $game_temp.evidence_amount the amount of item in the party's possession
# $game_temp.evidence_type 0 => Item, 1 => Weapon, 2 => Armor
# $game_temp.evidence_id the ID of the item chosen
#
# You can use any of these in a conditional branch by utilizing the script
# condition and typing in this:
#
# $game_temp.evidence_name == 'name'
# $game_temp.evidence_amount == positive integer
# $game_temp.evidence_type == integer between 0 and 2, inclusive
# $game_temp.evidence_id == positive integer
#
# If necessary, type and id will only return true for the exact item wanted.
# In general, name will be sufficient and probably easier, though confusion
# may arise if you have more than one piece of evidence with the same name.
# The amount is in case you want a number restriction on the evidence, so if
# you need two instead of just one or something. You can join conditions with
# &&, so this would be legitimate:
#
# $game_temp.evidence_type == 2 && $game_temp.evidence_id == 24
#==============================================================================
#==============================================================================
# ** RPG::BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# new method - evidence?
#==============================================================================
class RPG::BaseItem
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Evidence?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def evidence?
locker_id = $game_temp ? $game_temp.e_locker_id : 0
return true if self.note[/\\evidence\[#{locker_id}\]/i] != nil
return true if locker_id == 0 && self.note[/\\evidence([^\[]|$)/i] != nil
return false
end
end
#==============================================================================
# ** Game_Temp
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# new public instance variables - evidence_name; evidence_type; evidence_id;
# evidence_amount; e_locker_id
#==============================================================================
class Game_Temp
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :evidence_type # 0 => Item, 1 => Weapon, 2 => Armor
attr_accessor :evidence_id # Item ID
attr_accessor :evidence_name # The name of the evidence
attr_accessor :evidence_amount # The amount of that evidence in possession
attr_writer :e_locker_id # The scene ID of the evidence locker called
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Evidence Scene ID
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def e_locker_id
return @e_locker_id if @e_locker_id
return 0
end
end
#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - call_evidence
#==============================================================================
class Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Call Evidence
# locker_id : the ID of the evidence scene to call
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def call_evidence (locker_id = 0)
$game_temp.e_locker_id = locker_id
$scene = Scene_Evidence.new
@wait_count = 1
end
end
#==============================================================================
# ** Window_Item
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# aliased methods - include?, enable?
#==============================================================================
class Window_Item
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Include?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_dragon9_request_evince_selct_incl_8b4s include?
def include?(item)
return (item == nil ? false : item.evidence?) if $scene.is_a? (Scene_Evidence)
modalg_dragon9_request_evince_selct_incl_8b4s (item)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Enable?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_drgdd9_req_evidnc_954n enable?
def enable? (item)
return true if $scene.is_a? (Scene_Evidence)
return modalg_drgdd9_req_evidnc_954n (item)
end
end
#==============================================================================
# ** Scene_Evidence
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# This class is a subclass of Scene_Item. Instead of using a selected item,
# this script reserves it in a variable to be used in an event.
#==============================================================================
class Scene_Evidence < Scene_Item
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Return Scene
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def return_scene
$scene = Scene_Map.new
$game_temp.e_locker_id = 0
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Item Selection
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update_item_selection
if Input.trigger?(Input::B)
Sound.play_cancel
# Clear evidence variables
$game_temp.evidence_type = nil
$game_temp.evidence_id = nil
$game_temp.evidence_name = nil
$game_temp.evidence_amount = nil
return_scene
elsif Input.trigger?(Input::C)
@item = @item_window.item
if @item == nil
Sound.play_buzzer
else
Sound.play_decision
# Set evidence variables to the item chosen
$game_temp.evidence_type = @item.is_a? (RPG::Item) ? 0 : @item.is_a? (RPG::Weapon) ? 1 : 2
$game_temp.evidence_id = @item.id
$game_temp.evidence_name = @item.name
$game_temp.evidence_amount = $game_party.item_number (@item)
return_scene
end
end
end
end
Credit
Thanks
- dragndude9, the original requester of the script
- Loki333, for his seconding of the script
- DNZGames, for requesting multiple lockers
Support
Please post here at rmrk.net for the swiftest response
Demo
See
attached.
This script by
modern algebra is licensed under a
Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.