The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Rune on June 16, 2007, 08:40:43 PM

Title: Quest Log
Post by: Rune on June 16, 2007, 08:40:43 PM
My latest script :D
Instructions are inside the script, if anyone needs any help with it, you know where I am ;)

[spoiler=It resides here]#================================
#                        Quest Log Screen
#                               By Rune
#================================
# Introduction - This script calls a screen that keeps
# track of all your quests using variables.
#================================
# Instructions - Thoughout script
#================================
# To call - $scene = Scene_QuestPage1
#================================
# To start a quest, set it's variable to 1, to end it,
# set it to 2. Any Quest variables at 0 haven't been
# started or discovered
#================================

#++++++++++++++++++++++++++++++++
# Windows
#++++++++++++++++++++++++++++++++

class Window_QuestPage1 < Window_Base
  def initialize
    super(0, 64, 560, 350)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    refresh
  end
#================================
# Here's where you edit what each Quest is and which
# variables turn each one on. Add Quests as you please.
#================================
  def refresh
    self.contents.clear
#================================
# Set variable and "Quest Start" number
#================================
    if $game_variables[51] >= 1
#================================
# Set Quest objective, whenever a new quest is added,
# add 32 to the second number
#================================
      self.contents.draw_text(0, 0, 528, 32, "Quest 1")
    end
#================================
# And repeat until all quests are set
#================================
    if $game_variables[52] >= 1
      self.contents.draw_text(0, 32, 528, 32, "Quest 2")
    end
  end
end
#-----------------------------------------------------------------
class Window_QuestPage2 < Window_Base
  def initialize
    super(0, 64, 560, 350)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    refresh
  end
#================================
# Same here, set variables for Page 2 of the Quest Log
# Do NOT repeat Quests
#================================
  def refresh
    self.contents.clear
    if $game_variables[76] >= 1
      self.contents.draw_text(0, 0, 528, 32, "Quest 3")
    end
    if $game_variables[77] >= 1
      self.contents.draw_text(0, 32, 528, 32, "Quest 4")
    end
  end
