Since current quest window scripts don't meet with my needs (still have bugs or difficult to use), I decided to make my own quest window. So far, constructing the quest window itself was not a problem.
The problem is, now I want to integrate my quest window within the menu, requiring me to make a new Scene. I don't know how to make my own Scene. What methods should be inside my new Scene class? I tried to mimic some Scenes (such as Scene_Menu) but all failed. Could anyone explain to me how to make a good Scene?
Oh, by the way, how to make a selectable window automatically scrolls when there are more options than available height? I tried it and the window didn't scroll, though I heard it should've automatically scrolled. I want to have one more option in my menu for displaying the quest status.
This is my script so far, excluding the Scene I made (it was a big mess):
Note that this script doesn't handle side quests yet (I'm planning to make side quests) and doesn't specify the rewards (my game doesn't have rewards so far). Also, it doesn't save any previous quests that are already completed. Maybe I'll improve to solve these issues (though I don't need them right now).
As you can see, instead of editing quests within script editor, I decided to use a file so I no longer need enter the script editor. I name it MainQuest.rxdata and should reside in Data directory. The MainQuest.rxdata uses 11 lines each quest. The first line will be quest's main objective while the remaining lines are used to describe actions to accomplish the quest (up to 10 actions). For example...
I'm planning to extend this file so I can hold as many actions as I like.
Oh, by the way, is there a method in RGSS that allows me to read some lines (not all) from specific location? For example, to pick quest #2, instead of reading all the files, I'd like to read only line 12 to 22, so less memory will be used.
Any suggestions for improvement? Thank you.
The problem is, now I want to integrate my quest window within the menu, requiring me to make a new Scene. I don't know how to make my own Scene. What methods should be inside my new Scene class? I tried to mimic some Scenes (such as Scene_Menu) but all failed. Could anyone explain to me how to make a good Scene?
Oh, by the way, how to make a selectable window automatically scrolls when there are more options than available height? I tried it and the window didn't scroll, though I heard it should've automatically scrolled. I want to have one more option in my menu for displaying the quest status.
This is my script so far, excluding the Scene I made (it was a big mess):
Code:
#access this class using $quest
class MainQuest
attr_accessor :steps_completed
attr_accessor :main_quest
attr_accessor :quest_id
attr_accessor :current_step
def initialize(quest_id)
@steps_completed = Array.new(10)
for i in 0 ... 10
@steps_completed[i] = false
end
@quest_id = quest_id
pick_quest(@quest_id)
end
def pick_quest(quest_id)
#open file
f = File.open("Data/MainQuest.rxdata")
#read file
quest = f.readlines
#pick only quest_id
@main_quest = quest[11 * (quest_id - 1), 11]
#slice unneeded characters
#quest header
@main_quest[0].slice!("#" + quest_id.to_s + " ")
@main_quest[0].slice!("\n")
#line 1 to 10, remove "\n"
for i in 1 .. 10
@main_quest[i].slice!("\n")
end
p @main_quest
end
end
class Window_Quest < Window_Base
def initialize
super(0, 0, 640, 416)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
def refresh
p $quest.current_step
#draw each line to the window
self.contents.draw_text(0, 0, 640, 32, $quest.main_quest[0])
for i in 1 .. 10
if $quest.steps_completed[i - 1]
self.contents.font.color = disabled_color
else
if i == $quest.current_step
self.contents.font.color = Color.new(0, 255, 0, 255)
else
self.contents.font.color = normal_color
end
end
if $quest.main_quest[i] != ""
self.contents.draw_text(0, 32 * i, 640, 32, i.to_s + ". " + $quest.main_quest[i])
end
end
end
end
class Scene_Save < Scene_File
alias quest_save write_save_data
def write_save_data(file)
quest_save(file)
Marshal.dump($quest, file) if $quest != nil
end
end
class Scene_Load < Scene_File
alias quest_load read_save_data
def read_save_data(file)
quest_load(file)
$quest = Marshal.load(file)
end
end
Note that this script doesn't handle side quests yet (I'm planning to make side quests) and doesn't specify the rewards (my game doesn't have rewards so far). Also, it doesn't save any previous quests that are already completed. Maybe I'll improve to solve these issues (though I don't need them right now).
As you can see, instead of editing quests within script editor, I decided to use a file so I no longer need enter the script editor. I name it MainQuest.rxdata and should reside in Data directory. The MainQuest.rxdata uses 11 lines each quest. The first line will be quest's main objective while the remaining lines are used to describe actions to accomplish the quest (up to 10 actions). For example...
Code:
#1 Calm the boy.
Find Gloria.
Ask her for 100 golds.
Buy some candies from the store.
Give the candies to the boy.
#2 Find Gloria's ribbon.
Calm Gloria down.
Ask the girl what happened.
Find Nicholas and ask for the ribbon.
Find an old tree for a bird nest.
Fight the bird.
Return the ribbon to Gloria.
Fix Gloria's ribbon.
Return the fixed ribbon to Gloria.
Wash Gloria's ribbon and dry it.
Return the ribbon to Gloria.
I'm planning to extend this file so I can hold as many actions as I like.
Oh, by the way, is there a method in RGSS that allows me to read some lines (not all) from specific location? For example, to pick quest #2, instead of reading all the files, I'd like to read only line 12 to 22, so less memory will be used.
Any suggestions for improvement? Thank you.