The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Rune on June 06, 2007, 07:41:59 PM

Title: Records/Rewards Script
Post by: Rune on June 06, 2007, 07:41:59 PM
Here it is, my first checked, edited and commented script :P
Hope you like :P

Insert this above main and call it Scene_Records
[spoiler]=begin
=================================
                             Record Script
                                By Rune
              Initial Idea By Rubymatt/Dark Ruby
         Checked and edited by Rubymatt/Dark Ruby
=================================
A simple(ish) records script that basically records your
achievements throughout the game... and gives
trophies/medals (whatever floats your boat) when you
reach certain targets
=================================
There are a total of 11 set variable spaces, although 14
can also be made.  If you decrease the font size, more can
be added.  Contact me if you wish to add a decent amount
more.
=================================
To call the script, use $scene = Scene_Records.new

The variables in the Game_Rewards can be edited using
any scripting knowledge.  Otherwise, use this line:

$var1 = $game_variables[x]

This will refer the game variable of x, so you can change
it in-game if you are not a scripter.  Replace the x with
the in-game variable to use.

Skills Required -
Slight editing of Scene_Save and Scene_Load.
=================================
Credit goes to:
Rune, for the script itself
Rubymatt/Dark Ruby, for the idea, inspiration, and editing
SirJackRex/Mexneto, for the icons
=================================
Editing:

Go to Scene_Save.  Below the line:

    Marshal.dump($game_player, file)

Add:

    Marshal.dump($game_rewards, file)

Next, go to Scene_Load.  Below the line:

    $game_player        = Marshal.load(file)

Add:

    $game_rewards        = Marshal.load(file)

=end
#================================
# Here's where you name your variables and pick which
# ones go where
# This is the window that displays the actual amount of
# the variables
#================================

class Game_Rewards
  attr_accessor :var1
  attr_accessor :var2
  attr_accessor :var3
  attr_accessor :var4
  attr_accessor :var5
  attr_accessor :var6
  attr_accessor :var7
  attr_accessor :var8
  attr_accessor :var9
  attr_accessor :var10
  attr_accessor :var11
  def initialize
    $var1 = 0
    $var2 = 0
    $var3 = 0
    $var4 = 0
    $var5 = 0
    $var6 = 0
    $var7 = 0
    $var8 = 0
    $var9 = 0
    $var10 = 0
    $var11 = 0
  end
end

class Window_Count < Window_Base
  def initialize
    super(0, 0, 104, 384)
    self.contents = Bitmap.new(width - 32, height - 32)
    @game_rewards = Game_Rewards.new
    refresh
  end
  def refresh
    self.contents.clear
    self.contents.font.name = "Tahoma"
    self.contents.font.size = $defaultfontsize
    self.contents.draw_text(0, 0, 72, 32, $var1.to_s, 1)
    self.contents.draw_text(0, 32, 72, 32, $var2.to_s, 1)
    self.contents.draw_text(0, 64, 72, 32, $var3.to_s, 1)
    self.contents.draw_text(0, 96, 72, 32, $var4.to_s, 1)
    self.contents.draw_text(0, 128, 72, 32, $var5.to_s, 1)
    self.contents.draw_text(0, 160, 72, 32, $var6.to_s, 1)
    self.contents.draw_text(0, 192, 72, 32, $var7.to_s, 1)
    self.contents.draw_text(0, 224, 72, 32, $var8.to_s, 1)
    self.contents.draw_text(0, 256, 72, 32, $var9.to_s, 1)
    self.contents.draw_text(0, 288, 72, 32, $var10.to_s, 1)
    self.contents.draw_text(0, 320, 72, 32, $var11.to_s, 1)
  end
end

#================================
# This window displays the awards you have earned
#================================

class Window_Trophy < Window_Base
  def initialize
    super(0, 0, 104, 384)
    self.contents = Bitmap.new(width - 32, height - 32)
    @game_rewards = Game_Rewards.new
    refresh
  end
 
