I have spent hours and finally realized whats been causing the event pages to repeat itself. Furthermore, I've also realized that the overlay script from Yami's have already taken up switches, and hence why events will not happen when a condition switch is turned on from 1- 5.
But now its a different story.
No matter what switches I use, to redirect an event to a second page, the first page only keeps repeating itself. I have deducted the cause of this to three scripts.
when I say these three scripts, I mean, if you take em out of the script list, the events function as normal as day.
But now its a different story.
No matter what switches I use, to redirect an event to a second page, the first page only keeps repeating itself. I have deducted the cause of this to three scripts.
when I say these three scripts, I mean, if you take em out of the script list, the events function as normal as day.
Code:
#===============================================================================# Quest System# By Lecode# For Strashiner# ------------------------------------------------------------------------------# Terms of Use:# ------------------------------------------------------------------------------# -Credit is required (Lecode)# -For Strashiner project only# ------------------------------------------------------------------------------# ...#===============================================================================module Lecode module StrashQuestSystem Quests = { "Mysterious herbs" => { id: 1, icon: 201, description: "The town herbalist is looking for some medicinal plants. "+ "Eldeweiss can be found on high mountains.", objectives: [ ["Collect 6 Medicinal Herbs","item?(18,6)"], ["Collect 2 Edelweiss","item?(19,2)"], ["Report to the Herbalist","switch?(1)"] ], rewards: [ [:exp,600],[:gold,3000],[:item,1,6],[:item,2,4] ,[:item,3,2] ], abandonable: true, difficulty: 2, recom_lvl: 1, story: false }, "Defend the town" => { id: 2, icon: 9, description: "The guards is looking for someone to help "+ "to keep away the goblins.", objectives: [ ["Kill 2 Goblins","enemy?(3,2)"], ["Kill 1 Chef Goblins","enemy?(4,1)"], ["Report to the Guard Capitaine","switch?(2)"] ], rewards: [ [:exp,12000],[:gold,30000],[:armor,47,1] ], abandonable: true, difficulty: 4, recom_lvl: 6, story: false }, } Difficulty_Icon = 125 Exp_Icon = 341 Gold_Icon = 262 Objective_Icon = 234 CategStory_Icon = 125 CategAll_Icon = 234 CategProgress_Icon = 236 CategCompleted_Icon = 238 Name_Color = 14 Rewards_Color = 1 Progress_Color = 3 Notif_Sound = ["Book1",75,150] endendclass Game_Interpreter def take_quest(id) $quest_system.quests.find { |q| q.id == id }.accept end def quest_accepted?(id) !$quest_system.current_quests.find { |q| q.id == id }.nil? end def quest_completed?(id) !$quest_system.completed_quests.find { |q| q.id == id }.nil? end def goal_completed?(id,goal_nbr) quest = $quest_system.quests.find { |q| q.id == id } return false if quest.nil? return quest.goal(goal_nbr-1).complete? end endclass Quest attr_accessor :order attr_reader :state attr_reader :id attr_reader :name attr_reader :icon attr_reader :description attr_reader :rewards attr_reader :abandonable attr_reader :difficulty attr_reader :lvl attr_reader :objectives def initialize(data) @order = 0 @id = data[:id] @name = data[:name] @icon = data[:icon] @description = data[:description] @rewards = data[:rewards] @state = :non_accepted @abandonable = data[:abandonable] @difficulty = data[:difficulty] @lvl = data[:recom_lvl] @objectives = data[:objectives] @story = data[:story] make_goals @accepted = false end def story? @story end def make_goals @goals = [] @objectives.each { |info| text = info[0] if info[1] =~ /item\?\((\d+),(\d+)\)/i goal = QuestGoal_Item.new(self,text,$1.to_i,$2.to_i) elsif info[1] =~ /enemy\?\((\d+),(\d+)\)/i goal = QuestGoal_Monster.new(self,text,$1.to_i,$2.to_i) elsif info[1] =~ /switch\?\((\d+)\)/i goal = QuestGoal_Switch.new(self,text,$1.to_i) elsif info[1] =~ /var\?\((\d+),(\d+)\)/i goal = QuestGoal_Variable.new(self,text,$1.to_i,$2.to_i) end msgbox "Nil" if goal.nil? @goals.push(goal) } end def goal(index) @goals[index] end def item_goals_check @goals.each { |g| next unless g.type == :item old_progress = g.progress g.check if g.progress != old_progress notif_goal(g) end } check_completion end def monster_goals_check(en_id) @goals.each { |g| next unless g.type == :monster old_progress = g.progress g.check(en_id) if g.progress != old_progress notif_goal(g) end } check_completion end def switch_goals_check @goals.each { |g| next unless g.type == :switch old_progress = g.progress g.check if g.progress != old_progress notif_goal(g) end } check_completion end def var_goals_check @goals.each { |g| next unless g.type == :var old_progress = g.progress g.check if g.progress != old_progress notif_goal(g) end } check_completion end def check_completion if @goals.all? { |g| g.complete? } quest_completed else @state = @accepted ? :accepted : :non_accepted end end def quest_completed @state = :completed give_rewards notif_completion end def give_rewards for info in @rewards case info[0] when :exp $game_party.members.each { |m| m.gain_exp(info[1]) } text = "Party + #{info[1]} EXP" when :gold text = "Party + #{info[1]} Gold" $game_party.gain_gold(info[1]) when :item obj = $data_items[info[1]] $game_party.gain_item(obj,info[2]) text = "Obtained #{obj.name}" when :weapon obj = $data_weapons[info[1]] $game_party.gain_item(obj,info[2]) text = "Obtained #{obj.name}" when :armor obj = $data_armors[info[1]] $game_party.gain_item(obj,info[2]) text = "Obtained #{obj.name}" end $notif_factory.create_notif("Text",{text: text}) end end def notif_goal(goal) text = goal.text text += ": #{goal.progress}/#{goal.goal_nbr}" $notif_factory.create_notif("Text",{text: text}) end def notif_completion text = @name text +=": COMPLETED" $notif_factory.create_notif("Text",{text: text}) end def accept return if accepted? return if completed? @accepted = true @state = :accepted @order = $quest_system.order $quest_system.order += 1 text = "New quest: #{@name}" $notif_factory.create_notif("Text",{text: text}) end def accepted? @state == :accepted end def completed? @state == :completed end def repeat abandon end def abandon @state = :non_accepted make_goals end endclass QuestGoal attr_reader :type attr_reader :goal_nbr attr_reader :progress attr_reader :quest attr_reader :text def initialize(quest,text) @quest = quest @text = text @goal_nbr = 0 @progress = 0 @type = :nil end def complete? @progress >= @goal_nbr endendclass QuestGoal_Item < QuestGoal def initialize(quest,text,item_id,goal_nbr) super(quest,text) @item_id = item_id @goal_nbr = goal_nbr @type = :item end def check @progress = $game_party.item_number($data_items[@item_id]) endendclass QuestGoal_Monster < QuestGoal def initialize(quest,text,enemy_id,goal_nbr) super(quest,text) @enemy_id = enemy_id @goal_nbr = goal_nbr @type = :monster end def check(enemy_id) return if complete? @progress += 1 if enemy_id == @enemy_id endendclass QuestGoal_Switch < QuestGoal def initialize(quest,text,switch_id) super(quest,text) @switch_id = switch_id @goal_nbr = 1 @type = :switch end def check @progress = $game_switches[@switch_id] ? 1 : 0 endendclass QuestGoal_Variable < QuestGoal def initialize(quest,text,var_id,goal_nbr) super(quest,text) @var_id = var_id @goal_nbr = goal_nbr @type = :var end def check @progress = $game_variables[@var_id] endendclass QuestSystem include Lecode::StrashQuestSystem attr_accessor :board_quests attr_accessor :order attr_reader :quests def initialize load_quests @order = 0 @bord_quests = [] end def load_quests @quests = [] Quests.each { |key,value| data = value data[:name] = key quest = Quest.new(data) @quests.push(quest) } end def sorted_quests @quests.sort_by { |q| q.order } end def current_quests sorted_quests.select { |q| q.state == :accepted } end def completed_quests sorted_quests.select { |q| q.state == :completed } end def get_board_quests @quests.select { |q| @board_quests.include?(q.id) } end endclass Game_Party alias lequestsys_gain_item gain_item def gain_item(*args) lequestsys_gain_item(*args) $quest_system.current_quests.each { |q| q.item_goals_check } end alias lequestsys_lose_item lose_item def lose_item(*args) lequestsys_lose_item(*args) $quest_system.current_quests.each { |q| q.item_goals_check } end endclass Game_Enemy alias lequestsys_perfce perform_collapse_effect def perform_collapse_effect lequestsys_perfce $quest_system.current_quests.each { |q| q.monster_goals_check(@enemy_id) } end endclass Game_Switches alias lequestsys_on_change on_change def on_change $quest_system.current_quests.each { |q| q.switch_goals_check } end endclass Game_Variables alias lequestsys_on_change on_change def on_change $quest_system.current_quests.each { |q| q.var_goals_check } end endmodule DataManager class << self alias lequestsys_create_game_objects create_game_objects alias lequestsys_make_save_contents make_save_contents alias lequestsys_extract_save_contents extract_save_contents end def self.create_game_objects lequestsys_create_game_objects $quest_system = QuestSystem.new end def self.make_save_contents contents = lequestsys_make_save_contents contents[:quest_sys] = $quest_system contents end def self.extract_save_contents(contents) lequestsys_extract_save_contents(contents) $quest_system = contents[:quest_sys] || QuestSystem.new endend
Code:
#===============================================================================# Quest Board Scene# By Lecode# For Strashiner# ------------------------------------------------------------------------------# Terms of Use:# ------------------------------------------------------------------------------# -Credit is required (Lecode)# -For Strashiner project only# ------------------------------------------------------------------------------# ...#===============================================================================class Scene_QuestsBoard < Scene_MenuBase def start super create_header_window create_info_window create_list_window create_confirm_window debut end def create_header_window @header_window = Window_QuestsBHeader.new end def create_info_window @info_window = Window_QuestInfo.new end def create_list_window @list_window = Window_QuestsBList.new @list_window.info = @info_window end def create_confirm_window @confirm_window = Window_Confirm.new("Accept this quest ?") @confirm_window.set_handler(:yes, method(:take_quest)) @confirm_window.set_handler(:no,method(:close_confirm)) end def debut @list_window.refresh @list_window.select(0) @list_window.activate end def call_confirm quest = @list_window.item if quest.accepted? or quest.completed? Sound.play_buzzer return end Sound.play_ok @confirm_window.open @confirm_window.activate @info_window.deactivate end def take_quest quest = @list_window.item Sound.play_ok quest.accept close_confirm go_list_window @list_window.refresh end def close_confirm @confirm_window.close go_list_window end def update super if Input.trigger?(:C) if @list_window.active Sound.play_ok go_info_window elsif @info_window.active call_confirm end elsif Input.trigger?(: Sound.play_cancel if @info_window.active go_list_window elsif @confirm_window.active close_confirm else return_scene end end end def go_info_window @list_window.deactivate @info_window.activate end def go_list_window @info_window.deactivate @list_window.activate end endclass Window_QuestsBHeader < Window_Base def initialize super(get_x,15,window_width,window_height) refresh end def get_x Graphics.width/2 - window_width/2 end def get_y 15 end def window_width Graphics.width*0.7 end def window_height fitting_height(1) end def refresh contents.clear contents.font.size = Font.default_size+4 my_draw_text("Quests Board",:center,0) end endclass Window_QuestsBList < Window_Selectable attr_accessor :info def initialize super(get_x,get_y,window_width,window_height) @data = [] @info = nil end def get_x Graphics.width/2 - window_width/2 end def get_y 75 end def window_width Graphics.width*0.9 end def window_height fitting_height(3) 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 current_item_enabled? enable?(@data[index]) end def enable?(item) item.state == :non_accepted end def make_item_list @data = $quest_system.get_board_quests end def draw_item(index) quest = @data[index] if quest rect = item_rect(index) rect.width -= 4 color = enable?(quest) ? normal_color : disabled_color draw_icon(quest.icon,rect.x,rect.y) my_draw_text(quest.name,rect.x+24,rect.y,color) case quest.state when :non_accepted text = "-READY-" when :accepted text = "-ACCEPTED-" when :completed text = "-COMPLETED-" color = text_color(3) end size = text_size(text).width x = rect.width - size my_draw_text(text,x,rect.y,color) end end def refresh make_item_list create_contents draw_all_items end def select(*args) super(*args) @info.refresh(item) unless @info.nil? end end class Window_QuestInfo < Window_Scrollable include Lecode::StrashQuestSystem def initialize @line_nbr = 1 super(get_x,get_y,window_width,window_height) end def get_x Graphics.width/2 - window_width/2 end def get_y 75 + fitting_height(3) + 12 end def window_width Graphics.width*0.9 end def window_height fitting_height(8) end def min_oy 0 end def max_oy [@line_nbr - 8,0].max*line_height end def row_max @line_nbr end def draw(quest) return if quest.nil? left_lines = 0 right_lines = 0 #- Name x = 0; y = 0 contents.font.size = Font.default_size+4 my_draw_text(quest.name,:center,y,text_color(Name_Color)) contents.font.size = Font.default_size #- Difficulty x = 4 y += line_height left_lines += 1 quest.difficulty.times { draw_icon(Difficulty_Icon,x,y) x += 24 } #- Level x = 4 y += line_height left_lines += 1 rect = my_draw_text("Recom. Level: ",x,y,system_color) x += rect.width + 2 my_draw_text(quest.lvl,x,y,normal_color) #- Rewards x = 4 y += line_height left_lines += 1 my_draw_text("Rewards:",x,y,system_color) y += line_height left_lines += 1 quest.rewards.each { |info| case info[0] when :exp icon = Exp_Icon text = info[1].to_s + " Exp" when :gold icon = Gold_Icon text = info[1].to_s + " " + Vocab::currency_unit when :item icon = $data_items[info[1]].icon_index text = "x"+info[2].to_s when :weapon icon = $data_weapons[info[1]].icon_index text = "x"+info[2].to_s when :armor icon = $data_armors[info[1]].icon_index text = "x"+info[2].to_s when :custom icon = info[1] text = info[2] end draw_border(x,y,24,24,normal_color) draw_icon(icon,x,y) my_draw_text(text,x+26,y,normal_color) y += line_height left_lines += 1 } #- Line x = 130 y = line_height draw_vert_line(x,y,40*line_height - y) #- Description x += 6 text = quest.description.gsub("\n","") max_width = contents_width - x y = wrap_text(x,y,text,max_width) right_lines += y/line_height #- Objectives y += line_height right_lines += 1 draw_icon(Objective_Icon,x,y) my_draw_text("Objectives:",x+25,y,system_color) quest.objectives.each { |info| text = info[0] y += line_height right_lines += 1 my_draw_text("-"+text,x,y,normal_color) } #- @line_nbr = right_lines if right_lines >= left_lines @line_nbr = left_lines if right_lines <= left_lines end end
Code:
#===============================================================================# Quest Book Scene# By Lecode# For Strashiner# ------------------------------------------------------------------------------# Terms of Use:# ------------------------------------------------------------------------------# -Credit is required (Lecode)# -For Strashiner project only# ------------------------------------------------------------------------------# ...#===============================================================================class Scene_QuestsBook < Scene_MenuBase def start super create_category_window create_info_window create_list_window debut end def create_category_window @category_window = Window_QuestCategory.new @category_window.set_handler(:story, method(:categ_to_list_window)) @category_window.set_handler(:all, method(:categ_to_list_window)) @category_window.set_handler(:in_progress, method(:categ_to_list_window)) @category_window.set_handler(:completed, method(:categ_to_list_window)) @category_window.select(0) end def create_info_window @info_window = Window_QuestBookInfo.new end def create_list_window @list_window = Window_QuestsBookList.new @list_window.info = @info_window end def debut @info_window.refresh(nil) @category_window.refresh @category_window.activate end def category_all @list_window.category = :all categ_to_list_window end def category_progress @list_window.category = :in_progress categ_to_list_window end def category_completed @list_window.category = :completed categ_to_list_window end def categ_to_list_window @category_window.deactivate @list_window.category = @category_window.current_symbol @list_window.refresh @list_window.select(0) @list_window.activate end def list_to_categ_window @list_window.clear.deactivate @list_window.unselect @info_window.refresh(nil) debut end def list_to_info_window @list_window.deactivate @info_window.activate end def info_to_list_window @info_window.deactivate @list_window.activate end def update super if Input.trigger?(: Sound.play_cancel if @list_window.active list_to_categ_window elsif @info_window.active info_to_list_window else return_scene end elsif Input.trigger?(:C) Sound.play_ok list_to_info_window if @list_window.active end end endclass Window_QuestCategory < Window_HorzCommand include Lecode::StrashQuestSystem def initialize clear_command_list make_command_list super(0, 0) end def window_width Graphics.width end def col_max return 4 end def spacing return 8 end def make_command_list add_command("Story Quests", :story) add_command("All Quests", :all) add_command("In Progress", :in_progress) add_command("Completed", :completed) end def draw_item(index) change_color(normal_color, command_enabled?(index)) rect = item_rect_for_text(index) icon_index = get_icon(index) draw_icon(icon_index,rect.x, rect.y) draw_text(rect, command_name(index), alignment) end def get_icon(index) case index when 0; return CategStory_Icon when 1; return CategAll_Icon when 2; return CategProgress_Icon when 3; return CategCompleted_Icon end end endclass Window_QuestsBookList < Window_Selectable attr_accessor :info attr_accessor :category def initialize super(get_x,get_y,window_width,window_height) @data = [] @info = nil @category = :all end def get_x 0 end def get_y line_height*2 end def window_width 220 end def window_height Graphics.height - fitting_height(1) 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 current_item_enabled? enable?(@data[index]) end def enable?(item) true end def make_item_list case @category when :story @data = $quest_system.sorted_quests.select { |q| q.story? && (q.accepted? or q.completed?) } when :all @data = $quest_system.sorted_quests.select { |q| q.state != :non_accepted } when :in_progress @data = $quest_system.current_quests when :completed @data = $quest_system.completed_quests end end def draw_item(index) quest = @data[index] if quest rect = item_rect(index) rect.width -= 4 draw_icon(quest.icon,rect.x,rect.y) color = quest.completed? ? text_color(3) : normal_color my_draw_text(quest.name,rect.x+24,rect.y,color) end end def refresh make_item_list create_contents draw_all_items end def select(*args) super(*args) @info.refresh(item) unless @info.nil? end def clear contents.clear self end endclass Window_QuestBookInfo < Window_Scrollable include Lecode::StrashQuestSystem def initialize @line_nbr = 1 super(get_x,get_y,window_width,window_height) end def get_x 220 end def get_y line_height*2 end def window_width Graphics.width-get_x end def window_height Graphics.height - fitting_height(1) end def min_oy 0 end def max_oy [@line_nbr - 14,0].max*line_height end def row_max @line_nbr end def true_contents_height super + 2 end def draw(quest) return if quest.nil? @line_nbr = 0 #- Name x = 0; y = 0 contents.font.size = Font.default_size+4 my_draw_text(quest.name,:center,y,text_color(Name_Color)) contents.font.size = Font.default_size #- Difficulty x = 4 y += line_height quest.difficulty.times { draw_icon(Difficulty_Icon,x,y) x += 24 } #- Level x = 4 y += line_height rect = my_draw_text("Recommended Level: ",x,y,system_color) x += rect.width + 2 my_draw_text(quest.lvl,x,y,normal_color) #- State x = 4 y += line_height rect = my_draw_text("State: ",x,y,system_color) x += rect.width + 2 text = quest.state == :completed ? "Completed" : "In Progress" my_draw_text(text,x,y,normal_color) #- Description x = 4 y += line_height text = quest.description.gsub("\n","") max_width = contents_width - x y = wrap_text(x,y,text,max_width) #- Objectives x = 4 y += line_height draw_icon(Objective_Icon,x,y) my_draw_text("Objectives:",x+25,y,system_color) change_color(normal_color) quest.objectives.each_with_index { |info,i| x = 4 goal = quest.goal(i) text = "( #{goal.progress}/#{goal.goal_nbr} )" y += line_height rect = my_draw_text(text,x,y,text_color(Progress_Color)) x += rect.width + 2 #- text = info[0] change_color(normal_color) max_width = contents_width - x y = wrap_text(x,y,"-"+text,max_width) } #- Rewards x = 4 y += line_height my_draw_text("Rewards:",x,y,system_color) y += line_height quest.rewards.each { |info| case info[0] when :exp icon = Exp_Icon text = info[1].to_s + " Exp" when :gold icon = Gold_Icon text = info[1].to_s + " " + Vocab::currency_unit when :item icon = $data_items[info[1]].icon_index text = "x"+info[2].to_s when :weapon icon = $data_weapons[info[1]].icon_index text = "x"+info[2].to_s when :armor icon = $data_armors[info[1]].icon_index text = "x"+info[2].to_s when :custom icon = info[1] text = info[2] end draw_border(x,y,24,24,normal_color) draw_icon(icon,x,y) my_draw_text(text,x+26,y,normal_color) y += line_height } #- @line_nbr = y/line_height end end