end
#-----------------------------------------------------------------
class Window_Quest < Window_Base
  def initialize
    super(0, 0, 560, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    refresh
  end
  def refresh
    self.contents.clear
#================================
# Edit the color of the "Quest Log" at the top of the
# screen  (r, g, b)
#================================
    self.contents.font.color = Color.new(0, 255, 160)
#================================
# Decide what is placed at the top of the screen
#================================
    self.contents.draw_text(0, 0, 496, 32, "Quest Log", 1)
  end
end
#-----------------------------------------------------------------
class Window_Next < Window_Base
  def initialize
    super(0, 416, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    refresh
  end
  def refresh
    self.contents.clear
#================================
# Edit the color of the "Next Page" at the bottom of the
# screen  (r, g, b)
#================================
    self.contents.font.color = Color.new(0, 255, 160)
    self.contents.draw_text(480, 0, 128, 32, "Next Page -->")
  end
end
#-----------------------------------------------------------------
class Window_Complete< Window_Base
  def initialize
    super(560, 0, 80, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    refresh
  end
  def refresh
    self.contents.clear
#================================
# Edit the color of the "Complete?" text in the window
# (r, g, b)
#================================
    self.contents.font.color = Color.new(0, 255, 160)
    self.contents.draw_text(0, 0, 48, 32, "Complete?", 1)
  end
end
#-----------------------------------------------------------------
class Window_Prev < Window_Base
  def initialize
    super(0, 416, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    refresh
  end
  def refresh
    self.contents.clear
#================================
# Edit the color of the "Next Page" at the bottom of the
# screen  (r, g, b)
#================================
    self.contents.font.color = Color.new(0, 255, 160)
    self.contents.draw_text(0, 0, 128, 32, "<-- Prev Page")
  end
end
#-----------------------------------------------------------------
class Window_YN1 < Window_Base
  def initialize
    super(560, 64, 80, 350)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    refresh
  end
  def refresh
    self.contents.clear
#================================
# Set a variable to 2 to end it's quest
#================================
# If Quest is complete
#================================
    if $game_variables[51] == 2
      self.contents.draw_text(0, 0, 42, 32, "YES", 1)
#================================
# If Quest isn't started
#================================
    elsif $game_variables[51] == 0
      self.contents.draw_text(0, 0, 42, 32, "")
#================================
# If Quest is started but incomplete
#================================
    elsif $game_variables[51] == 1
      self.contents.draw_text(0, 0, 42, 32, "NO", 1)
    end
   
    if $game_variables[52] == 2
      self.contents.draw_text(0, 32, 42, 32, "YES", 1)
    elsif $game_variables[52] == 0
      self.contents.draw_text(0, 32, 42, 32, "")
    elsif $game_variables[52] == 1
      self.contents.draw_text(0, 32, 42, 32, "NO", 1)
    end
   
  end
end
#-----------------------------------------------------------------
class Window_YN2 < Window_Base
  def initialize
    super(560, 64, 80, 350)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    refresh
  end
  def refresh
    self.contents.clear
#================================
# Set a variable to 2 to end it's quest
#================================
# If Quest is complete
#================================
    if $game_variables[76] == 2
      self.contents.draw_text(0, 0, 42, 32, "YES", 1)
#================================
# If Quest isn't started
#================================
    elsif $game_variables[76] == 0
      self.contents.draw_text(0, 0, 42, 32, "")
#================================
# If Quest is started but incomplete
#================================
    elsif $game_variables[76] == 1
      self.contents.draw_text(0, 0, 42, 32, "NO", 1)
    end
   
    if $game_variables[77] == 2
      self.contents.draw_text(0, 32, 42, 32, "YES", 1)
    elsif $game_variables[77] == 0
      self.contents.draw_text(0, 32, 42, 32, "")
    elsif $game_variables[77] == 1
      self.contents.draw_text(0, 32, 42, 32, "NO", 1)
    end
   
  end
end
#-----------------------------------------------------------------

#++++++++++++++++++++++++++++++++
# Pages
#++++++++++++++++++++++++++++++++

class Scene_QuestPage1
  def main
    @top_window = Window_Quest.new
    @quest_window = Window_QuestPage1.new
    @next_window = Window_Next.new
    @comp_window = Window_Complete.new
    @check_window = Window_YN1.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @top_window.dispose
    @quest_window.dispose
    @next_window.dispose
    @comp_window.dispose
    @check_window.dispose
  end
  def update
    @top_window.update
    @quest_window.update
    @next_window.update
    @comp_window.update
    @check_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    end
    if Input.trigger?(Input::R)
      $game_system.se_play($data_system.decision_se)
      $scene = Scene_QuestPage2.new
    end
  end
end
#-----------------------------------------------------------------
#-----------------------------------------------------------------
#-----------------------------------------------------------------
class Scene_QuestPage2
  def main
    @top_window = Window_Quest.new
    @quest_window = Window_QuestPage2.new
    @next_window = Window_Prev.new
    @comp_window = Window_Complete.new
    @check_window = Window_YN2.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @top_window.dispose
    @quest_window.dispose
    @next_window.dispose
    @comp_window.dispose
    @check_window.dispose
  end
  def update
    @top_window.update
    @quest_window.update
    @next_window.update
    @comp_window.update
    @check_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    end
    if Input.trigger?(Input::L)
      $game_system.se_play($data_system.decision_se)
      $scene = Scene_QuestPage1.new
    end
  end
end
[/spoiler]

[spoiler=Screenies]
Before Quest Start
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi163.photobucket.com%2Falbums%2Ft302%2Fpsychomathic-paniac%2FQLogb4.jpg&hash=fad583cb47050314fa25e6037c9b6aa8dda93239)
Quest Incomplete
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi163.photobucket.com%2Falbums%2Ft302%2Fpsychomathic-paniac%2FQLogQst.jpg&hash=f91f82098c82fc630f4ba63aae395500daa18017)
Quest Complete
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi163.photobucket.com%2Falbums%2Ft302%2Fpsychomathic-paniac%2FQLogQcmplt.jpg&hash=b44cc7f33b80cbb7ed5a267829f03df35c2f4d7b)
[/spoiler]

That's it, and enjoy kiddies ;)
Title: Re: Quest Log
Post by: Halestorm5 on June 16, 2007, 09:20:30 PM
A screenshot please?
Title: Re: Quest Log
Post by: Rune on June 16, 2007, 10:03:48 PM
Ah! I forgot that >.< Be right back

[EDIT]
There you go :D
Title: Re: Quest Log
Post by: Polraudio on June 16, 2007, 11:54:37 PM
Hey nice even the most simplest scripts are cool.
using variables? after i seen how you used them maybe i might learn off of that to make my Juke better. Im just learning lots this week
Title: Re: Quest Log
Post by: Rune on June 17, 2007, 12:54:10 AM
Lol, I tried editing your Juke so that you couldn't play certain tunes until certain points in the game, by changing variables :D
Didn't work though... :(
Title: Re: Quest Log
Post by: Polraudio on June 17, 2007, 01:02:16 AM
i will find a way to make that happen if it means death. LOL JK
but i will find a way tho
Title: Re: Quest Log
Post by: Kokowam on June 17, 2007, 01:05:01 AM
Nice script, Rune! It may be less flashy than that other guy's, but this is easier to handle.
Title: Re: Quest Log
Post by: Rune on June 17, 2007, 01:16:48 AM
Thanks :D
Holy Sh-... I just saw the time, g-night my good friends, see you in about 7-8 hours :D
Title: Re: Quest Log
Post by: zzzdude on July 09, 2007, 01:02:41 PM
New to the forums, hi.

Now, I have been looking for a quest log script since I can't script at all.

I found this:
http://shadowdestiny.byethost14.com/forums/index.php?s=&showtopic=85

But if you read my LATER post, it says I had an error with the script.

So, two questions:
1. Is this your script.
2. What can I do to fix it? (if its not yours, I will get yours    :D)
Title: Re: Quest Log
Post by: modern algebra on July 09, 2007, 02:37:17 PM
It's nice. Does it have descriptions as well? I.e. Can there be multiple parts of one quest? like: Find the key and return it, then go to the warehouse with him and kill the raiders

There are a couple quest logs out there so I'd suggest you add some things to make yours special. Either way it is a good, simple script.
Title: Re: Quest Log
Post by: Rune on July 09, 2007, 04:24:37 PM
Quote from: zzzdude on July 09, 2007, 01:02:41 PM
New to the forums, hi.

Now, I have been looking for a quest log script since I can't script at all.

I found this:
http://shadowdestiny.byethost14.com/forums/index.php?s=&showtopic=85 (http://shadowdestiny.byethost14.com/forums/index.php?s=&showtopic=85)

But if you read my LATER post, it says I had an error with the script.

So, two questions:
1. Is this your script.
2. What can I do to fix it? (if its not yours, I will get yours    :D)


The one on the link or the one in this thread?
Thread - Yes
Link - No, this is the only quest log script I have made

If I can get the link to work, i'll certainly try to fix your problem ;) (if the owner doesn't)

Quote from: modern algebra on July 09, 2007, 02:37:17 PM
It's nice. Does it have descriptions as well? I.e. Can there be multiple parts of one quest? like: Find the key and return it, then go to the warehouse with him and kill the raiders

There are a couple quest logs out there so I'd suggest you add some things to make yours special. Either way it is a good, simple script.

You could do that by fiddling with a few variables here and there :) (If anyone needs help with this, just either post or PM me ;) ), or if youre thinking about calling a window that gives you instructions and whether you've done them or not... i'm pretty sure you could do that with a bit of work.

And i'll see what I could do to make this better than the other quest log scripts :P (Ideas anyone?)
Title: Re: Quest Log
Post by: zzzdude on July 09, 2007, 08:24:46 PM
Oh, I see.

I will just remove the one I got froom the link, and put yours in    :D
Title: Re: Quest Log
Post by: zzzdude on July 09, 2007, 09:06:58 PM
Using your script, I had this error:
script 'main' line 14: NoMethodError occured.
undefined method `main' for scene_questpage1: class

What did I do wrong?
Title: Re: Quest Log
Post by: Rune on July 10, 2007, 04:49:08 PM
Post your main script
Title: Re: Quest Log
Post by: modern algebra on July 11, 2007, 03:26:54 PM
Are you using PK Rune? I just looked through ans saw $defaultfontsize. That is going to cause errors for anyone not using PKE.
Title: Re: Quest Log
Post by: Rune on July 11, 2007, 03:59:18 PM
Yeah, I am :-\ should I change it to say something else?
Title: Re: Quest Log
Post by: modern algebra on July 11, 2007, 05:04:47 PM
well, put in a failsafe. something like:

if $defaultfontsize != nil
  self.contents.font.size = $defaultfontsize
  self.contents.font.name = $defaultfontname
end


With regular version, those variables aren't defined, so they will get an error there. Normally, I don't bother setting a font size and name. I think it defaults to 22, Arial. The benefit to doing it that way is that you only have to change the values of those two variables in order to change the font name and size everywhere, and you won't have to run through all your scripts.
Title: Re: Quest Log
Post by: Rune on July 11, 2007, 05:18:28 PM
Right, will try that later, i'm not on RMXP atm :P
Title: Re: Quest Log
Post by: subzero on July 18, 2007, 04:10:22 AM
you think you could put in a demo?
Title: Re: Quest Log
Post by: Rune on July 18, 2007, 10:45:52 AM
Um... yeah, once i'm less busy :D
Title: Re: Quest Log
Post by: subzero on July 18, 2007, 05:35:59 PM
Ok cool.
and Thanks
Title: Re: Quest Log
Post by: zzzdude on August 05, 2007, 03:18:22 AM
terribly sorry, went to california, had my lappy break        D:
I will post the main script in a minute