#================================
# Here, you can set how much of a certain variable you
# need for each trophy/medal
#================================
 
  def refresh
    self.contents.clear
    # Variable 1 Bronze
    if $var1 >= 100
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 1 Silver
    if $var1 >= 500
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 4, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 1 Gold
    if $var1 >= 2000
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 4, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 2 Bronze
    if $var2 >= 100
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 36, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 2 Silver
    if $var2 >= 500
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 36, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 2 Gold
    if $var2 >= 2000
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 36, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 3 Bronze
    if $var3 >= 25
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 68, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 3 Silver
    if $var3 >= 50
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 68, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 3 Gold
    if $var3 >= 100
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 68, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 4 Bronze
    if $var4 >= 3
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 100, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 4 Silver
    if $var4 >= 6
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 100, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 4 Gold
    if $var4 >= 10
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 100, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 5 Bronze
    if $var5 >= 100000
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 132, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 5 Silver
    if $var5 >= 1000000
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 132, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 5 Gold
    if $var5 >= 5000000
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 132, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 6 Bronze
    if $var6 >= 100
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 164, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 6 Silver
    if $var6 >= 200
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 164, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 6 Gold
    if $var6 >= 300
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 164, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 7 Bronze
    if $var7 >= 1000
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 196, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Silver
    if $var7 >= 2000
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 196, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Gold
    if $var7 >= 3000
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 196, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 8 Bronze
    if $var8 >= 1000
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 228, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Silver
    if $var8 >= 2000
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 228, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Gold
    if $var8 >= 3000
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 228, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 9 Bronze
    if $var9 >= 1000
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 260, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Silver
    if $var9 >= 2000
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 260, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Gold
    if $var9 >= 3000
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 260, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 10 Bronze
    if $var10 >= 1000
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 292, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Silver
    if $var10 >= 2000
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 292, bitmap, Rect.new(0, 0, 24, 24))
    end
    #Gold
    if $var10 >= 3000
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 292, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Variable 11 Bronze
    if $var11 >= 1000
      bitmap = RPG::Cache.icon("bronze")
      self.contents.blt(0, 324, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Silver
    if $var11 >= 2000
      bitmap = RPG::Cache.icon("silver")
      self.contents.blt(25, 324, bitmap, Rect.new(0, 0, 24, 24))
    end
    # Gold
    if $var11 >= 3000
      bitmap = RPG::Cache.icon("gold")
      self.contents.blt(50, 324, bitmap, Rect.new(0, 0, 24, 24))
    end
  end
end

# Actual Scene

class Scene_Records
  def main
   
#================================
# What goes in the middle box
#================================
   
    s1 = "Variable 1"
    s2 = "Variable 2"
    s3 = "Variable 3"
    s4 = "Variable 4"
    s5 = "Variable 5"
    s6 = "Variable 6"
    s7 = "Variable 7"
    s8 = "Variable 8"
    s9 = "Variable 9"
    s10 = "Variable 10"
    s11 = "Variable 11"
    @spriteset = Spriteset_Map.new
    @command_window = Window_Command.new(320, [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11])
    @command_window.y = 0
    @command_window.x = 160
    @command_window.back_opacity = 180
    @trophy_window = Window_Trophy.new
    @trophy_window.x = 56
    @trophy_window.back_opacity = 180
    @count_window = Window_Count.new
    @count_window.x = 480
    @count_window.back_opacity = 180
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @spriteset.dispose
    @trophy_window.dispose
    @count_window.dispose
  end
  def update
    @command_window.update
    @spriteset.update
    @trophy_window.update
    @count_window.update
      if @command_window.active
      update_command
      return
    end
    end
  end
  def update_command
  if Input.trigger?(Input::B)
    $game_system.se_play($data_system.cancel_se)
    $scene = Scene_Map.new
    return
  end
end
[/spoiler]

[spoiler=Screenies]
Before
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi163.photobucket.com%2Falbums%2Ft302%2Fpsychomathic-paniac%2Frecordscrn1.jpg&hash=a92230eab2cdea7c2f12550c35e97b336ccdf252)

After
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi163.photobucket.com%2Falbums%2Ft302%2Fpsychomathic-paniac%2Frecordscrn2.jpg&hash=6368410c0d84778dc35205a7b0ca62c0d833873a)
[/spoiler]

You will also need the icons attached to this post.... call them bronze, silver and gold, corresponding to their colors
Remember to give credit to whomever it says in the comments in the script
Title: Re: Records/Rewards Script
Post by: Shinami on June 06, 2007, 08:06:46 PM
Quote from: Rune on June 06, 2007, 07:41:59 PM
Here it is, my first checked, edited and commented script :P
Congratulations! My first script was crap that never ceases to embarrass me. XD
Title: Re: Records/Rewards Script
Post by: Rune on June 06, 2007, 08:12:46 PM
Lol, that meant that my previous scripts weren't commented or checked for improvements, then edited :P
Title: Re: Records/Rewards Script
Post by: Rune on June 08, 2007, 02:26:01 PM
No-one? :(
Title: Re: Records/Rewards Script
Post by: modern algebra on June 08, 2007, 03:41:55 PM
It looks pretty good, but I am still unclear on what it does

Basically, is it the user giving marks to the player for various tasks through variables?

And this shows a screen which has a record of the achievements and the marks they got?

If that's what it is, then good job. Perfect for Stage games, and also for minigames and the like. It adds a nice little feature.


Title: Re: Records/Rewards Script
Post by: Rune on June 08, 2007, 06:00:31 PM
Yup, pretty much... i'll get a couple of screenshots up in a minute... so no more people get confused... i thought it was prety self-explanatory T.T'
Title: Re: Records/Rewards Script
Post by: Rune on June 09, 2007, 10:35:21 AM
Screenies up :D