Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Jaberwocky's Quest Log
- # Mon Feb 26, 2007
- #------------------------------------------------------------------------------
- #
- # CONTROLS IN THE QUEST LOG:
- #
- # Up/Down arrows scroll through the list, Left/Right changes lists.
- #
- #------------------------------------------------------------------------------
- #
- # INSTALLING INTO THE MENU:
- #
- # To set up the quest log so it is accessed through your menu, you will need
- # to edit your Scene_Menu's 'main' and 'update_command' methods.
- #
- # Editing the 'main' method requires you to add an additional 'Quest' command
- # option and to perform any additional edits as required.
- #
- # And when you edit the 'update_command' method, you will insert a block of
- # code that includes the following statements:
- #
- # $game_temp.quest_menu_calling = true
- # $scene = Scene_Quests.new
- #
- #
- #------------------------------------------------------------------------------
- #
- # BRINGING UP THE QUEST LOG SCREEN THROUGH A SCRIPT CALL:
- #
- # You can call the quest log from a map. To do so, you will use script call
- # such as this: $scene = Scene_Quests.new
- #
- # That's really it.
- #
- #------------------------------------------------------------------------------
- #
- # TURNING ON/OFF QUESTS
- #
- # Activating quests and turning on/off switches in the system is easy.
- #
- # This system calls on a series of switch arrays created in the 'Game_Temp'
- # class that identifies which quests have been performed. By default, the
- # switch array accessed are 'qupdate' and 'qupdate2'.
- #
- # To activate a quest, you turn on a switch in the array after specifying the
- # number of the quest and an 'objective number' of 0 (zero). This is the
- # syntax of the script call:
- #
- # $game_temp.qupdate[Quest Number][Objective Number] = true
- #
- # So, to activate the third quest, use this: $game_temp.qupdate[3][0] = true
- #
- # Like I just stated, use an 'objective number' of 0.
- #
- # The quest number specifies the quest block in the list of quests, while the
- # objective number identifies the tasks to be performed in your quests. For
- # the objective number, setting 0 to 'true' will show the quest on the list.
- # And values of 1 on up are the goals for the quest.
- #
- # And these values can also be turned off by setting them to 'false'
- #
- # * * *
- #
- # If you have a second page of quests, such as 'completed' quests, that use
- # a 'qupdate2' value, you will use '$game_temp.qupdate2[Quest][Objective]'
- # in your script calls.
- #
- #------------------------------------------------------------------------------
- #
- # THE TWO PAGES OF LISTS (What lists??):
- #
- # By design, the system is set up to have only two lists of quests... the 1st
- # list being 'incomplete' quests (or quests in progress), and the 2nd list
- # being 'completed' quests. The second list is typically a 'near duplicate'
- # of the first list with subtle changes to show that the quest(s) were done.
- #
- # == This means the code for the first and second list are near identical ==
- #
- # Each list you access is its own class. You don't have to 'alias' anything,
- # or do any super-special editing other than what you'll be instructed herein.
- # The cool part is that each list of quests (completed or otherwise) can have
- # its own setup. Each list can have its own rendered background image and its
- # own collection of color choices for the text displayed.
- #
- #------------------------------------------------------------------------------
- #
- # ACCESSING A SPECIFIC PAGES OF LISTS:
- #
- # By general design, when you call the Quest Log, the system assumes you are
- # going to load the very first list, or list #1. Most of the time, this list
- # is the 'incomplete' list. But what if you want to access the second list?
- #
- # You can specify exactly which page of lists you wish to call by using the
- # 'Scene_Quest' script call as explained earlier, but with a minor change so
- # you can specify which page. Here's the syntax:
- #
- # $scene = Scene_Quests.new(list number)
- #
- # The 'list number' in the parentesis indicates which list to access. So if
- # you wish to access the second list, use '$scene = Scene_Quests.new(2)'
- #
- # NOTE: Certain changes to the script may be necessary if you have more than
- # two lists in your project.
- #
- #------------------------------------------------------------------------------
- #
- # MORE THAN TWO PAGE OF LISTS:
- #
- # Again... By design, the system is set up to have only 2 lists of quests...
- # the 1st list being 'incomplete' quests (or quests in progress), and the 2nd
- # list being 'completed' quests. The second list is typically a 'near dupli-
- # cate' of the first list with subtle changes to show that the quest(s) were
- # done.
- #
- # But, you can increase the number of lists, thereby increasing the number of
- # pages you can cycle through. It will take some work.
- #
- # * First, take note of the names of your 'quest pages', aka the code with
- # names such as Game_Quest, Game_Quest2, Game_Quest3... etc. It will be
- # necessary to reference them in the script itself. You will receive in-
- # structions on this soon.
- #
- # * How many pages have you created? Again, by design it is set up to have
- # only 2 lists of quests. But if you made three pages, then you will have
- # to add an additional set of switches in the Game_Temp class. If you look
- # in Game_Temp, you will see arrays such as 'qupdate' and 'qupdate2'. For
- # each additional quest page, you'll need to create an additional qupdate
- # array such as qupdate3. In Game_Temp, you will need to add it into the
- # Public Instance Variables (aka those attr_accessors), create it in the
- # initialize method, and then add it into the for i in 0... loop.
- #
- # * The next thing you will need to do is edit the script to allow you to
- # load and save the additional qupdate arrays you just created. These are
- # easy to do just by copying the Marshall.load and Marshall.dump lines you
- # will find in the script, and changing the qupdate names accordingly.
- #
- # * The nest step is to edit the 'initialize' method in Scene_Quests itself.
- # Look at the 'case...end' block of code. Right now, it only has two sets
- # of code, one that loads the data from the Game_Quest class into $qdata
- # and copies the qupdate array into the @quest_sw value, and the other
- # that copies the data from Game_Quest2.... etc. You will need to make a
- # 3rd case that copies your new page (Game_Quest3 ? ) into $qdata and have
- # it copy its qupdate3(?) array of switches into @quest_sw.
- #
- # * Finally, at the bottom of the script, in the 'update_command' method,
- # there are two blocks of code that are executed when you press the left
- # or right buttons. Within these are some 'case...end' blocks of code that
- # will reload the Quest Log based on the which page/list you are currently
- # using. So if you are currently on the 1st page/list of quests and hit
- # the [align=right] button, you should go to the 2nd page. You will want to add
- # additional code to allow you to switch to the 3rd page when you're cur-
- # rently on the 2nd page when pressing the [align=right] button, or switch to
- # the 3rd page when you're on the 1st one when hitting the [align=left] button.
- #
- # It'll take a little time to get it right for intermediate or beginner
- # scripters, but not too long. Good luck
- #
- #------------------------------------------------------------------------------
- #
- # TERMS:
- #
- # Credit Jaberwocky if you use this.
- #
- #==============================================================================
- module JABERWOCKY
- module_function
- # Quest Settings
- # General default settings to customize
- # your quest system and display.
- Quest_Max = 10 # Maximum number of quests
- Quest_Backgrd = "" # Optional 'nil' to use map as background
- Quest_Opacity = 240 # Opacity of quest screen
- Quest_Z = 990 # Adjustable Z-Depth for the quest screen
- # Quest Icons
- # The graphic icons that appear depending
- # on whether a goal has or hasn't been reached.
- # Must be placed in the Graphics\Icon folder.
- # ==Optional. May set to 'nil'==
- InProgress = "aktywne"
- Completed = "skonczone"
- # Coordinate Settings for the command window
- # This affects the command window system
- # and not the background image itself.
- QCommand_X = -10
- QCommand_Y = 50
- QCommand_Width = 182
- QCommand_Height = 380
- # Coordinate Settings for the description window
- # This affects the placement of the quest text
- # and not the background image itself.
- QDescrips_X = 160
- QDescrips_Y = 75
- QDescrips_Width = 480
- QDescrips_Height = 480
- end
- #==============================================================================
- # ** Bitmap
- #------------------------------------------------------------------------------
- # The bitmap class. Bitmaps are expressions of so-called graphics.
- #==============================================================================
- class Bitmap
- #--------------------------------------------------------------------------
- # * Object Initialization
- # x : x-coordinates
- # y : y-coordinates
- # width : window width
- # height : window height
- # align : text alignment
- # ouline : text outline color
- # inside : text interior color
- #--------------------------------------------------------------------------
- def draw_text_outline_custom(x, y, width, height, text, align, outline, inside)
- if $qdata.useoutlines == true
- self.font.color = outline
- draw_text(x + 1, y + 1, width, height, text, align)
- draw_text(x + 1, y - 1, width, height, text, align)
- draw_text(x - 1, y - 1, width, height, text, align)
- draw_text(x - 1, y + 1, width, height, text, align)
- end
- self.font.color = inside
- draw_text(x, y, width, height, text, align)
- end
- end
- #==============================================================================
- # ** Game_Temp
- #------------------------------------------------------------------------------
- # This class handles temporary data that is not included with save data.
- # Refer to "$game_temp" for the instance of this class.
- #==============================================================================
- class Game_Temp
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :map_bgm # map music (for battle memory)
- attr_accessor :qupdate # quest switch arrays
- attr_accessor :qupdate2 # quest switch arrays
- attr_accessor :quest_menu_calling # quest calling flag (menu)
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias asdfghjkl initialize
- def initialize
- # Perform the original call
- asdfghjkl
- # Create the quest switch arrays
- @qupdate = []
- @qupdate2 = []
- # Set the default call switch
- @quest_menu_calling = false
- # Increase the switch arrays to the number of quests
- for i in 0...JABERWOCKY::Quest_Max
- @qupdate[i] = []
- @qupdate2[i] = []
- end
- end
- end
- #==============================================================================
- # ** Window_Quest
- #------------------------------------------------------------------------------
- # This window displays the quest screen, including the descriptive text and
- # the goals for the quest in progress. Goals change colors and have an icon
- # next to them.
- #==============================================================================
- class Window_Quest < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, JABERWOCKY::QDescrips_Width, JABERWOCKY::QDescrips_Height)
- self.contents = Bitmap.new(width - 32, height - 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- # Set the line count to 0
- y = 0
- # For every line in the description array
- for i in 0...$qdata.desc[$scene.quest_id[$scene.command_window.index]].size
- # Draw each line of text
- self.contents.draw_text_outline_custom(2, 24 * y,
- JABERWOCKY::QDescrips_Width, 32, $qdata.desc[$scene.
- quest_id[$scene.command_window.index]][i], 0, $qdata.descoutline,
- $qdata.desctext)
- # Increase the line count
- y += 1
- end
- # For each line in the goal array
- for i in 0...$qdata.goals[$scene.quest_id[$scene.command_window.index]].size
- # Increase the line count
- y += 1
- # If this goal has been completed
- if $scene.quest_sw[$scene.quest_id[$scene.command_window.index]][i + 1]
- # Draw the completed icon if available
- unless JABERWOCKY::Completed == nil
- bitmap = RPG::Cache.icon(JABERWOCKY::Completed)
- self.contents.blt(0, 4 + ( y * 24) , bitmap, Rect.new(0, 0, 18, 18))
- end
- # Draw each line of text
- self.contents.draw_text_outline_custom(24, 0 + (y * 24),
- JABERWOCKY::QDescrips_Width-24, 24, $qdata.goals[$scene.
- quest_id[$scene.command_window.index]][i], 0, $qdata.compoutline,
- $qdata.comptext)
- # If this goal has not been reached
- else
- # Draw the incomplete icon if available
- unless JABERWOCKY::InProgress == nil
- bitmap = RPG::Cache.icon(JABERWOCKY::InProgress)
- self.contents.blt(0, 4 + ( y * 24) , bitmap, Rect.new(0, 0, 18, 18))
- end
- # Draw each line of text
- self.contents.draw_text_outline_custom(24, 0 + (y * 24),
- JABERWOCKY::QDescrips_Width-24, 24, $qdata.goals[$scene.
- quest_id[$scene.command_window.index]][i], 0, $qdata.incompoutline,
- $qdata.incomptext)
- end
- end
- end
- end
- #==============================================================================
- # ** Window_QCmand
- #------------------------------------------------------------------------------
- # This window displays the list of quests on the left.
- #==============================================================================
- class Window_Qmand < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- # width : window width
- # commands : command text string array
- #--------------------------------------------------------------------------
- def initialize(commands)
- super(JABERWOCKY::QCommand_X, JABERWOCKY::QCommand_Y,
- JABERWOCKY::QCommand_Width, JABERWOCKY::QCommand_Height)
- self.contents = Bitmap.new(width - 32, commands.size * 32)
- @commands = commands
- @item_max = @commands.size
- self.index = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- for i in 0...@commands.size
- self.contents.draw_text_outline_custom(0, 32 * i, self.contents.width, 32,
- @commands[i],1, $qdata.menuoutline, $qdata.menutext)
- end
- end
- end
- #==============================================================================
- # ** Scene_Save
- #------------------------------------------------------------------------------
- # This class performs save screen processing.
- #==============================================================================
- class Scene_Save < Scene_File
- #--------------------------------------------------------------------------
- # * Write Save Data
- # file : write file object (opened)
- #--------------------------------------------------------------------------
- alias qwertyuiop write_save_data
- def write_save_data(file)
- # Perform the original call
- qwertyuiop(file)
- # Save the quest switch data
- Marshal.dump($game_temp.qupdate, file)
- Marshal.dump($game_temp.qupdate2, file)
- end
- end
- #==============================================================================
- # ** Scene_Load
- #------------------------------------------------------------------------------
- # This class performs load screen processing.
- #==============================================================================
- class Scene_Load < Scene_File
- #--------------------------------------------------------------------------
- # * Read Save Data
- # file : file object for reading (opened)
- #--------------------------------------------------------------------------
- alias zxcvbnm read_save_data
- def read_save_data(file)
- # Perform the original call
- zxcvbnm(file)
- # Load the quest switch data
- $game_temp.qupdate = Marshal.load(file)
- $game_temp.qupdate2 = Marshal.load(file)
- end
- end
- #==============================================================================
- # ** Scene_Quests
- #------------------------------------------------------------------------------
- # This class performs quest screen processing.
- #==============================================================================
- class Scene_Quests
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :quest_id # quest ID numbers
- attr_accessor :command_window # command window
- attr_accessor :quest_sw # quest switches
- #--------------------------------------------------------------------------
- # * Object Initialization
- # list : quest list number
- #--------------------------------------------------------------------------
- def initialize(list = 1)
- @quest_index = 0
- @currentlist = list
- case list
- # HEREIN DECIDES WHICH PAGE TO SWITCH
- when 1 ; $qdata = Game_Quest.new
- @quest_sw = $game_temp.qupdate
- when 2 ; $qdata = Game_Quest2.new
- @quest_sw = $game_temp.qupdate2
- # ===================================
- end
- end
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- # Displays the background picture, or the map if set to nil
- if JABERWOCKY::Quest_Backgrd == nil
- @spriteset = Spriteset_Map.new
- else
- @backpic = Sprite.new
- @backpic.bitmap = RPG::Cache.picture(JABERWOCKY::Quest_Backgrd)
- @backpic.z = JABERWOCKY::Quest_Z
- end
- # Show the quest page's pic if available
- unless $qdata.backpicture == nil
- @questback = Sprite.new
- @questback.bitmap = RPG::Cache.picture($qdata.backpicture)
- @questback.opacity = JABERWOCKY::Quest_Opacity
- @questback.z = JABERWOCKY::Quest_Z + 1
- end
- # Create the quest arrays
- questwin = []
- @quest_id = []
- # Increase the switch arrays to the number of quests
- for i in 1...JABERWOCKY::Quest_Max
- if @quest_sw[i][0] == true
- questwin.push($qdata.name[i])
- @quest_id.push(i)
- end
- end
- # Add the quest names to the command window array
- if questwin.size == 0
- questwin.push($qdata.name[0])
- @quest_id.push(0)
- end
- # Create the quest command window
- @command_window = Window_Qmand.new(questwin)
- @command_window.index = @quest_index
- @command_window.opacity = 0
- @command_window.z = JABERWOCKY::Quest_Z + 2
- # Create the window for the description text and goals:
- @desc_window = Window_Quest.new
- @desc_window.x = JABERWOCKY::QDescrips_X
- @desc_window.y = JABERWOCKY::QDescrips_Y
- @desc_window.z = JABERWOCKY::Quest_Z + 2
- @desc_window.opacity = 0
- # Execute transition
- Graphics.transition
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update_command
- # Abort loop if screen is changed
- break if $scene != self
- end
- # Dispose of the command and description windows
- @command_window.contents.clear
- @command_window.dispose
- @desc_window.contents.clear
- @desc_window.dispose
- # Dispose the background picture or spritesheet
- if JABERWOCKY::Quest_Backgrd == nil
- @spriteset.dispose
- else
- @backpic.dispose
- end
- # Dispose the quest page picture if it exists
- unless $qdata.backpicture == nil
- @questback.dispose unless @questback == nil
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update (when command window is active)
- #--------------------------------------------------------------------------
- def update_command
- # If the up directional button was pressed
- if Input.repeat?(Input::UP)
- if @command_window.index == 0
- @command_window.index = @quest_id.size - 1
- else
- @command_window.index -= 1
- end
- unless @quest_id.size == 1
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se) unless @quest_id.size == 1
- # Refresh the description window
- @desc_window.refresh
- end
- end
- # If the down directional button was pressed
- if Input.repeat?(Input::DOWN)
- if @command_window.index == @quest_id.size - 1
- @command_window.index = 0
- else
- @command_window.index += 1
- end
- unless @quest_id.size == 1
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se)
- # Refresh the description window
- @desc_window.refresh
- end
- end
- # If B button was pressed
- if Input.trigger?(Input::B)
- # Play cancel SE
- $game_system.se_play($data_system.cancel_se)
- # If called from the menu
- if $game_temp.quest_menu_calling
- # Clear save call flag
- $game_temp.quest_menu_calling = false
- # Switch to the menu screen
- $scene = Scene_Menu.new(4)
- return
- end
- # Switch to the map screen
- $scene = Scene_Map.new
- return
- end
- # If the left directional button was pressed
- if Input.trigger?(Input::LEFT)
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se)
- # Dispose the quest page picture if it exists
- @questback.dispose unless $qdata.backpicture == nil
- # Branch by currently loaded quest page
- case @currentlist
- # HEREIN DECIDES WHICH PAGE TO SWITCH
- when 1 ; $scene = Scene_Quests.new(2)
- when 2 ; $scene = Scene_Quests.new(1)
- # ===================================
- end
- end
- # If the right directional button was pressed
- if Input.trigger?(Input::RIGHT)
- # Play cursor SE
- $game_system.se_play($data_system.cursor_se)
- # Dispose the quest page picture if it exists
- @questback.dispose unless $qdata.backpicture == nil
- # Branch by currently loaded quest page
- case @currentlist
- # HEREIN DECIDES WHICH PAGE TO SWITCH
- when 1 ; $scene = Scene_Quests.new(2)
- when 2 ; $scene = Scene_Quests.new(1)
- # ===================================
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement