Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
damasterofthearts

EPIC FAILURE IN SCRIPT

Question

Okay.

So once again I ran into a problem in some other script.

I've found a very good title script and have been using it for a while.

I made a really cool title, but it doesn't work with Gubids Tactical Battle System. (This Again)

The defect only happens when I use the title script.

It says:

 

"Script '-Game_Char_Iso_Update-' line 35: NoMethodError Occurred. Undefined method `[]' for

nil:NilClass

 

 

 

And then shuts off.

 

Does anyone know how to fix it?

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Oh, I was going to suggest that it could be a Charset Compatability Issue. Scripts in English usually use the UTF-8 as the Language Character Set, but if a Script is written in a Charset that isnt compatible with UTF-8, like Japanese, some of those characters can cause problems.

 

There is an easy way to fix this. First of all, Always make a backup of your Project. Then select the script on the left hand pane, then hold the Shift Key down on your keyboard and press the Deliver Key! It might be labeled as DEL on your keyboard also...

 

devil.gif

 

(Like I said, ALWAYS make a back up of your Project!)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • Guest
      By Guest
      Hey everyone!
      I just got my new laptop because my old one broke...
      But im unable to run RMXP :o
      I have already bought it so i hoped i was able to download it again by downloading the trial and entering the activation code again. Or should i do it on a different way? I can't find a different way to redownload the full game client though.
       
      When im trying to open the trial i get the following error (i did run as admin) rgss104e.DII was not found (roughly translated from my language)
       
      Please help me! :)
    • By scar86
      Ok So I just got RPG maker Xp, and am having a lot of fun with it, but I keep encountering this problem that's been holding me back in my progress.
       
      In the first pic my party is at the top and the enemy (Frog) is at the bottom, the battler works correctly without a hitch.
       
      But whenever I try to load custom battlers, (or sometimes battlers that we're in the game already)
      I get the error you can see in the second pic where the hound is cut in half. It keeps scrolling through the selected row of sprites, as it is supposed to, but for some reason there is a gap between the images causing it not to fluidly animate. I've gone into the advanced configuration and set up the hound's battler in the custom settings, and it still doesn't work.
       
      Edit: I'm also using the Chrono trigger battle add-on.
       
      Does anyone know how I can fix this? Thanks.

    • Guest
      By Guest
      Hi everyone!
      Sorry for posting another help topic I hope im not annoying you guys.
       
      Lately i made a quest. You need to gather flowers with an event that gives you an item "white flower" Now the problem is that with a conditional branch you can only do a item and not an amount of that item.
      Is there anyway to do this? Or shouldn't i use a conditional branch for this?
      Thx
      mxmmix
    • By thegilr0y
      I'm trying to implement two different codes into my game but when I do I get an error and I'm not sure why. I'm an extreme beginner when it comes to scripting but I've tried searching for the problem but I'm not finding it. The two codes that I'm using are Juan José Sánchez Ramírez's Medina Stories License Board 2.0 and kellessdee's XMB Menu System. When I have them both in my scripts and I start a new game it gives me the error:
      Script 'Medina Stories License' Line 3317: NoMethodError occurred.
      undefined method '[ ]' for nil: NilClass.
      Additionally, when I continue a game it starts fine until I go to open my menu, then it gives me the error:
      Script 'XMB Menu' Line 4681: NoMethodError occurred.
      undefined method 'sound_volume' for #<ams:0x9c27af8></ams:0x9c27af8>
       
      Please help me! I really would like both of these in my game! The actual script I use is as follows
      #==============================================================================# ** Medina Stories License Board v2.0.0#------------------------------------------------------------------------------# Author: Juan José Sánchez Ramírez# Release Date: August 21, 2011#------------------------------------------------------------------------------# «Introduction»## This script is a quasi-identical replica of the Final Fantasy XII License# Board. Character development in Final Fantasy XII is based largely on the# acquisition of "licenses". Licenses are required to equip weapons and armor,# learn magicks and technicks, and enhace a character's abilities.#------------------------------------------------------------------------------# «Features»## License board (the board can be unique for each character or it can be the# same for all characters)# Board editor# License points# Custom board size# Custom board graphics (i.e., tiles, tile size, font size, background,# foreground, animations, etc.)# Custom board names (i.e., license description, license class, etc.)# Compatible with larger parties (parties with more than four characters)#------------------------------------------------------------------------------# «Instructions»## Step 1. Copy the script.## Step 2. Add the pictures to your Pictures folder.## Step 3. Call the Scene_EditBoard class with the following code. If you do# not have a Boards.rxdata file, the game will create one for you. Create a# new board. The README.txt file in your Game folder contains a list of all# skills, weapons and armor in the database.## $scene = Scene_EditBoard.new## Step 4. Call the Scene_BoardSelect class with the following code.## $scene = Scene_BoardSelect.new## Step 5. To add license points to your characters, use the following code.# For the purpose of teaching, I shall add 50 license points to every# character.## for actor in $game_party.actors# actor.ap += 50# end## Configuring your license board## The FFXII module, at the beginning of the script, contains global variables# and classes which handle the license board interface. Every single class and# variable in the module is editable. For more information regarding the FFXII# module, read the comments in the script.#------------------------------------------------------------------------------# «FAQ»## What are licenses?# In addition to enabling a character to equip various items or cast potent# magicks, there are also licenses to boost stats. Licenses can be obtained on# the "license board" by using "license points" (LP).## Simply obtaining a license for a skill allows a character to use that# ability. Licenses for statistic boosts do not require are effective# immediately after being obtained. Licenses for weapons and armor allow a# character to equip such weapons or armor, but require the items to be in the# party's inventory.## How do you choose licenses?# You are free to choose which licenses each character acquires. There are# several categories of licenses, and using LP to obtain them will gradually# open up new licenses on the same area of the board.## Which are the license board categories?# Licenses are loosely divided into four different categories:# 1. Statistic Boosts# 2. Weapons# 3. Armor# 4. Skills## How can I display the license board?# The license board can be displayed by opening the Board Select screen and# choosing a character.#------------------------------------------------------------------------------# «Compatibility»## Not SDK compatible.## The script rewrites the following classes:# Game_Actor# Game_Party# Bitmap# Window_EquipItem# Window_InputNumber# Window_BoardSelectable# Scene_Title.#------------------------------------------------------------------------------# «Credits and Thanks»## All credits go to Juan José Sánchez Ramírez.# Do not credit me as medinastories, Medina, Medina Stories, or any other# variation of these names.## Special thanks go to Renan Tsuneo Hangai Junior, also known as RTH, who# wrote the Ability Grid script, which I edited to write this script, and# Teekatas S., also known as Raindropmemory, who made the Legendora Iconset.## For more Final Fantasy XII scripts, I suggest searching for Renan Tsuneo# Hangai Junior's Active Dimension Battle script, which includes the Ability# Grid script.#------------------------------------------------------------------------------# «Author's Notes»## This script was designed for my RPG Maker XP project, Medina Stories. I# first had the idea to make this script a couple of years ago upon# encountering Renan Tsuneo Hangai Junior's Active Dimension Battle script,# which includes the Ability Grid script. When I further analyzed the Ability# Grid script, I figured how to manage large amounts of information# effectively using tables, and storing these tables in encrypted arrays.## Please let me know of any bugs, glitches or suggestions.## New in v2.0.0## Added a zoom in/zoom out function.# The script now draws borders around the edges of the board.# Fixed the Window_BoardConfirm class. The confirm window now adjusts its# width to text.# Added a 'smart start' function. The board cursor now starts at the next# available tile.# Added an action list window.# Aliased the Game_Actor and Scene_title classes.## New in v1.1.2## Fixed the Window_BoardSelectable class.## New in v1.1.1## The README.txt file is now printed when calling the Scene_EditBoard class.# The Boards.rxdata file is now written if it does not exist.# The script no longer rewrites the Main class.#------------------------------------------------------------------------------# «Terms and Conditions»## Free for Commercial Use. Must include the scripter's name.#==============================================================================#==============================================================================# ** MedinaStories#------------------------------------------------------------------------------# This module contains global variables and classes.#==============================================================================module MedinaStories # New board width NEW_BOARD_XSIZE = 24 # New board height NEW_BOARD_YSIZE = 24 # Board zoom capability (percentage) ZOOM = 0.5 # Maximum ability points AP_MAX = 9999 # Maximum party members ACTOR_MAX = 12 # Status bitmap STATUS = RPG::Cache.picture("bar") # Help bitmap HELP = RPG::Cache.picture("Help") # Learned skills bitmap LEARNED_SKILLS = RPG::Cache.picture("Skills") # Category bitmap CATEGORY = RPG::Cache.picture("Category") # Category hue array CATEGORY_HUE = [90, 270, 0, 180, 0, 180, 120, 120, 240, 0, 180] # Star bitmap STAR = RPG::Cache.picture("Star") # Line bitmap LINE = RPG::Cache.picture("Line") # Cursor bitmap CURSOR = RPG::Cache.picture("cursor") # Board background bitmap BOARD_BG = RPG::Cache.picture("parchment") # Tile bitmap width TILE_X_SIZE = 64 # Tile bitmap height TILE_Y_SIZE = 64 # Board margin in tiles BOARD_MARGIN = 2 # Tile license points font size TILE_AP_FONT_SIZE = 16 # Tile level font size TILE_LEVEL_FONT_SIZE = 16 # Hidden tile text string HIDDEN = "???" # License points text string LP = "LP" # Miniature board bitmap MINIBOARD = "Graphics/Pictures/minibg" # Miniature board margin in pixels MINIBOARD_MARGIN = 8 # Miniature board tile width MINI_TILE_XSIZE = 8 # Miniature board tile height MINI_TILE_YSIZE = 8 # Shadow bitmap SHADOW = RPG::Cache.picture("shadow") # Black bitmap BLACK = RPG::Cache.picture("black") # Animation bitmap ANIMATION = RPG::Cache.picture("Light1") # Animation horizontal frames ANIMATION_HORIZONTAL_FRAMES = 5 # Animation vertical frames ANIMATION_VERTICAL_FRAMES = 3 # Animation total frames ANIMATION_TOTAL_FRAMES = 15 # Animation blend type ANIMATION_BLENDTYPE = 1 # Random array for board tiles RANDOM_ARRAY = [ [1, 3, 1, 3, 0, 1, 0, 3, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 3, 2, 3, 1, 3, 2], [1, 3, 3, 2, 2, 0, 2, 1, 1, 3, 1, 3, 1, 3, 0, 2, 0, 1, 0, 3, 0, 0, 0, 0], [3, 2, 0, 3, 3, 3, 1, 2, 1, 2, 1, 1, 1, 3, 3, 1, 1, 3, 3, 2, 1, 1, 3, 3], [1, 1, 0, 3, 3, 1, 1, 3, 3, 0, 2, 3, 2, 0, 0, 3, 1, 3, 0, 3, 1, 2, 3, 2], [3, 1, 0, 0, 2, 0, 1, 2, 0, 2, 3, 1, 3, 1, 2, 3, 3, 3, 0, 3, 3, 0, 3, 3], [3, 1, 3, 1, 1, 3, 1, 3, 3, 1, 1, 0, 3, 2, 2, 2, 0, 2, 1, 2, 0, 2, 0, 1], [2, 3, 2, 3, 1, 3, 0, 2, 0, 0, 3, 1, 2, 0, 0, 2, 0, 2, 2, 2, 2, 1, 1, 3], [3, 0, 3, 2, 3, 2, 3, 0, 3, 2, 2, 0, 3, 3, 2, 3, 2, 2, 1, 2, 3, 0, 1, 0], [1, 3, 0, 1, 3, 3, 1, 2, 3, 2, 0, 1, 1, 2, 1, 1, 0, 2, 3, 1, 0, 3, 0, 3], [0, 2, 2, 0, 2, 2, 2, 0, 2, 0, 2, 2, 1, 0, 2, 3, 2, 0, 3, 2, 3, 0, 1, 0], [3, 0, 0, 3, 2, 1, 2, 1, 3, 2, 2, 3, 3, 0, 3, 0, 2, 1, 2, 1, 3, 1, 1, 3], [1, 0, 2, 2, 0, 3, 3, 1, 3, 2, 0, 2, 3, 0, 1, 0, 2, 3, 3, 1, 3, 3, 0, 0], [3, 0, 3, 0, 3, 0, 3, 2, 1, 3, 1, 0, 3, 1, 2, 3, 0, 2, 2, 0, 2, 0, 2, 1], [1, 1, 2, 0, 3, 1, 0, 2, 3, 3, 2, 1, 2, 2, 3, 1, 1, 3, 3, 0, 3, 1, 2, 1], [3, 2, 3, 2, 2, 3, 0, 2, 0, 0, 0, 3, 0, 1, 2, 1, 0, 3, 3, 2, 2, 2, 1, 0], [1, 2, 2, 1, 1, 0, 2, 2, 2, 2, 1, 2, 1, 2, 2, 0, 1, 0, 3, 0, 2, 1, 2, 1], [2, 0, 3, 0, 3, 1, 3, 2, 0, 3, 3, 3, 0, 0, 0, 2, 3, 0, 2, 1, 2, 2, 1, 3], [3, 2, 0, 3, 2, 0, 2, 2, 2, 2, 3, 2, 0, 2, 3, 3, 0, 2, 2, 2, 2, 1, 1, 0], [3, 0, 1, 0, 3, 2, 1, 3, 3, 3, 1, 1, 1, 3, 0, 3, 3, 0, 0, 3, 2, 2, 1, 1], [3, 0, 2, 3, 3, 2, 0, 1, 1, 1, 1, 0, 2, 0, 3, 1, 0, 0, 3, 3, 1, 2, 0, 0], [0, 2, 0, 0, 2, 0, 0, 2, 2, 1, 3, 2, 2, 3, 0, 2, 2, 0, 2, 0, 3, 2, 2, 2], [3, 1, 3, 3, 2, 1, 0, 1, 1, 0, 0, 3, 1, 1, 2, 2, 1, 0, 3, 0, 2, 2, 1, 1], [2, 0, 2, 2, 0, 2, 2, 0, 1, 2, 0, 0, 3, 3, 1, 3, 3, 2, 3, 0, 2, 0, 1, 3], [3, 2, 2, 0, 3, 1, 0, 0, 1, 1, 1, 2, 3, 0, 3, 3, 2, 1, 3, 0, 1, 0, 1, 2]] #-------------------------------------------------------------------------- # * Avatar Bitmap # id : actor ID #-------------------------------------------------------------------------- def AVATAR(id) return RPG::Cache.picture("avatar#{id}") rescue RPG::Cache.picture("avatar-1") end #-------------------------------------------------------------------------- # * Tile Bitmap # id : tile ID # x : tile x-coordinate # y : tile y-coordinate #-------------------------------------------------------------------------- def TILE(id, x, y) return RPG::Cache.picture("white#{RANDOM_ARRAY[x][y]}") if id == 0 return RPG::Cache.picture("dark#{RANDOM_ARRAY[x][y]}") if id == 1 end #-------------------------------------------------------------------------- # * Icon Bitmap # type : tile type # active : true / false #-------------------------------------------------------------------------- def ICON(type, boolean=false) return RPG::Cache.picture("#{type}") if boolean == true or type == -1 return RPG::Cache.picture("#{type}v") end #-------------------------------------------------------------------------- # * Border Bitmap # id : tile ID #-------------------------------------------------------------------------- def BORDER(id) return RPG::Cache.picture("border#{id}") end #-------------------------------------------------------------------------- # * Miniature Board Tile # type : tile type #-------------------------------------------------------------------------- def MINI_TILE(type) return RPG::Cache.picture("mini#{type}") rescue RPG::Cache.picture("mini-1") end #-------------------------------------------------------------------------- # * Confirmation Message # message : message text string #-------------------------------------------------------------------------- def CONFIRM_MESSAGE(message) return "Obtain #{message}?" end #-------------------------------------------------------------------------- # * Board Name # id : board ID #-------------------------------------------------------------------------- def BOARD_NAME(id) case id when 0 return "No Board" end return "Board" end #-------------------------------------------------------------------------- # * Board Item # type : tile type # value : tile value #-------------------------------------------------------------------------- def BOARD_ITEM(type, value) case type when 8 # Skills return $data_skills[value] when 9 # Weapon Set return $data_weapons[value] when 10 # Armor Set return $data_armors[value] end return nil end #-------------------------------------------------------------------------- # * Board Item # type : tile type # value : tile value #-------------------------------------------------------------------------- def BOARD_DESCRIPTION(type, value) case type when 0 # HP return "Increase max HP by #{value}" when 1 # SP return "Increase max MP by #{value}" when 2 # Strength return "Increase physical attack" when 3 # Physical Defense return "Increase physical defense" when 4 # Intelligence return "Increase magick potency" when 5 # Magic Defense return "Increase magick defense" when 6 # Agility return "Increase agility" when 7 # Dexterity return "Increase dexterity" when 8 # Skills return "#{$data_skills[value].description}" when 9 # Weapon Set return "#{$data_weapons[value].description}" when 10 # Armor Set return "#{$data_armors[value].description}" end return nil end #-------------------------------------------------------------------------- # * Board Item # type : tile type # value : tile value # level : tile level #-------------------------------------------------------------------------- def BOARD_CLASS(type, value, level) case type when 0 # HP return "Max HP" when 1 # SP return "Max MP" when 2 # Strength return "Strength" when 3 # Physical Defense return "Physical Defense" when 4 # Intelligence return "Intelligence" when 5 # Magic Defense return "Magic Defense" when 6 # Agility return "Agility" when 7 # Dexterity return "Dexterity" when 8 # Skills if level == -1 return "" elsif value >= 0 and value <= 6 return "White Magick #{level}" elsif value >= 7 and value <= 32 return "Black Magick #{level}" elsif value >= 33 and value <= 56 return "Green Magick #{level}" elsif value >= 57 and value <= 80 return "Arcane Magick #{level}" else return "#{$data_skills[value].name}" end when 9 # Weapon Set if level == -1 return "" elsif value >= 0 and value <= 4 return "Swords #{level}" elsif value >= 5 and value <= 8 return "Spears #{level}" elsif value >= 9 and value <= 12 return "Axes #{level}" elsif value >= 13 and value <= 16 return "Daggers #{level}" elsif value >= 17 and value <= 20 return "Bows #{level}" elsif value >= 21 and value <= 24 return "Guns #{level}" elsif value >= 25 and value <= 28 return "Maces #{level}" elsif value >= 29 and value <= 32 return "Poles #{level}" else return "#{$data_weapons[value].name}" end when 10 # Armor Set if level == -1 return "" elsif value >= 0 and value <= 4 return "Shields #{level}" elsif value >= 5 and value <= 8 return "Helmets #{level}" elsif value >= 9 and value <= 12 return "Hats #{level}" elsif value >= 13 and value <= 16 return "Armors #{level}" elsif value >= 17 and value <= 20 return "Breastplates #{level}" elsif value >= 21 and value <= 24 return "Robes #{level}" elsif value >= 25 and value <= 32 return "Rings #{level}" else return "#{$data_armors[value].name}" end end return nil end #========================================================================== # «Warning» # # Do not change the following global variables and classes! #========================================================================== #-------------------------------------------------------------------------- # * Print Item List #-------------------------------------------------------------------------- def item_list # Load database $data_skills = load_data("Data/Skills.rxdata") $data_weapons = load_data("Data/Weapons.rxdata") $data_armors = load_data("Data/Armors.rxdata") # Create a new file and write to it File.open("README.txt", "wb") do |file| # Add skills for i in 1...$data_skills.size item = $data_skills[i] file.print("#{item.id}\t") file.print("#{item.name}\t") file.puts("#{item.description}") end # Add weapons for i in 1...$data_weapons.size item = $data_weapons[i] file.print("#{item.id}\t") file.print("#{item.name}\t") file.puts("#{item.description}") end # Add armors for i in 1...$data_armors.size item = $data_armors[i] file.print("#{item.id}\t") file.print("#{item.name}\t") file.puts("#{item.description}") end end end #-------------------------------------------------------------------------- # * Create Empty Board # xsize : new board width # ysize : new board height #-------------------------------------------------------------------------- def new_board(xsize, ysize) $data_boards = get_boards board = Table.new(xsize, ysize, 9) for x in 0...board.xsize for y in 0...board.ysize for z in 0...board.zsize case z when 0 # ACTIVATED board[x, y, z] = 0 when 1 # VISIBLE board[x, y, z] = 0 when 2 # AP board[x, y, z] = 0 when 3 # TYPE board[x, y, z] = -1 when 4 # OBJECT 1 VALUE board[x, y, z] = 0 when 5 # OBJECT 2 VALUE board[x, y, z] = 0 when 6 # OBJECT 3 VALUE board[x, y, z] = 0 when 7 # OBJECT 4 VALUE board[x, y, z] = 0 when 8 # LEVEL board[x, y, z] = -1 end end end end $data_boards.push(board) save_boards($data_boards) end #-------------------------------------------------------------------------- # * Delete Board # index : board ID #-------------------------------------------------------------------------- def delete_board(index) $data_boards = get_boards $data_boards.delete_at(index) save_boards($data_boards) end #-------------------------------------------------------------------------- # * Save Board # boards : boards data #-------------------------------------------------------------------------- def save_boards(boards) save_data(boards, "Data/Boards.rxdata") end #-------------------------------------------------------------------------- # * Get Boards #-------------------------------------------------------------------------- def get_boards $data_boards = load_data("Data/Boards.rxdata") rescue $data_boards = [] return $data_boards endend#==============================================================================# ** Game_Actor#------------------------------------------------------------------------------# This class handles the actor. It's used within the Game_Actors class# ($game_actors) and refers to the Game_Party class ($game_party).#==============================================================================class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :board # board ID attr_reader :ap # ability points #-------------------------------------------------------------------------- # * Setup # actor_id : actor ID #-------------------------------------------------------------------------- alias mslb_game_actor_setup setup def setup(actor_id) @board = Board.new(0) @ap = 0 mslb_game_actor_setup(actor_id) end #-------------------------------------------------------------------------- # * Get AP #-------------------------------------------------------------------------- def ap=(ap) @ap = [[ap, 0].max, AP_MAX].min end #-------------------------------------------------------------------------- # * Get Maximum HP #-------------------------------------------------------------------------- def maxhp n = [[base_maxhp + @maxhp_plus, 1].max, 9999].min for i in @states n *= $data_states[i].maxhp_rate / 100.0 end n += @board.hp n = [[integer(n), 1].max, 9999].min return n end #-------------------------------------------------------------------------- # * Get Maximum SP #-------------------------------------------------------------------------- def maxsp n = [[base_maxsp + @maxsp_plus, 0].max, 999].min for i in @states n *= $data_states[i].maxsp_rate / 100.0 end n += @board.sp n = [[integer(n), 0].max, 999].min return n end #-------------------------------------------------------------------------- # * Get Strength #-------------------------------------------------------------------------- def str n = [[base_str + @str_plus, 1].max, 99].min for i in @states n *= $data_states[i].str_rate / 100.0 end n += @board.str n = [[integer(n), 1].max, 99].min return n end #-------------------------------------------------------------------------- # * Get Intelligence #-------------------------------------------------------------------------- def int n = [[base_int + @int_plus, 1].max, 99].min for i in @states n *= $data_states[i].int_rate / 100.0 end n += @board.int n = [[integer(n), 1].max, 99].min return n end #-------------------------------------------------------------------------- # * Get Dexterity #-------------------------------------------------------------------------- def dex n = [[base_dex + @dex_plus, 1].max, 99].min for i in @states n *= $data_states[i].dex_rate / 100.0 end n += @board.dex n = [[integer(n), 1].max, 99].min return n end #-------------------------------------------------------------------------- # * Get Agility #-------------------------------------------------------------------------- def agi n = [[base_agi + @agi_plus, 1].max, 99].min for i in @states n *= $data_states[i].agi_rate / 100.0 end n += @board.agi n = [[integer(n), 1].max, 99].min return n end #-------------------------------------------------------------------------- # * Get Physical Defense #-------------------------------------------------------------------------- def pdef n = [[base_pdef, 0].max, 999].min for i in @states n *= $data_states[i].pdef_rate / 100.0 end n += @board.pdef n = [[integer(n), 0].max, 999].min return n end #-------------------------------------------------------------------------- # * Get Magic Defense #-------------------------------------------------------------------------- def mdef n = [[base_mdef, 0].max, 999].min for i in @states n *= $data_states[i].mdef_rate / 100.0 end n += @board.mdef n = [[integer(n), 0].max, 999].min return n end #-------------------------------------------------------------------------- # * Determine if Equippable # item : item #-------------------------------------------------------------------------- def equippable?(item) # If weapon if item.is_a?(RPG::Weapon) weapon_set = $data_classes[@class_id].weapon_set weapon_set = @board.weapon_set | weapon_set # If included among equippable weapons in current class and board if weapon_set.include?(item.id) return true end end # If armor if item.is_a?(RPG::Armor) armor_set = $data_classes[@class_id].armor_set armor_set = @board.armor_set | armor_set # If included among equippable armor in current class and board if armor_set.include?(item.id) return true end end return false end #-------------------------------------------------------------------------- # * Skills #-------------------------------------------------------------------------- def skills @board.skills.sort! skills = @board.skills | @skills return skills end #-------------------------------------------------------------------------- # * Determine if Finished Learning Skill # skill_id : skill ID #-------------------------------------------------------------------------- def skill_learn?(skill_id) return (@skills + @board.skills).include?(skill_id) endend#==============================================================================# ** Game_Party#------------------------------------------------------------------------------# This class handles the party. It includes information on amount of gold# and items. Refer to "$game_party" for the instance of this class.#==============================================================================class Game_Party #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Add an Actor # actor_id : actor ID #-------------------------------------------------------------------------- def add_actor(actor_id) # Get actor actor = $game_actors[actor_id] # If the party has less than ACTOR_MAX and this actor is not in the party if @actors.size < ACTOR_MAX and not @actors.include?(actor) # Add actor @actors.push(actor) # Refresh player $game_player.refresh end endend#==============================================================================# ** Animated_Sprite#------------------------------------------------------------------------------# This sprite is used to display an animated image. It observes a superclass# and automatically changes sprite conditions.#==============================================================================class Animated_Sprite < RPG::Sprite #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :frames # frames total attr_reader :bitmap # bitmap attr_accessor :frame # frame ID attr_accessor :wait # frame delay #-------------------------------------------------------------------------- # * Object Initialization # bitmap : bitmap # x : draw spot x-coordinate # y : draw spot y-coordinate # columns : columns # rows : rows # frames : frame total # blend_type : blend type # viewport : viewport #-------------------------------------------------------------------------- def initialize(bitmap, x, y, columns, rows, frames, blend_type=0, wait=1, viewport=nil) super(viewport) @bitmap = bitmap @ox, @oy = x, y @columns = columns @rows = rows @frames = frames self.blend_type = blend_type @wait = wait @counter = wait @frame = 0 update end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if ready? self.bitmap = @bitmap self.x = @ox self.y = @oy cw = @bitmap.width / @columns ch = @bitmap.height / @rows self.src_rect.set(0, 0, cw, ch) sx = (@frame % @columns) * cw sy = (@frame / @columns) * ch self.src_rect.set(sx, sy, cw, ch) @counter = 0 else @counter += 1 end end #-------------------------------------------------------------------------- # * Ready? #-------------------------------------------------------------------------- def ready? return @counter >= @wait endend#==============================================================================# ** Dynamic_Sprite#------------------------------------------------------------------------------# This sprite is used to display a moving image. It observes a superclass# and automatically changes sprite conditions.#==============================================================================class Dynamic_Sprite < RPG::Sprite #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :true_x # true x attr_accessor :true_y # true y attr_accessor :true_zoom_x # true zoom x attr_accessor :true_zoom_y # true zoom y attr_accessor :true_opacity # true opacity attr_accessor :speed # speed #-------------------------------------------------------------------------- # * Object Initialization # viewport : viewport #-------------------------------------------------------------------------- def initialize(viewport=nil) super(viewport) @true_x = 0 @true_y = 0 @true_zoom_x = 1.00 @true_zoom_y = 1.00 @true_opacity = 255 @speed = 5 end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if self.y < @true_y n = (@true_y - self.y) / @speed n = 1 if n == 0 self.y += n elsif self.y > @true_y n = (self.y - @true_y) / @speed n = 1 if n == 0 self.y -= n end if self.x < @true_x n = (@true_x - self.x) / @speed n = 1 if n == 0 self.x += n elsif self.x > @true_x n = (self.x - @true_x) / @speed n = 1 if n == 0 self.x -= n end if self.zoom_y < @true_zoom_y n = (@true_zoom_y - self.zoom_y) / @speed n = 1 if n == 0 self.zoom_y += n elsif self.zoom_y > @true_zoom_y n = (self.zoom_y - @true_zoom_y) / @speed n = 1 if n == 0 self.zoom_y -= n end if self.zoom_x < @true_zoom_x n = (@true_zoom_x - self.zoom_x) / @speed n = 1 if n == 0 self.zoom_x += n elsif self.zoom_x > @true_zoom_x n = (self.zoom_x - @true_zoom_x) / @speed n = 1 if n == 0 self.zoom_x -= n end if self.opacity < @true_opacity n = (@true_opacity - self.opacity) / @speed n = 1 if n == 0 self.opacity += n elsif self.opacity > @true_opacity n = (self.opacity - @true_opacity) / @speed n = 1 if n == 0 self.opacity -= n end endend#==============================================================================# ** Sprite_AvailableLP#------------------------------------------------------------------------------# This sprite is used to display available LP. It observes the Scene_Board# class and automatically changes sprite conditions.#==============================================================================class Sprite_AvailableLP < RPG::Sprite #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Object Initialization # actor : actor # board : board # viewport : viewport #-------------------------------------------------------------------------- def initialize(actor, board, viewport=nil) super(viewport) self.bitmap = STATUS.dup @actor = actor @board = board @ap = @actor.ap self.y = 15 refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.bitmap.clear self.bitmap = STATUS.dup self.bitmap.draw_actor_name( @actor, 72, -5) self.bitmap.draw_actor_ap( @actor, 71, 15) self.bitmap.draw_actor_avatar(@actor, 12, 0) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if @actor.ap != @ap @ap = @actor.ap refresh end endend#==============================================================================# ** Sprite_LicenseDescription#------------------------------------------------------------------------------# This sprite is used to display board help. It observes the Scene_Board# class and automatically changes sprite conditions.#==============================================================================class Sprite_LicenseDescription < Dynamic_Sprite #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Object Initialization # cursor : cursor # board : board # edit_mode : true / false # viewport : viewport #-------------------------------------------------------------------------- def initialize(cursor, board, edit_mode=false, viewport=nil) super(viewport) self.bitmap = HELP.dup @cursor = cursor @board = board @edit_mode = edit_mode @ox, @oy = @cursor.tile_x, @cursor.tile_y self.y = 370 self.opacity = 0 refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.bitmap.clear self.bitmap = HELP.dup x, y = @cursor.tile_x, @cursor.tile_y hue = CATEGORY_HUE[@board.type?(x, y)] self.bitmap.draw_board_category( @board, x, y, 28, 20, hue) self.bitmap.draw_board_ap( @board, x, y, 55, 16) self.bitmap.draw_board_activated( @board, x, y, 114, 18, @edit_mode) self.bitmap.draw_board_class( @board, x, y, 138, 16) self.bitmap.draw_board_item( @board, x, y, 62, 42, 0, @edit_mode) self.bitmap.draw_board_item( @board, x, y, 312, 42, 1, @edit_mode) self.bitmap.draw_board_item( @board, x, y, 62, 63, 2, @edit_mode) self.bitmap.draw_board_item( @board, x, y, 312, 63, 3, @edit_mode) self.bitmap.draw_board_description(@board, x, y, 90, 42, @edit_mode) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if [@cursor.tile_x, @cursor.tile_y] != [@ox, @oy] @ox, @oy = @cursor.tile_x, @cursor.tile_y refresh end endend#==============================================================================# ** Cursor_Base#------------------------------------------------------------------------------# This sprite is used to display the cursor. It observes a superclass# and automatically changes sprite conditions.#==============================================================================class Sprite_Cursor < Dynamic_Sprite #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Object Initialization # viewport : viewport #-------------------------------------------------------------------------- def initialize(viewport=nil) super(viewport) self.bitmap = CURSOR endend#==============================================================================# ** Spriteset_Board#------------------------------------------------------------------------------# This class brings together the board tiles, icons and active slots.# It's used within the Scene_Board class.#==============================================================================class Spriteset_Board #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :tiles # tiles attr_accessor :icons # icons attr_accessor :active # active attr_accessor :border # border attr_accessor :zoom # zoom #-------------------------------------------------------------------------- # * Object Initialization # board : board # edit_mode : true / false #-------------------------------------------------------------------------- def initialize(board, edit_mode=false) @board = board @edit_mode = edit_mode @bg = Plane.new @bg.bitmap = BOARD_BG xs, ys = TILE_X_SIZE, TILE_Y_SIZE @tiles = Dynamic_Sprite.new @tiles.bitmap = Bitmap.new(@board.xsize * xs, @board.ysize * ys) @icons = Dynamic_Sprite.new @icons.bitmap = Bitmap.new(@board.xsize * xs, @board.ysize * ys) @icons.blink_on @active = Dynamic_Sprite.new @active.bitmap = Bitmap.new(@board.xsize * xs, @board.ysize * ys) @border = Dynamic_Sprite.new @border.bitmap = Bitmap.new(@board.xsize * xs, @board.ysize * ys) @zoom = true refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh @tiles.bitmap.clear @icons.bitmap.clear @active.bitmap.clear @border.bitmap.clear for x in 0...@board.xsize for y in 0...@board.ysize @tiles.bitmap.draw_board_tile(@board, x, y) @icons.bitmap.draw_board_icon(@board, x, y, @edit_mode) @active.bitmap.draw_board_active(@board, x, y, @edit_mode) @active.bitmap.draw_board_border(@board, x, y) end end if @zoom == false @tiles.true_zoom_x = ZOOM @tiles.true_zoom_y = ZOOM @icons.true_zoom_x = ZOOM @icons.true_zoom_y = ZOOM @active.true_zoom_x = ZOOM @active.true_zoom_y = ZOOM @border.true_zoom_x = ZOOM @border.true_zoom_y = ZOOM else @tiles.true_zoom_x = 1.0 @tiles.true_zoom_y = 1.0 @icons.true_zoom_x = 1.0 @icons.true_zoom_y = 1.0 @active.true_zoom_x = 1.0 @active.true_zoom_y = 1.0 @border.true_zoom_x = 1.0 @border.true_zoom_y = 1.0 end end #-------------------------------------------------------------------------- # * Dispose #-------------------------------------------------------------------------- def dispose @bg.dispose @tiles.dispose @icons.dispose @active.dispose @border.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @tiles.update @icons.update @active.update @border.update endend#==============================================================================# ** Bitmap#------------------------------------------------------------------------------# The bitmap class. Bitmaps are expressions of so-called graphics.# Sprites and other objects must be used to display bitmaps on the screen.#==============================================================================class Bitmap #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Draw Actor Name # actor : actor # x : draw spot x-coordinate # y : draw spot y-coordinate #-------------------------------------------------------------------------- def draw_actor_name(actor, x, y) self.draw_outline(x, y, 120, 32, actor.name) end #-------------------------------------------------------------------------- # * Draw Actor AP # actor : actor # x : draw spot x-coordinate # y : draw spot y-coordinate # width : draw spot width #-------------------------------------------------------------------------- def draw_actor_ap(actor, x, y, width=78) color = Color.new(204, 204, 153) text = LP self.draw_outline(x, y, 32, 32, text, 0, color) ap_x = x + width - 48 ap = actor.ap.to_s self.draw_outline(ap_x, y, 48, 32, ap, 2, color) end #-------------------------------------------------------------------------- # * Draw Actor Avatar # actor : actor # x : draw spot x-coordinate # y : draw spot y-coordinate #-------------------------------------------------------------------------- def draw_actor_avatar(actor, x, y) rect = Rect.new(0, 0, 60, 60) avatar = AVATAR(actor.id) self.blt(x, y, avatar, rect) end #-------------------------------------------------------------------------- # * Draw Actor Minimap # actor : actor # x : draw spot x-coordinate # y : draw spot y-coordinate #-------------------------------------------------------------------------- def draw_actor_minimap(actor, x, y) bitmap = Bitmap_MiniBoard.new(actor.board) rect = Rect.new(0, 0, bitmap.width, bitmap.height) self.blt(x, y, bitmap, rect) end #-------------------------------------------------------------------------- # * Draw Board Category # board : board # bx : board x-coordinate # by : board y-coordinate # x : draw spot x-coordinate # y : draw spot y-coordinate # hue : hue #-------------------------------------------------------------------------- def draw_board_category(board, bx, by, x, y, hue=0) if board.ap_cost?(bx, by) > 0 bitmap = Bitmap.new(26, 26) rect = Rect.new(0, 0, 26, 26) bitmap.blt(0, 0, CATEGORY, rect) bitmap.hue_change(hue) self.blt(x, y, bitmap, rect) end end #-------------------------------------------------------------------------- # * Draw Board AP # board : board # bx : board x-coordinate # by : board y-coordinate # x : draw spot x-coordinate # y : draw spot y-coordinate # width : draw spot width #-------------------------------------------------------------------------- def draw_board_ap(board, bx, by, x, y, width = 56) if board.ap_cost?(bx, by) > 0 color = Color.new(204, 204, 153) text = LP self.draw_outline(x, y, 32, 32, text, 0, color) ap_x = x + width - 48 ap = board.ap_cost?(bx, by).to_s self.draw_outline(ap_x, y, 48, 32, ap, 2, color) end end #-------------------------------------------------------------------------- # * Draw Board Activated # board : board # bx : board x-coordinate # by : board y-coordinate # x : draw spot x-coordinate # y : draw spot y-coordinate # edit_mode : true / false #-------------------------------------------------------------------------- def draw_board_activated(board, bx, by, x, y, edit_mode=false) if board.activated?(bx, by) or edit_mode and board.visible?(bx, by) bitmap = Bitmap.new(24, 24) rect = Rect.new(0, 0, 24, 24) bitmap.blt(0, 0, STAR, rect) self.blt(x, y, bitmap, rect) end end #-------------------------------------------------------------------------- # * Draw Board Class # board : board # bx : board x-coordinate # by : board y-coordinate # x : draw spot x-coordinate # y : draw spot y-coordinate # width : draw spot width #-------------------------------------------------------------------------- def draw_board_class(board, bx, by, x, y, width=472) board_class = board.class(bx, by) if board_class != nil self.draw_outline(x, y, width, 32, board_class) end end #-------------------------------------------------------------------------- # * Draw Board Item # board : board # bx : board x-coordinate # by : board y-coordinate # x : draw spot x-coordinate # y : draw spot y-coordinate # n : item number # edit_mode : true / false # width : draw spot width #-------------------------------------------------------------------------- def draw_board_item(board, bx, by, x, y, n=0, edit_mode=false, width=240) item = board.item(bx, by, n) if item != nil if board.visible?(bx, by) or edit_mode bitmap = RPG::Cache.icon(item.icon_name) rect = Rect.new(0, 0, 24, 24) self.blt(x, y + 4, bitmap, rect) self.draw_outline(x + 28, y, 212, 32, item.name) else text = HIDDEN self.draw_outline(x + 28, y, 212, 32, text) end end end #-------------------------------------------------------------------------- # * Draw Board Description # board : board # bx : board x-coordinate # by : board y-coordinate # x : draw spot x-coordinate # y : draw spot y-coordinate # edit_mode : true / false # width : draw spot width #-------------------------------------------------------------------------- def draw_board_description(board, bx, by, x, y, edit_mode=false, width=480) type = board.type?(bx, by) if type >= 0 and type < 8 if board.visible?(bx, by) or edit_mode description = board.description(bx, by) self.draw_outline(x, y, width, 32, description) else text = HIDDEN self.draw_outline(x, y, width, 32, text) end end end #-------------------------------------------------------------------------- # * Draw Board Tile # board : board # bx : board x-coordinate # by : board y-coordinate #-------------------------------------------------------------------------- def draw_board_tile(board, bx, by) type = board.type?(bx, by) if type >= 0 xs, ys = TILE_X_SIZE, TILE_Y_SIZE bitmap = Bitmap.new(xs, ys) id = (bx + by) % 2 rect = Rect.new(0, 0, xs, ys) bitmap.blt(0, 0, TILE(id, bx, by), rect) self.blt(bx * xs, by * ys, bitmap, rect) end end #-------------------------------------------------------------------------- # * Draw Board Border # board : board # bx : board x-coordinate # by : board y-coordinate #-------------------------------------------------------------------------- def draw_board_border(board, bx, by) neighboring_tiles = [board.type?(bx-1, by-1), board.type?(bx, by-1), board.type?(bx+1, by-1), board.type?(bx-1, by ), board.type?(bx+1, by ), board.type?(bx-1, by+1), board.type?(bx, by+1), board.type?(bx+1, by+1)] type = board.type?(bx, by) if type < 0 xs, ys = TILE_X_SIZE, TILE_Y_SIZE bitmap = Bitmap.new(xs, ys) rect = Rect.new(0, 0, xs, ys) # Upper left corner if neighboring_tiles[1] >= 0 and neighboring_tiles[3] >= 0 bitmap.blt(0, 0, BORDER(0), rect) # Draw concave corner end if neighboring_tiles[0] >= 0 and neighboring_tiles[1] < 0 and neighboring_tiles[3] < 0 bitmap.blt(0, 0, BORDER(1), rect) # Draw convex corner end if neighboring_tiles[1] >= 0 and not neighboring_tiles[3] >= 0 bitmap.blt(0, 0, BORDER(2), rect) # Draw horizontal border end if neighboring_tiles[3] >= 0 and not neighboring_tiles[1] >= 0 bitmap.blt(0, 0, BORDER(3), rect) # Draw vertical border end # Upper right corner if neighboring_tiles[1] >= 0 and neighboring_tiles[4] >= 0 bitmap.blt(0, 0, BORDER(4), rect) # Draw concave corner end if neighboring_tiles[2] >= 0 and neighboring_tiles[1] < 0 and neighboring_tiles[4] < 0 bitmap.blt(0, 0, BORDER(5), rect) # Draw convex corner end if neighboring_tiles[1] >= 0 and not neighboring_tiles[4] >= 0 bitmap.blt(0, 0, BORDER(6), rect) # Draw horizontal border end if neighboring_tiles[4] >= 0 and not neighboring_tiles[1] >= 0 bitmap.blt(0, 0, BORDER(7), rect) # Draw vertical border end # Lower left corner if neighboring_tiles[6] >= 0 and neighboring_tiles[3] >= 0 bitmap.blt(0, 0, BORDER(8), rect) # Draw concave corner end if neighboring_tiles[5] >= 0 and neighboring_tiles[6] < 0 and neighboring_tiles[3] < 0 bitmap.blt(0, 0, BORDER(9), rect) # Draw convex corner end if neighboring_tiles[6] >= 0 and not neighboring_tiles[3] >= 0 bitmap.blt(0, 0, BORDER(10), rect) # Draw horizontal border end if neighboring_tiles[3] >= 0 and not neighboring_tiles[6] >= 0 bitmap.blt(0, 0, BORDER(11), rect) # Draw vertical border end # Lower right corner if neighboring_tiles[6] >= 0 and neighboring_tiles[4] >= 0 bitmap.blt(0, 0, BORDER(12), rect) # Draw concave corner end if neighboring_tiles[7] >= 0 and neighboring_tiles[6] < 0 and neighboring_tiles[4] < 0 bitmap.blt(0, 0, BORDER(13), rect) # Draw convex corner end if neighboring_tiles[6] >= 0 and not neighboring_tiles[4] >= 0 bitmap.blt(0, 0, BORDER(14), rect) # Draw horizontal border end if neighboring_tiles[4] >= 0 and not neighboring_tiles[6] >= 0 bitmap.blt(0, 0, BORDER(15), rect) # Draw vertical border end self.blt(bx * xs, by * ys, bitmap, rect) end end #-------------------------------------------------------------------------- # * Draw Board Icon # board : board # bx : board x-coordinate # by : board y-coordinate # edit_mode : true / false #-------------------------------------------------------------------------- def draw_board_icon(board, bx, by, edit_mode) visible = board.visible?(bx, by) activated = board.activated?(bx, by) if visible and not activated and not edit_mode xs, ys = TILE_X_SIZE, TILE_Y_SIZE bitmap = Bitmap.new(xs, ys) type = board.type?(bx, by) rect = Rect.new(0, 0, xs, ys) bitmap.blt(0, 0, ICON(type), rect) bitmap.font.size = TILE_AP_FONT_SIZE ap_y = ys - bitmap.font.size * 2 - 8 ap_cost = board.ap_cost?(bx, by).to_s color = Color.new(204, 204, 153) bitmap.draw_outline(0, ap_y, xs, ys, ap_cost, 0, color) bitmap.font.size = TILE_LEVEL_FONT_SIZE level = board.level?(bx, by) if level >= 0 bitmap.draw_outline(0, 0, xs, ys, level.to_s, 2) end self.blt(bx * xs, by * ys, bitmap, rect) end end #-------------------------------------------------------------------------- # * Draw Board Active # board : board # bx : board x-coordinate # by : board y-coordinate # edit_mode : true / false #-------------------------------------------------------------------------- def draw_board_active(board, bx, by, edit_mode) visible = board.visible?(bx, by) activated = board.activated?(bx, by) if visible and activated or edit_mode xs, ys = TILE_X_SIZE, TILE_Y_SIZE bitmap = Bitmap.new(xs, ys) type = board.type?(bx, by) rect = Rect.new(0, 0, xs, ys) bitmap.blt(0, 0, ICON(type, true), rect) bitmap.font.size = TILE_LEVEL_FONT_SIZE level = board.level?(bx, by) if level >= 0 bitmap.draw_outline(0, -8, xs, ys, level.to_s, 2) end self.blt(bx * xs, by * ys, bitmap, rect) end end #-------------------------------------------------------------------------- # * Draw Board Statistics # board : board #-------------------------------------------------------------------------- def draw_board_statistics(board) self.draw_text(0, 0, 408, 32, board.name) self.draw_text(0, 0, 408, 32, "Tiles: #{board.tiles}", 1) self.draw_text(0, 0, 408, 32, "ID: #{board.id}", 2) self.draw_text(32, 48, 344, 32, "X Size: #{board.xsize}") self.draw_text(32, 48, 344, 32, "Y Size: #{board.ysize}", 2) stats = board.statistics text = ["HP", "SP", "Strength", "Physical Defense", "Intelligence", "Magical Defense", "Agility", "Dexterity", "Skills", "Weapon Set", "Armor Set"] for i in 0...text.length self.draw_text(32, 96 + i * 32, 344, 32, "#{text[i]}: #{stats[i]}") end end #-------------------------------------------------------------------------- # * Draw Miniature Board Tile # board : board # bx : board x-coordinate # by : board y-coordinate #-------------------------------------------------------------------------- def draw_miniboard_tile(board, bx, by) type = board.type?(bx, by) activated = board.activated?(bx, by) xs, ys = MINI_TILE_XSIZE, MINI_TILE_YSIZE margin = MINIBOARD_MARGIN cx, cy = bx * xs + margin, by * ys + margin rect = Rect.new(0, 0, xs, ys) if type != -1 and not activated self.blt(cx, cy, MINI_TILE(-1), rect) elsif activated self.blt(cx, cy, MINI_TILE(type), rect) end end #-------------------------------------------------------------------------- # * Draw Outline # x : draw spot x-coordinate # y : draw spot y-coordinate # w : draw spot width # h : draw spot height # text : text string displayed # align : alignment (0..flush left, 1..center, 2..flush right) # color : text string color #-------------------------------------------------------------------------- def draw_outline(x, y, w, h, text, align=0, color=Color.new(255, 255, 255)) self.font.color = Color.new(0, 0, 0) self.draw_text(x, y + 1, w, h, text, align) # U self.draw_text(x - 1, y + 1, w, h, text, align) # UL self.draw_text(x - 1, y, w, h, text, align) # L self.draw_text(x - 1, y - 1, w, h, text, align) # DL self.draw_text(x, y - 1, w, h, text, align) # D self.draw_text(x + 1, y - 1, w, h, text, align) # DR self.draw_text(x + 1, y, w, h, text, align) # R self.draw_text(x + 1, y + 1, w, h, text, align) # UR self.font.color = color self.draw_text(x, y, w, h, text, align) endend#==============================================================================# ** Bitmap_MiniBoard#------------------------------------------------------------------------------# This bitmap draws a miniature board. It observes the Window_BoardSelectable# class and automatically changes bitmap conditions.#==============================================================================class Bitmap_MiniBoard < Bitmap #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Object Initialization # board : board #-------------------------------------------------------------------------- def initialize(board) super(MINIBOARD) @board = board update end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update for x in 0...@board.xsize for y in 0...@board.ysize self.draw_miniboard_tile(@board, x, y) end end endend#==============================================================================# ** Window_EquipItem#------------------------------------------------------------------------------# This window displays choices when opting to change equipment on the# equipment screen.#==============================================================================class Window_EquipItem < Window_Selectable #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # Add equippable weapons if @equip_type == 0 weapon_set = $data_classes[@actor.class_id].weapon_set for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 and @actor.equippable?($data_weapons[i]) @data.push($data_weapons[i]) end end end # Add equippable armor if @equip_type != 0 armor_set = $data_classes[@actor.class_id].armor_set for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 and @actor.equippable?($data_armors[i]) if $data_armors[i].kind == @equip_type-1 @data.push($data_armors[i]) end end end end # Add blank page @data.push(nil) # Make a bit map and draw all items @item_max = @data.size self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max-1 draw_item(i) end endend#==============================================================================# ** Window_InputNumber#------------------------------------------------------------------------------# This window is for inputting numbers, and is used within the# message window.#==============================================================================class Window_InputNumber < Window_Base #-------------------------------------------------------------------------- # * Object Initialization # digits_max : digit count # message : message text string # width : width #-------------------------------------------------------------------------- def initialize(digits_max, message, width) @digits_max = digits_max @message = message @number = 0 # Calculate cursor width from number width (0-9 equal width and postulate) dummy_bitmap = Bitmap.new(32, 32) @cursor_width = dummy_bitmap.text_size("0").width + 8 dummy_bitmap.dispose super(0, 0, width, 64) self.contents = Bitmap.new(width - 32, height - 32) text_x = @cursor_width * @digits_max + 32 self.contents.draw_text(text_x, 0, width - text_x - 32, 32, @message) self.z += 9999 @index = 0 refresh update_cursor_rect end #-------------------------------------------------------------------------- # * Get Number #-------------------------------------------------------------------------- def number return @number end #-------------------------------------------------------------------------- # * Set Number # number : new number #-------------------------------------------------------------------------- def number=(number) @number = [[number, 0].max, 10 ** @digits_max - 1].min refresh end #-------------------------------------------------------------------------- # * Cursor Rectangle Update #-------------------------------------------------------------------------- def update_cursor_rect self.cursor_rect.set(@index * @cursor_width, 0, @cursor_width, 32) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super # If up or down directional button was pressed if Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN) $game_system.se_play($data_system.cursor_se) # Get current place number and change it to 0 place = 10 ** (@digits_max - 1 - @index) n = @number / place % 10 @number -= n * place # If up add 1, if down substract 1 n = (n + 1) % 10 if Input.repeat?(Input::UP) n = (n + 9) % 10 if Input.repeat?(Input::DOWN) # Reset current place number @number += n * place refresh end # Cursor right if Input.repeat?(Input::RIGHT) if @digits_max >= 2 $game_system.se_play($data_system.cursor_se) @index = (@index + 1) % @digits_max end end # Cursor left if Input.repeat?(Input::LEFT) if @digits_max >= 2 $game_system.se_play($data_system.cursor_se) @index = (@index + @digits_max - 1) % @digits_max end end update_cursor_rect end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents.font.color = normal_color s = sprintf("%0*d", @digits_max, @number) for i in 0...@digits_max self.contents.draw_text(i * @cursor_width + 4, 0, 32, 32, s[i,1]) end text_x = @cursor_width * @digits_max + 32 self.contents.draw_text(text_x, 0, width - text_x - 32, 32, @message) endend#==============================================================================# ** Window_BoardSelectable#------------------------------------------------------------------------------#  This window class contains cursor movement and scroll functions.#==============================================================================class Window_BoardSelectable < Window_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :index # cursor position #-------------------------------------------------------------------------- # * Object Initialization # x : window x-coordinate # y : window y-coordinate # width : window width # height : window height #-------------------------------------------------------------------------- def initialize(x, y, width, height) super(x, y, width, height) @item_max = 1 @column_max = 1 @index = -1 @scroll_y = 0 @scroll_speed = 5 @cursor = Sprite_Cursor.new @cursor.z = 65536 update_cursor end #-------------------------------------------------------------------------- # * Set Cursor Position # index : new cursor position #-------------------------------------------------------------------------- def index=(index) @index = index update_cursor_rect end #-------------------------------------------------------------------------- # * Get Row Count #-------------------------------------------------------------------------- def row_max return (@item_max + @column_max - 1) / @column_max end #-------------------------------------------------------------------------- # * Get Top Row #-------------------------------------------------------------------------- def top_row return @scroll_y / (self.contents.height / row_max) rescue 0 end #-------------------------------------------------------------------------- # * Set Top Row # row : row shown on top #-------------------------------------------------------------------------- def top_row=(row) if row < 0 row = 0 elsif row > row_max - 1 row = row_max - 1 end @scroll_y = row * ((self.height - 32) / page_row_max) end #-------------------------------------------------------------------------- # * Get Number of Rows Displayable on 1 Page #-------------------------------------------------------------------------- def page_row_max return (self.height - 32) / (self.contents.height / row_max) rescue 1 end #-------------------------------------------------------------------------- # * Get Number of Items Displayable on 1 Page #-------------------------------------------------------------------------- def page_item_max return page_row_max * @column_max end #-------------------------------------------------------------------------- # * Update Cursor Rectangle #-------------------------------------------------------------------------- def update_cursor_rect if @index < 0 self.cursor_rect.empty return end row = @index / @column_max if row < self.top_row self.top_row = row elsif row > self.top_row + (self.page_row_max - 1) self.top_row = row - (self.page_row_max - 1) end cursor_width = (self.width - 32) / @column_max x = @index % @column_max * cursor_width y = @index / @column_max * (self.contents.height / row_max) - @scroll_y rescue 0 self.cursor_rect.set(x, y, 0, 0) end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update super if self.active and @item_max > 0 and @index >= 0 if Input.repeat?(Input::DOWN) if Input.press?(Input::SHIFT) $game_system.se_play($data_system.cursor_se) n = @index + page_item_max @index = n > @item_max - 1 ? @item_max - 1 : n elsif (@column_max == 1 and Input.trigger?(Input::DOWN)) or @index < @item_max - @column_max $game_system.se_play($data_system.cursor_se) @index = (@index + @column_max) % @item_max end end if Input.repeat?(Input::UP) if Input.press?(Input::SHIFT) $game_system.se_play($data_system.cursor_se) n = @index - page_item_max @index = n < 0 ? 0 : n elsif (@column_max == 1 and Input.trigger?(Input::UP)) or @index >= @column_max $game_system.se_play($data_system.cursor_se) @index = (@index - @column_max + @item_max) % @item_max end end if Input.repeat?(Input::RIGHT) if @column_max >= 2 and @index < @item_max - 1 $game_system.se_play($data_system.cursor_se) @index += 1 end end if Input.repeat?(Input::LEFT) if @column_max >= 2 and @index > 0 $game_system.se_play($data_system.cursor_se) @index -= 1 end end if Input.repeat?(Input::R) if self.top_row + (self.page_row_max - 1) < (self.row_max - 1) $game_system.se_play($data_system.cursor_se) @index = [@index + self.page_item_max, @item_max - 1].min self.top_row += self.page_row_max end end if Input.repeat?(Input::L) if self.top_row > 0 $game_system.se_play($data_system.cursor_se) @index = [@index - self.page_item_max, 0].max self.top_row -= self.page_row_max end end end update_cursor_rect update_scroll update_cursor end #-------------------------------------------------------------------------- # * Update Cursor #-------------------------------------------------------------------------- def update_cursor @cursor.true_x = self.cursor_rect.x + self.x @cursor.true_y = self.cursor_rect.y + self.y + 16 @cursor.update @cursor.visible = (self.visible and self.index >= 0) end #-------------------------------------------------------------------------- # * Update Scroll #-------------------------------------------------------------------------- def update_scroll if self.oy < @scroll_y n = (@scroll_y - self.oy) / @scroll_speed n = 1 if n == 0 self.oy += n elsif self.oy > @scroll_y n = (self.oy - @scroll_y) / @scroll_speed n = 1 if n == 0 self.oy -= n end end #-------------------------------------------------------------------------- # * Dispose #-------------------------------------------------------------------------- def dispose @cursor.dispose super endend#==============================================================================# ** Window_BoardConfirm#------------------------------------------------------------------------------# This window is used to confirm the activation of a slot.#==============================================================================class Window_BoardConfirm < Window_BoardSelectable #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :message # message #-------------------------------------------------------------------------- # * Object Initialization # commands : command text string array #-------------------------------------------------------------------------- def initialize(commands) super(0, 0, 32, commands.size * 32 + 64) @item_max = commands.size @commands = commands width = 32 height = @item_max * 32 + 32 self.contents = Bitmap.new(width, height) @message = "" refresh self.index = 0 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh dummy_bitmap = Bitmap.new(640, 32) width = dummy_bitmap.text_size(message).width + 32 height = @item_max * 32 + 32 self.width = width self.contents = Bitmap.new(@message.empty? ? 32 : width - 32, height) self.contents.clear self.contents.draw_outline(0, 0, self.width - 32, 32, @message) for i in 0...@item_max self.draw_item(i, 32, i * 32 + 32) end end #-------------------------------------------------------------------------- # * Draw Item # index : item number # color : text color #-------------------------------------------------------------------------- def draw_item(index, x, y, color=normal_color) self.contents.draw_outline(x, y, 120, 32, @commands[index], 0, color) end #-------------------------------------------------------------------------- # * Update Cursor #-------------------------------------------------------------------------- def update_cursor @cursor.true_x = self.cursor_rect.x + self.x + 8 correction = @index % @item_max * 16 @cursor.true_y = self.cursor_rect.y + self.y + 48 - correction @cursor.update @cursor.visible = (self.visible and self.index >= 0) endend#==============================================================================# ** Window_BoardSelect#------------------------------------------------------------------------------# This window selects a board to display from an actor.#==============================================================================class Window_BoardSelect < Window_BoardSelectable #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 672, 512) @item_max = $game_party.actors.size @column_max = 3 rows_max = (@item_max + @column_max - 1) / @column_max self.contents = Bitmap.new(width - 32, rows_max * 240) @bg = Plane.new @bg.bitmap = BOARD_BG @shadow_sprite = RPG::Sprite.new @shadow_sprite.bitmap = SHADOW.dup refresh self.index = 0 self.x = -16 self.y = -16 self.opacity = 0 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...$game_party.actors.size x = i % @column_max * 208 y = i / @column_max * 240 actor = $game_party.actors[i] self.contents.draw_actor_minimap(actor, x + 8, y + 32) self.contents.draw_actor_name( actor, x + 12, y) self.contents.draw_actor_ap( actor, x + 126, y + 4) end end #-------------------------------------------------------------------------- # * Update Cursor #-------------------------------------------------------------------------- def update_cursor correction = @index % @column_max * 5 @cursor.true_x = self.cursor_rect.x + self.x + 26 - correction @cursor.true_y = self.cursor_rect.y + self.y + 48 @cursor.update @cursor.visible = (self.visible and self.index >= 0) end #-------------------------------------------------------------------------- # * Dispose #-------------------------------------------------------------------------- def dispose self.contents.clear @bg.dispose @shadow_sprite.dispose super endend#==============================================================================# ** Window_ActionList#------------------------------------------------------------------------------# This window displays an action list from an actor.#==============================================================================class Window_ActionList < Window_BoardSelectable #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :page_max # page total attr_accessor :page # current page attr_accessor :actor_skills # actor skills #-------------------------------------------------------------------------- # * Object Initialization # actor : actor # skills : skills #-------------------------------------------------------------------------- def initialize(actor, skills) super(0, 0, 672, 512) @item_max = 33 @actor = actor @classes = classes(skills) @skills = sort_skills(skills) @page_max = page_total + 1 @page = 0 @actor_skills = [] @column_max = 3 width = 32 height = @item_max * 32 + 32 self.contents = Bitmap.new(width, height) self.contents = LEARNED_SKILLS.dup refresh self.x = -16 self.y = -16 self.opacity = 0 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear self.contents = LEARNED_SKILLS.dup current_page = 0 items = 0 for i in 0...@skills.size items += @skills[i].size if items > @item_max items = @skills[i].size current_page += 1 end if current_page == @page for j in 0...@skills[i].size index = j + items - @skills[i].size x = index % @column_max * 130 y = index / @column_max * 32 index += @item_max * @page if @actor_skills.include?(@skills[i][j]) name = BOARD_ITEM(8, @skills[i][j]).name self.contents.draw_outline(190 + x, 82 + y, 120, 32, name) else name = HIDDEN self.contents.draw_outline(190 + x, 82 + y, 120, 32, name) end if j == 0 if i > 0 src_bitmap = Bitmap.new(640, 4) src_rect = Rect.new(0, 0, 640, 4) src_bitmap.blt(0, 0, LINE, src_rect) self.contents.blt(0, 78 + y, src_bitmap, src_rect) end src_bitmap = Bitmap.new(64, 64) bitmap = RPG::Cache.picture(@classes[i]) rescue Bitmap.new(64, 64) src_rect = Rect.new(0, 0, 64, 64) src_bitmap.blt(0, 0, bitmap, src_rect) self.contents.blt(93, 82 + y, src_bitmap, src_rect) end end end end refresh_help end #-------------------------------------------------------------------------- # * Refresh Help #-------------------------------------------------------------------------- def refresh_help src_bitmap = LEARNED_SKILLS src_rect = Rect.new(60, 50, 520, 32) self.contents.blt(60, 50, src_bitmap, src_rect) self.contents.draw_actor_name(@actor, 68, 52) current_page = 0 items = 0 for i in 0...@skills.size items += @skills[i].size if items > @item_max items = @skills[i].size current_page += 1 end if current_page == @page index = @index - (items - @skills[i].size) if index >= 0 and @actor_skills.include?(@skills[i][index]) str = BOARD_DESCRIPTION(8, @skills[i][index]) self.contents.draw_outline(174, 52, 400, 32, str) end end end end #-------------------------------------------------------------------------- # * Update Cursor #-------------------------------------------------------------------------- def update_cursor correction = @index % @column_max * 83 @cursor.true_x = self.cursor_rect.x + self.x + 186 - correction correction = @index / @column_max * 11 @cursor.true_y = self.cursor_rect.y + self.y + 94 - correction @cursor.update @cursor.visible = (self.visible and self.index >= 0) end #-------------------------------------------------------------------------- # * Get Classes # skills : skills #-------------------------------------------------------------------------- def classes(skills) classes = [] skills.each {|skill_id| str = BOARD_CLASS(8, skill_id, nil).strip classes.push(str) if not classes.include?(str) } return classes end #-------------------------------------------------------------------------- # * Sort Skills # skills : skills #-------------------------------------------------------------------------- def sort_skills(skills) skill_array = [] for i in 0...@classes.size array = [] if not skills.empty? for j in 0...skills.size str = BOARD_CLASS(8, skills[j], nil).strip array.push(skills[j]) if @classes[i] == str end end skill_array.push(array) end return skill_array end #-------------------------------------------------------------------------- # * Page Total #-------------------------------------------------------------------------- def page_total page_max = 0 items = 0 for i in 0...@skills.size items += @skills[i].size if items > @item_max items = @skills[i].size page_max += 1 end end return page_max endend#==============================================================================# ** Window_EditBoardLeft#------------------------------------------------------------------------------# This window designates boards on the board edit screen.#==============================================================================class Window_EditBoardLeft < Window_Selectable #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, 192, 352) self.index = 0 refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @item_max = $data_boards.size + 1 self.contents = Bitmap.new(width - 32, @item_max * 32) for i in 0...@item_max - 1 text = "License Board #{i}" self.contents.draw_text(4, i * 32, 152, 32, text) end self.contents.draw_text(4, self.contents.height - 32, 152, 32, "New board") end #-------------------------------------------------------------------------- # * Get Index #-------------------------------------------------------------------------- def index? return self.index end #-------------------------------------------------------------------------- # * Get Board #-------------------------------------------------------------------------- def board return Board.new(index?) rescue nil endend#==============================================================================# ** Window_EditBoardRight#------------------------------------------------------------------------------# This window displays boards separately on the board edit screen.#==============================================================================class Window_EditBoardRight < Window_Base #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :board # board #-------------------------------------------------------------------------- # * Object Initialization # board : board #-------------------------------------------------------------------------- def initialize(board=nil) super(192, 0, 448, 480) self.contents = Bitmap.new(width - 32, height - 32) @board = board refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.clear if @board != nil self.contents.draw_board_statistics(@board) else self.contents.draw_text(4, 0, 408, 32, "Create new board") end endend#==============================================================================# ** Window_EditBoardKey#------------------------------------------------------------------------------# This window designates boards on the board edit screen.#==============================================================================class Window_EditBoardKey < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 352, 192, 128) self.contents = Bitmap.new(width - 32, height - 32) refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.contents.draw_text(0, 0, 152, 32, "A: Delete") self.contents.draw_text(0, 32, 152, 32, "B: Cancel") self.contents.draw_text(0, 64, 152, 32, "C: Decision") endend#==============================================================================# ** Scene_Title#------------------------------------------------------------------------------# This class performs title screen processing.#==============================================================================class Scene_Title #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- alias mslb_scene_title_main main def main # Load Boards.rxdata, create new if it does not exist $data_boards = get_boards if $data_boards.empty? new_board(NEW_BOARD_XSIZE, NEW_BOARD_YSIZE) p "New Boards.rxdata file created!" end mslb_scene_title_main endend#==============================================================================# ** Scene_BoardSelect#------------------------------------------------------------------------------#  This class performs board select screen processing.#==============================================================================class Scene_BoardSelect #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Object Initialization # index : index #-------------------------------------------------------------------------- def initialize(index=0) @index = index end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main $data_boards = get_boards @select_window = Window_BoardSelect.new @select_window.index = @index Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @select_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @select_window.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new return end if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) actor_index = @select_window.index actor = $game_party.actors[actor_index] board = actor.board $scene = Scene_Board.new(board, actor_index) return end endend#==============================================================================# ** Scene_Board#------------------------------------------------------------------------------#  This class performs board screen processing.#==============================================================================class Scene_Board #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Object Initialization # board : board # actor_index : actor index #-------------------------------------------------------------------------- def initialize(board, actor_index) @board = board @actor_index = actor_index @actor = $game_party.actors[@actor_index] end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main $data_boards = get_boards @spriteset = Spriteset_Board.new(@board) x, y = @board.init_pos(@actor.ap) @cursor = Cursor_Board.new(@board, x, y) @cursor.px, @cursor.py = BOARD_MARGIN, BOARD_MARGIN update_cursor @shadow_sprite = RPG::Sprite.new @shadow_sprite.bitmap = SHADOW.dup @status_sprite = Sprite_AvailableLP.new(@actor, @board) @help_sprite = Sprite_LicenseDescription.new(@cursor, @board) update_help @confirm_window = Window_BoardConfirm.new(["Yes","No"]) @confirm_window.back_opacity = 160 @confirm_window.x = 320 - @confirm_window.width / 2 @confirm_window.y = 240 - @confirm_window.height / 2 @confirm_window.index = -1 @confirm_window.active = false @confirm_window.visible = false @black_sprite = Dynamic_Sprite.new @black_sprite.bitmap = BLACK @black_sprite.true_opacity = 0 @black_sprite.opacity = 0 @skills_window = Window_ActionList.new(@actor, @board.skills?) @skills_window.index = -1 @skills_window.active = false @skills_window.visible = false Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @spriteset.dispose @cursor.dispose @shadow_sprite.dispose @status_sprite.dispose @skills_window.dispose @confirm_window.dispose @black_sprite.dispose @help_sprite.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @spriteset.update @cursor.update @status_sprite.update @skills_window.update @confirm_window.update @black_sprite.update @help_sprite.update if @confirm_window.active update_confirm return end if @skills_window.active update_skills return end if Input.repeat?(Input.dir8) $game_system.se_play($data_system.cursor_se) update_cursor update_help end if Input.trigger?(Input::X) $game_system.se_play($data_system.decision_se) @skills_window.index = 0 @skills_window.active = true @skills_window.visible = true @skills_window.actor_skills = @board.skills.sort! @skills_window.refresh @black_sprite.true_opacity = 128 return end if Input.trigger?(Input::A) $game_system.se_play($data_system.decision_se) xs = @spriteset.zoom == true ? TILE_X_SIZE * ZOOM : TILE_X_SIZE ys = @spriteset.zoom == true ? TILE_Y_SIZE * ZOOM : TILE_Y_SIZE margin = BOARD_MARGIN max_x = 640 / xs - 1 - margin max_y = 480 / ys - 1 - margin if @spriteset.zoom == true @spriteset.zoom = false @cursor.px = max_x if @cursor.px < max_x and @cursor.tile_x >= max_x @cursor.py = max_y if @cursor.py < max_y and @cursor.tile_y >= max_y else @spriteset.zoom = true @cursor.px = max_x if @cursor.px > max_x and @cursor.tile_x >= max_x @cursor.py = max_y if @cursor.py > max_y and @cursor.tile_y >= max_y end @cursor.px = margin if @cursor.px > @cursor.tile_x @cursor.py = margin if @cursor.py > @cursor.tile_y @spriteset.refresh update_cursor return end if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) $scene = Scene_BoardSelect.new(@actor_index) return end if Input.trigger?(Input::C) x, y = @cursor.tile_x, @cursor.tile_y valid = @board.valid?(x, y) visible = @board.visible?(x, y) activated = @board.activated?(x, y) ap_cost = @board.ap_cost?(x, y) if valid and visible and not activated and @actor.ap >= ap_cost $game_system.se_play($data_system.decision_se) board_class = @board.class(x, y) @confirm_window.message = CONFIRM_MESSAGE(board_class) @confirm_window.refresh @confirm_window.x = (640 - @confirm_window.width) / 2 @confirm_window.index = 1 @confirm_window.active = true @confirm_window.visible = true @black_sprite.true_opacity = 128 else $game_system.se_play($data_system.buzzer_se) end return end if Input.trigger?(Input::R) $game_system.se_play($data_system.cursor_se) @actor_index += 1 @actor_index %= $game_party.actors.size actor = $game_party.actors[@actor_index] board = actor.board $scene = Scene_Board.new(board, @actor_index) return end if Input.trigger?(Input::L) $game_system.se_play($data_system.cursor_se) @actor_index += $game_party.actors.size - 1 @actor_index %= $game_party.actors.size actor = $game_party.actors[@actor_index] board = actor.board $scene = Scene_Board.new(board, @actor_index) return end end #-------------------------------------------------------------------------- # * Help Update #-------------------------------------------------------------------------- def update_help x, y = @cursor.tile_x, @cursor.tile_y if @board.valid?(x, y) @help_sprite.true_y = 360 @help_sprite.true_opacity = 255 else @help_sprite.true_y = 370 @help_sprite.true_opacity = 0 end end #-------------------------------------------------------------------------- # * Cursor Update #-------------------------------------------------------------------------- def update_cursor xs = @spriteset.zoom == true ? TILE_X_SIZE : TILE_X_SIZE * ZOOM ys = @spriteset.zoom == true ? TILE_Y_SIZE : TILE_Y_SIZE * ZOOM max_x = 640 / xs - 1 max_y = 480 / ys - 1 margin = BOARD_MARGIN case Input.dir8 when 2 # Down @cursor.tile_y += 1 if @cursor.py < max_y - margin @cursor.py += 1 elsif @cursor.tile_y >= @board.ysize @cursor.py = margin end when 4 # Left @cursor.tile_x -= 1 if @cursor.px > margin @cursor.px -= 1 elsif @cursor.tile_x < 0 @cursor.px = max_x - margin end when 6 # Right @cursor.tile_x += 1 if @cursor.px < max_x - margin @cursor.px += 1 elsif @cursor.tile_x >= @board.xsize @cursor.px = margin end when 8 # Up @cursor.tile_y -= 1 if @cursor.py > margin @cursor.py -= 1 elsif @cursor.tile_y < 0 @cursor.py = max_y - margin end end @cursor.tile_x %= @board.xsize @cursor.tile_y %= @board.xsize cx = (@cursor.px - @cursor.tile_x) * xs cy = (@cursor.py - @cursor.tile_y) * ys @spriteset.tiles.true_x = cx @spriteset.tiles.true_y = cy @spriteset.icons.true_x = cx @spriteset.icons.true_y = cy @spriteset.active.true_x = cx @spriteset.active.true_y = cy @cursor.true_x = (@cursor.px * xs) - 20 @cursor.true_y = (@cursor.py * ys) - 4 end #-------------------------------------------------------------------------- # * Confirm Window Update #-------------------------------------------------------------------------- def update_confirm if Input.trigger?(Input::B) $game_system.se_play($data_system.cursor_se) @confirm_window.index = 1 return end if Input.trigger?(Input::C) case @confirm_window.index when 0 # Confirm $game_system.se_play($data_system.decision_se) @confirm_window.index = -1 @confirm_window.active = false @confirm_window.visible = false @confirm_window.update @black_sprite.true_opacity = 0 x, y = @cursor.tile_x, @cursor.tile_y @board.activate(x, y, true) @actor.ap -= @board.ap_cost?(x, y) @spriteset.refresh @status_sprite.refresh @help_sprite.refresh animation when 1 # Cancel $game_system.se_play($data_system.cancel_se) @confirm_window.index = -1 @confirm_window.active = false @confirm_window.visible = false @confirm_window.update @black_sprite.true_opacity = 0 end return end end #-------------------------------------------------------------------------- # * Skills Update #-------------------------------------------------------------------------- def update_skills if Input.repeat?(Input.dir8) $game_system.se_play($data_system.cursor_se) @skills_window.refresh_help return end if Input.trigger?(Input::X) $game_system.se_play($data_system.decision_se) @skills_window.index = -1 @skills_window.active = false @skills_window.visible = false @black_sprite.true_opacity = 0 return end if Input.trigger?(Input::R) $game_system.se_play($data_system.cursor_se) @skills_window.page += 1 @skills_window.page %= @skills_window.page_max @skills_window.refresh return end if Input.trigger?(Input::L) $game_system.se_play($data_system.cursor_se) @skills_window.page -= 1 @skills_window.page %= @skills_window.page_max @skills_window.refresh end end #-------------------------------------------------------------------------- # * Animation #-------------------------------------------------------------------------- def animation bitmap = ANIMATION xs = @spriteset.zoom == true ? TILE_X_SIZE : TILE_X_SIZE * ZOOM ys = @spriteset.zoom == true ? TILE_Y_SIZE : TILE_Y_SIZE * ZOOM hf = ANIMATION_HORIZONTAL_FRAMES vf = ANIMATION_VERTICAL_FRAMES tf = ANIMATION_TOTAL_FRAMES blend = ANIMATION_BLENDTYPE cx = (@cursor.px * xs) - ((bitmap.width / hf) - xs) / 2 cy = (@cursor.py * ys) - ((bitmap.height / vf) - ys) / 2 @animation = Animated_Sprite.new(bitmap, cx, cy, hf, vf, tf, blend) loop do if @animation.ready? @animation.frame += 1 end @animation.update @black_sprite.update Graphics.update if @animation.frame == @animation.frames break end end @animation.dispose endend#==============================================================================# ** Scene_EditBoard#------------------------------------------------------------------------------# This class performs board edit screen processing.#==============================================================================class Scene_EditBoard #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Object Initialization # index : index #-------------------------------------------------------------------------- def initialize(index=0) @index = index item_list end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main $data_boards = get_boards @left_window = Window_EditBoardLeft.new @right_window = Window_EditBoardRight.new @key_window = Window_EditBoardKey.new @left_window.index = @index @right_window.board = @left_window.board @right_window.refresh Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @left_window.dispose @right_window.dispose @key_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @right_window.board = @left_window.board @right_window.refresh @left_window.update @right_window.update if @left_window.active update_left return end end #-------------------------------------------------------------------------- # * Frame Update (when left window is active) #-------------------------------------------------------------------------- def update_left if Input.trigger?(Input::A) $game_system.se_play($data_system.decision_se) index = @left_window.index? delete_board(index) shutdown return end if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) shutdown return end if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) board = @right_window.board index = @left_window.index? if board != nil $scene = Scene_CreateBoard.new(board) else xsize, ysize = NEW_BOARD_XSIZE, NEW_BOARD_YSIZE new_board(xsize, ysize) shutdown end return end end #-------------------------------------------------------------------------- # * Shutdown #-------------------------------------------------------------------------- def shutdown Audio.bgm_fade(800) Audio.bgs_fade(800) Audio.me_fade(800) $scene = nil endend#==============================================================================# ** Scene_CreateBoard#------------------------------------------------------------------------------#  This class performs board create screen processing.#==============================================================================class Scene_CreateBoard #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Object Initialization # board : board #-------------------------------------------------------------------------- def initialize(board) @board = board end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main $data_boards = get_boards @spriteset = Spriteset_Board.new(@board, true) x, y = 0, 0 @cursor = Cursor_Board.new(@board, x, y) @cursor.px, @cursor.py = BOARD_MARGIN, BOARD_MARGIN update_cursor @shadow_sprite = RPG::Sprite.new @shadow_sprite.bitmap = SHADOW.dup @help_sprite = Sprite_LicenseDescription.new(@cursor, @board, true) update_help @commands = ["Health Points", "Magic Points", "Strength", "Power Defense", "Intelligence", "Magic Defense", "Agility", "Dexterity", "Skill", "Weapon", "Armor", "Empty"] @command_window = Window_Command.new(192, @commands) @command_window.back_opacity = 160 @command_window.x = 160 - @command_window.width / 2 @command_window.y = 240 - @command_window.height / 2 @command_window.index = -1 @command_window.active = false @command_window.visible = false width = 640 - @command_window.width - @command_window.x * 2 @input_window = [] for i in 0..5 if i == 5 @input_window.push( Window_InputNumber.new(3, "Set level", width)) elsif i == 4 @input_window.push( Window_InputNumber.new(3, "Set AP cost", width)) else @input_window.push( Window_InputNumber.new(3, "Set value #{i+1}", width)) end @input_window[i].back_opacity = 160 @input_window[i].x = 160 + @command_window.width / 2 @input_window[i].y = @command_window.y + @input_window[i].height * i @input_window[i].active = false @input_window[i].visible = false end @confirm_window = Window_Command.new( 192, ["Save changes", "Discard changes"]) @confirm_window.back_opacity = 160 @confirm_window.x = 320 - @confirm_window.width / 2 @confirm_window.y = 240 - @confirm_window.height / 2 @confirm_window.index = -1 @confirm_window.active = false @confirm_window.visible = false Graphics.transition loop do Graphics.update Input.update update if $scene != self break end end Graphics.freeze @spriteset.dispose @cursor.dispose @shadow_sprite.dispose @help_sprite.dispose @command_window.dispose for i in 0..5 @input_window[i].dispose end @confirm_window.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update @spriteset.update @cursor.update @help_sprite.update if @command_window.active loop do Graphics.update Input.update @command_window.update update_command if !@command_window.active break end end return end for i in 0..5 if @input_window[i].active loop do Graphics.update Input.update @input_window[i].update update_input(i) if !@input_window[i].active break end end return end end if @confirm_window.active loop do Graphics.update Input.update @confirm_window.update update_confirm if !@confirm_window.active break end end return end if Input.repeat?(Input.dir8) $game_system.se_play($data_system.cursor_se) update_cursor update_help end if Input.trigger?(Input::A) $game_system.se_play($data_system.decision_se) x, y = @cursor.tile_x, @cursor.tile_y visible = @board.visible?(x, y) == true ? false : true @board.visible(x, y, visible) @help_sprite.refresh @help_sprite.update return end if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @confirm_window.index = 0 @confirm_window.active = true @confirm_window.visible = true return end if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @command_window.index = 0 @command_window.active = true @command_window.visible = true return end end #-------------------------------------------------------------------------- # * Help Update #-------------------------------------------------------------------------- def update_help x, y = @cursor.tile_x, @cursor.tile_y if @board.valid?(x, y) @help_sprite.true_y = 360 @help_sprite.true_opacity = 255 else @help_sprite.true_y = 370 @help_sprite.true_opacity = 0 end end #-------------------------------------------------------------------------- # * Cursor Update #-------------------------------------------------------------------------- def update_cursor xs, ys = TILE_X_SIZE, TILE_Y_SIZE max_x = 640 / xs - 1 max_y = 480 / ys - 1 margin = BOARD_MARGIN case Input.dir8 when 2 # Down @cursor.tile_y += 1 if @cursor.py < max_y - margin @cursor.py += 1 elsif @cursor.tile_y >= @board.ysize @cursor.py = margin end when 4 # Left @cursor.tile_x -= 1 if @cursor.px > margin @cursor.px -= 1 elsif @cursor.tile_x < 0 @cursor.px = max_x - margin end when 6 # Right @cursor.tile_x += 1 if @cursor.px < max_x - margin @cursor.px += 1 elsif @cursor.tile_x >= @board.xsize @cursor.px = margin end when 8 # Up @cursor.tile_y -= 1 if @cursor.py > margin @cursor.py -= 1 elsif @cursor.tile_y < 0 @cursor.py = max_y - margin end end @cursor.tile_x %= @board.xsize @cursor.tile_y %= @board.ysize cx = (@cursor.px - @cursor.tile_x) * xs cy = (@cursor.py - @cursor.tile_y) * ys @spriteset.tiles.true_x = cx @spriteset.tiles.true_y = cy @spriteset.icons.true_x = cx @spriteset.icons.true_y = cy @spriteset.active.true_x = cx @spriteset.active.true_y = cy @cursor.true_x = (@cursor.px * xs) - 20 @cursor.true_y = (@cursor.py * ys) - 4 end #-------------------------------------------------------------------------- # * Command Window Update #-------------------------------------------------------------------------- def update_command if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @command_window.index = -1 @command_window.active = false @command_window.visible = false @command_window.update @help_sprite.refresh update_help return end if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) length = @commands.length - 1 if @command_window.index == length @command_window.index = -1 @command_window.active = false @command_window.visible = false @command_window.update x, y = @cursor.tile_x, @cursor.tile_y @board.reset_tile(x, y) @spriteset.refresh @help_sprite.refresh update_help else @command_window.active = false @command_window.update @input_window[0].number = 0 @input_window[0].active = true @input_window[0].visible = true @input_window[0].update end return end end #-------------------------------------------------------------------------- # * Input Window Update #-------------------------------------------------------------------------- def update_input(i) if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) if i == 0 @command_window.active = true @command_window.update else @input_window[i - 1].active = true @input_window[i - 1].visible = true @input_window[i - 1].update end @input_window[i].active = false @input_window[i].visible = false @input_window[i].update return end if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @input_window[i].active = false @input_window[i].update if i == 5 @command_window.visible = false for i in 0..5 @input_window[i].visible = false end x, y = @cursor.tile_x, @cursor.tile_y input = [@input_window[4].number, @command_window.index, @input_window[0].number, @input_window[1].number, @input_window[2].number, @input_window[3].number, @input_window[5].number == 0 ? -1 : @input_window[5].number] @board.set_tile(x, y, input) @spriteset.refresh @help_sprite.refresh update_help else @input_window[i + 1].number = 0 @input_window[i + 1].active = true @input_window[i + 1].visible = true @input_window[i + 1].update end return end end #-------------------------------------------------------------------------- # * Confirm Window Update #-------------------------------------------------------------------------- def update_confirm if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @confirm_window.index = -1 @confirm_window.active = false @confirm_window.visible = false @confirm_window.update return end if Input.trigger?(Input::C) if @confirm_window.index == 0 $game_system.se_play($data_system.decision_se) boards = get_boards boards[@board.id] = @board.board save_boards(boards) end @confirm_window.index = -1 @confirm_window.active = false @confirm_window.visible = false @confirm_window.update $scene = Scene_EditBoard.new(@board.id) return end endend#==============================================================================# ** Board#------------------------------------------------------------------------------# This class defines a board and all of its settings. Board data is found in# the Data folder under the name Board.rxdata. Refer to the MedinaStories# module to learn how to make a Board.rxdata file.#------------------------------------------------------------------------------# «Introduction»## Boards are stored in Table[] BOARDS.## BOARDS = Table[bOARD_0, BOARD_1, BOARD_2, ...]## Each board is a Table with three dimensions (x, y, z), BOARD_n, where n is# an integer equal to or greater than 0.## BOARD_n = Table.new(x, y, z)## Dimensions x and y measure, respectively, the Table's width and height.# Dimension z manages attributes such as ACTIVATED, VISIBLE, AP COST, TYPE,# VALUE and LEVEL. This data is stored as integers.## If BOARD_n[x, y, 0] = v, this means the space occupied by the coordinate# (x, y) when z is equal to 0 is equal to v. If v is equal to 0, then tile# (x, y) is false or NOT ACTIVATED. If v is equal to 1, then tile (x, y) is# true or ACTIVATED.## The following figure outlines the board data structure:# x : 24 (default)# y : 24 (default)# z :# 0 : ACTIVATED# 0 : false# 1 : true# 1 : VISIBLE# 0 : false# 1 : true# 2 : AP COST# 3 : TYPE# -1 : nothing# 0 : hp# 1 : mp# 2 : str# 3 : pdef# 4 : int# 5 : mdef# 6 : agi# 7 : dex# 8 : skill# 9 : weapon# 10 : armor# 4, 5, 6, 7 : VALUE# statistic boost# skill id# weapon id# armor id# 8 : LEVEL## By default, all slots are NOT ACTIVATED, NOT VISIBLE, AP COST 0, TYPE -1,# VALUE 0 and LEVEL -1.#------------------------------------------------------------------------------# «Creating an Empty Board»## The following code excerpt creates an empty board:## BOARD_n = Table.new(24, 24, 9)# for x in 0...BOARD_n.xsize# for y in 0...BOARD_n.ysize# for z in 0...BOARD_n.zsize# case z# when 0 # ACTIVATED# BOARD_n[x, y, z] = 0# when 1 # VISIBLE# BOARD_n[x, y, z] = 0# when 2 # AP COST# BOARD_n[x, y, z] = 0# when 3 # TYPE# BOARD_n[x, y, z] = -1# when 4 # OBJECT 1 VALUE# BOARD_n[x, y, z] = 0# when 5 # OBJECT 2 VALUE# BOARD_n[x, y, z] = 0# when 6 # OBJECT 3 VALUE# BOARD_n[x, y, z] = 0# when 7 # OBJECT 4 VALUE# BOARD_n[x, y, z] = 0# when 8 # LEVEL# BOARD_n[x, y, z] = -1# end# end# end# end#------------------------------------------------------------------------------# «Editing a Board»## Once created, boards can be edited manually. Simply type in a coordinate# (x, y), an attribute number and a value. Always start with OBJECT 1 VALUE,# since this value is necessary to compute board data. You might have up to# four different values in a single coordinate (x, y). Hence, if you're TYPE# is a skill, by activating tile (x, y) you can learn up to four skills.## The following code excerpt creates a coordinate (x, y) with four skills:## # Define ACTIVATED# BOARD_n[x, y, 0] = 0# # Define VISIBLE# BOARD_n[x, y, 1] = 0# # Define AP COST# BOARD_n[x, y, 2] = 40# # Define TYPE# BOARD_n[x, y, 3] = 8# # Define OBJECT 1 VALUE# BOARD_n[x, y, 4] = 1# # Define OBJECT 2 VALUE# BOARD_n[x, y, 5] = 2# # Define OBJECT 3 VALUE# BOARD_n[x, y, 6] = 3# # Define OBJECT 4 VALUE# BOARD_n[x, y, 7] = 4# # Define LEVEL# BOARD_n[x, y, 8] = 9#------------------------------------------------------------------------------# «Conclusions»## Tile (x, y) is NOT ACTIVATED and NOT VISIBLE. To activate tile (x, y), you# need to spend 40 ability points. Tile (x, y) TYPE is a skill with values# 1, 2, 3 and 4. By activating this tile you will learn skills 1, 2, 3 and 4.## _____ The attribute AP COST appears in the lower left corner of the# | 9| tile. The attribute LEVEL appears in the upper right corner of# | | the tile. If LEVEL is equal to -1, then no level will be shown# |40___| and OBJECT 1 will be used as the tile's class name.## Boards graphic files and text can be edited in the MedinaStories module.##==============================================================================class Board #-------------------------------------------------------------------------- # * Invariables #-------------------------------------------------------------------------- include MedinaStories # Medina Stories module #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_reader :id # board ID attr_reader :board # board table attr_reader :xsize # board width attr_reader :ysize # board height attr_accessor :hp # health points attr_accessor :sp # special points attr_accessor :str # strength attr_accessor :pdef # physical defense attr_accessor :int # intelligence attr_accessor :mdef # magic defense attr_accessor :agi # agility attr_accessor :dex # dexterity attr_accessor :skills # skills attr_accessor :weapon_set # weapon set attr_accessor :armor_set # armor set #-------------------------------------------------------------------------- # * Object Initialization # board_id : board ID #-------------------------------------------------------------------------- def initialize(board_id) @id = board_id @board = $data_boards[@id].dup @xsize = @board.xsize @ysize = @board.ysize reset end #-------------------------------------------------------------------------- # * Reset Board #-------------------------------------------------------------------------- def reset @hp = 0 @sp = 0 @str = 0 @pdef = 0 @int = 0 @mdef = 0 @agi = 0 @dex = 0 @skills = [] @weapon_set = [] @armor_set = [] end #-------------------------------------------------------------------------- # * Reset Tile # x : board x-coordinate # y : board y-coordinate #-------------------------------------------------------------------------- def reset_tile(x, y) activated(x, y, false) visible(x, y, false) ap_cost(x, y, 0) type(x, y, -1) for i in 0..3 value(x, y, 0, i) end level(x, y, -1) end #-------------------------------------------------------------------------- # * Initial Position # ap : license points #-------------------------------------------------------------------------- def init_pos(ap=0) ox, oy = 0, 0 for x in 0...@board.xsize for y in 0...@board.ysize if visible?(x, y) and not activated?(x, y) and ap_cost?(x, y) <= ap ox, oy = x, y break end end break if ox > 0 or oy > 0 end return ox, oy end #-------------------------------------------------------------------------- # * Determine if Valid # x : board x-coordinate # y : board y-coordinate #-------------------------------------------------------------------------- def valid?(x, y) return @board[x, y, 3] >= 0 rescue false end #-------------------------------------------------------------------------- # * Activate Slot # x : board x-coordinate # y : board y-coordinate # boolean : false / true #-------------------------------------------------------------------------- def activate(x, y, boolean) @board[x, y, 0] = [false, true].index(boolean) for obj in 0..3 n = value?(x, y, obj) case type?(x, y) when 0 # HP @hp += n when 1 # SP @sp += n when 2 # Strength @str += n when 3 # Physical Defense @pdef += n when 4 # Intelligence @int += n when 5 # Magic Defense @mdef += n when 6 # Agility @agi += n when 7 # Dexterity @dex += n when 8 # Skills @skills.push(n) when 9 # Weapon Set @weapon_set.push(n) when 10 # Armor Set @armor_set.push(n) end end if (y - 1) >= 0 if valid?(x, y - 1) # Up visible(x, y - 1, true) end end if (y + 1) < @board.ysize if valid?(x, y + 1) # Down visible(x, y + 1, true) end end if (x - 1) >= 0 if valid?(x - 1, y) # Left visible(x - 1, y, true) end end if (x + 1) < @board.xsize if valid?(x + 1, y) # Right visible(x + 1, y, true) end end end #-------------------------------------------------------------------------- # * Set Activated # x : board x-coordinate # y : board y-coordinate # boolean : false / true #-------------------------------------------------------------------------- def activated(x, y, bool) @board[x, y, 0] = bool == true ? 1 : 0 end #-------------------------------------------------------------------------- # * Set Visible # x : board x-coordinate # y : board y-coordinate # boolean : false / true #-------------------------------------------------------------------------- def visible(x, y, bool) @board[x, y, 1] = bool == true ? 1 : 0 end #-------------------------------------------------------------------------- # * Set AP Cost # x : board x-coordinate # y : board y-coordinate # ap_cost : license points cost #-------------------------------------------------------------------------- def ap_cost(x, y, ap_cost) @board[x, y, 2] = ap_cost end #-------------------------------------------------------------------------- # * Set Type # x : board x-coordinate # y : board y-coordinate # type : type #-------------------------------------------------------------------------- def type(x, y, type) @board[x, y, 3] = type end #-------------------------------------------------------------------------- # * Set Value # x : board x-coordinate # y : board y-coordinate # value : value # obj : object ID #-------------------------------------------------------------------------- def value(x, y, value, obj=0) @board[x, y, 4 + obj] = value end #-------------------------------------------------------------------------- # * Set Level # x : board x-coordinate # y : board y-coordinate # level : level #-------------------------------------------------------------------------- def level(x, y, level) @board[x, y, 8] = level end #-------------------------------------------------------------------------- # * Set Tile # x : board x-coordinate # y : board y-coordinate # input : input #-------------------------------------------------------------------------- def set_tile(x, y, input) if input ap_cost(x, y, input[0]) type(x, y, input[1]) for i in 0..3 value(x, y, input[2 + i], i) end level(x, y, input[6]) end end #-------------------------------------------------------------------------- # * Get Activated # x : board x-coordinate # y : board y-coordinate #-------------------------------------------------------------------------- def activated?(x, y) return [false, true][@board[x, y, 0]] end #-------------------------------------------------------------------------- # * Get Visible # x : board x-coordinate # y : board y-coordinate #-------------------------------------------------------------------------- def visible?(x, y) return [false, true][@board[x, y, 1]] end #-------------------------------------------------------------------------- # * Get License Point Cost # x : board x-coordinate # y : board y-coordinate #-------------------------------------------------------------------------- def ap_cost?(x, y) if @board[x, y, 2] return @board[x, y, 2] end return 0 end #-------------------------------------------------------------------------- # * Get Type # x : board x-coordinate # y : board y-coordinate #-------------------------------------------------------------------------- def type?(x, y) if @board[x, y, 3] return @board[x, y, 3] end return -1 end #-------------------------------------------------------------------------- # * Get Value # x : board x-coordinate # y : board y-coordinate # obj : object ID #-------------------------------------------------------------------------- def value?(x, y, obj=0) if @board[x, y, 4 + obj] return @board[x, y, 4 + obj] end return 0 end #-------------------------------------------------------------------------- # * Get Level # x : board x-coordinate # y : board y-coordinate #-------------------------------------------------------------------------- def level?(x, y) if @board[x, y, 8] return @board[x, y, 8] end return -1 end #-------------------------------------------------------------------------- # * Get Skills #-------------------------------------------------------------------------- def skills? skills = [] for x in 0...@board.xsize for y in 0...@board.ysize type = type?(x, y) if type == 8 for i in 0..3 value = value?(x, y, i) if value > 0 skills.push(value) end end end end end return skills.sort! end #-------------------------------------------------------------------------- # * Get Board Name #-------------------------------------------------------------------------- def name return BOARD_NAME(@id) end #-------------------------------------------------------------------------- # * Get Board Statistics #-------------------------------------------------------------------------- def statistics stats = [] for x in 0...@board.xsize for y in 0...@board.ysize type = type?(x, y) if type >= 0 and type < 8 value = value?(x, y) stats[type] += value rescue stats[type] = value elsif type >= 8 for i in 0..3 value = value?(x, y, i) if value > 0 stats[type] += 1 rescue stats[type] = 1 end end end end end return stats end #-------------------------------------------------------------------------- # * Get Item # x : board x-coordinate # y : board y-coordinate # obj : object ID #-------------------------------------------------------------------------- def item(x, y, obj=0) type = type?(x, y) value = value?(x, y, obj) return BOARD_ITEM(type, value) end #-------------------------------------------------------------------------- # * Get Description # x : board x-coordinate # y : board y-coordinate # obj : object ID #-------------------------------------------------------------------------- def description(x, y, obj=0) type = type?(x, y) value = value?(x, y, obj) return BOARD_DESCRIPTION(type, value) end #-------------------------------------------------------------------------- # * Get Class # x : board x-coordinate # y : board y-coordinate #-------------------------------------------------------------------------- def class(x, y) type = type?(x, y) value = value?(x, y) level = level?(x, y) return BOARD_CLASS(type, value, level) end #-------------------------------------------------------------------------- # * Get Tiles #-------------------------------------------------------------------------- def tiles tiles = 0 for x in 0...@board.xsize for y in 0...@board.ysize tiles += 1 if valid?(x, y) end end return tiles endend#==============================================================================# ** Cursor_Board#------------------------------------------------------------------------------# This sprite is used to display the cursor. It observes the Scene_Board# class and automatically changes sprite conditions.#==============================================================================class Cursor_Board < Sprite_Cursor #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :tile_x # tile x-coordinate attr_accessor :tile_y # tile y-coordinate attr_accessor :px # cursor pan x-coordinate attr_accessor :py # cursor pan y-coordinate #-------------------------------------------------------------------------- # * Object Initialization # board : board # x : cursor x-coordinate # y : cursor y-coordinate # viewport : viewport #-------------------------------------------------------------------------- def initialize(board, x=0, y=0, viewport=nil) super(viewport) @board = board @tile_x, @tile_y = x, y @px, @py = 0, 0 endend
       
      and
       

      =beginXMB (Xross Media Bar or PSP/PS3) Style Menu System Script Version 1.0written by: kellessdeecontact:wakingdreams.weebly.com[url="http://www.rmxpunlimited.net/forums/"]http://www.rmxpunlimited.net/forums/[/url]kellessdee@gmail.comDISCLAIMER: Anyone is free to use this anyway they would like, I only ask forcredit where due. Enjoy :)==============================================================================***** INSTRUCTIONS ************************************************************ Put Script above Main* The background files belong in Graphics/Pictures/back* The menu icon files belong in Graphics/Pictures/menu* Players can add/remove background files if they'd like throughout the game* NOTE: Remind them not to remove "default" background* To set a different default background, go to the beginning of* class Settings, and change DEFAULT_BACKGROUND = 'Blue Waves' to* DEFAULT_BACKGROUND = 'filename'* filename being the name of the background you wish to set as default* Any issues/bug reports you can send to any of the contacts I have provided*********************************************************************************** SCRIPTER NOTES: ********************************************************* If you are a scripter, I have created new methods to certain pre-existing* classes. You can take advantage of these if you'd like :)* BITMAP CLASS* added:>>draw_frame(x, y, width, height)* draws a rectangular outline>>draw_gradient_bar(x, y, width, height, min, max, start_color, end_color)* draws a gradient bar (for hp/sp/etc.)>>draw_gradient(x, y, width, height, start_color, end_color)* draws a simple gradient in a bitmap>>draw_actor_...(...)* added the methods from Window_Base used to draw actor info (such as graphic,* hp, sp, etc.) They are used the same way as in Window_Base******************************************************************************===============================================================================end#=============================================================================# ** Settings#-----------------------------------------------------------------------------# This class contains Settings data for the XMB menu#=============================================================================class Settings #--------------------------------------------------------------------------- # * Constants #--------------------------------------------------------------------------- DEFAULT_BACKGROUND = 'Blue Waves' #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_accessor :music_volume attr_accessor :sound_volume attr_accessor :bg attr_accessor :themes attr_accessor :item_sort_type attr_accessor :item_sort_reverse #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize @music_volume = 100 @sound_volume = 100 @bg = DEFAULT_BACKGROUND @themes = [] @item_sort_type = 2 @item_sort_reverse = false # Update theme options update_themes end # initialize #--------------------------------------------------------------------------- # * Update Themes #--------------------------------------------------------------------------- def update_themes # Add themes from Graphics/Pictures/back/ # Players can add their own themes at any point # every time a file is loaded or new game created, this array is updated @themes.clear Dir.foreach('Graphics/Pictures/back/') {|back| if back != '.' && back != '..' @themes.push(back.chomp(File.extname(back))) end # if back } end # update_themesend # settings#=============================================================================# ** XMB Menu#-----------------------------------------------------------------------------# This class holds the main menu data for the XMB (psp) style menu, and also# holds the corresponding instance of it's sub menu#=============================================================================class XMB_Menu #--------------------------------------------------------------------------- # * Constants #--------------------------------------------------------------------------- BMP_RECT = Rect.new(0, 0, 128, 128) # Src_rect for icon bitmap #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_accessor :sub_index # Currently selected sub menu option attr_reader :selected # Whether this menu is currently selected attr_reader :options # Menu Sub options attr_accessor :step # Movement step counter attr_accessor :move_left # Moving left flag attr_accessor :move_right # Moving right flag #--------------------------------------------------------------------------- # * Object Initialization # name : actual name of specific main menu option # options : sub-menu options array # index : index in main menu option array #--------------------------------------------------------------------------- def initialize(name, options, index) @name = name # Create Icon @icon = RPG::Sprite.new @icon.x = 128 * index + 114 @icon.y = 64 @icon.z = 9999 @icon.bitmap = Bitmap.new(136, 136) # Store image @image = RPG::Cache.picture('menu/' + @name) @image_s = RPG::Cache.picture('menu/' + @name + '_s') # Create Sub Menu @options = [] options.each_index {|i| @options.push(XMB_Sub_Menu.new(options[i], i, @icon.x)) } # Default to not selected @selected = index == 0 @sub_index = 0 # Not moving @move_left = false @move_right = false @move_up = false @move_down = false # Movement step counter @step = 0 # Set up bitmap refresh end # initialize #--------------------------------------------------------------------------- # * Refresh Object #--------------------------------------------------------------------------- def refresh # Clear Bitmap @icon.bitmap.clear # If this entry is currently selected if @selected # Draw Shadow @icon.bitmap.blt(2, 2, @image_s, BMP_RECT, 100) @icon.bitmap.blt(4, 4, @image_s, BMP_RECT, 50) @icon.bitmap.blt(6, 6, @image_s, BMP_RECT, 25) # Draw Icon @icon.bitmap.blt(0, 0, @image, BMP_RECT) # Draw Title @icon.bitmap.draw_text(0, 104, 128, 32, @name, 1) else # Draw Shadow @icon.bitmap.blt(2, 2, @image_s, BMP_RECT, 75) @icon.bitmap.blt(4, 4, @image_s, BMP_RECT, 35) @icon.bitmap.blt(6, 6, @image_s, BMP_RECT, 10) # Draw Icon with lower opacity @icon.bitmap.blt(0, 0, @image, BMP_RECT, 125) @options.each {|option| option.opacity = 0 } end # if @selected end # refresh #--------------------------------------------------------------------------- # * Opacity #--------------------------------------------------------------------------- def opacity=(opacity) @icon.opacity = opacity end # opacity #--------------------------------------------------------------------------- # * Moving? #--------------------------------------------------------------------------- def moving? return @move_up || @move_down || @move_right || @move_left end # moving? #--------------------------------------------------------------------------- # * Update Frame #--------------------------------------------------------------------------- def update # Update sub options if selected @options.each{|option| option.refresh} if @selected && moving? if @move_up # If at last option if @sub_index > @options.size # Stop moving @move_up = false @sub_index = @options.size return else # Move up slide_up return end # if @sub_index elsif @move_down # If at first option if @sub_index < 0 # Stop moving @move_down = false @sub_index = 0 else # Move down slide_down end # if @sub_index elsif @move_right slide_right return elsif @move_left slide_left return else unless moving? if @selected # If Up button is pressed if Input.repeat?(Input::UP) && @sub_index > 0 @step = 128 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Switch Sub index @move_down = true # Increment index @options[@sub_index].deselect @sub_index -= 1 @options[@sub_index].select return end # if Input # If Down button is pressed if Input.repeat?(Input::DOWN) && @sub_index < (@options.size - 1) @step = 128 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Switch Sub index @move_up = true # Decrement index @options[@sub_index].deselect @sub_index += 1 @options[@sub_index].select return end # if Input end # if @selected end # unless moving? end # if @move_up elsif.. end # update #--------------------------------------------------------------------------- # * Slide Up #--------------------------------------------------------------------------- def slide_up # Move all options up @options.each {|option| # If previously selected option if option == @options[@sub_index-1] option.move(-64) else option.move(-32) end # if option } # Decrement counter @step -= 32 if @step == 0 # Stop moving @move_up = false end # if @step end # slide_up #--------------------------------------------------------------------------- # * Slide Down #--------------------------------------------------------------------------- def slide_down # Move all options down @options.each {|option| # If newly selected option if option == @options[@sub_index] option.move(64) else option.move(32) end # if option } # Decrement counter @step -= 32 if @step == 0 # Stop moving @move_down = false end # if @step end # slide_down #--------------------------------------------------------------------------- # * Slide Left #--------------------------------------------------------------------------- def slide_left # Move Left @icon.x -= 32 # Move Sub menu options @options.each {|option| option.slide(-32)} @step -= 32 if @step == 0 # Stop moving @move_left = false end # if @step end # slide_left #--------------------------------------------------------------------------- # * Slide Right #--------------------------------------------------------------------------- def slide_right # Move Right @icon.x += 32 # Move Sub menu options @options.each {|option| option.slide(32)} @step -= 32 if @step == 0 # Stop moving @move_right = false end # if @step end # slide_right #--------------------------------------------------------------------------- # * Select #--------------------------------------------------------------------------- def select # Display sub options @options.each {|option| option.opacity = 255} @selected = true refresh end # select #--------------------------------------------------------------------------- # * Deselect #--------------------------------------------------------------------------- def deselect # Hide sub options @options.each {|option| option.opacity = 0} @selected = false refresh end # deselect #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @icon.dispose end # disposeend #XMB_Menu#=============================================================================# ** XMB_Sub_Menu#-----------------------------------------------------------------------------# This class is contained within each XMB_Menu class and displays the# current sub menu options#=============================================================================class XMB_Sub_Menu #--------------------------------------------------------------------------- # * Public instance variables #--------------------------------------------------------------------------- attr_reader :name #--------------------------------------------------------------------------- # * Constants #--------------------------------------------------------------------------- BMP_RECT = Rect.new(0, 0, 128, 128) # Src_rect for icon bitmap #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(name, index, x) @name = name # Create icon @icon = RPG::Sprite.new @icon.x = x @icon.y = index * 128 + 200 # Create Bitmap @icon.bitmap = Bitmap.new(320, 128) @image = RPG::Cache.picture('menu/' + @name) @image_s = RPG::Cache.picture('menu/' + @name + '_s') # Set selected @selected = index == 0 refresh end # initialize #--------------------------------------------------------------------------- # * Refresh Contents #--------------------------------------------------------------------------- def refresh # Clear Bitmap @icon.bitmap.clear # If this entry is currently selected if @selected # Draw Shadow @icon.bitmap.blt(2, 2, @image_s, BMP_RECT, 100) @icon.bitmap.blt(4, 4, @image_s, BMP_RECT, 50) @icon.bitmap.blt(6, 6, @image_s, BMP_RECT, 25) # Draw Icon @icon.bitmap.blt(0, 0, @image, BMP_RECT) # Draw Title @icon.bitmap.draw_text(128, 48, 320, 32, @name) unless $scene.phase > 0 else # Draw Shadow @icon.bitmap.blt(2, 2, @image_s, BMP_RECT, 75) @icon.bitmap.blt(4, 4, @image_s, BMP_RECT, 35) @icon.bitmap.blt(6, 6, @image_s, BMP_RECT, 10) # Draw Icon with lower opacity @icon.bitmap.blt(0, 0, @image, BMP_RECT, 125) end # if @selected end # refresh #--------------------------------------------------------------------------- # * Opacity #--------------------------------------------------------------------------- def opacity=(opacity) @icon.opacity = opacity end # opacity #--------------------------------------------------------------------------- # * Move UP/DOWN #--------------------------------------------------------------------------- def move(pixels) @icon.y += pixels end # move #--------------------------------------------------------------------------- # * Slide LEFT/RIGHT #--------------------------------------------------------------------------- def slide(pixels) @icon.x += pixels end # slide #--------------------------------------------------------------------------- # * Select #--------------------------------------------------------------------------- def select @selected = true refresh end # select #--------------------------------------------------------------------------- # * Deselect #--------------------------------------------------------------------------- def deselect @selected = false refresh end # deselect #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @icon.dispose end # disposeend # XMB_Sub_Menu#=============================================================================# ** Sprite_Menu#-----------------------------------------------------------------------------# The super class for all selectable sub menus within the XMB menu script#=============================================================================class Sprite_Menu < Sprite #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_accessor :index attr_reader :info #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super self.x = 146 @item_max = 1 @index = 0 end # initialize #--------------------------------------------------------------------------- # * Update Frame #--------------------------------------------------------------------------- def update if @move_down self.y += 12 @step -= 12 if @step == 0 @move_down = false end # if @step return elsif @move_up self.y -= 12 @step -= 12 if @step == 0 @move_up = false end # if @step return else # If Down button is pressed if Input.repeat?(Input::DOWN) && @index > 0 @step = 48 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Change index @index -= 1 # Shift up @move_up = true end # if Input # If Up button is pressed if Input.repeat?(Input::UP) && @index < (@item_max - 1) @step = 48 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Change index @index += 1 # Shift down @move_down = true end # if Input # if Info window exists if @info != nil update_info end # if @info # Refresh contents, defined in sub classes refresh end # if @move_down elsif.. end # update #--------------------------------------------------------------------------- # * Deselected Color #--------------------------------------------------------------------------- def deselected_color return Color.new(255, 255, 255, 125) end # deselected_color #--------------------------------------------------------------------------- # * Selected Color #--------------------------------------------------------------------------- def selected_color return Color.new(255, 255, 255, 255) end # Selected_color #--------------------------------------------------------------------------- # * Set Info Window #--------------------------------------------------------------------------- def info=(info_window) # Set info window @info = info_window if @info != nil # update info update_info end # if @info end # infoend # Sprite_menu#=============================================================================# ** Sprite_Selection#-----------------------------------------------------------------------------# This class is the parent class for any highlighted selection menus#=============================================================================class Sprite_Selection #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_accessor :index attr_accessor :active #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize @bg = Sprite.new @bg.bitmap = Bitmap.new(640, 480) @bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 255)) @bg.opacity = 180 @data = [] @index = 0 @item_max = 1 @active = true end #--------------------------------------------------------------------------- # * Update Frame #--------------------------------------------------------------------------- def update # Update Flash if @index > -1 @data.each_index {|i| @data[i].opacity = 255 if @data[i].opacity < 255 && i != @index } if @data[@index].opacity <= 100 @step = 10 elsif @data[@index].opacity >= 255 @step = -10 end @data[@index].opacity += @step else @data.each {|sprite| if sprite.opacity <= 100 @step = 10 elsif sprite.opacity >= 255 @step = -10 end sprite.opacity += @step } end # If Up is pressed if Input.repeat?(Input::UP) && @index >= 0 && @active # Play Cursor SE $game_system.se_play($data_system.cursor_se) # change index @index = (@index - @item_max - 1) % @item_max end # If Down is pressed if Input.repeat?(Input::DOWN) && @index >= 0 && @active # Play Cusor SE $game_system.se_play($data_system.cursor_se) # Change index @index = (@index + 1) % @item_max end end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @bg.dispose @data.each {|sprite| sprite.dispose} endend # Sprite_Selection#=============================================================================# ** Sprite_Confirmation#-----------------------------------------------------------------------------# Class that displays Yes/No Confirmation Selection#=============================================================================class Sprite_Confirmation < Sprite_Selection #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(confirmation_text) super() @text = Sprite.new @text.bitmap = Bitmap.new(640, 48) @text.bitmap.draw_text(0, 0, 640, 48, confirmation_text, 1) @item_max = 2 words = ['Yes', 'No'] 2.times {|i| @data.push(RPG::Sprite.new) @data[i].bitmap = Bitmap.new(640, 48) @data[i].bitmap.draw_text(0, 0, 640, 48, words[i], 1) } @text.y = 168 @data[0].y = 216 @data[1].y = 264 end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @text.dispose super endend # Sprite_Confirmation#=============================================================================# ** Sprite_Actor_Info#-----------------------------------------------------------------------------# Displays Actor Info for item/skill usage#=============================================================================class Sprite_Actor_Info < RPG::Sprite #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(x, y, actor) super() self.x = x self.y = y self.bitmap = Bitmap.new(480, 64) @actor = actor refresh end #--------------------------------------------------------------------------- # * Refresh Contents #--------------------------------------------------------------------------- def refresh self.bitmap.clear self.bitmap.draw_actor_graphic(@actor, 0, 8) self.bitmap.draw_text(48, 0, 100, 32, @actor.name) self.bitmap.draw_actor_hp(@actor, 48, 32) self.bitmap.draw_actor_state(@actor, 212, 0) self.bitmap.draw_actor_sp(@actor, 212, 32) endend # Sprite_Actor_Info#=============================================================================# ** Sprite_Actor_Preview#-----------------------------------------------------------------------------# Displays Actor Status Preview#=============================================================================class Sprite_Actor_Preview < RPG::Sprite #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(actor) super() self.x = 32 self.y = 368 self.bitmap = Bitmap.new(480, 64) @actor = actor refresh end #--------------------------------------------------------------------------- # * Refresh Contents #--------------------------------------------------------------------------- def refresh self.bitmap.clear self.bitmap.draw_actor_graphic(@actor, 0, 8) self.bitmap.draw_text(48, 0, 100, 32, @actor.name) self.bitmap.draw_actor_hp(@actor, 48, 32) self.bitmap.draw_actor_sp(@actor, 212, 32) endend # Sprite_Actor_Info#=============================================================================# ** Sprite_Items#-----------------------------------------------------------------------------# This class draws the current items held available for use#=============================================================================class Sprite_Items < Sprite_Menu #--------------------------------------------------------------------------- # * Constants #--------------------------------------------------------------------------- ALPHANUMERIC = 0 QUANTITY = 1 STANDARD = 2 #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super redraw end # initialize #--------------------------------------------------------------------------- # * Redraw #--------------------------------------------------------------------------- def redraw if self.bitmap != nil self.bitmap.clear self.bitmap = nil end @data = [] # Add carried items to data array (1...$data_items.size).each {|i| non_key = ($data_items[i].scope != 0 || $data_items[i].occasion != 3) if $game_party.item_number(i) > 0 && non_key @data.push($data_items[i]) end } @item_max = @data.size if @item_max > 0 # Sort Items case $settings.item_sort_type when ALPHANUMERIC sort_alpha when QUANTITY sort_quantity when STANDARD @data.reverse! if $settings.item_sort_reverse end height = 48 * @item_max self.bitmap = Bitmap.new(320, height) self.y = 280 - height if self.index > 0 self.y += self.index * 48 end (0...@item_max).each {|i| draw_item(i) } else self.bitmap = Bitmap.new(320, 32) self.y = 248 draw_item(nil) end end # redraw #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh # Used for refreshing menu, to avoid resorting data array # Use redraw when item is used to clear empty item slots self.bitmap.clear if @item_max > 0 (0...@item_max).each {|i| draw_item(i) } else draw_item(nil) end end # refresh #--------------------------------------------------------------------------- # * Sort by alphanumeric #--------------------------------------------------------------------------- def sort_alpha begin swapped = false (1...@data.size).each {|i| if $settings.item_sort_reverse if @data[i-1].name[0] < @data[i].name[0] @data[i-1], @data[i] = @data[i], @data[i-1] swapped = true end else if @data[i-1].name[0] > @data[i].name[0] @data[i-1], @data[i] = @data[i], @data[i-1] swapped = true end end } end while swapped end #--------------------------------------------------------------------------- # * Sort by quantity #--------------------------------------------------------------------------- def sort_quantity begin swapped = false (1...@data.size).each {|i| if $settings.item_sort_reverse if $game_party.item_number(@data[i-1].id) > $game_party.item_number(@data[i].id) @data[i-1], @data[i] = @data[i], @data[i-1] swapped = true end else if $game_party.item_number(@data[i-1].id) < $game_party.item_number(@data[i].id) @data[i-1], @data[i] = @data[i], @data[i-1] swapped = true end end } end while swapped end #--------------------------------------------------------------------------- # * Draw Item #--------------------------------------------------------------------------- def draw_item(index) if index == nil self.bitmap.font.color = selected_color self.bitmap.draw_text(4, 0, 212, 32, '(Empty)') else item = @data[index] icon = RPG::Cache.icon(item.icon_name) number = $game_party.item_number(item.id) x = 4 y = self.bitmap.height - (48 * index) - 32 if index == self.index self.bitmap.font.color = selected_color opacity = 255 else self.bitmap.font.color = deselected_color opacity = 100 end self.bitmap.blt(x, y + 4, icon, Rect.new(0, 0, 24, 24), opacity) self.bitmap.draw_text(x + 28, y, 212, 32, item.name, 0) self.bitmap.draw_text(x + 240, y, 16, 32, 'x', 1) self.bitmap.draw_text(x + 256, y, 24, 32, number.to_s, 2) end end # draw_item #--------------------------------------------------------------------------- # * Selected Item #--------------------------------------------------------------------------- def item return @data[self.index] end # item #--------------------------------------------------------------------------- # * Update Info #--------------------------------------------------------------------------- def update_info self.info.set_text(self.item == nil ? '' : self.item.description) end # update_infoend # Sprite_Items#=============================================================================# ** Sprite_Sort#-----------------------------------------------------------------------------# This class allows the player to determine how to sort Items in inventory#=============================================================================class Sprite_Sort < Sprite_Menu #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super self.bitmap = Bitmap.new(320, 144) self.y = 136 @item_max = 3 @data = ['Alphanumeric', 'Quantity', 'Standard'] refresh end #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh self.bitmap.clear @data.each_index {|i| y = 144 - (48 * i) - 32 self.bitmap.font.color = i == self.index ? selected_color : deselected_color self.bitmap.draw_text(4, y, 320, 32, @data[i]) } end #--------------------------------------------------------------------------- # * Update Info #--------------------------------------------------------------------------- def update_info case self.index when 0 # Alphanumeric self.info.set_text('Sort items alphabetically') when 1 # Quantity self.info.set_text('Sory items by amount held') when 2 # Standard self.info.set_text('Sort items by ID number') end endend # Sprite_Sort#=============================================================================# ** Sprite_Sort_Type#-----------------------------------------------------------------------------# This class handles whether sorting method is reversed or not#=============================================================================class Sprite_Sort_Type < Sprite_Selection #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super words = ['Ascending Order', 'Descending Order'] 2.times {|i| @data.push(RPG::Sprite.new) @data[i].bitmap = Bitmap.new(320, 48) @data[i].x = 160 @data[i].y = 48 * i + 192 @data[i].bitmap.draw_text(0, 0, 320, 48, words[i], 1) } @item_max = 2 end # Initializeend # Sprite_Sort_Type#=============================================================================# ** Sprite_Important#-----------------------------------------------------------------------------# This class displays the party's important items#=============================================================================class Sprite_Important < Sprite_Menu #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super draw end # initialize #--------------------------------------------------------------------------- # * Redraw #--------------------------------------------------------------------------- def draw if self.bitmap != nil self.bitmap.clear self.bitmap = nil end @data = [] # Add carried items to data array (1...$data_items.size).each {|i| non_key = ($data_items[i].scope == 0 && $data_items[i].occasion == 3) if $game_party.item_number(i) > 0 && non_key @data.push($data_items[i]) end } @item_max = @data.size if @item_max > 0 height = 48 * @item_max self.bitmap = Bitmap.new(320, height) self.y = 280 - height (0...@item_max).each {|i| draw_item(i)} else self.bitmap = Bitmap.new(320, 32) self.y = 248 draw_item(nil) end end # redraw #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh # Used for refreshing menu self.bitmap.clear if @item_max > 0 (0...@item_max).each {|i| draw_item(i)} else draw_item(nil) end end # refresh #--------------------------------------------------------------------------- # * Draw Item #--------------------------------------------------------------------------- def draw_item(index) if index == nil self.bitmap.font.color = selected_color self.bitmap.draw_text(4, 0, 212, 32, '(Empty)') else item = @data[index] icon = RPG::Cache.icon(item.icon_name) number = $game_party.item_number(item.id) x = 4 y = self.bitmap.height - (48 * index) - 32 if index == self.index self.bitmap.font.color = selected_color opacity = 255 else self.bitmap.font.color = deselected_color opacity = 100 end self.bitmap.blt(x, y + 4, icon, Rect.new(0, 0, 24, 24), opacity) self.bitmap.draw_text(x + 28, y, 212, 32, item.name, 0) self.bitmap.draw_text(x + 240, y, 16, 32, 'x', 1) self.bitmap.draw_text(x + 256, y, 24, 32, number.to_s, 2) end end # draw_item #--------------------------------------------------------------------------- # * Selected Item #--------------------------------------------------------------------------- def item return @data[self.index] end # item #--------------------------------------------------------------------------- # * Update Info #--------------------------------------------------------------------------- def update_info self.info.set_text(self.item == nil ? '' : self.item.description) end # update_infoend # Sprite_Important#=============================================================================# ** Sprite_Skills#-----------------------------------------------------------------------------# This class displays selected party member's skills#=============================================================================class Sprite_Skills < Sprite_Menu #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(actor) super() @actor = actor draw end #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def draw if self.bitmap != nil self.bitmap.clear self.bitmap = nil end @data = [] @actor.skills.each_index {|i| skill = $data_skills[@actor.skills[i]] if skill != nil @data.push(skill) end } @item_max = @data.size if @item_max > 0 height = 48 * @item_max self.bitmap = Bitmap.new(320, height) self.y = 280 - height @data.each_index {|i| draw_skill(i)} end end #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh self.bitmap.clear @data.each_index {|i| draw_skill(i)} end #--------------------------------------------------------------------------- # * Draw Skill #--------------------------------------------------------------------------- def draw_skill(index) skill = @data[index] icon = RPG::Cache.icon(skill.icon_name) x = 4 y = self.bitmap.height - (index * 48) - 32 if index == self.index self.bitmap.font.color = selected_color opacity = 255 else self.bitmap.font.color = deselected_color opacity = 100 end self.bitmap.blt(x, y + 4, icon, Rect.new(0, 0, 24, 24), opacity) self.bitmap.draw_text(x + 28, y, 212, 32, skill.name, 0) self.bitmap.draw_text(x + 240, y, 36, 32, skill.sp_cost.to_s, 2) self.bitmap.draw_text(x + 276, y, 36, 32, 'Sp', 2) end #--------------------------------------------------------------------------- # * Update Info #--------------------------------------------------------------------------- def update_info self.info.set_text(self.skill == nil ? '' : self.skill.description) end #--------------------------------------------------------------------------- # * Skill #--------------------------------------------------------------------------- def skill return @data[self.index] endend # Sprite_Skills#=============================================================================# ** Sprite_Equip#-----------------------------------------------------------------------------# The selection menu for equip type#=============================================================================class Sprite_Equip < Sprite_Selection #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(actor) super() @actor = actor @item_max = 5 @items = [] @display = Sprite.new @display.bitmap = Bitmap.new(232, 160) @display.x = 328 @display.y = 272 5.times {|i| @data.push(RPG::Sprite.new) @data[i].bitmap = Bitmap.new(200, 32) @data[i].x = 128 @data[i].y = i * 32 + 272 } @data[0].bitmap.draw_text(0, 0, 200, 32, $data_system.words.weapon) @data[1].bitmap.draw_text(0, 0, 200, 32, $data_system.words.armor1) @data[2].bitmap.draw_text(0, 0, 200, 32, $data_system.words.armor2) @data[3].bitmap.draw_text(0, 0, 200, 32, $data_system.words.armor3) @data[4].bitmap.draw_text(0, 0, 200, 32, $data_system.words.armor4) refresh end #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh @display.bitmap.clear @items[0] = $data_weapons[@actor.weapon_id] @items[1] = $data_armors[@actor.armor1_id] @items[2] = $data_armors[@actor.armor2_id] @items[3] = $data_armors[@actor.armor3_id] @items[4] = $data_armors[@actor.armor4_id] @items.each_index {|i| @display.bitmap.draw_item_name(@items[i], 0, i * 32) } end #--------------------------------------------------------------------------- # * Item #--------------------------------------------------------------------------- def item return @items[@index] end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose super @display.dispose endend#=============================================================================# ** Sprite_Equipment#-----------------------------------------------------------------------------# This class displays selected party member's equipment#=============================================================================class Sprite_Equipment #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_reader :phase #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(actor) @actor = actor @phase = 0 # Create Equip Menu @equipment = Sprite_Equip.new(@actor) # Draw Actor Info @actor_info = Sprite.new @actor_info.bitmap = Bitmap.new(400, 64) @actor_info.x, @actor_info.y = 128, 32 @actor_info.bitmap.draw_text(0, 0, 200, 32, @actor.name) @actor_info.bitmap.draw_text(200, 0, 200, 32, $data_classes[@actor.class_id].name) @actor_info.bitmap.draw_actor_hp(@actor, 0, 32) @actor_info.bitmap.draw_actor_sp(@actor, 200, 32) # Create Parameters sprite @parameters = Sprite.new @parameters.bitmap = Bitmap.new(240, 96) @parameters.x, @parameters.y = 128, 136 refresh end #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh # Draw Actor Parameters @parameters.bitmap.clear 4.times {|i| @parameters.bitmap.draw_actor_parameter(@actor, 0, i * 32, i) } if @new_atk != nil @parameters.bitmap.draw_text(160, 0, 40, 32, '>>', 1) @parameters.bitmap.draw_text(200, 0, 36, 32, @new_atk.to_s, 2) end if @new_pdef != nil @parameters.bitmap.draw_text(160, 32, 40, 32, '>>', 1) @parameters.bitmap.draw_text(200, 32, 36, 32, @new_pdef.to_s, 2) end if @new_mdef != nil @parameters.bitmap.draw_text(160, 64, 40, 32, '>>', 1) @parameters.bitmap.draw_text(200, 64, 36, 32, @new_mdef.to_s, 2) end end #--------------------------------------------------------------------------- # * Update #--------------------------------------------------------------------------- def update # Update Equipment selection @equipment.update update_info unless @phase == 0 update_equip_item return end # If C button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # Open Equip Item menu @equip_item = Sprite_Equip_Item.new(@actor, @equipment.index) @equipment.active = false @phase = 1 return end end #--------------------------------------------------------------------------- # * Update Equip Item #--------------------------------------------------------------------------- def update_equip_item # Update Equip Item Menu @equip_item.update # Get equipped item item1 = @equipment.item # Get currently selected item item2 = @equip_item.item # Change equipment last_hp = @actor.hp last_sp = @actor.sp @actor.equip(@equipment.index, item2 == nil ? 0 : item2.id) # Get parameters for after equipment change new_atk = @actor.atk new_pdef = @actor.pdef new_mdef = @actor.mdef # Return equipment @actor.equip(@equipment.index, item1 == nil ? 0 : item1.id) @actor.hp = last_hp @actor.sp = last_sp # Draw new stats new_parameters(new_atk, new_pdef, new_mdef) # If B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return to equipment selection @equip_item.dispose @equip_item = nil @equipment.active = true new_parameters(nil, nil, nil) @phase = 0 # Update Input to clear key cache Input.update return end # If C button is pressed if Input.trigger?(Input::C) # Play equip SE $game_system.se_play($data_system.equip_se) # Equip Item @actor.equip(@equipment.index, item2 == nil ? 0 : item2.id) # Return @phase = 0 @equip_item.dispose @equip_item = nil @equipment.refresh @equipment.active = true new_parameters(nil, nil, nil) return end end #--------------------------------------------------------------------------- # * New Parameters #--------------------------------------------------------------------------- def new_parameters(new_atk, new_pdef, new_mdef) if @new_atk != new_atk || @new_pdef != new_pdef || @new_mdef != new_mdef @new_atk = new_atk @new_pdef = new_pdef @new_mdef = new_mdef refresh end end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @equipment.dispose @actor_info.dispose @parameters.dispose end #--------------------------------------------------------------------------- # * Info #--------------------------------------------------------------------------- def info=(info) @info = info end #--------------------------------------------------------------------------- # * Update Info #--------------------------------------------------------------------------- def update_info if @equipment.active item = @equipment.item else item = @equip_item.item end @info.set_text(item == nil ? '' : item.description) endend # Sprite_Equipment#=============================================================================# ** Sprite_Equip_Item#-----------------------------------------------------------------------------# This class allows the player to select item to equip#=============================================================================class Sprite_Equip_Item #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_accessor :index #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(actor, type) @actor = actor @type = type @index = 0 # Create Viewport for scrolling @viewport = Viewport.new(354, 256, 272, 192) @viewport.z = 9999 # Create background @back = Sprite.new(@viewport) @back.bitmap = Bitmap.new(240, 192) @back.bitmap.fill_rect(0, 0, 272, 192, Color.new(0, 0, 0, 255)) @back.opacity = 180 @data = [] @items = [] refresh end #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh if @type == 0 j = 0 (1...$data_weapons.size).each {|i| weap_set = $data_classes[@actor.class_id].weapon_set if $game_party.weapon_number(i) > 0 && weap_set.include?(i) @data.push(RPG::Sprite.new(@viewport)) @data[j].bitmap = Bitmap.new(240, 32) @data[j].bitmap.draw_item_name($data_weapons[i], 4, 0) @items.push($data_weapons[i]) j += 1 end } else j = 0 (1...$data_armors.size).each {|i| armor_set = $data_classes[@actor.class_id].armor_set if $game_party.armor_number(i) > 0 && armor_set.include?(i) && $data_armors[i].kind == @type - 1 @data.push(RPG::Sprite.new(@viewport)) @data[j].bitmap = Bitmap.new(240, 32) @data[j].bitmap.draw_item_name($data_armors[i], 4, 0) @items.push($data_armors[i]) j += 1 end } end @data.push(RPG::Sprite.new(@viewport)) @data[@data.size-1].bitmap = Bitmap.new(240, 32) @data[@data.size-1].bitmap.draw_text(4, 0, 200, 32, '(Empty)') @items.push(nil) # Arrange Items @data.each_index {|i| @data[i].y = i * 32 } @item_max = @data.size if @item_max * 32 > 192 draw_arrows end end #--------------------------------------------------------------------------- # * Draw Arrows #--------------------------------------------------------------------------- def draw_arrows @arrows = [] # Draw Up Arrow @arrows[0] = Sprite.new @arrows[0].x, @arrows[0].y, @arrows[0].z = 540, 224, 9999 @arrows[0].bitmap = Bitmap.new(136, 136) image = RPG::Cache.picture('menu/Arrow_up') image_s = RPG::Cache.picture('menu/Arrow_up_s') bmp_rect = Rect.new(0, 0, 128, 128) # Draw Shadow @arrows[0].bitmap.blt(2, 2, image_s, bmp_rect, 100) @arrows[0].bitmap.blt(4, 4, image_s, bmp_rect, 50) @arrows[0].bitmap.blt(6, 6, image_s, bmp_rect, 25) # Draw Icon @arrows[0].bitmap.blt(0, 0, image, bmp_rect) # Draw Down Arrow @arrows[1] = Sprite.new @arrows[1].x, @arrows[1].y, @arrows[1].z = 540, 352, 9999 @arrows[1].bitmap = Bitmap.new(136, 136) image = RPG::Cache.picture('menu/Arrow_down') image_s = RPG::Cache.picture('menu/Arrow_down_s') # Draw Shadow @arrows[1].bitmap.blt(2, 2, image_s, bmp_rect, 100) @arrows[1].bitmap.blt(4, 4, image_s, bmp_rect, 50) @arrows[1].bitmap.blt(6, 6, image_s, bmp_rect, 25) # Draw Icon @arrows[1].bitmap.blt(0, 0, image, bmp_rect) # Set Visibility @arrows[0].visible = @data[0].y < 0 @arrows[1].visible = @data[@item_max - 1].y > 160 end #--------------------------------------------------------------------------- # * Update #--------------------------------------------------------------------------- def update # Update Flash @data.each_index {|i| @data[i].opacity = 255 if @data[i].opacity < 255 && i != @index } if @data[@index].opacity <= 100 @step = 10 elsif @data[@index].opacity >= 255 @step = -10 end @data[@index].opacity += @step # Update Scroll arrows if @arrows != nil @arrows[0].visible = @data[0].y < 0 @arrows[1].visible = @data[@item_max - 1].y > 160 end # If Up Button is pressed if Input.repeat?(Input::UP) && @index > 0 # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Decrease index @index -= 1 # If scroll needed if @data[0].y < 0 scroll_up end return end # If Down Button is pressed if Input.repeat?(Input::DOWN) && @index < @item_max - 1 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Increase index @index += 1 # If scroll needed if @data[@item_max - 1].y > 160 scroll_down end return end end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @viewport.dispose @back.dispose @data.each {|sprite| sprite.dispose} if @arrows != nil @arrows.each {|arrow| arrow.dispose} end end #--------------------------------------------------------------------------- # * Scroll Up #--------------------------------------------------------------------------- def scroll_up @data.each {|sprite| sprite.y += 32} end #--------------------------------------------------------------------------- # * Scroll Down #--------------------------------------------------------------------------- def scroll_down @data.each {|sprite| sprite.y -= 32} end #--------------------------------------------------------------------------- # * Item #--------------------------------------------------------------------------- def item return @items[@index] endend # Sprite_Equip_Item#=============================================================================# ** Sprite_Music#-----------------------------------------------------------------------------# This class handles music volume adjustments#=============================================================================class Sprite_Music < Sprite ICON_UP = RPG::Cache.icon('Menu_Icon_Sound_More') ICON_DOWN = RPG::Cache.icon('Menu_Icon_Sound_Less') SRC_RECT = Rect.new(0, 0, 24, 24) #--------------------------------------------------------------------------- # * Object Initializatioin #--------------------------------------------------------------------------- def initialize super self.x = 146 self.y = 264 self.bitmap = Bitmap.new(216, 32) refresh end #--------------------------------------------------------------------------- # * Refresh Content #--------------------------------------------------------------------------- def refresh # Clear bitmap self.bitmap.clear # Draw Icons self.bitmap.blt(0, 4, ICON_DOWN, SRC_RECT) self.bitmap.blt(192, 4, ICON_UP, SRC_RECT) # Draw bar self.bitmap.draw_gradient_bar(28, 8, 160, 16, $settings.music_volume, 100, Color.new(25, 25, 255, 255), Color.new(175, 175, 255, 255)) end #--------------------------------------------------------------------------- # * Update Frame #--------------------------------------------------------------------------- def update # if Left button is pressed if Input.repeat?(Input::LEFT) && $settings.music_volume > 0 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Decrease volume $settings.music_volume -= 5 $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) refresh end # if Right button is pressed if Input.repeat?(Input::RIGHT) && $settings.music_volume < 100 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Increase volume $settings.music_volume += 5 $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) refresh end endend#=============================================================================# ** Sprite_Sound#-----------------------------------------------------------------------------# This class handles sound volume adjustments#=============================================================================class Sprite_Sound < Sprite ICON_UP = RPG::Cache.icon('Menu_Icon_Sound_More') ICON_DOWN = RPG::Cache.icon('Menu_Icon_Sound_Less') SRC_RECT = Rect.new(0, 0, 24, 24) #--------------------------------------------------------------------------- # * Object Initializatioin #--------------------------------------------------------------------------- def initialize super self.x = 146 self.y = 264 self.bitmap = Bitmap.new(216, 32) refresh end #--------------------------------------------------------------------------- # * Refresh Content #--------------------------------------------------------------------------- def refresh # Clear bitmap self.bitmap.clear # Draw Icons self.bitmap.blt(0, 4, ICON_DOWN, SRC_RECT) self.bitmap.blt(192, 4, ICON_UP, SRC_RECT) # Draw bar self.bitmap.draw_gradient_bar(28, 8, 160, 16, $settings.sound_volume, 100, Color.new(25, 25, 255, 255), Color.new(175, 175, 255, 255)) end #--------------------------------------------------------------------------- # * Update Frame #--------------------------------------------------------------------------- def update # if Left button is pressed if Input.repeat?(Input::LEFT) && $settings.sound_volume > 0 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Decrease volume $settings.sound_volume -= 5 refresh end # if Right button is pressed if Input.repeat?(Input::RIGHT) && $settings.sound_volume < 100 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Increase volume $settings.sound_volume += 5 refresh end endend#=============================================================================# ** Sprite_Theme#-----------------------------------------------------------------------------# This class allows the player to modify in-game settings#=============================================================================class Sprite_Theme < Sprite_Menu #--------------------------------------------------------------------------- # * Constants #--------------------------------------------------------------------------- SRC_RECT = Rect.new(0, 0, 640, 480) # Src Rect for background preview #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super # Setup data @data = [] # Add themes $settings.themes.each {|theme| @data.push(theme)} # Set size and position height = @data.size * 136 self.y = 348 - height self.bitmap = Bitmap.new(480, height) @item_max = @data.size refresh end # initialize #--------------------------------------------------------------------------- # * Refresh Contents #--------------------------------------------------------------------------- def refresh # Clear bitmap self.bitmap.clear # Draw contents @data.each_index {|i| self.bitmap.font.color = i == self.index ? selected_color : deselected_color self.bitmap.draw_text(180, (@item_max - i - 1) * 136 + 45, 320, 32, @data[i]) # draw Preview bmp = RPG::Cache.picture('back/' + @data[i]) opacity = i == self.index ? 255 : 100 # Draw Shadow self.bitmap.fill_rect(2, (@item_max - i - 1) * 136 + 2, 162, 122, Color.new(0, 0, 0, 100)) self.bitmap.fill_rect(3, (@item_max - i - 1) * 136 + 3, 162, 122, Color.new(0, 0, 0, 50)) # Draw frame self.bitmap.draw_frame(0, (@item_max - i - 1) * 136, 162, 122, Color.new(255, 255, 255, 255)) rect = Rect.new(1, (@item_max - i - 1) * 136 + 1, 160, 120) self.bitmap.stretch_blt(rect, bmp, SRC_RECT, opacity) } end # refresh #--------------------------------------------------------------------------- # * Update Frame #--------------------------------------------------------------------------- def update if @move_down self.y += 34 @step -= 34 if @step == 0 @move_down = false end # if @step return elsif @move_up self.y -= 34 @step -= 34 if @step == 0 @move_up = false end # if @step return else # If Down button is pressed if Input.repeat?(Input::DOWN) && @index > 0 @step = 136 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Change index @index -= 1 # Shift up @move_up = true end # if Input # If Up button is pressed if Input.repeat?(Input::UP) && @index < (@item_max - 1) @step = 136 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Change index @index += 1 # Shift down @move_down = true end # if Input # if Info window exists if @info != nil update_info end # if @info # Refresh contents refresh end # if @move_down elsif.. end # update #--------------------------------------------------------------------------- # * Theme #--------------------------------------------------------------------------- def theme # Return selected theme return @data[self.index] end # themeend # Sprite_Theme#=============================================================================# ** Sprite_File_Preview#-----------------------------------------------------------------------------# This class displays the file preview#=============================================================================class Sprite_File_Preview < Sprite #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(file_index) super() self.bitmap = Bitmap.new(640, 72) self.y = 364 self.z = 9998 @bg = Sprite.new @bg.bitmap = Bitmap.new(640, 72) @bg.y = 364 @bg.z = 9997 @bg.bitmap.draw_gradient(0, 0, 640, 72, Color.new(0, 0, 0, 100), Color.new(0, 0, 0, 0)) @file_index = file_index @filename = "Save#{@file_index + 1}.rxdata" @time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, 'r') @time_stamp = file.mtime @characters = Marshal.load(file) @frame_count = Marshal.load(file) @game_system = Marshal.load(file) @game_switches = Marshal.load(file) @game_variables = Marshal.load(file) @total_sec = @frame_count / Graphics.frame_rate file.close end refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.bitmap.clear # Draw file number name = "Slot #{@file_index + 1}" self.bitmap.draw_text(32, 0, 600, 32, name) # If save file exists if @file_exist # Draw character (0...@characters.size).each {|i| bmp = RPG::Cache.character(@characters[i][0], @characters[i][1]) cw = bmp.rect.width / 4 ch = bmp.rect.height / 4 src_rect = Rect.new(0, 0, cw, ch) x = 300 - @characters.size * 32 + i * 64 - cw / 2 self.bitmap.blt(x, 60 - ch, bmp, src_rect) } # Draw play time hour = @total_sec / 60 / 60 min = @total_sec / 60 % 60 sec = @total_sec % 60 time_string = sprintf('%02d:%02d:%02d', hour, min, sec) self.bitmap.draw_text(4, 0, 600, 32, time_string, 2) # Draw timestamp time_string = @time_stamp.strftime('%Y/%m/%d %H:%M') self.bitmap.draw_text(4, 32, 600, 32, time_string, 2) end end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @bg.dispose super endend # Sprite_File_Preview#=============================================================================# ** Sprite_File#-----------------------------------------------------------------------------# Parent Class for file menus#=============================================================================class Sprite_File < Sprite_Menu #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super self.bitmap = Bitmap.new(320, 480) self.y = -200 @item_max = 10 @data = [] 10.times {|i| @data.push('Slot ' + (i + 1).to_s)} refresh end #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh # Clear bitmap self.bitmap.clear # Draw data @data.each_index {|i| y = self.bitmap.height - (i * 48) - 32 self.bitmap.font.color = i == self.index ? selected_color : deselected_color self.bitmap.draw_text(4, y, 320, 32, @data[i]) } if @preview != nil @preview.dispose @preview = nil end @preview = Sprite_File_Preview.new(self.index) end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @preview.dispose super endend # Sprite_File#=============================================================================# ** Sprite_Quit#-----------------------------------------------------------------------------# Quit Confirmation menu#=============================================================================class Sprite_Quit < Sprite_Menu #--------------------------------------------------------------------------- # * Constants #--------------------------------------------------------------------------- ICONS = [RPG::Cache.icon('Menu_Icon_Quit'), RPG::Cache.icon('Menu_Icon_Reset'), RPG::Cache.icon('Menu_Icon_Cancel')] SRC_RECT = Rect.new(0, 0, 24, 24) #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super self.y = 136 self.bitmap = Bitmap.new(320, 144) @item_max = 3 @data = ['Shutdown', 'Reset', 'Cancel'] refresh end # initialize #--------------------------------------------------------------------------- # * Refresh Contents #--------------------------------------------------------------------------- def refresh # Clear Bitmap self.bitmap.clear # Draw contents @data.each_index {|i| y = 144 - (i * 48) - 32 self.bitmap.font.color = i == self.index ? selected_color : deselected_color self.bitmap.draw_text(32, y, 312, 32, @data[i]) bmp = ICONS[i] opacity = i == self.index ? 255 : 100 self.bitmap.blt(4, y + 4, bmp, SRC_RECT, opacity) } end # refresh #--------------------------------------------------------------------------- # * Update Info #--------------------------------------------------------------------------- def update_info case self.index when 0 # Shutdown self.info.set_text('Quit game') when 1 # Reset self.info.set_text('Return to title screen') when 2 # Cancel self.info.set_text('Return to menu') end # case self.index end # update_infoend # Sprite_Quit#=============================================================================# ** Sprite_Party#-----------------------------------------------------------------------------# This class allows the player to select party members#=============================================================================class Sprite_Party < Sprite_Menu #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_accessor :selected #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super @back = Sprite.new @back.bitmap = Bitmap.new(640, 64) @back.x = 0 @back.y = 372 @back.bitmap.draw_gradient(0, 0, 640, 64, Color.new(0,0,0,100), Color.new(0,0,0,0)) @selected = nil @item_max = $game_party.actors.size height = @item_max * 48 self.bitmap = Bitmap.new(320, height) self.y = 280 - height refresh end #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh self.bitmap.clear @data = [] $game_party.actors.each {|actor| @data.push(actor.name) } @data.each_index {|i| self.bitmap.font.color = i == self.index || @selected == i ? selected_color : deselected_color y = self.bitmap.height - i * 48 - 32 self.bitmap.draw_text(4, y, 316, 32, @data[i]) } if self.index != @last_index if @preview != nil @preview.dispose @preview = nil end @preview = Sprite_Actor_Preview.new($game_party.actors[self.index]) else @preview.refresh end @last_index = self.index end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @back.dispose @preview.dispose super end #--------------------------------------------------------------------------- # * Visible #--------------------------------------------------------------------------- def visible(visible, hide_preview=true) if hide_preview @back.visible = visible @preview.visible = visible end self.visible = visible endend#=============================================================================# ** Sprite_Status#-----------------------------------------------------------------------------# This Class displays actor status info#=============================================================================class Sprite_Status #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize(actor) # Draw Background @bg = Sprite.new @bg.bitmap = Bitmap.new(640, 480) @bg.bitmap.fill_rect(0, 0, 640, 480, Color.new(0, 0, 0, 255)) @bg.opacity = 180 # Draw Actor Status @status = Sprite.new @status.bitmap = Bitmap.new(640, 480) # Draw Name @status.bitmap.draw_text(128, 32, 200, 32, actor.name) # Draw Class @status.bitmap.draw_text(328, 32, 200, 32, $data_classes[actor.class_id].name) # Draw HP @status.bitmap.draw_actor_hp(actor, 128, 64) # Draw SP @status.bitmap.draw_actor_sp(actor, 328, 64) # Draw Divider @status.bitmap.fill_rect(118, 104, 420, 1, Color.new(255, 255, 255, 255)) # Draw Level @status.bitmap.draw_actor_level(actor, 128, 112) # Draw EXP @status.bitmap.draw_actor_exp(actor, 328, 112) # Draw Divider @status.bitmap.fill_rect(118, 184, 420, 1, Color.new(255, 255, 255, 255)) # Draw Parameters 7.times {|i| @status.bitmap.draw_actor_parameter(actor, 128, i * 32 + 192, i) } # Draw Divider @status.bitmap.fill_rect(312, 184, 1, 234, Color.new(255, 255, 255, 255)) # Draw Equipment @status.bitmap.font.size -= 5 @status.bitmap.draw_text(328, 192, 200, 32, 'EQUIPMENT') @status.bitmap.font.size += 5 # Draw Divider @status.bitmap.fill_rect(312, 230, 226, 1, Color.new(255, 255, 255, 255)) # Draw Items @status.bitmap.draw_item_name($data_weapons[actor.weapon_id], 328, 240) @status.bitmap.draw_item_name($data_armors[actor.armor1_id], 328, 272) @status.bitmap.draw_item_name($data_armors[actor.armor2_id], 328, 304) @status.bitmap.draw_item_name($data_armors[actor.armor3_id], 328, 336) @status.bitmap.draw_item_name($data_armors[actor.armor4_id], 328, 368) end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @bg.dispose @status.dispose endend # Sprite_Status#=============================================================================# ** Sprite_Target#-----------------------------------------------------------------------------# A catchall class for targetting party members#=============================================================================class Sprite_Target < Sprite_Selection #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super @item_max = $game_party.actors.size height = @item_max * 96 @item_max.times {|i| y = 240 - (height / 2) + (i * 96) @data.push(Sprite_Actor_Info.new(160, y, $game_party.actors[i])) } end #--------------------------------------------------------------------------- # * Refresh #--------------------------------------------------------------------------- def refresh @data.each {|sprite| sprite.refresh} endend # Sprite_Target#=============================================================================# ** Sprite_PlayTime#-----------------------------------------------------------------------------# This Sprite displays the length of time played#=============================================================================class Sprite_PlayTime #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize # Create display time Sprite @time = Sprite.new @time.x = 450 @time.y = 8 @time.bitmap = Bitmap.new(140, 48) # Create icon Sprite @icon = Sprite.new @icon.x = 600 @icon.y = 20 @icon.bitmap = Bitmap.new(36, 36) icon = RPG::Cache.picture('/menu/Time') shadow = RPG::Cache.picture('/menu/Time_s') # Draw Icon and shadow @icon.bitmap.blt(1, 1, shadow, Rect.new(0, 0, 24, 24), 100) @icon.bitmap.blt(2, 2, shadow, Rect.new(0, 0, 24, 24), 50) @icon.bitmap.blt(3, 3, shadow, Rect.new(0, 0, 24, 24), 25) @icon.bitmap.blt(0, 0, icon, Rect.new(0, 0, 24, 24)) refresh end # initialize #--------------------------------------------------------------------------- # * Refresh Contents #--------------------------------------------------------------------------- def refresh @time.bitmap.clear @total_sec = Graphics.frame_count / Graphics.frame_rate hour = @total_sec / 60 / 60 min = @total_sec / 60 % 60 sec = @total_sec % 60 text = sprintf('%02d:%02d:%02d', hour, min, sec) @time.bitmap.draw_text(0, 8, 140, 32, text, 2) end # refresh #-------------------------------------------------------------------------- # * Update Frame #-------------------------------------------------------------------------- def update if Graphics.frame_count / Graphics.frame_rate != @total_sec refresh end # if Graphics end # refresh #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @time.dispose @icon.dispose end # disposeend # Sprite_PlayTime#=============================================================================# ** Sprite_Info#-----------------------------------------------------------------------------# Draws in-menu help info#=============================================================================class Sprite_Info < Sprite #--------------------------------------------------------------------------- # * Initialize #--------------------------------------------------------------------------- def initialize super self.y = 440 self.z = 9998 # Create bitmap self.bitmap = Bitmap.new(640, 32) # Draw bar back self.bitmap.draw_gradient(0, 0, 640, 32, Color.new(0,0,0,100), Color.new(0,0,0,0)) end # intitialize #--------------------------------------------------------------------------- # * Set Text #--------------------------------------------------------------------------- def set_text(text) # if text has changed if text != @text # Clear bitmap self.bitmap.clear # Redraw bar back self.bitmap.draw_gradient(0, 0, 640, 32, Color.new(0,0,0,100), Color.new(0,0,0,0)) # Draw new text self.bitmap.draw_text(16, 0, 640, 32, text) # Store current text @text = text end # if text end # set_textend # Sprite_Info#=============================================================================# ** Sprite_Currency#-----------------------------------------------------------------------------# Draws the current amount of money held by the party#=============================================================================class Sprite_Currency < Sprite #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize super self.x = 450 self.y = 48 self.bitmap = Bitmap.new(140, 32) self.bitmap.draw_text(0, 0, 140, 32, $game_party.gold.to_s + '$', 2) end # initializeend # Sprite_Currency#=============================================================================# ** Scene_Menu#-----------------------------------------------------------------------------# Puts together the psp styled menu#=============================================================================class Scene_Menu attr_accessor :phase #--------------------------------------------------------------------------- # * Constants #--------------------------------------------------------------------------- # Menu Phases MAIN = 0; CONSUME = 1; SORT = 2; IMPORTANT = 3; STATUS = 4; EQUIP = 5 SKILLS = 6; SWITCH = 7; SOUND = 8; MUSIC = 9; THEME = 10; SAVE = 11 LOAD = 12; QUIT = 13 #--------------------------------------------------------------------------- # * Main Processing #--------------------------------------------------------------------------- def main # set phase @phase = MAIN # Create PSP Background @background = Sprite.new @background.bitmap = RPG::Cache.picture('back/' + $settings.bg) # Create info Bar @info = Sprite.new @info = Sprite_Info.new # Sub Options Array sub_options = [['Consume', 'Sort', 'Important'], # inventory ['Status', 'Equip', 'Skills', 'Switch'], # Party ['Sound', 'Music', 'Theme'], # Settings ['Save', 'Load', 'Quit']] # System # Create Menu options array menu_options = ['Inventory', 'Party', 'Settings', 'System'] @menu = [] menu_options.each_index {|i| @menu.push(XMB_Menu.new(menu_options[i], sub_options[i], i)) } @menu_index = 0 @play_time = Sprite_PlayTime.new @currency = Sprite_Currency.new # Execute transition Graphics.transition # Main loop loop do # Update graphics Graphics.update # Update Input Input.update # Update frame update # If scene has changed, break loop if $scene != self break end # if $scene end # loop # Prepare transition Graphics.freeze # Dispose graphics @menu.each {|menu| menu.options.each {|option| option.dispose } menu.dispose } @play_time.dispose @info.dispose @currency.dispose @background.dispose end #--------------------------------------------------------------------------- # * Update Frame #--------------------------------------------------------------------------- def update # Set info text to current location @info.set_text($game_map.map_name) # Update playtime sprite @play_time.update if @phase == CONSUME && @menu[@menu_index].step == 0 # Move to Consume menu start_consume return elsif @phase == SORT && @menu[@menu_index].step == 0 # Move to Sort menu start_sort return elsif @phase == IMPORTANT && @menu[@menu_index].step == 0 # Move to Important Item menu start_important return elsif @phase == STATUS && @menu[@menu_index].step == 0 # Move to Status Menu start_party_target return elsif @phase == EQUIP && @menu[@menu_index].step == 0 # Move to Equip Menu start_party_target return elsif @phase == SKILLS && @menu[@menu_index].step == 0 # Move to Skills Menu start_party_target return elsif @phase == SWITCH && @menu[@menu_index].step == 0 # Move to Switch Menu start_party_target return elsif @phase == SAVE && @menu[@menu_index].step == 0 # Move to Save menu start_save return elsif @phase == LOAD && @menu[@menu_index].step == 0 # Move to Load menu start_load return elsif @phase == QUIT && @menu[@menu_index].step == 0 # Move to Quit menu start_quit return elsif @phase == THEME && @menu[@menu_index].step == 0 # Move to Theme menu start_theme return elsif @phase == SOUND && @menu[@menu_index].step == 0 # Move to Sound menu start_sound return elsif @phase == MUSIC && @menu[@menu_index].step == 0 # Move to Sound menu start_music return else # Update menu options @menu.each {|option| option.update } update_main_menu return end # if @phase elsif.. end # update #--------------------------------------------------------------------------- # * Update Main Menu #--------------------------------------------------------------------------- def update_main_menu # If menu is not moving unless @menu[@menu_index].moving? # If Left button is pressed if Input.repeat?(Input::LEFT) && @menu_index > 0 # Play Cursor SE $game_system.se_play($data_system.cursor_se) # Switch index @menu[@menu_index].deselect @menu_index -= 1 @menu[@menu_index].select # Move menu options @menu.each {|option| option.step = 128 option.move_right = true } return end # if Input # if Right Button is pressed if Input.repeat?(Input::RIGHT) && @menu_index < (@menu.size - 1) # Play cursor SE $game_system.se_play($data_system.cursor_se) # Switch index @menu[@menu_index].deselect @menu_index += 1 @menu[@menu_index].select # Move menu options @menu.each {|option| option.step = 128 option.move_left = true } return end # if Input # If B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return to game map $scene = Scene_Map.new return end # if Input # If C button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) case @menu[@menu_index].options[@menu[@menu_index].sub_index].name when 'Consume' # Switch phase @phase = CONSUME # Hide other menus & shift left shift_menu_left return when 'Sort' # Switch phase @phase = SORT # Hide other menus & shift left shift_menu_left return when 'Important' # Switch phase @phase = IMPORTANT # Hide other menus & shift menu left shift_menu_left return when 'Status' # Switch phase @phase = STATUS # Hide other menus & Shift menu left shift_menu_left return when 'Equip' # Switch phase @phase = EQUIP # Hide other menus & Shift menu left shift_menu_left return when 'Skills' # Switch phase @phase = SKILLS # Hide other menus & Shift menu left shift_menu_left return when 'Switch' # Switch phase @phase = SWITCH # Hide other menus & shift left shift_menu_left return when 'Sound' # Switch phase @phase = SOUND # Hide other menus & shift left shift_menu_left return when 'Music' # Switch phase @phase = MUSIC # Hide other menus & shift left shift_menu_left return when 'Theme' # Switch phase @phase = THEME # Hide other menus & shift left shift_menu_left return when 'Save' # If saving is disabled if $game_system.save_disabled # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Switch phase @phase = SAVE # Hide othe menus & Shift menu left shift_menu_left return when 'Load' # Switch phase @phase = LOAD # Hide othe menus & Shift menu left shift_menu_left return when 'Quit' # Switch phase @phase = QUIT # Hide other menus & shift left shift_menu_left return end # case end # if Input end # unless @menu.moving? end # update_main_menu #-------------------------------------------------------------------------- # * Start Consume #-------------------------------------------------------------------------- def start_consume # Create item sprite @item = Sprite_Items.new # Associate info @item.info = @info # Consume loop loop do # Update Graphics Graphics.update # Update input Input.update # Update menu update_consume # if phase has changed if @phase != CONSUME break end end # Return Menu shift_menu_right # Dispose items @item.dispose end #-------------------------------------------------------------------------- # * Update Consume #-------------------------------------------------------------------------- def update_consume # Update play time @play_time.update # Update item @item.update # If B button is pressed if Input.trigger?(Input::B) # Play Cancel SE $game_system.se_play($data_system.cancel_se) # Return to main phase @phase = MAIN return end # If C button is Pressed if Input.trigger?(Input::C) item = @item.item return if item == nil # If item triggers event with no target if item.scope == 0 && item.common_event_id > 0 # Command event call reservation $game_temp.common_event_id = item.common_event_id # Play item use SE $game_system.se_play(item.menu_se) # If consumable if item.consumable # Decrease used items by 1 $game_party.lose_item(item.id, 1) # Redraw item menu @item.redraw end # Switch to map screen $scene = Scene_Map.new @phase = MAIN return end # if Item cannot be used if item.scope < 3 || item.occasion == 1 || item.occasion == 3 || !$game_party.item_can_use?(item.id) # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play Decision SE $game_system.se_play($data_system.decision_se) # Switch to target menu item_target return end end #-------------------------------------------------------------------------- # * Item Target #-------------------------------------------------------------------------- def item_target # Create target menu @target = Sprite_Target.new item = @item.item # if item targets entire party if item.scope == 4 || item.scope == 6 @target.index = -1 end # Target loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update play time @play_time.update # Update target @target.update # If B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # return break end # If C Button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # If target is all if @target.index == -1 # Apply item effects to entire party used = false $game_party.actors.each {|actor| used |= actor.item_effect(item)} end # If single target if @target.index >= 0 # Apply item use effects to target actor target = $game_party.actors[@target.index] used = target.item_effect(item) end # If an item was used if used # Play item use SE $game_system.se_play(item.menu_se) # If consumable if item.consumable # Decrease used items by 1 $game_party.lose_item(item.id, 1) # Redraw item menu @item.redraw end # Remake target window contents @target.refresh # If common event ID is valid if item.common_event_id > 0 # Common event call reservation $game_temp.common_event_id = item.common_event_id # Switch to map screen @phase = MAIN $scene = Scene_Map.new break end end # If item wasn't used unless used # Play buzzer SE $game_system.se_play($data_system.buzzer_se) end # If player runs out of item if $game_party.item_number(item.id) == 0 break end end end @target.dispose end #-------------------------------------------------------------------------- # * Start Sort #-------------------------------------------------------------------------- def start_sort # Create Sort menu @sort = Sprite_Sort.new # Associate info @sort.info = @info # Sort loop loop do # Update Graphics Graphics.update # Update input Input.update # Update sort menu update_sort # If phase has changed if @phase != SORT break end end # Shift menu right shift_menu_right # Dispose sort menu @sort.dispose end #-------------------------------------------------------------------------- # * Update Sort #-------------------------------------------------------------------------- def update_sort # Update play time @play_time.update # Update sort menu @sort.update # If B button is pressed if Input.trigger?(Input::B) # Play cancel se $game_system.se_play($data_system.cancel_se) # Return to main menu @phase = MAIN return end # If C button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # Switch to sort type menu sort_type_menu return end end #-------------------------------------------------------------------------- # * Sort Type Menu #-------------------------------------------------------------------------- def sort_type_menu # Create Sort Type Menu @sort_type = Sprite_Sort_Type.new # Sort Type Menu loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update Play Time @play_time.update # Update Sort Type @sort_type.update # if B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return break end if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # Set Sort $settings.item_sort_type = @sort.index $settings.item_sort_reverse = @sort_type.index == 1 # Return break end end @sort_type.dispose end #-------------------------------------------------------------------------- # * Start Important #-------------------------------------------------------------------------- def start_important # Create Important Item menu @important = Sprite_Important.new # Associate info @important.info = @info # Important item loop loop do # Update Graphics Graphics.update # Update input Input.update # Update important menu update_important # If phase has changed if @phase != IMPORTANT break end end # Shift menu right shift_menu_right # dispose menu @important.dispose end #-------------------------------------------------------------------------- # * Update Important #-------------------------------------------------------------------------- def update_important # Update play time @play_time.update # Update Important menu @important.update # If B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return to menu @phase = MAIN return end end #-------------------------------------------------------------------------- # * Start Party Target #-------------------------------------------------------------------------- def start_party_target # Create party menu @party = Sprite_Party.new # Set info text @info.set_text('Select a Party Member') # Party Target Loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update Party Select update_party_target # If phase has changed if @phase != STATUS && @phase != EQUIP && @phase != SKILLS && @phase != SWITCH break end end # Shift menu right shift_menu_right # Dispose party menu @party.dispose end #-------------------------------------------------------------------------- # * Update Party Target #-------------------------------------------------------------------------- def update_party_target # Update Play Time @play_time.update # Update Party Selection @party.update # If B button is pressed if Input.trigger?(Input::B) # Play Cancel SE $game_system.se_play($data_system.cancel_se) # Return to main menu @phase = MAIN return end # If C button is pressed if Input.trigger?(Input::C) # Switch to correct menu case @phase when STATUS # Play decision SE $game_system.se_play($data_system.decision_se) # Hide Party selection @party.visible(false) start_status # Show Party selection @party.visible(true) return when EQUIP # Play decision SE $game_system.se_play($data_system.decision_se) # Hide Party selection @party.visible(false) start_equip # Show Party selection @party.visible(true) return when SKILLS # if character has no skills unless $game_party.actors[@party.index].skills.size > 0 # Play buzzer se $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Hide Party selection @party.visible(false, false) start_skills # Show Party selection @party.visible(true) return when SWITCH # Play decision SE $game_system.se_play($data_system.decision_se) start_switch return end end end #-------------------------------------------------------------------------- # * Start Status #-------------------------------------------------------------------------- def start_status # Get actor index + actor + size actor_index = @party.index actor = $game_party.actors[actor_index] max = $game_party.actors.size # Create Status @status = Sprite_Status.new(actor) # Status Loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update Play Time @play_time.update # If B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return to menu break end # If L button is pressed if Input.trigger?(Input::L) # Play cursor SE $game_system.se_play($data_system.cursor_se) # Change Actor Index actor_index = (actor_index + max - 1) % max actor = $game_party.actors[actor_index] @status.dispose @status = nil @status = Sprite_Status.new(actor) end # If R button is pressed if Input.trigger?(Input::R) # Play cursor SE $game_system.se_play($data_system.cursor_se) # Change Actor Index actor_index = (actor_index + 1) % max actor = $game_party.actors[actor_index] @status.dispose @status = nil @status = Sprite_Status.new(actor) end end @status.dispose end #-------------------------------------------------------------------------- # * Start Equip #-------------------------------------------------------------------------- def start_equip # Get actor index + actor + size actor_index = @party.index actor = $game_party.actors[actor_index] max = $game_party.actors.size # Create Equip Screen @equip = Sprite_Equipment.new(actor) # Associate Info @equip.info = @info # Equip loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update Play Time @play_time.update # Update Equip Screen @equip.update # If equip phase is 0 if @equip.phase == 0 # If B button is pressed if Input.trigger?(Input::B) # Play Cancel SE $game_system.se_play($data_system.cancel_se) # Return to menu break end # If L button is pressed if Input.trigger?(Input::L) # Play Cursor SE $game_system.se_play($data_system.cancel_se) # Change Actor Index actor_index = (actor_index + max - 1) % max actor = $game_party.actors[actor_index] @equip.dispose @equip = nil @equip = Sprite_Equipment.new(actor) # Reassociate info @equip.info = @info end # If R button is pressed if Input.trigger?(Input::R) # Play Cursor SE $game_system.se_play($data_system.cancel_se) # Change Actor Index actor_index = (actor_index + 1) % max actor = $game_party.actors[actor_index] @equip.dispose @equip = nil @equip = Sprite_Equipment.new(actor) # Reassociate info @equip.info = @info end end end @equip.dispose @info.set_text('Select a Party Member') end #-------------------------------------------------------------------------- # * Start Skills #-------------------------------------------------------------------------- def start_skills # Get actor @cur_actor = $game_party.actors[@party.index] # Create Skills menu @skills = Sprite_Skills.new(@cur_actor) # Associate info @skills.info = @info @finish_menu = false # Skills loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update Menu update_skills # if finished menu if @finish_menu break end end @skills.dispose @info.set_text('Select a Party Member') end #-------------------------------------------------------------------------- # * Update Skills #-------------------------------------------------------------------------- def update_skills # if B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return @finish_menu = true return end # If C button is pressed if Input.trigger?(Input::C) @cur_skill = @skills.skill # If skill cannot be used if !@cur_actor.skill_can_use?(@cur_skill.id) || @cur_actor.sp < @cur_skill.sp_cost || @cur_skill.occasion == 1 || @cur_skill.occasion == 3 # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # If effect has no target and triggers common event if @cur_skill.scope == 0 && @cur_skill.common_event_id > 0 # Common event call reservation $game_temp.common_event_id = @cur_skill.common_event_id # Play use skill SE $game_system.se_play(@cur_skill.menu_se) # Use up SP @cur_actor.sp -= @cur_skill.sp_cost @party.refresh # Switch to map screen @phase = MAIN @finish_menu = true $scene = Scene_Map.new return end # If scope is ally if @cur_skill.scope >= 3 # If skill's scope is user if @cur_skill.scope == 7 # Use Skill used = @cur_actor.skill_effect(@cur_actor, @cur_skill) if used # Play skill use SE $game_system.se_play(@cur_skill.menu_se) # Use up SP @cur_actor.sp -= @cur_skill.sp_cost # Remake each window content @party.refresh # If command event ID is valid if @cur_skill.common_event_id > 0 # Command event call reservation $game_temp.common_event_id = @cur_skill.common_event_id # Switch to map screen @phase = MAIN @finish_menu = true $scene = Scene_Map.new return end else # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end end skill_target return end end end #-------------------------------------------------------------------------- # * Skill Target #-------------------------------------------------------------------------- def skill_target # Create target menu @target = Sprite_Target.new # if item targets entire party if @cur_skill.scope == 4 || @cur_skill.scope == 6 @target.index = -1 end # Target loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update play time @play_time.update # Update target @target.update # If B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # return break end # If C Button is pressed if Input.trigger?(Input::C) # If unable to use because SP ran out unless @cur_actor.skill_can_use?(@cur_skill.id) # Play buzzer SE $game_system.se_play($data_system.buzzer_se) break end # If target is all if @target.index == -1 # Apply skill use effects to entire party used = false $game_party.actors.each {|actor| used |= actor.skill_effect(@cur_actor, @cur_skill) } end # If single target if @target.index >= 0 # Apply skill use effects to target actor target = $game_party.actors[@target.index] used = target.skill_effect(@cur_actor, @cur_skill) end # If skill was used if used # Play skill use SE $game_system.se_play(@cur_skill.menu_se) # Use up SP @cur_actor.sp -= @cur_skill.sp_cost # Remake each window content @party.refresh @target.refresh # If command event ID is valid if @cur_skill.common_event_id > 0 # Command event call reservation $game_temp.common_event_id = @cur_skill.common_event_id # Switch to map screen @phase = MAIN @finish_menu = true $scene = Scene_Map.new break end else # Play buzzer SE $game_system.se_play($data_system.buzzer_se) end end end @target.dispose end #-------------------------------------------------------------------------- # * Start Switch #-------------------------------------------------------------------------- def start_switch # Get actor index actor_index = @party.index @party.selected = actor_index # Switch Loop loop do # Update Graphics Graphics.update # Update input Input.update # Update play Time @play_time.update # Update party selection @party.update # If B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return @party.selected = nil break end # If C button is pressed and selected 2 different party members if Input.trigger?(Input::C) && (actor_index != @party.index) # Play decision SE $game_system.se_play($data_system.decision_se) # Switch out party members $game_party.actors[actor_index], $game_party.actors[@party.index] = $game_party.actors[@party.index], $game_party.actors[actor_index] # Refresh menu @party.refresh # Refresh game player $game_player.refresh # Return @party.selected = nil break end end end #-------------------------------------------------------------------------- # * Start Save #-------------------------------------------------------------------------- def start_save # Create Save Menu @save = Sprite_File.new # Set info @info.set_text('Select a file to overwrite') # Save Loop loop do # Update Graphics Graphics.update # Update input Input.update # Update save menu update_save # If Phase has changed if @phase != SAVE break end end # Shift Menu Right shift_menu_right # Dispose Save menu @save.dispose end #-------------------------------------------------------------------------- # * Update Save #-------------------------------------------------------------------------- def update_save # Update Play Time @play_time.update # Update Save Menu @save.update # if B Button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return @phase = MAIN return end # If C Button is pressed if Input.trigger?(Input::C) # Play Decision SE $game_system.se_play($data_system.decision_se) # Create confirmation screen confirm = Sprite_Confirmation.new('Would you like to overwrite this file?') # Confirmation loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update Play Time @play_time.update # Update Confirmation confirm.update # If B Button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return break end # If C Button is pressed if Input.trigger?(Input::C) case confirm.index when 0 # Yes # Save file save_file(@save.index) # Refresh save file @save.refresh # Return break when 1 # No # Play decision SE $game_system.se_play($data_system.decision_se) # Cancel + Return break end end end confirm.dispose return end end #-------------------------------------------------------------------------- # * Save File #-------------------------------------------------------------------------- def save_file(file_index) # Play save SE $game_system.se_play($data_system.save_se) # Make Filename filename = "Save#{file_index + 1}.rxdata" # Write save data file = File.open(filename, 'wb') # Make character data for drawing save file characters = [] (0...$game_party.actors.size).each {|i| actor = $game_party.actors[i] characters.push([actor.character_name, actor.character_hue]) } # Write character data for drawing save file Marshal.dump(characters, file) # Wrire frame count for measuring play time Marshal.dump(Graphics.frame_count, file) # Increase save count by 1 $game_system.save_count += 1 # Save magic number # (A random value will be written each time saving with editor) $game_system.magic_number = $data_system.magic_number # Write each type of game object Marshal.dump($game_system, file) Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches, file) Marshal.dump($game_screen, file) Marshal.dump($game_actors, file) Marshal.dump($game_party, file) Marshal.dump($game_troop, file) Marshal.dump($game_map, file) Marshal.dump($game_player, file) Marshal.dump($settings, file) file.close end #-------------------------------------------------------------------------- # * Start Load #-------------------------------------------------------------------------- def start_load # Create Load Menu @load = Sprite_File.new # Set info text @info.set_text('Select a file to load') # Load Loop loop do # Update graphics Graphics.update # Update input Input.update # Update Menu update_load # If Phase has Changed if @phase != LOAD break end end # Shift Menu Right shift_menu_right # Dispose menu @load.dispose end #-------------------------------------------------------------------------- # * Update Load #-------------------------------------------------------------------------- def update_load # Update Play Time @play_time.update # Update Save Menu @load.update # if B Button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return @phase = MAIN return end # If C Button is pressed if Input.trigger?(Input::C) # Make Filename file_index = @load.index + 1 filename = "Save#{file_index}.rxdata" # If file doesn't exist unless FileTest.exist?(filename) # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play Decision SE $game_system.se_play($data_system.decision_se) # Create confirmation screen confirm = Sprite_Confirmation.new('Would you like to load this file?') # Confirmation loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update Play Time @play_time.update # Update Confirmation confirm.update # If B Button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return break end # If C Button is pressed if Input.trigger?(Input::C) case confirm.index when 0 # Yes # load file load_file(@load.index) # Return break when 1 # No # Play decision SE $game_system.se_play($data_system.decision_se) # Cancel + Return break end end end confirm.dispose return end end #-------------------------------------------------------------------------- # * Load File #-------------------------------------------------------------------------- def load_file(file_index) # Make Filename filename = "Save#{file_index + 1}.rxdata" # If file doesn't exist unless FileTest.exist?(filename) # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play load SE $game_system.se_play($data_system.load_se) # Read save data file = File.open(filename, 'rb') # Read character data for drawing save file characters = Marshal.load(file) # Read frame count for measuring play time Graphics.frame_count = Marshal.load(file) # Read each type of game object $game_system = Marshal.load(file) $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_screen = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_map = Marshal.load(file) $game_player = Marshal.load(file) $settings = Marshal.load(file) # If magic number is different from when saving # (if editing was added with editor) if $game_system.magic_number != $data_system.magic_number # Load map $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end # Refresh party members $game_party.refresh file.close # Restore BGM and BGS $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) # Update map (run parallel process event) $game_map.update # Switch to map screen $scene = Scene_Map.new @phase = MAIN end #-------------------------------------------------------------------------- # * Start Sound #-------------------------------------------------------------------------- def start_sound # Create sound object @sound = Sprite_Sound.new # Set Info window @info.set_text('Adjust the in game sound volume') # Sound loop loop do # Update graphics Graphics.update # Update input Input.update # Update sound update_sound # if Phase has changed if @phase != SOUND break end # if @phase end # loop # Return menu shift_menu_right # Dispose sound @sound.dispose end # start_sound #-------------------------------------------------------------------------- # * Update Sound #-------------------------------------------------------------------------- def update_sound # Update play time @play_time.update # Update sound @sound.update # if B or C button is pressed if Input.trigger?(Input::B) || Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # Return to menu @phase = MAIN return end end # update_sound #-------------------------------------------------------------------------- # * Start Music #-------------------------------------------------------------------------- def start_music # Create sound object @music = Sprite_Music.new # Set Info window @info.set_text('Adjust the in game music volume') # Sound loop loop do # Update graphics Graphics.update # Update input Input.update # Update sound update_music # if Phase has changed if @phase != MUSIC break end # if @phase end # loop # Return menu shift_menu_right # Dispose sound @music.dispose end # start_music #-------------------------------------------------------------------------- # * Update Music #-------------------------------------------------------------------------- def update_music # Update play time @play_time.update # Update sound @music.update # if B or C button is pressed if Input.trigger?(Input::B) || Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # Return to menu @phase = MAIN return end end # update_music #-------------------------------------------------------------------------- # * Start Theme #-------------------------------------------------------------------------- def start_theme # Create theme menu @theme = Sprite_Theme.new # Associate info @info.set_text('Change menu background') # Theme loop loop do # Update graphics Graphics.update # Update input Input.update # Update Theme menu update_theme # if phase has changed if @phase != THEME break end # if @phase end # loop # Return menu shift_menu_right # Dispose theme menu @theme.dispose end # start_theme #-------------------------------------------------------------------------- # * Update Theme #-------------------------------------------------------------------------- def update_theme # Update play time window @play_time.update # Update theme window @theme.update # if B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return to main menu @phase = MAIN return end # if Input # if C button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) # Switch backgrounds $settings.bg = @theme.theme @background.bitmap = RPG::Cache.picture('back/' + $settings.bg) # Return to main menu @phase = MAIN return end # if Input end # update_them #-------------------------------------------------------------------------- # * Start Quit #-------------------------------------------------------------------------- def start_quit # Create Quit menu @quit = Sprite_Quit.new # Associate info @quit.info = @info # Quit loop loop do # Update graphics Graphics.update # update input Input.update # Update Quit menu update_quit # If phase has changed if @phase != QUIT break end # if @phase end # loop # Return menu shift_menu_right # Dispose quit menu @quit.dispose end # start_quit #--------------------------------------------------------------------------- # * Update Quit #--------------------------------------------------------------------------- def update_quit # Update play time @play_time.update # Update quit menu @quit.update # If B button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # return to menu @phase = MAIN return end # if Input # if C button is pressed if Input.trigger?(Input::C) # Play decision SE $game_system.se_play($data_system.decision_se) case @quit.index when 0 # Shutdown @phase = MAIN $game_system.bgm_fade(800) $game_system.bgs_fade(800) $scene = nil when 1 # Reset @phase = MAIN $scene = Scene_Title.new when 2 # Cancel @phase = MAIN end # case return end # if Input end # update_quit #--------------------------------------------------------------------------- # * Hide and Shift Menus left #--------------------------------------------------------------------------- def shift_menu_left # Hide other menus @menu.each_index {|i| @menu[i].opacity = @menu_index == i ? 255 : 0 } @menu[@menu_index].options[@menu[@menu_index].sub_index].refresh # Shift Menu left @menu[@menu_index].step = 128 @menu[@menu_index].move_left = true end #--------------------------------------------------------------------------- # * Shift Menus Right #--------------------------------------------------------------------------- def shift_menu_right # Redisplay menu @menu.each_index {|i| @menu[i].opacity = 255 @menu[i].refresh } # Shift Menu Right @menu[@menu_index].step = 128 @menu[@menu_index].move_right = true endend # Scene_Menu#=============================================================================# ** Sprite_Title_Selection#-----------------------------------------------------------------------------# Handles Title Screen Selection#=============================================================================class Sprite_Title_Selection #--------------------------------------------------------------------------- # * Public Instance Variable #--------------------------------------------------------------------------- attr_accessor :index attr_reader :select #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize words = ['Start New Game', 'Load Saved Game', 'Shutdown'] @data = [] @index = 0 3.times {|i| @data.push(RPG::Sprite.new) @data[i].x = 32 @data[i].y = i * 48 + 320 @data[i].z += 10 @data[i].bitmap = Bitmap.new(200, 48) @data[i].bitmap.draw_text(0, 0, 200, 48, words[i]) } @cursor = Sprite.new @cursor.y = 320 @cursor.bitmap = Bitmap.new(640, 48) @select = true @width = 0 end #--------------------------------------------------------------------------- # * Update #--------------------------------------------------------------------------- def update @cursor.y = @index * 48 + 320 # Update Flash @data.each_index {|i| @data[i].opacity = 255 if @data[i].opacity < 255 && i != @index } if @data[@index].opacity <= 100 @step = 10 elsif @data[@index].opacity >= 255 @step = -10 end @data[@index].opacity += @step # If item is being selected if @select update_selection else # If Down Button is pressed if Input.repeat?(Input::DOWN) # Play cursor SE $game_system.se_play($data_system.cursor_se) # Change index @index = (@index + 1) % 3 # Start selection @select = true @width = 0 return end # If Up Button is pressed if Input.repeat?(Input::UP) # Play cursor SE $game_system.se_play($data_system.cursor_se) # Change index @index = (@index + 2) % 3 # Start Selection @select = true @width = 0 return end end end #--------------------------------------------------------------------------- # * Update Selection #--------------------------------------------------------------------------- def update_selection if @width > 640 @select = false return end @cursor.bitmap.clear @cursor.bitmap.draw_gradient(0, 0, @width, 48, Color.new(0, 0, 0, 200), Color.new(0, 0, 0, 0)) @width += 40 end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @cursor.dispose @data.each {|sprite| sprite.dispose} endend # Sprite_Title_Selection#=============================================================================# ** Sprite_File_Menu_Option#-----------------------------------------------------------------------------# Displays File in Save/Load Screen#=============================================================================class Sprite_File_Menu_Option < RPG::Sprite #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize(file_index, viewport) super(viewport) self.bitmap = Bitmap.new(640, 72) y = 80 * file_index self.y = y self.z = 9998 @bg = Sprite.new(viewport) @bg.bitmap = Bitmap.new(640, 72) @bg.y = y @bg.z = 9997 @bg.bitmap.draw_gradient(0, 0, 640, 72, Color.new(0, 0, 0, 100), Color.new(0, 0, 0, 0)) @file_index = file_index @filename = "Save#{@file_index + 1}.rxdata" @time_stamp = Time.at(0) @file_exist = FileTest.exist?(@filename) if @file_exist file = File.open(@filename, 'r') @time_stamp = file.mtime @characters = Marshal.load(file) @frame_count = Marshal.load(file) @game_system = Marshal.load(file) @game_switches = Marshal.load(file) @game_variables = Marshal.load(file) @total_sec = @frame_count / Graphics.frame_rate file.close end refresh end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def refresh self.bitmap.clear # Draw file number name = "Slot #{@file_index + 1}" self.bitmap.draw_text(32, 0, 600, 32, name) # If save file exists if @file_exist # Draw character (0...@characters.size).each {|i| bmp = RPG::Cache.character(@characters[i][0], @characters[i][1]) cw = bmp.rect.width / 4 ch = bmp.rect.height / 4 src_rect = Rect.new(0, 0, cw, ch) x = 300 - @characters.size * 32 + i * 64 - cw / 2 self.bitmap.blt(x, 60 - ch, bmp, src_rect) } # Draw play time hour = @total_sec / 60 / 60 min = @total_sec / 60 % 60 sec = @total_sec % 60 time_string = sprintf('%02d:%02d:%02d', hour, min, sec) self.bitmap.draw_text(4, 0, 600, 32, time_string, 2) # Draw timestamp time_string = @time_stamp.strftime('%Y/%m/%d %H:%M') self.bitmap.draw_text(4, 32, 600, 32, time_string, 2) end end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @bg.dispose super endend # Sprite_File_Menu_Option#=============================================================================# ** Sprite_File_Selection#-----------------------------------------------------------------------------# Handles Save/Load Screen Selection#=============================================================================class Sprite_File_Selection #--------------------------------------------------------------------------- # * Public Instance Variables #--------------------------------------------------------------------------- attr_accessor :index #--------------------------------------------------------------------------- # * Object Initialization #--------------------------------------------------------------------------- def initialize @index = 0 @data = [] @viewport = Viewport.new(0, 40, 640, 400) 10.times {|i| @data.push(Sprite_File_Menu_Option.new(i, @viewport))} end #--------------------------------------------------------------------------- # * Update #--------------------------------------------------------------------------- def update # Update flash @data.each_index {|i| @data[i].opacity = 255 if @data[i].opacity < 255 && i != @index } if @data[@index].opacity <= 100 @step = 10 elsif @data[@index].opacity >= 255 @step = -10 end @data[@index].opacity += @step # If Down Button is pressed if Input.trigger?(Input::DOWN) && @index < 9 # Play cursor SE $game_system.se_play($data_system.cursor_se) # Change index @index += 1 # if scroll needed if @data[9].y >= 400 scroll_up end end # If Up button is pressed if Input.trigger?(Input::UP) && @index > 0 # Play cursor se $game_system.se_play($data_system.cursor_se) # Change index @index -= 1 # if scroll needed if @data[0].y < 0 scroll_down end end end #--------------------------------------------------------------------------- # * Scroll Up #--------------------------------------------------------------------------- def scroll_up # Move File Options up @data.each {|sprite| sprite.y -= 80} end #--------------------------------------------------------------------------- # * Scroll Down #--------------------------------------------------------------------------- def scroll_down # Move File options down @data.each {|sprite| sprite.y += 80} end #--------------------------------------------------------------------------- # * Dispose #--------------------------------------------------------------------------- def dispose @data.each {|sprite| sprite.dispose} @viewport.dispose endend # Sprite_File_Selection#=============================================================================# ** Scene_Title#-----------------------------------------------------------------------------# Handles title screen#=============================================================================class Scene_Title #--------------------------------------------------------------------------- # * Main Processing #--------------------------------------------------------------------------- def main # If battle test if $BTEST battle_test return end # Load database $data_actors = load_data('Data/Actors.rxdata') $data_classes = load_data('Data/Classes.rxdata') $data_skills = load_data('Data/Skills.rxdata') $data_items = load_data('Data/Items.rxdata') $data_weapons = load_data('Data/Weapons.rxdata') $data_armors = load_data('Data/Armors.rxdata') $data_enemies = load_data('Data/Enemies.rxdata') $data_troops = load_data('Data/Troops.rxdata') $data_states = load_data('Data/States.rxdata') $data_animations = load_data('Data/Animations.rxdata') $data_tilesets = load_data('Data/Tilesets.rxdata') $data_common_events = load_data('Data/CommonEvents.rxdata') $data_system = load_data('Data/System.rxdata') # Make system object $game_system = Game_System.new # Make title graphic @sprite = Sprite.new @sprite.bitmap = RPG::Cache.title($data_system.title_name) # Make command window @command = Sprite_Title_Selection.new # Continue enabled determinant # Check if at least one save file exists # If enabled, make @continue_enabled true; if disabled, make it false @continue_enabled = false 10.times {|i| if FileTest.exist?("Save#{i+1}.rxdata") @continue_enabled = true end } if @continue_enabled @command.index = 1 end # Play title BGM $game_system.bgm_play($data_system.title_bgm) # Stop playing ME and BGS Audio.me_stop Audio.bgs_stop # Execute transition Graphics.transition # Main loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update menu update # if Scene has changed if $scene != self break end end # Prepare transition Graphics.freeze # Dispose windows @sprite.dispose @command.dispose end #--------------------------------------------------------------------------- # * Update Frame #--------------------------------------------------------------------------- def update # Update Commands @command.update # If C Button is pressed if Input.trigger?(Input::C) case @command.index when 0 # New Game # Play decision SE $game_system.se_play($data_system.decision_se) # New game command_new_game when 1 # Continue # if Continue not enabled unless @continue_enabled # Play Buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play decision SE $game_system.se_play($data_system.decision_se) # Load command_continue when 2 # Shutdown # Play decision SE $game_system.se_play($data_system.decision_se) # Shutdown command_shutdown end end end #--------------------------------------------------------------------------- # * Command New Game #--------------------------------------------------------------------------- def command_new_game # Stop BGM Audio.bgm_stop # Reset frame count for measuring play time Graphics.frame_count = 0 # Make each type of game object $game_temp = Game_Temp.new $game_system = Game_System.new $game_switches = Game_Switches.new $game_variables = Game_Variables.new $game_self_switches = Game_SelfSwitches.new $game_screen = Game_Screen.new $game_actors = Game_Actors.new $game_party = Game_Party.new $game_troop = Game_Troop.new $game_map = Game_Map.new $game_player = Game_Player.new # Set up initial party $game_party.setup_starting_members # Set up initial map position $game_map.setup($data_system.start_map_id) # Move player to initial position $game_player.moveto($data_system.start_x, $data_system.start_y) # Refresh player $game_player.refresh # Run automatic change for BGM and BGS set with map $game_map.autoplay # Update map (run parallel process event) $game_map.update # Switch to map screen $scene = Scene_Map.new end #--------------------------------------------------------------------------- # * Command Continue #--------------------------------------------------------------------------- def command_continue # Switch to Load screen $scene = Scene_Load.new end #--------------------------------------------------------------------------- # * Command Shut Down #--------------------------------------------------------------------------- def command_shutdown # Fade out BGM, BGS, and ME Audio.bgm_fade(800) Audio.bgs_fade(800) Audio.me_fade(800) # Shutdown $scene = nil end #-------------------------------------------------------------------------- # * Battle Test #-------------------------------------------------------------------------- def battle_test # Load database (for battle test) $data_actors = load_data('Data/BT_Actors.rxdata') $data_classes = load_data('Data/BT_Classes.rxdata') $data_skills = load_data('Data/BT_Skills.rxdata') $data_items = load_data('Data/BT_Items.rxdata') $data_weapons = load_data('Data/BT_Weapons.rxdata') $data_armors = load_data('Data/BT_Armors.rxdata') $data_enemies = load_data('Data/BT_Enemies.rxdata') $data_troops = load_data('Data/BT_Troops.rxdata') $data_states = load_data('Data/BT_States.rxdata') $data_animations = load_data('Data/BT_Animations.rxdata') $data_tilesets = load_data('Data/BT_Tilesets.rxdata') $data_common_events = load_data('Data/BT_CommonEvents.rxdata') $data_system = load_data('Data/BT_System.rxdata') # Reset frame count for measuring play time Graphics.frame_count = 0 # Make each game object $game_temp = Game_Temp.new $game_system = Game_System.new $game_switches = Game_Switches.new $game_variables = Game_Variables.new $game_self_switches = Game_SelfSwitches.new $game_screen = Game_Screen.new $game_actors = Game_Actors.new $game_party = Game_Party.new $game_troop = Game_Troop.new $game_map = Game_Map.new $game_player = Game_Player.new # Set up party for battle test $game_party.setup_battle_test_members # Set troop ID, can escape flag, and battleback $game_temp.battle_troop_id = $data_system.test_troop_id $game_temp.battle_can_escape = true $game_map.battleback_name = $data_system.battleback_name # Play battle start SE $game_system.se_play($data_system.battle_start_se) # Play battle BGM $game_system.bgm_play($game_system.battle_bgm) # Switch to battle screen $scene = Scene_Battle.new endend # Scene_Title#=============================================================================# ** Scene_File#-----------------------------------------------------------------------------# Handles Loading/Saving outside of menu#=============================================================================class Scene_File #-------------------------------------------------------------------------- # * Object Initialization # help_text : text string shown in the help window #-------------------------------------------------------------------------- def initialize(help_text, confirmation_text) @help_text = help_text @confirmation_text = confirmation_text end #-------------------------------------------------------------------------- # * Main Processing #-------------------------------------------------------------------------- def main # Draw Background @background = Sprite.new @background.bitmap = RPG::Cache.picture('back/' + $settings.bg) # Make info window @info = Sprite_Info.new @info.set_text(@help_text) # Make save file window @file = Sprite_File_Selection.new # Execute transition Graphics.transition # Main loop loop do # Update game screen Graphics.update # Update input information Input.update # Frame update update # Abort loop if screen is changed if $scene != self break end end # Prepare for transition Graphics.freeze # Dispose of windows @info.dispose @file.dispose @background.dispose end #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update # Update file selection @file.update # If C button was pressed if Input.trigger?(Input::C) # if Loading if $scene.is_a?(Scene_Load) # Make Filename file_index = @file.index + 1 filename = "Save#{file_index}.rxdata" # If file doesn't exist unless FileTest.exist?(filename) # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end end # Create confirmation screen confirm = Sprite_Confirmation.new(@confirmation_text) # Confirmation loop loop do # Update Graphics Graphics.update # Update Input Input.update # Update Confirmation confirm.update # If B Button is pressed if Input.trigger?(Input::B) # Play cancel SE $game_system.se_play($data_system.cancel_se) # Return break end # If C Button is pressed if Input.trigger?(Input::C) case confirm.index when 0 # Yes # Call method: on_decision (defined by the subclasses) on_decision(make_filename(@file.index)) # Return break when 1 # No # Play decision SE $game_system.se_play($data_system.decision_se) # Cancel + Return break end end end confirm.dispose return end # If B button was pressed if Input.trigger?(Input::B) # Call method: on_cancel (defined by the subclasses) on_cancel return end end #-------------------------------------------------------------------------- # * Make File Name # file_index : save file index (0-3) #-------------------------------------------------------------------------- def make_filename(file_index) return "Save#{file_index + 1}.rxdata" endend # Scene_File#=============================================================================# ** Scene_Save#-----------------------------------------------------------------------------# Handles Saving from outside menu (event calls)#=============================================================================class Scene_Save#-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super('Select a file to overwrite', 'Would you like to overwrite this file?') end #-------------------------------------------------------------------------- # * Decision Processing #-------------------------------------------------------------------------- def on_decision(filename) # Play save SE $game_system.se_play($data_system.save_se) # Write save data file = File.open(filename, 'wb') write_save_data(file) file.close # If called from event if $game_temp.save_calling # Clear save call flag $game_temp.save_calling = false # Switch to map screen $scene = Scene_Map.new return end end #-------------------------------------------------------------------------- # * Cancel Processing #-------------------------------------------------------------------------- def on_cancel # Play cancel SE $game_system.se_play($data_system.cancel_se) # If called from event if $game_temp.save_calling # Clear save call flag $game_temp.save_calling = false # Switch to map screen $scene = Scene_Map.new return end end #-------------------------------------------------------------------------- # * Write Save Data # file : write file object (opened) #-------------------------------------------------------------------------- def write_save_data(file) # Make character data for drawing save file characters = [] (0...$game_party.actors.size).each {|i| actor = $game_party.actors[i] characters.push([actor.character_name, actor.character_hue]) } # Write character data for drawing save file Marshal.dump(characters, file) # Wrire frame count for measuring play time Marshal.dump(Graphics.frame_count, file) # Increase save count by 1 $game_system.save_count += 1 # Save magic number # (A random value will be written each time saving with editor) $game_system.magic_number = $data_system.magic_number # Write each type of game object Marshal.dump($game_system, file) Marshal.dump($game_switches, file) Marshal.dump($game_variables, file) Marshal.dump($game_self_switches, file) Marshal.dump($game_screen, file) Marshal.dump($game_actors, file) Marshal.dump($game_party, file) Marshal.dump($game_troop, file) Marshal.dump($game_map, file) Marshal.dump($game_player, file) Marshal.dump($settings, file) endend # Scene_Save#=============================================================================# ** Scene_Load#-----------------------------------------------------------------------------# Handles Loading from outside menu (title screen)#=============================================================================class Scene_Load #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize # Remake Temporary object $game_temp = Game_Temp.new super('Select a file to load', 'Would you like to load this file?') end #-------------------------------------------------------------------------- # * Decision Processing #-------------------------------------------------------------------------- def on_decision(filename) # If file doesn't exist unless FileTest.exist?(filename) # Play buzzer SE $game_system.se_play($data_system.buzzer_se) return end # Play load SE $game_system.se_play($data_system.load_se) # Read save data file = File.open(filename, 'rb') read_save_data(file) file.close # Restore BGM and BGS $game_system.bgm_play($game_system.playing_bgm) $game_system.bgs_play($game_system.playing_bgs) # Update map (run parallel process event) $game_map.update # Switch to map screen $scene = Scene_Map.new end #-------------------------------------------------------------------------- # * Cancel Processing #-------------------------------------------------------------------------- def on_cancel # Play cancel SE $game_system.se_play($data_system.cancel_se) # Switch to title screen $scene = Scene_Title.new end #-------------------------------------------------------------------------- # * Read Save Data # file : file object for reading (opened) #-------------------------------------------------------------------------- def read_save_data(file) # Read character data for drawing save file characters = Marshal.load(file) # Read frame count for measuring play time Graphics.frame_count = Marshal.load(file) # Read each type of game object $game_system = Marshal.load(file) $game_switches = Marshal.load(file) $game_variables = Marshal.load(file) $game_self_switches = Marshal.load(file) $game_screen = Marshal.load(file) $game_actors = Marshal.load(file) $game_party = Marshal.load(file) $game_troop = Marshal.load(file) $game_map = Marshal.load(file) $game_player = Marshal.load(file) $settings = Marshal.load(file) # If magic number is different from when saving # (if editing was added with editor) if $game_system.magic_number != $data_system.magic_number # Load map $game_map.setup($game_map.map_id) $game_player.center($game_player.x, $game_player.y) end # Refresh party members $game_party.refresh endend # Scene_Load#=============================================================================# ** Bitmap#-----------------------------------------------------------------------------# Alias and redefine draw_text to draw PSP XMB style shadows#=============================================================================class Bitmap # Alias draw_text only once unless self.method_defined?(:draw_shadow) alias draw_shadow draw_text end # unless #=========================================================================== # * draw_text #=========================================================================== def draw_text(arg1 = 0, arg2 = 0, arg3 = 0, arg4 = 0, arg5 = 0, arg6 = 0) if arg1.is_a?(Rect) x = arg1.x y = arg1.y width = arg1.width height = arg1.height string = arg2 align = arg3 else x = arg1 y = arg2 width = arg3 height = arg4 string = arg5 align = arg6 end # if arg1.is_a?(Rect) color = self.font.color.dup # Set outline color to BLACK self.font.color = Color.new(0, 0, 0, 100) draw_shadow(x + 1, y + 1, width, height, string, align) self.font.color = Color.new(0, 0, 0, 75) draw_shadow(x + 2, y + 2, width, height, string, align) self.font.color = Color.new(0, 0, 0, 50) draw_shadow(x + 3, y + 3, width, height, string, align) self.font.color = Color.new(0, 0, 0, 25) draw_shadow(x + 4, y + 4, width, height, string, align) self.font.color = Color.new(0, 0, 0, 10) draw_shadow(x + 5, y + 5, width, height, string, align) # Draw text with original Color self.font.color = color draw_shadow(x, y, width, height, string, align) end # def draw_text #-------------------------------------------------------------------------- # * Draw Gradient Bar #-------------------------------------------------------------------------- def draw_gradient_bar(x, y, width, height, min, max, start_color, end_color) # Colors black = Color.new(0, 0, 0, 255) # Draw Bar back self.fill_rect(x, y, width, height, black) self.fill_rect(x - 1, y + 1, 1, height - 2, black) self.fill_rect(x + width, y + 1, 1, height - 2, black) # Get fill amount x += 3 y += 3 height -= 6 width -= 6 fill = (min.to_f / max) * width width = (width.to_f / fill) * 100 dr = (end_color.red - start_color.red) / width.to_f dg = (end_color.green - start_color.green) / width.to_f db = (end_color.blue - start_color.blue) / width.to_f da = (end_color.alpha - start_color.alpha) / width.to_f (0...fill).each {|i| start_color.red += dr unless start_color.red + dr < 0 start_color.green += dg unless start_color.green + dg < 0 start_color.blue += db unless start_color.blue + db < 0 start_color.alpha += da unless start_color.alpha + da < 0 self.fill_rect(x + i, y, 1, height, start_color) } end #-------------------------------------------------------------------------- # * Draw Gradient #-------------------------------------------------------------------------- def draw_gradient(x, y, width, height, start_color, end_color) dr = (end_color.red - start_color.red) / width.to_f dg = (end_color.green - start_color.green) / width.to_f db = (end_color.blue - start_color.blue) / width.to_f da = (end_color.alpha - start_color.alpha) / width.to_f (0...width).each {|i| start_color.red += dr unless start_color.red + dr < 0 start_color.green += dg unless start_color.green + dg < 0 start_color.blue += db unless start_color.blue + db < 0 start_color.alpha += da unless start_color.alpha + da < 0 self.fill_rect(x + i, y, 1, height, start_color) } end #-------------------------------------------------------------------------- # * Draw Frame #-------------------------------------------------------------------------- def draw_frame(x, y, width, height, color) self.fill_rect(x, y, 1, height, color) self.fill_rect(x, y, width, 1, color) self.fill_rect(x + width - 1, y, 1, height, color) self.fill_rect(x, y + height - 1, width, 1, color) end #-------------------------------------------------------------------------- # * Draw Actor Graphic #-------------------------------------------------------------------------- def draw_actor_graphic(actor, x, y) bitmap = RPG::Cache.character(actor.character_name, actor.character_hue) cw = bitmap.width / 4 ch = bitmap.height / 4 src_rect = Rect.new(0, 0, cw, ch) self.blt(x, y, bitmap, src_rect) end #-------------------------------------------------------------------------- # * Draw Actor HP #-------------------------------------------------------------------------- def draw_actor_hp(actor, x, y) # Draw HP bar sc = Color.new(255, 0, 0, 255) ec = Color.new(255, 175, 175, 255) self.draw_gradient_bar(x + 16, y + 24, 108, 8, actor.hp, actor.maxhp, sc, ec) # Draw "HP" text string self.draw_text(x, y, 32, 32, $data_system.words.hp) # Draw HP hp_x = x + 32 self.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2) # Draw MaxHP self.draw_text(hp_x + 48, y, 12, 32, '/', 1) self.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s) end #-------------------------------------------------------------------------- # * Draw Actor SP #-------------------------------------------------------------------------- def draw_actor_sp(actor, x, y) # Draw SP bar sc = Color.new(0, 0, 255, 255) ec = Color.new(175, 175, 255, 255) self.draw_gradient_bar(x + 16, y + 24, 108, 8, actor.sp, actor.maxsp, sc, ec) # Draw "SP" text string self.draw_text(x, y, 32, 32, $data_system.words.sp) # Draw SP hp_x = x + 32 self.draw_text(hp_x, y, 48, 32, actor.sp.to_s, 2) # Draw MaxSP self.draw_text(hp_x + 48, y, 12, 32, '/', 1) self.draw_text(hp_x + 60, y, 48, 32, actor.maxsp.to_s) end #-------------------------------------------------------------------------- # * Draw Actor EXP #-------------------------------------------------------------------------- def draw_actor_exp(actor, x, y) end #-------------------------------------------------------------------------- # * Draw Actor Level #-------------------------------------------------------------------------- def draw_actor_level(actor, x, y) self.draw_text(x, y, 64, 32, 'Level') self.draw_text(x + 64, y, 24, 32, actor.level.to_s, 2) end #-------------------------------------------------------------------------- # * Draw Actor Parameter #-------------------------------------------------------------------------- def draw_actor_parameter(actor, x, y, type) case type when 0 parameter_name = $data_system.words.atk parameter_value = actor.atk when 1 parameter_name = $data_system.words.pdef parameter_value = actor.pdef when 2 parameter_name = $data_system.words.mdef parameter_value = actor.mdef when 3 parameter_name = $data_system.words.str parameter_value = actor.str when 4 parameter_name = $data_system.words.dex parameter_value = actor.dex when 5 parameter_name = $data_system.words.agi parameter_value = actor.agi when 6 parameter_name = $data_system.words.int parameter_value = actor.int end self.draw_text(x, y, 120, 32, parameter_name) self.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2) end #-------------------------------------------------------------------------- # * Make State Text String for Drawing #-------------------------------------------------------------------------- def make_battler_state_text(battler, width, need_normal) # Get width of brackets brackets_width = self.text_size('[]').width # Make text string for state names text = '' battler.states.each {|i| if $data_states[i].rating >= 1 if text == '' text = $data_states[i].name else new_text = text + '/' + $data_states[i].name text_width = self.text_size(new_text).width if text_width > width - brackets_width break end text = new_text end end } # If text string for state names is empty, make it [normal] if text == '' if need_normal text = '[Normal]' end else # Attach brackets text = '[' + text + ']' end # Return completed text string return text end #-------------------------------------------------------------------------- # * Draw State #-------------------------------------------------------------------------- def draw_actor_state(actor, x, y, width = 320) text = make_battler_state_text(actor, width, true) self.draw_text(x, y, width, 32, text) end #-------------------------------------------------------------------------- # * Draw Actor Exp #-------------------------------------------------------------------------- def draw_actor_exp(actor, x, y) self.draw_text(x, y, 80, 32, 'Exp') self.draw_text(x, y + 32, 80, 32, 'Next') self.draw_text(x + 80, y, 84, 32, actor.exp_s, 2) self.draw_text(x + 80, y + 32, 84, 32, actor.next_rest_exp_s, 2) end #-------------------------------------------------------------------------- # * Draw Item Name #-------------------------------------------------------------------------- def draw_item_name(item, x, y) if item == nil self.draw_text(x, y, 212, 32, '(Empty)') return end bitmap = RPG::Cache.icon(item.icon_name) self.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.draw_text(x + 28, y, 212, 32, item.name) endend # class Bitmap#============================================================================# ** Game_Map#----------------------------------------------------------------------------# Modified to load Map name#============================================================================class Game_Map # Alias map setup alias new_game_map_setup setup # Make map_name public attr_reader :map_name #-------------------------------------------------------------------------- # * New Setup #-------------------------------------------------------------------------- def setup(map_id) # Set up map new_game_map_setup(map_id) # Load Map info @map_name = (load_data('Data/MapInfos.rxdata'))[map_id].name endend#============================================================================# ** Game_System#----------------------------------------------------------------------------# Modified to make use of volume settings#============================================================================class Game_System # Alias initialize to create Settings alias new_settings_initialize initialize #-------------------------------------------------------------------------- # * Initialize #-------------------------------------------------------------------------- def initialize # Create settings object $settings = Settings.new new_settings_initialize end #-------------------------------------------------------------------------- # * Play Background Music # bgm : background music to be played #-------------------------------------------------------------------------- def bgm_play(bgm) @playing_bgm = bgm if bgm != nil && bgm.name != '' Audio.bgm_play('Audio/BGM/' + bgm.name, $settings.music_volume, bgm.pitch) else Audio.bgm_stop end Graphics.frame_reset end #-------------------------------------------------------------------------- # * Play Music Effect # me : music effect to be played #-------------------------------------------------------------------------- def me_play(me) if me != nil && me.name != '' Audio.me_play('Audio/ME/' + me.name, $settings.music_volume, me.pitch) else Audio.me_stop end Graphics.frame_reset end #-------------------------------------------------------------------------- # * Play Background Sound # bgs : background sound to be played #-------------------------------------------------------------------------- def bgs_play(bgs) @playing_bgs = bgs if bgs != nil && bgs.name != '' Audio.bgs_play('Audio/BGS/' + bgs.name, $settings.sound_volume, bgs.pitch) else Audio.bgs_stop end Graphics.frame_reset end #-------------------------------------------------------------------------- # * Play Sound Effect # se : sound effect to be played #-------------------------------------------------------------------------- def se_play(se) if se != nil && se.name != '' Audio.se_play('Audio/SE/' + se.name, $settings.sound_volume, se.pitch) end endend
      .
    • Guest
      By Guest
      Lately i started making a dungeon for my game but it doesn't seem you can die outside a battle o.O
      My health stays on 1 (that is displayed yellow)...
       
      So could someone make a script that made possible to die outside a battle?
      or does this already exist? I couldn't find one myself.
       
      (it must be compatible for rmxp)
       
      Thanks,
      mxmmix
×
×
  • Create New...