Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Drago Simple Mission Script
- # Version 1.00
- # Author : LiTTleDRAgo
- #==============================================================================
- module LiTTleDRAgo
- MISSION = []
- # icon = icon index dari iconset
- # Judul = judul dari mission
- # switch = switch yang perlu dinyalakan untuk memunculkan mission
- # variable = [id, result],
- # kalau value dari variable >= (result) maka mission completed
- # kalau value dari variable <= (-result) maka mission failed
- # deskripsi = yaa tau sendiri lah
- # commonevent = Common Event yang akan dieksekusi kalau claim reward
- MISSION[1] = { "icon" => 234,
- "judul" => "Find the cat",
- "switch" => 4,
- "variable" => [1,4],
- "deskripsi" => ["Kucingku hilang, tolong bantu aku mencarinya",
- "2nd line",
- "3rd line",
- "4th line",
- "5th line",
- "From : Lea"],
- "commonevent" => 1, }
- MISSION[4] = { "icon" => 234,
- "judul" => "Find the dog",
- "switch" => 8,
- "variable" => [1,4],
- "deskripsi" => ["Cari anjing sialan itu, hidup atau mati !!",
- "Bila ketemu langsung pancung saja kepalanya",
- "---",
- "",
- "",
- "From : Kakek penjaga toko"],
- "commonevent" => 2, }
- # cara panggil =
- # $scene = Scene_Mission.new
- #
- # cara merubah Available / Accepted di game pakai script
- # $game_self_switches[["MissionAccept",JUDUL DARI MISSION]] = true / false
- #
- # Dibawah cuma konfigurasi string doang, pasti ngerti lah
- MISSION_VOCAB = "Silahkan Pilih Mission"
- TEXT_VOCAB = ["Available", "Accepted", "Completed" , "Failed"]
- COMMAND_VOCAB = ["Accept?" ,"Abort?", "Claim Reward?"]
- end
- #==============================================================================
- # ** Dialog system
- #------------------------------------------------------------------------------
- # credit to Zeriab
- #==============================================================================
- class Dialog
- STARTING_Z_VALUE = 1500 # Default value is 1500
- attr_accessor :value
- attr_writer :marked_to_close
- #--------------------------------------------------------------------------
- # * Getter with 'false' as default value
- #--------------------------------------------------------------------------
- def marked_to_close
- @marked_to_close = false if @marked_to_close.nil?
- return @marked_to_close
- end
- #--------------------------------------------------------------------------
- # * Initialization
- #--------------------------------------------------------------------------
- def mark_to_close
- self.marked_to_close = true
- end
- #--------------------------------------------------------------------------
- # * Show the dialog
- # Returns the value from the dialog
- #--------------------------------------------------------------------------
- def self.show(*args, &block)
- dialog = self.new(*args, &block)
- dialog.marked_to_close = false
- return dialog.main
- end
- #--------------------------------------------------------------------------
- # * Initialization
- #--------------------------------------------------------------------------
- def initialize(*args, &block)
- # For subclasses to overwrite
- end
- #--------------------------------------------------------------------------
- # * Main processing
- #--------------------------------------------------------------------------
- def main
- # Create the dimmed background
- create_background
- # Create Windows
- main_window
- # Main loop
- loop do
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- # Abort loop if the dialog should close
- if marked_to_close
- break
- end
- end
- # Dispose of windows
- main_dispose
- # Dispose of background
- dispose_background
- # Update input information
- Input.update
- # Returns the acquired value
- return self.value
- end
- #--------------------------------------------------------------------------
- # * Create the dimmed background
- #--------------------------------------------------------------------------
- def create_background
- bitmap = Bitmap.new(640,480)
- bitmap.fill_rect(0,0,640,480,Color.new(0,0,0,128))
- @background_sprite = Sprite.new
- @background_sprite.z = STARTING_Z_VALUE
- @background_sprite.bitmap = bitmap
- end
- #--------------------------------------------------------------------------
- # * Create the windows
- #--------------------------------------------------------------------------
- def main_window
- # For the subclasses to override
- # Remember to set their z.value to at least STARTING_Z_VALUE + 1
- end
- #--------------------------------------------------------------------------
- # * Dispose the background
- #--------------------------------------------------------------------------
- def dispose_background
- @background_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # * Dispose the windows
- #--------------------------------------------------------------------------
- def main_dispose
- # For the subclasses to override
- # Dispose your windows here
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- # For the subclasses to override
- if Input.trigger?(Input::B)
- mark_to_close
- end
- end
- end
- #==============================================================================
- # * A Simple Yes/No dialog
- #----------------------------------------------------------------------------
- # credit to Zeriab
- #==============================================================================
- class Dialog_YesNo < Dialog
- # self.value: false = No, true = Yes
- #--------------------------------------------------------------------------
- # * A show method
- #--------------------------------------------------------------------------
- def initialize(default_value = false, text = nil)
- # Sets the default value
- self.value = default_value
- @text = text
- # Sets the menu index
- if default_value
- @menu_index = 0
- else
- @menu_index = 1
- end
- end
- #--------------------------------------------------------------------------
- # * Create the windows
- #--------------------------------------------------------------------------
- def main_window
- @disposables = []
- # The command window
- @command_window = Window_Command.new(80, ['Yes', 'No'])
- @command_window.index = @menu_index
- @command_window.x = (640 - @command_window.width) / 2
- @command_window.y = (480 - @command_window.height) / 2
- @command_window.z = STARTING_Z_VALUE + 1
- @disposables << @command_window
- # The text window
- if @text.is_a?(String)
- @text_window = Window_Help.new
- @text_window.set_text(@text, 1)
- @text_window.z = STARTING_Z_VALUE + 1
- @disposables << @text_window
- end
- end
- #--------------------------------------------------------------------------
- # * Dispose the windows
- #--------------------------------------------------------------------------
- def main_dispose
- @disposables.each {|element| element.dispose}
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- @command_window.update
- if Input.trigger?(Input::B)
- mark_to_close
- end
- if Input.trigger?(Input::C)
- if @command_window.index == 0
- self.value = true
- else
- self.value = false
- end
- mark_to_close
- end
- end
- end
- #==============================================================================
- # ** Window_Item
- #------------------------------------------------------------------------------
- # This window displays a list of inventory items for the item screen, etc.
- #==============================================================================
- class Window_Mission < Window_Selectable
- #--------------------------------------------------------------------------
- # * 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)
- @column_max = 1
- self.index = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get Item
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # * Whether or not to include in item list
- # item : item
- #--------------------------------------------------------------------------
- def include?(item)
- return false if item == nil
- return false if !$game_switches[item["switch"]]
- return true
- end
- #--------------------------------------------------------------------------
- # * Whether or not to display in enabled state
- # item : item
- #--------------------------------------------------------------------------
- def enable?(item)
- return true
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- @data = []
- (0..LiTTleDRAgo::MISSION.size).each {|i|
- next unless include?(LiTTleDRAgo::MISSION[i])
- @data.push(LiTTleDRAgo::MISSION[i])
- }
- @data.push(nil) if include?(nil)
- @item_max = @data.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- # index : item number
- #--------------------------------------------------------------------------
- def draw_item(index)
- rect = item_rect(index)
- self.contents.clear_rect(rect)
- item = @data[index]
- if item != nil
- enabled = enable?(item)
- rect.width -= 4
- draw_icon(item["icon"], rect.x, rect.y, enabled)
- self.contents.draw_text(rect.x+24, rect.y, rect.width, WLH, item["judul"])
- end
- end
- #--------------------------------------------------------------------------
- # * Update Help Text
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(LiTTleDRAgo::MISSION_VOCAB)
- end
- end
- #==============================================================================
- # ** Window_Status
- #------------------------------------------------------------------------------
- # This window displays full status specs on the status screen.
- #==============================================================================
- class Window_MissionStatus < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- # actor : actor
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh(s=nil)
- self.contents.clear
- return if s.nil?
- text = [s["deskripsi"],$game_self_switches[["MissionAccept",s["judul"]]],[]]
- self.contents.draw_text(0, 4+24*0, 284, WLH, text[0][0])
- self.contents.draw_text(0, 4+24*1, 284, WLH, text[0][1])
- self.contents.draw_text(0, 4+24*2, 284, WLH, text[0][2])
- self.contents.draw_text(0, 4+24*3, 284, WLH, text[0][3])
- self.contents.draw_text(0, 4+24*4, 284, WLH, text[0][4])
- self.contents.draw_text(0, 4+24*5, 284, WLH, text[0][5])
- if $game_variables[s["variable"][0]] >= s["variable"][1]
- text[2] = LiTTleDRAgo::TEXT_VOCAB[2]
- elsif $game_variables[s["variable"][0]] <= (s["variable"][1]*-1)
- text[2] = LiTTleDRAgo::TEXT_VOCAB[3]
- else
- text[2] = text[1] ? LiTTleDRAgo::TEXT_VOCAB[1] : LiTTleDRAgo::TEXT_VOCAB[0]
- end
- self.contents.draw_text(0, 300, 310, WLH, text[2],2)
- end
- end
- #==============================================================================
- # ** Scene_Item
- #------------------------------------------------------------------------------
- # This class performs the item screen processing.
- #==============================================================================
- class Scene_Mission < Scene_Base
- #--------------------------------------------------------------------------
- # * Start processing
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- @viewport = Viewport.new(0, 0, 544, 416)
- @help_window = Window_Help.new
- @help_window.viewport = @viewport
- @item_window = Window_Mission.new(0, 56, 544-360, 360)
- @item_window.viewport = @viewport
- @item_window.help_window = @help_window
- @item_window.active = false
- @target_window = Window_MissionStatus.new(544-360, 56, 360, 360)
- hide_target_window
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @viewport.dispose
- @help_window.dispose
- @item_window.dispose
- @target_window.dispose
- end
- #--------------------------------------------------------------------------
- # * Return to Original Screen
- #--------------------------------------------------------------------------
- def return_scene
- $scene = Scene_Menu.new(0)
- end
- #--------------------------------------------------------------------------
- # * Update Frame
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- @help_window.update
- [@item_window,@target_window].each {|w| w.update}
- if @item_window.active
- update_item_selection
- elsif @target_window.active
- update_target_selection
- end
- end
- #--------------------------------------------------------------------------
- # * Update Item Selection
- #--------------------------------------------------------------------------
- def update_item_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- return_scene
- elsif Input.trigger?(Input::C)
- @item = @item_window.item
- if @item != nil && $game_switches[@item["switch"]]
- Sound.play_decision
- determine_item
- else
- Sound.play_buzzer
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Confirm Item
- #--------------------------------------------------------------------------
- def determine_item
- show_target_window(@item_window.index % 2 == 0)
- end
- #--------------------------------------------------------------------------
- # * Update Target Selection
- #--------------------------------------------------------------------------
- def update_target_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @item_window.refresh
- hide_target_window
- elsif Input.trigger?(Input::C)
- if @item == nil
- Sound.play_buzzer
- elsif $game_variables[@item["variable"][0]] >= @item["variable"][1]
- if !$game_self_switches[["MissionReward",@item["judul"]]]
- Sound.play_decision
- v = Dialog_YesNo.show(true, LiTTleDRAgo::COMMAND_VOCAB[2])
- if v
- $game_self_switches[["MissionReward",@item["judul"]]] = true
- Sound.play_decision
- @target_window.refresh(@item)
- $game_temp.common_event_id = @item["commonevent"]
- $scene = Scene_Map.new
- else
- Sound.play_buzzer
- end
- else
- Sound.play_buzzer
- end
- elsif $game_variables[@item["variable"][0]] <= (@item["variable"][1]*-1)
- Sound.play_buzzer
- else
- if !$game_self_switches[["MissionAccept",@item["judul"]]]
- Sound.play_decision
- v = Dialog_YesNo.show(true, LiTTleDRAgo::COMMAND_VOCAB[0])
- if v
- $game_self_switches[["MissionAccept",@item["judul"]]] = true
- Sound.play_decision
- @target_window.refresh(@item)
- else
- Sound.play_buzzer
- end
- else
- Sound.play_decision
- v = Dialog_YesNo.show(true, LiTTleDRAgo::COMMAND_VOCAB[1])
- if v
- $game_self_switches[["MissionAccept",@item["judul"]]] = false
- Sound.play_decision
- @target_window.refresh(@item)
- else
- Sound.play_buzzer
- end
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Confirm Target
- # If there is no effect (such as using a potion on an incapacitated
- # character), play a buzzer SE.
- #--------------------------------------------------------------------------
- def determine_target
- used = false
- if @item.for_all?
- for target in $game_party.members
- target.item_effect(target, @item)
- used = true unless target.skipped
- end
- else
- $game_party.last_target_index = @target_window.index
- target = $game_party.members[@target_window.index]
- target.item_effect(target, @item)
- used = true unless target.skipped
- end
- if used
- use_item_nontarget
- else
- Sound.play_buzzer
- end
- end
- #--------------------------------------------------------------------------
- # * Show Target Window
- # right : Right justification flag (if false, left justification)
- #--------------------------------------------------------------------------
- def show_target_window(right)
- @item_window.active = false
- @target_window.visible = true
- @target_window.active = true
- @target_window.refresh(@item)
- end
- #--------------------------------------------------------------------------
- # * Hide Target Window
- #--------------------------------------------------------------------------
- def hide_target_window
- @item_window.active = true
- @target_window.visible = false
- @target_window.active = false
- @viewport.rect.set(0, 0, 544, 416)
- @viewport.ox = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement