#============================================================================== # VARIABLE_QUESTS # Author Molegato # Version 1.1 #------------------------------------------------------------------------------ # Just a simple menu where some variable-based quests are shown #------------------------------------------------------------------------------ # INSTRUCTIONS # # You map each quest to a variable # If the variable value is 0, the quest doesn't appear in the menu # If the variable value is 1, it appears as 'unsolved' # If the variable value is 2, it appears as 'active' # If the variable value is 3 or greater, it appears as 'solved' # # Any quest on 'unsolved' state can turn into 'active' by selecting it # on the quest menu, and only a single quest can be active at any time. # # To call the menu, use SceneManager.call(Scene_Quests) on a script call, # you can directly program it on your custom menu, or put it on a common # event attached to an item or skill, for making it easier to access. #============================================================================== $imported = {} if $imported.nil? $imported['Molegato-VarQuests'] = true #============================================================================== # CONFIGURATION, YOU CAN TOUCH THIS #============================================================================== module MOLEGATO_QUESTS # Enable quest activation? QUEST_ACTIVATION=true # text shown to indicate a quest is not cleared TEXT_UNSOLVED="-Aviable-" # text sown to indicate a quest is cleared TEXT_SOLVED="-Solved-" # text sown to indicate a quest is activated TEXT_ACTIVE="-Active-" # color of the text in both cases COLOR_SOLVED=1 COLOR_UNSOLVED=2 COLOR_ACTIVE=3 #list of quests. Please follow the pattern shown on the commentary. QUEST_DATA=[ #name #var. #icon #image #description #block for long text ["first quest" ,1 ,1 ,"" ,"this is a first quest set up for testing.", "yadda yadda yadda yadda more yadda yadda and a bit of bla bla blah"], ["second quest" ,2 ,2 ,"window" ,"just another quest", "yadda yadda yadda yadda more yadda yadda and a bit of bla bla blah"], ["super quest" ,3 ,3 ,"window" ,"whatever. just keep going", "yadda yadda yadda yadda more yadda yadda and a bit of bla bla blah"], ] end #============================================================================== # END OF CONFIGURATION. EVERYTHING UNDER HERE IS A HELLISH MESS OF DEFICIENT # AMATEUR SCRIPTING. BE AWARE THAT MESSING WITH IT CAN RESULT IN DISASTER #============================================================================== #============================================================================== # ■ Scene_quests #============================================================================== class Scene_Quests < Scene_MenuBase def start super create_help_window create_info_window create_item_window end #-------------------------------------------------------------------------- # ● create windows #-------------------------------------------------------------------------- def create_item_window @item_window = Window_QuestList.new(0, @help_window.height,Graphics.width/2,Graphics.height-@help_window.height) @item_window.viewport = @viewport @item_window.help_window = @help_window @item_window.set_handler(:cancel, method(:return_scene)) @item_window.set_handler(:pagedown, method(:next_actor)) @item_window.set_handler(:pageup, method(:prev_actor)) @item_window.set_handler(:ok, method(:activate_quest)) @item_window.active=true @info_window.window=@item_window @info_window.refresh end def create_info_window @info_window = Window_Quest_Status.new(Graphics.width/2,@help_window.height,Graphics.width/2,Graphics.height-@help_window.height) @info_window.viewport = @viewport end def update super @info_window.update end def activate_quest return if MOLEGATO_QUESTS::QUEST_ACTIVATION==false if $game_variables[@item_window.item[1]]==1 $game_variables[@item_window.item[1]]=2 elsif $game_variables[@item_window.item[1]]==2 $game_variables[@item_window.item[1]]=1 end MOLEGATO_QUESTS::QUEST_DATA.each do |each| $game_variables[each[1]]=1 if $game_variables[each[1]]==2 and each[1]!=@item_window.item[1] @item_window.activate @item_window.refresh @info_window.refresh end end end #============================================================================== # ■ Window_QuestList #============================================================================== class Window_QuestList < Window_Selectable def initialize(x, y, width, height) super refresh @index=0 if item_max>0 end def col_max return 1 end def item_max @data ? @data.size : 1 end def item @data && index >= 0 ? @data[index] : nil end def make_item_list @data = [] for i in 0..MOLEGATO_QUESTS::QUEST_DATA.size-1 if $game_variables[MOLEGATO_QUESTS::QUEST_DATA[i][1]]!=0 quest = MOLEGATO_QUESTS::QUEST_DATA[i] @data.push(quest) end end end def draw_item(index) current_item = @data[index] if current_item rect = item_rect(index) rect.width -= 4 rect.x+=24 enableicon=false enableicon=true if $game_variables[current_item[1]]>1 draw_icon(current_item[2],0,rect.y,enableicon) change_color(text_color(MOLEGATO_QUESTS::COLOR_ACTIVE)) if $game_variables[current_item[1]]==2 draw_text(rect, current_item[0]) change_color(normal_color) end end def update_help @help_window.set_text(item[4]) if item end def refresh make_item_list create_contents draw_all_items end end #============================================================================== # ■ Window_Quest_Status #============================================================================== class Window_Quest_Status < Window_Selectable attr_accessor :index attr_accessor :window def initialize(x, y, width, height) super @index=0 end def refresh contents.clear #draw quest name return if !window.item change_color(system_color) draw_text(0, 0, contents.width, line_height, window.item[0],1) #draw if solved if $game_variables[window.item[1]]>2 change_color(text_color(MOLEGATO_QUESTS::COLOR_SOLVED)) draw_text(0, line_height, contents.width, line_height, MOLEGATO_QUESTS::TEXT_SOLVED,0) elsif $game_variables[window.item[1]]>1 change_color(text_color(MOLEGATO_QUESTS::COLOR_ACTIVE)) draw_text(0, line_height, contents.width, line_height, MOLEGATO_QUESTS::TEXT_ACTIVE,0) else change_color(text_color(MOLEGATO_QUESTS::COLOR_UNSOLVED)) draw_text(0, line_height, contents.width, line_height, MOLEGATO_QUESTS::TEXT_UNSOLVED,0) end #draw image, if must if not window.item[3].empty? height_gap=draw_system(window.item[3],contents.width/2,48,0.5,0)[3] else height_gap=48 end #draw big text block change_color(normal_color) textarray=window.item[5].split("\n") for i in 0..textarray.size-1 draw_text(0,height_gap+(line_height*i),contents.width,line_height,textarray[i]) end end def update super if @index and @window and @index!=@window.index @index=@window.index refresh end end end