Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Simple Journal
- # Author: Nicke
- # Created: 08/13/2011
- # Edited: 08/16/2011
- # Version: 1.0b
- #==============================================================================
- # Instructions
- # -----------------------------------------------------------------------------
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
- # -----------------------------------------------------------------------------
- #
- # To open Simple Journal use: $scene = Scene_Simple_Journal.new <- In your menu.
- #
- # Use the call script function to add, remove or complete a quest.
- # Quick example:
- # add_quest(id,type)
- #
- # add_quest(1,:main)
- # add_quest(0,:side)
- # complete_quest(0,:side)
- # fail_quest(1,:main)
- #
- # Note:
- # In Main quests you should only add 1 quest each time as it is
- # designed that way. However, to make main quest act like side quest page
- # simply set SCROLL_MAIN_QUESTS to true.
- # Every quest stores a variable if it is being completed or failed which then
- # can be used as you want.
- #
- #==============================================================================
- ($imported ||= {})["NICKE-SIMPLE-JOURNAL"] = true
- module NICKE
- module JOURNAL_SYSTEM
- # --------------------------------------------------------------------------
- # General settings.
- WIDTH = Graphics.width # Change the width of the journal window.
- HEIGHT = Graphics.height # Change the height of the journal window.
- FONT_TYPE = ["Rockwell", "Arial"] # Font type.
- TITLE = "Journal" # Journal title text.
- FOOTER = "Use Left/Right to change page." # Footer text.
- NO_ENTRIES = "No entries added..." # If no quest added show this text.
- COMPLETE_QUEST_VAR = 1 # Variable to store completed quests
- FAILED_QUEST_VAR = 2 # Variable to store failed quests.
- SCROLL_MAIN_QUESTS = false # Scroll at Main Quests too?
- # Note: If true, footer will be hidden.
- BUTTON_LEFT_PAGE = Input::LEFT # Button to change page to the left.
- BUTTON_RIGHT_PAGE = Input::RIGHT # Button to change page to the right.
- BACKGROUND_IMAGE_ACTIVE = false # Use a background image?
- BACKGROUND_IMAGE = "journal" # Background image file name.
- # Note: You might need to tweak the height and the position of the window
- # in order for it to be working smoothly with the slider.
- RETURN_TO_MAP = false # On terminate, go back to map instead?
- # --------------------------------------------------------------------------
- # Color, size and shadow.
- T_FONT_SIZE = 26 # Title font size.
- T_FONT_COLOR = Color.new(223,255,80) # Title font color.
- T_FONT_SHADOW = true # Title font shadow.
- QUEST_HEADER_SIZE = 20 # Quest Header font size.
- QUEST_HEADER_COLOR = Color.new(135,206,250) # Quest Header font color.
- QUEST_HEADER_SHADOW = true # Quest Header font shadow.
- QUEST_DETAILS_SIZE = 16 # Quest Details font size.
- QUEST_DETAILS_COLOR = Color.new(245,245,245) # Quest Details font color.
- QUEST_DETAILS_SHADOW = true # Quest Details font shadow.
- H_FONT_SIZE = 20 # Header font size.
- H_FONT_COLOR = Color.new(223,255,80) # Header font color.
- H_FONT_SHADOW = true # Header font shadow.
- F_FONT_SIZE = 18 # Footer font size.
- F_FONT_COLOR = Color.new(223,255,80) # Footer font color.
- F_FONT_SHADOW = true # Footer font shadow.
- NO_E_FONT_SIZE = 18 # No entries font size.
- NO_E_FONT_COLOR = Color.new(235,235,160) # No entries font color.
- NO_E_FONT_SHADOW = true # No entries font shadow.
- # --------------------------------------------------------------------------
- # MAIN QUESTS.
- # Main Quest[Index] = [Icon, "Title", "Details"]
- MAIN_Q_HEADER = "Main Quests" # Header text for Main quests.
- MAIN_QUESTS = [] # Don't touch it!
- MAIN_QUESTS[0] = [15, "The Terror in Townsil", "Travel to Townsil and talk to captain awesome."]
- MAIN_QUESTS[1] = [15, "The Terror in Townsil", "Search the town for clues."]
- MAIN_QUESTS[2] = [15, "The Terror in Townsil", "Go back to captain awesome and explain that the situation is crucial."]
- # --------------------------------------------------------------------------
- # SIDE QUESTS.
- # SIDE Quest[Index] = [Icon, "Title", "Details"]
- SIDE_Q_HEADER = "Side Quests" # Header text for Side quests.
- SIDE_QUESTS = [] # Don't touch it!
- SIDE_QUESTS[0] = [12, 'Kill the Orcs.', 'Hunt down ten orcs and kill them.']
- SIDE_QUESTS[1] = [75, 'Aid the doctor.', 'Help the doctor by finding the missing herbs.']
- SIDE_QUESTS[2] = [138, 'Find the forgotten girl.', 'Locate the missing girl in the woods.']
- SIDE_QUESTS[3] = [44, 'Armour Reparing.', 'Talk to the local blacksmith to get the armour fixed.']
- SIDE_QUESTS[4] = [151, 'Special Delivery.', 'Take the box filled with unique materials to the mayor in town.']
- SIDE_QUESTS[5] = [64, 'Brew a potion.', 'Gather the missing ingrediens for the health potion.']
- SIDE_QUESTS[6] = [22, 'Solve the bandit problem.', 'Track down and get rid of the bandits that lurks within the deep forest.']
- # --------------------------------------------------------------------------
- end
- end
- # *** Don't edit below unless you know what you are doing. ***
- class Game_System
- attr_accessor :main_quests
- attr_accessor :side_quests
- attr_accessor :completed_quests
- attr_accessor :failed_quests
- alias nicke_quest_initialize initialize unless $@
- def initialize(*args, &block)
- nicke_quest_initialize(*args, &block)
- @main_quests = []
- @side_quests = []
- @completed_quests = [] # Going to be used later on.
- @failed_quests = [] # Going to be used later on.
- end
- end
- class Game_Interpreter
- include NICKE::JOURNAL_SYSTEM
- def add_quest(id, type)
- # Method to add a quest.
- case type
- when :main # Main quests.
- unless $game_system.main_quests.include?(MAIN_QUESTS[id])
- $game_system.main_quests.push(MAIN_QUESTS[id])
- end unless MAIN_QUESTS[id].nil?
- when :side # Side quests.
- unless $game_system.side_quests.include?(SIDE_QUESTS[id])
- $game_system.side_quests.push(SIDE_QUESTS[id])
- end unless SIDE_QUESTS[id].nil?
- end
- end
- def complete_quest(id, type)
- # Method to complete a quest.
- case type
- when :main # Main quests.
- if $game_system.main_quests.include?(MAIN_QUESTS[id])
- $game_system.main_quests.delete(MAIN_QUESTS[id])
- $game_system.completed_quests.push(MAIN_QUESTS[id])
- $game_variables[COMPLETE_QUEST_VAR] += 1
- end
- when :side # Side quests.
- if $game_system.side_quests.include?(SIDE_QUESTS[id])
- $game_system.side_quests.delete(SIDE_QUESTS[id])
- $game_system.completed_quests.push(SIDE_QUESTS[id])
- $game_variables[COMPLETE_QUEST_VAR] += 1
- end
- end
- end
- def fail_quest(id, type)
- # Method for quest failed.
- case type
- when :main # Main quests.
- unless MAIN_QUESTS[id].nil?
- $game_system.main_quests.delete(MAIN_QUESTS[id])
- $game_system.failed_quests.push(MAIN_QUESTS[id])
- $game_variables[FAILED_QUEST_VAR] += 1
- end
- when :side # Side quests.
- unless SIDE_QUESTS[id].nil?
- $game_system.side_quests.delete(SIDE_QUESTS[id])
- $game_system.failed_quests.push(SIDE_QUESTS[id])
- $game_variables[FAILED_QUEST_VAR] += 1
- end
- end
- end
- end
- class Scene_Simple_Journal < Scene_Base
- include NICKE::JOURNAL_SYSTEM
- def start
- # Create the bg if true and make a new instance of Window_Simple_Journal.
- super()
- @journal_window = Window_Simple_Journal.new(true)
- if BACKGROUND_IMAGE_ACTIVE == true
- create_bg
- @journal_window.opacity = 0
- end
- end
- def create_bg
- # Method for creating the background image.
- @bg = Sprite.new
- @bg.bitmap = Cache.picture(BACKGROUND_IMAGE)
- end
- def update
- super
- # Method for checking input triggers.
- if Input.trigger?(Input::B)
- Sound.play_cancel
- if RETURN_TO_MAP == true
- $scene = Scene_Map.new
- else
- $scene = Scene_Menu.new(0)
- end
- elsif Input.trigger?(BUTTON_LEFT_PAGE) || Input.trigger?(BUTTON_RIGHT_PAGE)
- Sound.play_decision
- main = @journal_window.main
- @journal_window.dispose
- @journal_window = Window_Simple_Journal.new(!main)
- elsif Input.trigger?(Input::UP)
- y = @journal_window.oy
- @journal_window.oy = [y - 52, 0].max
- elsif Input.trigger?(Input::DOWN)
- return if @journal_window.contents.height < @journal_window.height
- y = @journal_window.oy
- @journal_window.oy = [y + 52, @journal_window.height - y + 16].min
- end
- @journal_window.opacity = 0 if BACKGROUND_IMAGE_ACTIVE == true
- end
- def terminate(*args, &block)
- # Method for disposing the bg and the journal window.
- super
- @journal_window.dispose
- @bg.dispose if BACKGROUND_IMAGE_ACTIVE == true
- end
- end
- class Window_Simple_Journal < Window_Base
- include NICKE::JOURNAL_SYSTEM
- attr_reader :main
- def initialize(main = true)
- super(0,0,WIDTH, HEIGHT)
- @main = main
- # This will allow scrolling if there are too many items.
- if !@main
- self.contents = Bitmap.new(self.width - 32, HEIGHT - 56 + ($game_system.side_quests.size - 1) * WLH)
- else
- self.contents = Bitmap.new(self.width - 32, HEIGHT - 56 + ($game_system.main_quests.size - 1) * WLH) unless SCROLL_MAIN_QUESTS != true
- end
- refresh
- end
- def refresh
- self.contents.clear
- # Add Graphics.
- addGraphics
- # Add Quests.
- addQuests
- end
- def self_rect
- # Return the value of contents rect.
- return self.contents.rect
- end
- def draw_text(x, y, text, align)
- # Method for drawing the text.
- title = self_rect
- title.x = x
- title.y = y
- title.height = 28
- self.contents.draw_text(title,text,align)
- end
- def draw_line(x, y)
- # Create two lines actually, one is acting like the shadow.
- line = self_rect
- line.height = 1
- line.width -= 10
- line.x = x
- line.y = y
- self.contents.fill_rect(line,normal_color)
- line.y += 1
- color = Color.new(0,0,0,200)
- self.contents.fill_rect(line,color)
- end
- def addQuests
- if @main
- # Fill it with the current main quest data.
- quests = $game_system.main_quests
- else
- # Fill it with the current side quest data.
- quests = $game_system.side_quests
- end
- # If no quests have been added show no entries instead.
- if quests.empty?
- contents.font.name = FONT_TYPE
- contents.font.size = NO_E_FONT_SIZE
- contents.font.color = NO_E_FONT_COLOR
- contents.font.shadow = NO_E_FONT_SHADOW
- draw_text(0, 160, NO_ENTRIES, 1)
- return
- end
- yoff = WLH * 2
- quests.each_with_index { |q, i|
- draw_icon( q[0], 0, i * yoff + 84) ;
- # Font, size, color & shadow.
- contents.font.name = FONT_TYPE
- contents.font.size = QUEST_HEADER_SIZE
- contents.font.color = QUEST_HEADER_COLOR
- contents.font.shadow = QUEST_HEADER_SHADOW
- self.contents.draw_text(10, 68 + i * yoff, self.contents.width - 16, WLH, q[1], 1)
- contents.font.name = FONT_TYPE
- contents.font.size = QUEST_DETAILS_SIZE
- contents.font.color = QUEST_DETAILS_COLOR
- contents.font.shadow = QUEST_DETAILS_SHADOW
- self.contents.draw_text(27, 60 + (i * yoff)+WLH, self.contents.width - 16, WLH, q[2])
- }
- end
- def addGraphics
- # Method for drawing the graphics and some headers.
- self.contents.font.name = FONT_TYPE
- self.contents.font.size = T_FONT_SIZE
- self.contents.font.color = T_FONT_COLOR
- self.contents.font.shadow = T_FONT_SHADOW
- draw_text(0, 0, TITLE, 1) if BACKGROUND_IMAGE_ACTIVE != true
- self.contents.font.name = FONT_TYPE
- self.contents.font.size = H_FONT_SIZE
- self.contents.font.color = H_FONT_COLOR
- self.contents.font.shadow = H_FONT_SHADOW
- if @main
- draw_text(0, 42, MAIN_Q_HEADER, 1)
- self.contents.font.name = FONT_TYPE
- self.contents.font.size = F_FONT_SIZE
- self.contents.font.color = F_FONT_COLOR
- self.contents.font.shadow = F_FONT_SHADOW
- draw_text(0,360, FOOTER, 1) unless SCROLL_MAIN_QUESTS == true
- draw_line(5,356) unless SCROLL_MAIN_QUESTS == true
- else
- draw_text(0, 42, SIDE_Q_HEADER, 1)
- end
- draw_line(5,36) if BACKGROUND_IMAGE_ACTIVE != true
- end
- end # END OF FILE
- #=*==========================================================================*=#
- # ** END OF FILE
- #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement