Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # Drago Simple Mission Script
- # Version 2.50
- # 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
- # misal = [1,4]
- # kalau value dari variable 1 = 4 (atau lebih besar) -> completed
- # kalau value dari variable 1 = -4 (atau lebih kecil) -> fail
- #
- # deskripsi = yaa tau sendiri lah
- # gambar = file gambar yang diselipkan di kanan atas board, ga wajib
- # commonevent = Common Event yang akan dieksekusi kalau claim reward
- MISSION[1] = { "icon" => 94,
- "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"],
- "gambar" => "test",
- "commonevent" => 1, }
- MISSION[2] = { "icon" => 54,
- "judul" => "Find the dog",
- "switch" => 8,
- "variable" => [2,4],
- "deskripsi" => ["Cari anjing sialan itu, hidup atau mati !!",
- "Bila ketemu langsung pancung saja kepalanya",
- "",
- "",
- "",
- "From : Kakek penjaga toko"],
- "commonevent" => 2, }
- # Transparency dari menu, makin kecil angkanya makin transparan
- BACK_OPACITY = 200
- # Posisi gambar X, Y, WIDTH, HEIGHT
- GAMBAR = [180,0,180,130]
- # cara panggil =
- # $scene = Scene_Mission.new
- #
- # cara merubah Ambil Request di game pakai script
- # change_accepted(mission_id, value=true)
- #
- # cara merubah Ambil Reward di game pakai script
- # change_claimed(mission_id, value=true)
- #
- # cara check mission sedang diambil atau tidak dengan call script
- # mission_accepted?(mission_id)
- #
- # cara check mission sudah diambil rewardnya atau tidak dengan call script
- # mission_claimed?(mission_id)
- #
- # Dibawah cuma konfigurasi string doang, pasti ngerti lah
- MISSION_VOCAB = "Silahkan Pilih Mission"
- TEXT_VOCAB = ["Unavailable",
- "Available",
- "Accepted",
- "Completed",
- "Failed",
- "Reward Accepted",]
- COMMAND_VOCAB = ["Take this request?" ,
- "Abort this request?",
- "Claim Reward?",]
- HEADER_BOARD = ["Mission Board"]
- HEADER_MENU = ["No.","Request Name","Status"]
- end
- #==============================================================================
- # ** Game_Interpreter
- #------------------------------------------------------------------------------
- # An interpreter for executing event commands. This class is used within the
- # Game_Map, Game_Troop, and Game_Event classes.
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # * Change Accepted
- #--------------------------------------------------------------------------
- def change_accepted(mission_id, value=true)
- task = LiTTleDRAgo::MISSION[mission_id]
- $game_self_switches[["MissionAccept",task["judul"]]] = value
- end
- #--------------------------------------------------------------------------
- # * Change Claimed
- #--------------------------------------------------------------------------
- def change_claimed(mission_id, value=true)
- task = LiTTleDRAgo::MISSION[mission_id]
- $game_self_switches[["MissionReward",task["judul"]]] = value
- end
- #--------------------------------------------------------------------------
- # * Mission Accepted?
- #--------------------------------------------------------------------------
- def mission_accepted?(mission_id)
- task = LiTTleDRAgo::MISSION[mission_id]
- return $game_self_switches[["MissionAccept",task["judul"]]]
- end
- #--------------------------------------------------------------------------
- # * Mission Claimed?
- #--------------------------------------------------------------------------
- def mission_claimed?(mission_id)
- task = LiTTleDRAgo::MISSION[mission_id]
- return $game_self_switches[["MissionReward",task["judul"]]]
- end
- 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 if the dialog should not close
- while !marked_to_close
- # Update game screen
- Graphics.update
- # Update input information
- Input.update
- # Frame update
- update
- 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 = (Graphics.width - @command_window.width) / 2
- @command_window.y = (Graphics.height - @command_window.height) / 2
- @command_window.z = STARTING_Z_VALUE + 50
- @command_window.opacity = 0
- @command_window.back_opacity = 0
- @disposables << @command_window
- # The text window
- if @text.is_a?(String)
- pos = [@command_window.x, @command_window.y]
- wh = [@command_window.width, @command_window.height]
- @text_window = Window_MissionStatus.new(pos[0]-50,pos[1]-50,wh[0]+100,wh[1]+50)
- @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+50, width, height-50)
- self.back_opacity = 0
- self.opacity = 0
- @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 true
- end
- #--------------------------------------------------------------------------
- # * Whether or not to display in enabled state
- # item : item
- #--------------------------------------------------------------------------
- def enable?(item)
- return false if !$game_switches[item["switch"]]
- 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
- fontsize = self.contents.font.size
- create_contents
- self.contents.font.color = system_color
- self.contents.font.size = 16
- for i in 0...@item_max
- draw_item(i)
- end
- self.contents.font.color = normal_color
- self.contents.font.size = fontsize
- 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+24, rect.y, enabled) if item["icon"]
- text = enabled ? (item["judul"] ? item["judul"] : "???") : "???"
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- self.contents.draw_text(rect.x, rect.y, 200, WLH, sprintf("%02d", index))
- self.contents.draw_text(rect.x+24+24, rect.y, 200, WLH, text)
- if enabled
- if $game_variables[item["variable"][0]] >= item["variable"][1]
- self.contents.font.color = Color.new(0,255,0,255)
- text = LiTTleDRAgo::TEXT_VOCAB[3]
- elsif $game_variables[item["variable"][0]] <= (item["variable"][1]*-1)
- self.contents.font.color = crisis_color
- text = LiTTleDRAgo::TEXT_VOCAB[4]
- else
- if $game_self_switches[["MissionAccept",item["judul"]]]
- self.contents.font.color = Color.new(0,255,255,255)
- text = LiTTleDRAgo::TEXT_VOCAB[2]
- else
- text = LiTTleDRAgo::TEXT_VOCAB[1]
- end
- end
- else
- text = LiTTleDRAgo::TEXT_VOCAB[0]
- end
- self.contents.draw_text(rect.x, rect.y, 315, WLH, text,2)
- 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)
- self.back_opacity = LiTTleDRAgo::BACK_OPACITY
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh(s=nil)
- self.contents.clear
- return if s.nil?
- s == 'Header' ? mission_header(s) : mission_description(s)
- end
- #--------------------------------------------------------------------------
- # * Mission Header
- #--------------------------------------------------------------------------
- def mission_header(s)
- fontsize = self.contents.font.size
- self.contents.font.color = system_color
- self.contents.font.size = 16
- s = LiTTleDRAgo::HEADER_MENU
- self.contents.draw_text(0, 0, 315, WLH, LiTTleDRAgo::HEADER_BOARD,1)
- self.contents.draw_text(0, 30, 315, WLH, "#{s[0]} #{s[1]}",0)
- self.contents.draw_text(0, 30, 315, WLH, "#{s[2]}",2)
- self.contents.font.color = normal_color
- self.contents.font.size = fontsize
- end
- #--------------------------------------------------------------------------
- # * Mission Description
- #--------------------------------------------------------------------------
- def mission_description(s)
- fontsize = self.contents.font.size
- self.contents.font.size = 16
- if s["gambar"]
- g = LiTTleDRAgo::GAMBAR
- bitmap = Cache.picture(s["gambar"])
- src_rect = Rect.new(g[0], g[1], g[2], g[3])
- self.contents.stretch_blt(src_rect, bitmap, bitmap.rect)
- end
- text = [s["deskripsi"], s["variable"], ["MissionAccept",s["judul"]]]
- text[3] = [LiTTleDRAgo::TEXT_VOCAB, $game_variables[text[1][0]]]
- (0..text[0].size).each {|i|
- self.contents.draw_text(0, 4+24*i, 284, WLH, text[0][i]) } if text[0]
- if text[3][1] >= text[1][1]
- self.contents.font.color = Color.new(0,255,0,255)
- text[5] = text[3][0][3]
- elsif text[3][1] <= (text[1][1]*-1)
- self.contents.font.color = crisis_color
- text[5] = text[3][0][4]
- else
- if $game_self_switches[text[2]]
- self.contents.font.color = Color.new(0,255,255,255)
- text[5] = text[3][0][2]
- else
- text[5] = text[3][0][1]
- end
- end
- self.contents.draw_text(0, 200, 320, WLH, text[5],2)
- if $game_self_switches[["MissionReward",s["judul"]]]
- self.contents.draw_text(0, 200, 320, WLH, text[3][0][5],0)
- end
- self.contents.font.color = normal_color
- self.contents.font.size = fontsize
- end
- #--------------------------------------------------------------------------
- # * Set Text
- # text : character string displayed in window
- # align : alignment (0..flush left, 1..center, 2..flush right)
- #--------------------------------------------------------------------------
- def set_text(text, align = 0)
- if text != @text or align != @align
- self.contents.clear
- self.contents.font.color = normal_color
- self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
- @text = text
- @align = align
- end
- 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)
- @item_window = []
- @item_window[0] = Window_Help.new
- @item_window[0].viewport = @viewport
- @item_window[1] = Window_Mission.new(100, 86, 360, 260)
- @item_window[1].viewport = @viewport
- @item_window[1].help_window = @item_window[0]
- @item_window[1].active = false
- @item_window[2] = Window_MissionStatus.new(100, 86, 360, 260)
- @item_window[3] = Window_MissionStatus.new(100, 86, 360, 260)
- @item_window[3].refresh('Header')
- @item_window[3].z -= 400
- @menuback_sprite.z -= 400
- show_target_window(false)
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- @viewport.dispose
- @item_window.each {|i| i ? i.dispose : nil }
- end
- #--------------------------------------------------------------------------
- # * Return to Original Screen
- #--------------------------------------------------------------------------
- def return_scene
- $scene = Scene_Map.new
- end
- #--------------------------------------------------------------------------
- # * Update Frame
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- (0..2).each {|w| @item_window[w].update }
- if @item_window[1].active
- update_item_selection
- elsif @item_window[2].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[1].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(true)
- end
- #--------------------------------------------------------------------------
- # * Update Target Selection
- #--------------------------------------------------------------------------
- def update_target_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @item_window[1].refresh
- show_target_window(false)
- elsif Input.trigger?(Input::C)
- v = [$game_variables[@item["variable"][0]], @item["variable"][1] ]
- if @item == nil
- Sound.play_buzzer
- elsif v[0] >= v[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
- @item_window[2].refresh(@item)
- $game_temp.common_event_id = @item["commonevent"]
- $scene = Scene_Map.new
- else
- Sound.play_cancel
- end
- else
- Sound.play_buzzer
- end
- elsif v[0] <= (v[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
- @item_window[1].refresh
- @item_window[2].refresh(@item)
- show_target_window(false)
- else
- Sound.play_cancel
- 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
- @item_window[1].refresh
- @item_window[2].refresh(@item)
- show_target_window(false)
- else
- Sound.play_cancel
- end
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Show Target Window
- # right : Right justification flag (if false, left justification)
- #--------------------------------------------------------------------------
- def show_target_window(value)
- @item_window[1].active = !value
- @item_window[2].visible = value
- @item_window[2].active = value
- if value
- @item_window[2].refresh(@item)
- else
- @viewport.rect.set(0, 0, 544, 416)
- @viewport.ox = 0
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement