RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Graphical Favourite Items

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Graphical Favourite Items
Version: 1.0
Author: modern algebra
Date: August 23, 2010

Version History


  • <Version 1.0> 08.23.2010 - Original Release

Description


This script gives a graphic representation to an actor's favourite item by showing a message when it is first discovered and afterwards showing it in the Status window for that actor. It will also give exp to the party and individual, as much as you specify. It was originally designed to be an addon to the Actor Specific Item Effects script, but I decided to release them separately since I realized it could be used on its own to add a small biographical element to the game's actors or as a minigame to discover actor's favourite foods, with or without any special effects those items give.

Features

  • This script provides a graphical framework for giving actors favourite foods
  • Could make a neat minigame (discovering all your actor's favourite foods) or a simple biographical quirk to give your actors more depth
  • Complements the Actor Specific Item Effects script very well.

Screenshots



Instructions

This script requires Zeriab's Dialog System and must be placed below Actor Specific Item Effects if you are using that script.

Please see the header of the script for further instructions.

Script


Code: [Select]
#==============================================================================
#    Graphical Favourite Items
#      Complement to Actor Specific Item Effects v. 1.0
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: August 23, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#   
#    This script gives a graphic representation to an actor's favourite item by
#   showing a message when it is first discovered and afterwards showing it in
#   the Status window for that actor. It will also give exp to the party and
#   individual, as much as you specify. It was originally designed to be an
#   addon to the Actor Specific Item Effects script, but I decided to release
#   them separately since I realized it could be used on its own to add a small
#   biographical element to the game's actors or as a minigame to discover
#   actor's favourite foods, with or without any special effects those items
#   give.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    This script requires Zeriab's Dialog System, which can be found here:
#      http://rmrk.net/index.php/topic,24828.0.html
#
#    Place this script above Main and below all the default scripts and below
#   Zeriab's Dialog system. If using Actor Specific Item Effects, it should
#   be placed below that as well.
#
#    You can check whether an actor's favourite item has been discovered in the
#   script field of a conditional branch with the code:
#      $game_actors[actor_id].favourite_item_discovered
#    Similarly, you can force a item to be discovered through a script call:
#      $game_actors[actor_id].favourite_item_discovered = true
#
#    To get the ID of an actor's favourite item is, you can use the code:
#      $game_actors[actor_id].favourite_item
#
#    Configuration on the script is located below. Please read the instructions
#   prior to each constant.
#==============================================================================
#  GFI_FAVOURITE_ITEMS - this is where you set up what the favourite items of
#    actors are. Note that in order to make this script independent, it need
#    not correspond to any special effect set up in the Actor Specific Item
#    Effects script. For each actor, you need to set a line in the hash like
#    this:
#            actor_id => item_id,
#    Do not neglect the commas! Every line should have a comma at the end.
#    Example:
#            1 => 2,
#    Would mean that Actor 1's (Ralph's) favourite item would be item 2 (High
#    Potion). Once discovered, it will show up in the status screen as such.
#    Each actor may only have one favourite item, but you can choose that some
#    actors do not have any. Simply exclude them from the array.
GFI_FAVOURITE_ITEMS = {
  1 => 1, # Ralph's favourite item is a Potion
  2 => 4, # Ulrika's favourite item is a Magic Water
}
#  GFI_MUST_DISCOVER - this constant determines whether or not the actor needs
#    to discover the item or whether it is already known. true indicates that
#    the item must be discovered; false means that it will always be known
GFI_MUST_DISCOVER = true
#  GFI_DISCOVER_BY_USE - if the above value is true, this determines whether
#    the favourite item can be discovered by using it on the actor, or whether
#    it can only be discovered via using the script code:
#      $game_actors[actor_id].favourite_item_discovered = true
#    All of the GFI_DISCOVER_ constants below depend on this value being true.
  GFI_DISCOVER_BY_USE = true
#  GFI_DISCOVER_MESSAGE - this is the format for the message that appears when
#    a favourite item is discovered by use. %n indicates where the actor's name
#    will appear, and %i will be replaced with the item's name.
GFI_DISCOVER_MESSAGE = "You have discovered %n's favourite food: %i"
#  GFI_DISCOVER_SE - this is the SE that will play upon discovering a favourite
#    item. It may be simply the "name", or you may specify volume and pitch by
#    using an array in the format: ["name", volume, pitch]
GFI_DISCOVER_SE = "Item2"
#  GFI_DISCOVER_EXP_PARTY - this is the amount of experience everyone in the
#    party gets when an actor discovers his/her favourite item.
GFI_DISCOVER_EXP_PARTY = 50
#  GFI_DISCOVER_EXP_INDIVIDUAL - In addition to the party experience, this is
#    the amount the particular actor gets when he/she discovers his/her
#    favourite item.
GFI_DISCOVER_EXP_INDIVIDUAL = 100
#  GFI_STATUS_LABEL - this is the label to identify favourite item in the
#    status screen.
GFI_STATUS_LABEL = "Favourite Food: "
#  GFI_STATUS_X - this is the x coordinate for where favourite item shows up in
#    the status screen. If set to -1, it will be aligned with the parameters
#    (ATK, DEF, SPI, AGI)
GFI_STATUS_X = -1
#  GFI_STATUS_Y - this is the y coordinate for where favourite item shows up in
#    the status screen. If set to -1, it will be placed at the very bottom.
GFI_STATUS_Y = -1
#==============================================================================
#  END CONFIGURATION
#==============================================================================

GFI_FAVOURITE_ITEMS.default = 0
#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new public variables - favourite_item_discovered; favourite_item
#    aliased method - setup; item_effect
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader   :favourite_item
  attr_accessor :favourite_item_discovered
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Setup
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias monag_favfood_stup_6yh1 setup
  def setup (*args)
    @favourite_item_discovered = !GFI_MUST_DISCOVER
    monag_favfood_stup_6yh1 (*args) # Run Original Method
    @favourite_item = GFI_FAVOURITE_ITEMS[@actor_id]
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Apply Item Effect
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modlb_fvgrph_itmefct_4tq3 item_effect
  def item_effect (user, item, *args)
    if item != nil && item.id == @favourite_item && !@favourite_item_discovered && GFI_DISCOVER_BY_USE
      @favourite_item_discovered = true
      se = GFI_DISCOVER_SE.is_a? (Array) ? GFI_DISCOVER_SE : [GFI_DISCOVER_SE]
      RPG::SE.new (*se).play
      gain_exp (GFI_DISCOVER_EXP_INDIVIDUAL, false)
      $game_party.members.each { |actor| actor.gain_exp (GFI_DISCOVER_EXP_PARTY, false) }
      # Run Dialog
      Dialog_DiscoverFavourite.show (self, item)
    end
    modlb_fvgrph_itmefct_4tq3 (user, item, *args)
  end
end

#==============================================================================
# ** Window_Status
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - draw_parameters
#==============================================================================

class Window_Status
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Draw Parameters
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdaba_fvfd_drawparam_1io9 draw_parameters
  def draw_parameters (param_x, *args)
    mdaba_fvfd_drawparam_1io9 (param_x, *args) # Run Original Method
    # Draw Favourite item
    if @actor.favourite_item_discovered && @actor.favourite_item > 0
      x = GFI_STATUS_X == -1 ? param_x : GFI_STATUS_X
      y = GFI_STATUS_Y == -1 ? self.contents.height - WLH : GFI_STATUS_Y
      contents.font.color = system_color
      tw = contents.text_size (GFI_STATUS_LABEL).width
      contents.draw_text (x, y, tw + 16, WLH, GFI_STATUS_LABEL)
      draw_item_name($data_items[@actor.favourite_item], x + tw, y)
    end
  end
end

#==============================================================================
# ** Dialog_DiscoverFavourite
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This class processes when a favourite item is discovered
#==============================================================================

class Dialog_DiscoverFavourite < Dialog
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * A show method
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize(actor, item)
    @actor = actor
    @item = item
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create the windows
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def main_window
    text = GFI_DISCOVER_MESSAGE.gsub (/%n/) { @actor.name }
    text.gsub! (/%i/) { @item.name }
    tw = [@background_sprite.bitmap.text_size (text).width + 40, Graphics.width].min
    @discover_window = Window_Help.new
    @discover_window.width = tw
    @discover_window.create_contents
    @discover_window.x = (Graphics.width - tw) / 2
    @discover_window.y = (Graphics.height - @discover_window.height) / 2
    @discover_window.z = STARTING_Z_VALUE + 1
    @discover_window.set_text (text, 1)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Dispose the windows
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def main_dispose
    @discover_window.dispose
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update
    if Input.trigger?(Input::B) || Input.trigger?(Input::C)
      mark_to_close
      self.value = false
    end
  end
end

Credit


  • modern algebra
  • Zeriab, for the Dialog System

Thanks

  • hikomarukun

Support


Please post in this topic at RMRK for support, no matter how old the topic is. Do not PM me.

Known Compatibility Issues

No known compatibility issues. This script requires Zeriab's Dialog System. Also, if using Actor Specific Item Effects, you must place this script below that one.

**
Rep: +0/-0Level 75
Hello everyone ^_^
To you sir, I thank an infinite amount! may the masses build shrines and monuments to your greatness and generosity and scripting prowess! Haha Thanks Modern Algebra, this is amazing!
RPMG2k forever!