Editing Quest Log

Started by firevenge007, November 20, 2013, 03:36:28 pm

Previous topic - Next topic

firevenge007

Using game_guy's code from his Quest Logger, I was wondering if it was possible to have the color of the name of the quest in the quest list to be colored based on completion.

#===============================================================================
# Quest Log System
# Author game_guy
# Version 3.0
#-------------------------------------------------------------------------------
# Intro:
# A script that keeps track of quests you obtain and complete.
#
# Features:
# Marks quest names with a yellow color if they're completed
# Easy to setup one quest
# Be able to use a fairly long description
# Be able to display a picture
# Easy to add and complete a quest
# More compatible than earlier versions
#
# Instructions:
# Scroll down a bit until you see # Being Config. Follow the instructions there.
# Scroll below that and you'll see Begin Quest Setup. Follow the steps there.
#
# Script Calls:
# Quest.add(id) ~ Adds the quest(id) to the parties quests.
# Quest.take(id) ~ Takes the quest(id) from the party.
# Quest.complete(id) ~ Makes the quest(id) completed.
# Quest.completed?(id) ~ Returns true if the quest(id) is completed.
# Quest.has?(id) ~ Returns true if the party has quest(id).
#
# Credits:
# game_guy ~ for making it
# Beta Testers ~ Sally and Landith
# Blizzard ~ Small piece of code I borrowed from his bestiary
#===============================================================================
module GameGuy
 #==================================================
 # Begin Config
 # UsePicture ~ true means it'll show pictures in
 #              the quests, false it wont.
 #==================================================
 UsePicture   = false
 
 def self.qreward(id)
   case id
   #==================================================
   # Quest Reward
   # Use when x then return "Reward"
   # x = id, Reward = reward in quotes
   #==================================================
   when 1 then return "100 Gold"
   when 2 then return "3 Potions"
   when 3 then return "Strength Ring"
   end
   return "????"
 end
 
 def self.qpicture(id)
   case id
   #==================================================
   # Quest Picture
   # Use when x then return "picture"
   # x = id, picture = picutre name in quotes
   #==================================================
   when 1 then return "ghost"
   end
   return nil
 end
 
 def self.qname(id)
   case id
   #==================================================
   # Quest Name
   # Use when x then return "name"
   # x = id, name = quest name in quotes
   #==================================================
   when 1 then return "Bob's Chicken"
   when 2 then return "Lost My Weapon"
   when 3 then return "Finding The Letter"
   when 4 then return "Do You Believe in Magic"
   when 5 then return "Quest For A Bowl"
   when 6 then return "Quest For Quest"
   when 7 then return "Rat Catcher"
   when 8 then return "Baby Trouble"
   when 9 then return "Monster Mother"
   when 10 then return "Purity of Water"
   when 11 then return "Sailor's Quest"
   when 12 then return "Dangerous Passage"
   when 13 then return "The Search For Hidden Treasure"
   when 14 then return "Pricilla's Possession"
   when 15 then return "Agilequest"
   when 16 then return "Quest of the Musaph"
   when 17 then return "The Urothmyte Trials"
   when 18 then return "Bar Fight!"
   when 19 then return "Abandoned Village"
   when 20 then return "Milk Quest Part 1"
   when 21 then return "Milk Quest Part 2"
   when 22 then return "Milk Quest Part 3"
   when 23 then return "Herbalist Dungeon"
   when 24 then return "Expidition To The Danger Zone"
   when 25 then return "Angel Flight"
   when 26 then return "Combat Guild"
   when 27 then return "Leothon's Mini-Quest"
   when 28 then return "Warped Diamond"
   when 29 then return "Fortune"
   when 30 then return "The Mysterious Source"
   end
   return ""
 end
 
 def self.qlocation(id)
   case id
   #==================================================
   # Quest Location
   # Use when x then return "location"
   # x = id, location = location in quotes
   #==================================================
   when 1 then return "Tutorial"
   when 2 then return "Kirkwood Forest"
   when 3 then return "Ridgeville Woods"
   when 4 then return "Ridgeville Woods"
   when 5 then return "Creekside"
   when 6 then return "Emporia"
   when 7 then return "Emporia Harbor"
   when 8 then return "East Lakiki Island"
   when 9 then return "East Lakiki Island"
   when 10 then return "East Lakiki Island"
   when 11 then return "East Lakiki Island"
   when 12 then return "Lakiki Desert Dungeon"
   when 13 then return "Saharan Village"
   when 14 then return "Saharan Village"
   when 15 then return "Swampy Marshes"
   when 16 then return "Swamp"
   when 17 then return "Ruins of Urothmus"
   when 18 then return "Quanzfalls Tavern"
   when 19 then return "Abandoned Village"
   when 20 then return "Peaceful Wood"
   when 21 then return "Jungle Crossover"
   when 22 then return "Jungle Village"
   when 23 then return "Herbalist's Realm"
   when 24 then return "Paladin City"
   when 25 then return "West Lakiki Island"
   when 26 then return "Fairie's Woods"
   when 27 then return "Combat Guild"
   when 28 then return "Combat Guild"
   when 29 then return "Poisonous Woods Tree Hollow"
   when 30 then return "Legends Area"
   end
   return "????"
 end
 
 def self.qdescription(id)
   case id
   #==================================================
   # Quest Description
   # Use when x then return "description"
   # x = id, description = quest description in quotes
   #==================================================
   when 1 then return "Kill a chicken and bring back a feather to Farmer Bob."
   when 2 then return "Give the wounded adventurer his weapon back by defeating the monster who took it."
   when 3 then return "Go find a letter that this man lost and give it back to him."
   when 4 then return "Bring the sick girl a magic potion to heal her."
   when 5 then return "Get the man a bowl by following these steps. \n\ Go North to Emporia. Go to the shop that sells blowing pipes and molten glass. Make him a bowl out of the glass."
   when 6 then return "Solve the puzzle that the woman gives you. Turn the right switches to unlock the barrier to the treasure!"
   when 7 then return "Get the sailor his rat that he lost somewhere in Kirkwood forest."
   when 8 then return "Get the woman her baby. \n\ She lost it somewhere on Lakiki Island."
   when 9 then return "Slay the beast within the woman to rid her of her angry spirit."
   when 10 then return "Bring Acquatica back a bottle of pure water by killing water salamanders."
   when 11 then return "Go on an adventure with the little sailor boy to unexplored lands."
   when 12 then return "Try to find your way through the Desert tunnels. /n/ Watch out for boulders!"
   end
   return ""
 end
 
