Evidence Locker

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
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


Code: [Select]
#==============================================================================
#  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


  • modern algebra

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.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: November 11, 2010, 05:41:00 PM by modern algebra »

**
Rep: +0/-0Level 84
Its really very useful, thank you!  :D

**
Rep: +0/-0Level 84
I don't know if it's possible...

How can I subtract the item after the player presents it to the person?

Other than using the conditional branch that checks if he presents it, and then using the event command to subtract the said item. But in my game, there are a lot items and I don't want to use like many conditional branches. That would get messy. Also, in some cases I'm using the 'or' feature. Like $game_temp.evidence_id == 1 || $game_temp.evidence_id == 2. How can I subtract that since I don't know which one the player will present the item #1 or item #2?

So I'm here, wondering if it's possible to do something like this in easier way?

Other than that, this script is really useful. Nice work.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
Well, you can do it like this - underneath these three lines:

Code: [Select]
        $game_temp.evidence_id = @item.id
        $game_temp.evidence_name = @item.name
        $game_temp.evidence_amount = $game_party.item_number (@item)

Place this:

Code: [Select]
$game_party.lose_item (@item, 1)

So that section of the script would look like:


Code: [Select]
      else
        # 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)
        $game_party.lose_item (@item, 1)
        return_scene
      end

But it will only and always remove 1 instance of that item. I personally think the method you've suggested would work better.

**
Rep: +0/-0Level 84
I don't know if I should necropost but it seems you're still around so...

If you're in mood for scripting, maybe you can create a skill add-on or update for Evidence Locker? So I would have both items and skills evidence locker? (Note: I don't mean having both items and skills in one window. It would be nice to be able to summon the item window when I call for it, and later summon the skill window when I call for it)

If you're looking for specifics, I want the player to be able to 'present' his skills. Now I'm not sure how it all works out for the multiple members in party... Pressing a specific key to go through different members' skill-list, or using the script call to get a specific member's skill-list? 

I'm only really interested into the presented skill's ID but if you want, you can make additional features like skill's name, etc, for others.

Your Evidence Locker is incredibly amazing. I've been working with it for months and loving it so far. I admit that I'm not using your Evidence Locker to present the evidences. Instead I have been using it for the gift system, and other things relating to the presented items.

I want to be able to 'present' a skill to the guy so he can upgrade it (via my event system)

**
Rep:
Level 84
Quis custodiet ipsos custodes?
I'm glad Devlin did necropost. This is really cool, modern. It makes me want to add a storyline detour just to use it.

*
A Random Custom Title
Rep:
Level 96
wah
I wish this had a demo so I could see the script in action as it should be. D:

To me, the instructions are a little unclear because I don't know what goes where and ?_? I also don't really get what happens when all the conditions are met and stuff.. XP I'm just dumb? Idk.

**
Rep: +0/-0Level 74
Novice Video Game Developer
Is there any way (or an alternate/modified script) to create multiple Evidence lists? (eg So when calling for Evidence, you could number lists so items with /evidence1 show up in one list, and /evidence2 show up in another) I haven't tried to experiment to find out if there is, as I have no ability to script whatsoever. I know this is a necropost, but I really need to know!

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
it wouldn't be terribly hard to modify it to include a feature like that, but currently there is none that I know of.

**
Rep: +0/-0Level 74
Novice Video Game Developer
would anyone be willing to spare any time to try this for me? i have no idea how to script, and don't want to ruin the script for my game. it would be much appreciated?

**
Rep: +0/-0Level 74
Novice Video Game Developer
thank you so much!

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
No problem. And yeah, updated to 1.1 everybody.

***
Rep:
Level 80
Monster Hunter
so Modern Algebra if i'm correct this in a condition branch "$game_temp.evidence_amount == 2" should check if the player has 2 or more of the item
before going on with the rest of the event?
(sorry for the necropost)


*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best RPG Maker User (Scripting)2011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best Use of Avatar and Signature Space2010 Favourite Staff Member2010 Most Mature Member
That would check if they had exactly 2. If you wanted 2 or more, you would use:

Code: [Select]
$game_temp.evidence_amount >= 2

or just:

Code: [Select]
$game_temp.evidence_amount > 1

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Zero to Hero2014 Best IRC Quote2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Unless they somehow got 1.6 of the item.
*mind explodes*
it's like a metaphor or something i don't know

**
Rep:
Level 56
Tower of Hats
Sorry for the necropost...
But I need to know if there's any chance of you making this compatible with the Simple Sort Inventory script that cozziekuns made?
I really need it for my project.