end

module Quest
 
 def self.add(id)
   $game_party.add_quest(id)
 end
 
 def self.take(id)
   $game_party.take_quest(id)
 end
 
 def self.complete(id)
   $game_party.complete(id)
 end
 
 def self.completed?(id)
   return $game_party.completed?(id)
 end
 
 def self.has?(id)
   return $game_party.has_quest?(id)
 end
 
end
 
class Game_Party
 
 attr_accessor :quests
 attr_accessor :completed
 
 alias gg_quests_lat initialize
 def initialize
   @quests = []
   @completed = []
   gg_quests_lat
 end
 
 def add_quest(id)
   unless @quests.include?(id)
     @quests.push(id)
   end
 end
 
 def completed?(id)
   return @completed.include?(id)
 end
 
 def complete(id)
   unless @completed.include?(id)
     if @quests.include?(id)
       @completed.push(id)
     end
   end
 end
 
 def has_quest?(id)
   return @quests.include?(id)
 end
 
 def take_quest(id)
   @quests.delete(id)
   @completed.delete(id)
 end
 
end
class Scene_Quest
 def main
   @quests = []
   for i in $game_party.quests
     @quests.push(GameGuy.qname(i))
   end
   @map = Spriteset_Map.new
   @quests2 = []
   for i in $game_party.quests
     @quests2.push(i)
   end
   @quests.push("No Quests") if @quests.size < 1
   @quests_window = Window_Command.new(160, @quests)
   @quests_window.height = 480
   @quests_window.back_opacity = 110
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   @quests_window.dispose
   @quest_info.dispose if @quest_info != nil
   @map.dispose
 end
 def update
   @quests_window.update
   if @quests_window.active
     update_quests
     return
   end
   if @quest_info != nil
     update_info
     return
   end
 end
 def update_quests
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Menu.new
     return
   end
   if Input.trigger?(Input::C)
     $game_system.se_play($data_system.decision_se)
     @quest_info = Window_QuestInfo.new(@quests2[@quests_window.index])
     @quest_info.back_opacity = 110
     @quests_window.active = false
     return
   end
 end
 def update_info
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     @quests_window.active = true
     @quest_info.dispose
     @quest_info = nil
     return
   end
 end
end
class Window_QuestInfo < Window_Base
 def initialize(quest)
   super(160, 0, 480, 480)
   self.contents = Bitmap.new(width - 32, height - 32)
   @quest = quest
   refresh
 end
 def refresh
   self.contents.clear
   if GameGuy::UsePicture
     pic = GameGuy.qpicture(@quest)
     bitmap = RPG::Cache.picture(GameGuy.qpicture(@quest)) if pic != nil
     rect = Rect.new(0, 0, bitmap.width, bitmap.height) if pic != nil
     self.contents.blt(480-bitmap.width-32, 0, bitmap, rect) if pic != nil
   end
   self.contents.font.color = system_color
   self.contents.draw_text(0, 0, 480, 32, "Quest:")
   self.contents.font.color = normal_color
   self.contents.draw_text(0, 32, 480, 32, GameGuy.qname(@quest))
   self.contents.font.color = system_color
   self.contents.draw_text(0, 64, 480, 32, "Reward:")
   self.contents.font.color = normal_color
   self.contents.draw_text(0, 96, 480, 32, GameGuy.qreward(@quest))
   self.contents.font.color = system_color
   self.contents.draw_text(0, 128, 480, 32, "Location:")
   self.contents.font.color = normal_color
   self.contents.draw_text(0, 160, 480, 32, GameGuy.qlocation(@quest))
   self.contents.font.color = system_color
   self.contents.draw_text(0, 192, 480, 32, "Completion:")
   self.contents.font.color = normal_color
   if $game_party.completed.include?(@quest)
     self.contents.font.color = crisis_color
     self.contents.draw_text(0, 224, 480, 32, "Completed")
   else
     self.contents.font.color = normal_color
     self.contents.draw_text(0, 224, 480, 32, "Not Started")
   end
   self.contents.font.color = system_color
   self.contents.draw_text(0, 256, 480, 32, "Description:")
   self.contents.font.color = normal_color
   text = self.contents.slice_text(GameGuy.qdescription(@quest), 480)
   text.each_index {|i|
       self.contents.draw_text(0, 288 + i*32, 480, 32, text[i])}
 end
end
class Bitmap
 
 def slice_text(text, width)
   words = text.split(' ')
   return words if words.size == 1
   result, current_text = [], words.shift
   words.each_index {|i|
       if self.text_size("#{current_text} #{words[i]}").width > width
         result.push(current_text)
         current_text = words[i]
       else
         current_text = "#{current_text} #{words[i]}"
       end
       result.push(current_text) if i >= words.size - 1}
   return result
 end
 
end
class Scene_Load < Scene_File

 alias load_party_variables on_decision
 def on_decision(filename)
   load_party_variables(filename)
   # Initializes quest variables to empty arrays UNLESS they are not nil to begin with
   $game_party.quests ||= []
   $game_party.completed ||= []
 end

end


Not started would be colored red, In progression would be colored yellow, and Completed would be colored green.

When the Quest would be marked red, it would not show what the description of the quest is until a seperate command is called, "Quest.progress(id)", which would put the quest into progression and color the name yellow, as well as showing the description.

The reason I want to try this out is so that players see the whole quest list and can decide if they could start the quest or not. They can keep track of which quests they have done from the color of the names in the quest list as well.

Any help would be fantastic!

Thank you for your time.

KK20

Any reason you can't use my quest system? It already does what you are asking for (the "not accepted", "currently doing", and "completed" stuff).

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

firevenge007

Okay, I'll try yours out - but I need to figure out how to fix the same nil problem that I got like the other quest script. I tried using your fix for it but it wouldn't work :)

KK20

That's because the variable names in my script are different from G_G's. Not to mention, there is one more variable I use.

class Scene_Load < Scene_File

  alias load_party_variables on_decision
  def on_decision(filename)
    load_party_variables(filename)
    # Initializes quest variables to empty arrays UNLESS they are not nil to begin with
    $game_party.quests_new ||= []
    $game_party.quests_accepted ||= []
    $game_party.quests_completed ||= []
  end

end


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

firevenge007

Is it possible to have a quest point system where different quests are worth different amounts of points.

Ex:

easy quests = 1 quest points
medium quests = 2 quest points
hard quests = 3 quest points


So there would be an option on how many points to put based on which quest

when 1 .. 3 then return 1
when 4 then return 2
when 5 .. 8 then return 3

KK20

You can always event that in. Immediately after completing the quest, use a Change Variable command and add the points in. If you want to display these points, I'd need to know where to put it so that I can make the necessary edit.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

firevenge007

November 20, 2013, 05:05:15 pm #6 Last Edit: November 20, 2013, 05:11:04 pm by firevenge007
This is kind of what I had in mind





Edit: Keep in mind, the first image is real. I edited the side-skill script to include another tab which would direct it to the Quest slide.

KK20

Add this to the configuration module (you can put it directly after the end # <-- Don't delete this 'end' ! line):

  def self.score(id)
    case id
    #===========================================================================
    # Quest Score - The amount of points given for completing the quest.
    # Configure:
    #     when x then return POINTS
    # x = Quest ID
    # POINTS = Amount of points
    #===========================================================================
    when 1..4 then return 2
    when 5 then return 3
    when 6..10 then return 5
    end
    return 0
  end

And throw put this at the bottom of the script:

class Game_Party
  attr_accessor :questscore
  alias init_scores initialize
  def initialize
    init_scores
    @questscore = 0
  end
  alias award_points complete
  def complete(id)
    if !completed?(id) and @quests_accepted.include?(id)
      @questscore += QuestData.score(id)
    end
    award_points(id)
  end
end
#--------------------
class Scene_Quest
  alias new_score_window main
  def main
    @score_window = QuestScoreWindow.new
    @score_window.back_opacity = 128 if QuestData::ShowMapBackGround
    new_score_window
    @score_window.dispose
  end
 
  alias update_score_window update
  def update
    @score_window.visible = !@quest_info.visible
    update_score_window
  end
end
#--------------------
class Window_QuestList < Window_Selectable
  def initialize(type=0)
    super(0, 128, 640, 288)
    @column_max = 5
    @type = type
    refresh
    self.index = 0
  end
end
#--------------------
class QuestScoreWindow < Window_Base
  def initialize
    super(0,416, 640, 64)
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.draw_text(0,0,width-32,32,"Quest Score: " + $game_party.questscore.to_s,1)
  end
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

firevenge007

Thank you for your help!

Though there's one little thing - when a quest is completed - an error: NoMethodError occured. undefined method '+' for nil:NilClass pops up.
this redirects me to this line:

      @questscore += QuestData.score(id)

Thank you again!

KK20

Oh yeah...saved games...

Just add

$game_party.questscore ||= 0

to that fix I provided you with before.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!