[XP] Help with Rune's Biography Script

Started by Launian, March 11, 2012, 01:14:53 am

Previous topic - Next topic

Launian

March 11, 2012, 01:14:53 am Last Edit: March 11, 2012, 01:31:08 am by Launian
Hello, everyone. I wanted to know if any of you guys could help me with a little problem I encountered while setting up this script:

When it draws the bio window, it takes the default battler and doubles its size (hence making it all blurry and awful), but I'd like to get a higher-resolution pic in there (I got the pictures alredy, on the subfolder Graphics\Battlers\Bio\).

Now, the part of the code that selects the image (as far as I can tell, anyways) is this:


bitmap = RPG::Cache.battler(@actor.battler_name, @actor.battler_hue)


If anyone knows the answer just from reading my post, great. If not, then here's the whole script:

Spoiler: ShowHide
=begin
=================================
     Character biography script (revised with pictures)
                             By Rune
                 Revision 1.3 by statesman88
            Expanded from Mr. Wiggles' revision
=================================
Introduction
=================================
This is a script that calls a window that displays different
aspects about a character... like their age, height, weight,
gender etc. These can be changed though. This script is
free to use and edit as long as credit is given to me.
=================================
Edits
=================================
-1.3: Fixed $defaultfontsize error
-Deleted Biography subsection, since I don't think you need
a Biography and a History
-Added the battler image of the actor. If the image is small
enough, it will be doubled in size. (To be doubled, the
original image must fit within one of two boxes: 224x144
px OR 112x208 px.)
=================================
Instructions
=================================
Insert this script above main, and call it Scene_Biography.
Then, ctrl + f to search for the different aspects of
characters you wish to change, so for a character's age,
you would search biog_age, and for gender you would
search, biog_gender. Each aspect is listed in the
character's order in the database, and the different stats
of each character are set at default to (what I think of)
the default 8 characters.

Once the script is in your game, you may wish to add it
to your menu. To do so... in Scene_Menu make a new
option, and add it into the comand_window list. Then go
down to the first time it says "when 0", 'when 1" etc and
copy and paste the status, equip or skill responses. Then
go all the way down to where it says "when 1", "when 2"
etc, and type this.

$game_system.se_play($data_system.decision_se)
$scene = Scene_Biography.new(@status_window.index)

If you don't know how to do that then just tell me, and
i'll help you out, and if you need any more help,
PM me ;)
=================================
Any last words?
=================================
Again PM me if you need any help in changing the text or
anything like that, though even non-scripters should be
able to do that. And enjoy ;)
=end


class Window_Base
 def biog_color
   return Color.new(0, 255, 160)
 end
 def draw_actor_name(actor, x, y)
   self.contents.font.color = normal_color
   self.contents.draw_text(x, y, 120, 32, actor.name)
 end
end

class Window_Biography < Window_Base
 def initialize(actor)
   super(0, 0, 640, 480)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = Font.default_name
   self.contents.font.size = Font.default_size
      # Rune's code; may be for compatibility with a certain message system?
      # self.contents.font.name = $defaultfonttype
      # self.contents.font.size = $defaultfontsize
   @actor = actor
   refresh
 end
 def refresh
   self.contents.font.color = biog_color
   self.contents.draw_text(0, 0, 80, 32, "Name:")
   self.contents.draw_text(0, 32, 80, 32, "Age:")
   self.contents.draw_text(0, 64, 80, 32, "Gender:")
   self.contents.draw_text(0, 96, 80, 32, "Race:")
   self.contents.draw_text(0, 128, 80, 32, "Profession:")
   self.contents.draw_text(0, 160, 80, 32, "Height:")
   self.contents.draw_text(0, 192, 80, 32, "Weapon:")
   self.contents.draw_text(0, 224, 80, 32, "From:")
   self.contents.draw_text(0, 256, 80, 32, "Specialty:")
   self.contents.draw_text(0, 288, 80, 32, "History:")
   self.contents.font.color = normal_color
   draw_actor_name(@actor, 96, 0)
   biog_age
   biog_gender
   biog_race
   biog_height
   biog_weight
   biog_weapon
   biog_from
   biog_specialty
   biog_history
   biog_pic
 end
 def biog_age
   case(@actor.id)
   when 1
     self.contents.draw_text(96, 32, 64, 32, "17")
   when 2
     self.contents.draw_text(96, 32, 64, 32, "16")
   when 3
     self.contents.draw_text(96, 32, 64, 32, "19")
   when 4
     self.contents.draw_text(96, 32, 64, 32, "24")
   when 5
     self.contents.draw_text(96, 32, 64, 32, "17")
   when 6
     self.contents.draw_text(96, 32, 64, 32, "14")
   when 7
     self.contents.draw_text(96, 32, 64, 32, "16")
   when 8
     self.contents.draw_text(96, 32, 64, 32, "22")
   end
 end
 def biog_gender
   case(@actor.id)
   when 1
     self.contents.draw_text(96, 64, 96, 32, "Male")
   when 2
     self.contents.draw_text(96, 64, 96, 32, "Female")
   when 3
     self.contents.draw_text(96, 64, 96, 32, "Male")
   when 4
     self.contents.draw_text(96, 64, 96, 32, "Male")
   when 5
     self.contents.draw_text(96, 64, 96, 32, "Female")
   when 6
     self.contents.draw_text(96, 64, 96, 32, "Male")
   when 7
     self.contents.draw_text(96, 64, 96, 32, "Female")
   when 8
     self.contents.draw_text(96, 64, 96, 32, "Female")
   end
 end
 def biog_race
   case(@actor.id)
   when 1
     self.contents.draw_text(96, 96, 96, 32, "Human")
   when 2
     self.contents.draw_text(96, 96, 96, 32, "Human")
   when 3
     self.contents.draw_text(96, 96, 96, 32, "Human")
   when 4
     self.contents.draw_text(96, 96, 96, 32, "Elf")
   when 5
     self.contents.draw_text(96, 96, 96, 32, "Anthalus")
   when 6
     self.contents.draw_text(96, 96, 96, 32, "Half-Elf")
   when 7
     self.contents.draw_text(96, 96, 96, 32, "Elf")
   when 8
     self.contents.draw_text(96, 96, 96, 32, "Human")
   end
 end
 def biog_height
   case(@actor.id)
   when 1
     self.contents.draw_text(96, 160, 64, 32, "5' 7''")
   when 2
     self.contents.draw_text(96, 160, 64, 32, "5' 4''")
   when 3
     self.contents.draw_text(96, 160, 64, 32, "5' 8''")
   when 4
     self.contents.draw_text(96, 160, 64, 32, "6' 0''")
   when 5
     self.contents.draw_text(96, 160, 64, 32, "5' 6''")
   when 6
     self.contents.draw_text(96, 160, 64, 32, "5' 2''")
   when 7
     self.contents.draw_text(96, 160, 64, 32, "5' 5''")
   when 8
     self.contents.draw_text(96, 160, 64, 32, "5' 9''")
   end
 end
 def biog_weight
   case(@actor.id)
   when 1
     self.contents.draw_text(96, 128, 128, 32, "Knight")
   when 2
     self.contents.draw_text(96, 128, 128, 32, "Mage")
   when 3
     self.contents.draw_text(96, 128, 128, 32, "Paladin")
   when 4
     self.contents.draw_text(96, 128, 128, 32, "Assassin")
   when 5
     self.contents.draw_text(96, 128, 128, 32, "Cleric")
   when 6
     self.contents.draw_text(96, 128, 128, 32, "Mage")
   when 7
     self.contents.draw_text(96, 128, 128, 32, "Hunter")
   when 8
     self.contents.draw_text(96, 128, 128, 32, "11 st 2 lbs")
   end
 end
 def biog_weapon
   case(@actor.id)
   when 1
     self.contents.draw_text(96, 192, 128, 32, "Sword")
   when 2
     self.contents.draw_text(96, 192, 128, 32, "Wands")
   when 3
     self.contents.draw_text(96, 192, 96, 32, "Lance")
   when 4
     self.contents.draw_text(96, 192, 160, 32, "Knives/Wristbands")
   when 5
     self.contents.draw_text(96, 192, 160, 32, "Staffs")
   when 6
     self.contents.draw_text(96, 192, 96, 32, "Wands")
   when 7
     self.contents.draw_text(96, 192, 96, 32, "Distance Weapons")
   when 8
     self.contents.draw_text(96, 192, 96, 32, "Rod")
   end
 end
 def biog_from
   case(@actor.id)
   when 1
     self.contents.draw_text(96, 224, 160, 32, "Random Town")
   when 2
     self.contents.draw_text(96, 224, 160, 32, "Random Castle")
   when 3
     self.contents.draw_text(96, 224, 160, 32, "Random City")
   when 4
     self.contents.draw_text(96, 224, 160, 32, "Random Village")
   when 5
     self.contents.draw_text(96, 224, 160, 32, "Random Elf Village")
   when 6
     self.contents.draw_text(96, 224, 160, 32, "Random City")
   when 7
     self.contents.draw_text(96, 224, 160, 32, "Random Village")
   when 8
     self.contents.draw_text(96, 224, 160, 32, "Random Town")
   end
 end
 def biog_specialty
   case(@actor.id)
   when 1
     self.contents.draw_text(96, 256, 160, 32, "High damage")
   when 2
     self.contents.draw_text(96, 256, 160, 32, "Destructive Magic")
   when 3
     self.contents.draw_text(96, 256, 160, 32, "Defender")
   when 4
     self.contents.draw_text(96, 256, 160, 32, "Stealth")
   when 5
     self.contents.draw_text(96, 256, 160, 32, "Healing Magic")
   when 6
     self.contents.draw_text(96, 256, 160, 32, "Support Magic")
   when 7
     self.contents.draw_text(96, 256, 160, 32, "Multi-attacking")
   when 8
     self.contents.draw_text(96, 256, 160, 32, "Black Magic")
   end
 end
 def biog_history
   case(@actor.id)
   when 1
     self.contents.draw_text(96, 288, 288, 32, "Insert first line of history here")
     self.contents.draw_text(96, 320, 288, 32, "Insert second line of history here")
     self.contents.draw_text(96, 352, 288, 32, "Insert third line of history here")
     self.contents.draw_text(96, 384, 288, 32, "Insert fourth line of history here")
     self.contents.draw_text(96, 416, 288, 32, "Insert fifth line of history here")
   when 2
     self.contents.draw_text(96, 288, 288, 32, "Insert first line of history here")
     self.contents.draw_text(96, 320, 288, 32, "Insert second line of history here")
     self.contents.draw_text(96, 352, 288, 32, "Insert third line of history here")
     self.contents.draw_text(96, 384, 288, 32, "Insert fourth line of history here")
     self.contents.draw_text(96, 416, 288, 32, "Insert fifth line of history here")
   when 3
     self.contents.draw_text(96, 288, 288, 32, "Insert first line of history here")
     self.contents.draw_text(96, 320, 288, 32, "Insert second line of history here")
     self.contents.draw_text(96, 352, 288, 32, "Insert third line of history here")
     self.contents.draw_text(96, 384, 288, 32, "Insert fourth line of history here")
     self.contents.draw_text(96, 416, 288, 32, "Insert fifth line of history here")
   when 4
     self.contents.draw_text(96, 288, 288, 32, "Insert first line of history here")
     self.contents.draw_text(96, 320, 288, 32, "Insert second line of history here")
     self.contents.draw_text(96, 352, 288, 32, "Insert third line of history here")
     self.contents.draw_text(96, 384, 288, 32, "Insert fourth line of history here")
     self.contents.draw_text(96, 416, 288, 32, "Insert fifth line of history here")
   when 5
     self.contents.draw_text(96, 288, 288, 32, "Insert first line of history here")
     self.contents.draw_text(96, 320, 288, 32, "Insert second line of history here")
     self.contents.draw_text(96, 352, 288, 32, "Insert third line of history here")
     self.contents.draw_text(96, 384, 288, 32, "Insert fourth line of history here")
     self.contents.draw_text(96, 416, 288, 32, "Insert fifth line of history here")
   when 6
     self.contents.draw_text(96, 288, 288, 32, "Insert first line of history here")
     self.contents.draw_text(96, 320, 288, 32, "Insert second line of history here")
     self.contents.draw_text(96, 352, 288, 32, "Insert third line of history here")
     self.contents.draw_text(96, 384, 288, 32, "Insert fourth line of history here")
     self.contents.draw_text(96, 416, 288, 32, "Insert fifth line of history here")
   when 7
     self.contents.draw_text(96, 288, 288, 32, "Insert first line of history here")
     self.contents.draw_text(96, 320, 288, 32, "Insert second line of history here")
     self.contents.draw_text(96, 352, 288, 32, "Insert third line of history here")
     self.contents.draw_text(96, 384, 288, 32, "Insert fourth line of history here")
     self.contents.draw_text(96, 416, 288, 32, "Insert fifth line of history here")
   when 8
     self.contents.draw_text(96, 288, 288, 32, "Insert first line of history here")
     self.contents.draw_text(96, 320, 288, 32, "Insert second line of history here")
     self.contents.draw_text(96, 352, 288, 32, "Insert third line of history here")
     self.contents.draw_text(96, 384, 288, 32, "Insert fourth line of history here")
     self.contents.draw_text(96, 416, 288, 32, "Insert fifth line of history here")
   end
 end
 def biog_pic
     bitmap = RPG::Cache.battler(@actor.battler_name, @actor.battler_hue)
     @biogpicwidth = bitmap.width
     @biogpicheight = bitmap.height
         # Prepare to align image with upper right corner (32 pixel margin)
     @biogpicx = 602 - @biogpicwidth
     @bigbiogpicx = 602 - bitmap.width
         # Checks whether the image is small enough to be doubled; it will
         # only use stretch_blt if it fits into 224x144 px OR 112x208 px
         # before being enlarged.
    self.contents.stretch_blt(Rect.new(@biogpicx, 32, @biogpicwidth, @biogpicheight), bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))    
 end
end

class Scene_Biography
 def initialize(actor_index = 0)
   @actor_index = actor_index
 end
 def main
   @actor = $game_party.actors[@actor_index]
   @biog_window = Window_Biography.new(@actor)
   Graphics.transition
   loop do
     Graphics.update
     Input.update
     update
     if $scene != self
       break
     end
   end
   Graphics.freeze
   @biog_window.dispose
 end
 def update
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Switch to menu screen
     $scene = Scene_Map.new
     return
   end
   if Input.trigger?(Input::R)
     $game_system.se_play($data_system.cursor_se)
     @actor_index += 1
     @actor_index %= $game_party.actors.size
     $scene = Scene_Biography.new(@actor_index)
     return
   end
   if Input.trigger?(Input::L)
     $game_system.se_play($data_system.cursor_se)
     @actor_index += $game_party.actors.size - 1
     @actor_index %= $game_party.actors.size
     $scene = Scene_Biography.new(@actor_index)
     return
   end
 end
end


Nevermind the names or any other info in there =p My project is still a long way from finished.

Anyways, thanks a lot for anyone who takes the time to take a look at this. And if you need any more info, let me know.

If I were to leave tonight, would your hand try to reach me?

ForeverZer0

If you like it to look something like this:

Spoiler: ShowHide


Take a look here and see if it fits your needs.

http://forum.chaos-project.com/index.php/topic,6783.0.html
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Launian

Thanks; that's pretty much what Rune's script has. My problem is, I want the script to take the image from a certain folder (not the battlers' default one), but I have no idea how to do it <.< Like, if you wanted to put a face, for example, instead of the battler. How'd you do that?

If I were to leave tonight, would your hand try to reach me?

ForeverZer0

Take a closer look at the config:

Spoiler: ShowHide
  # Filenames of character pictures. 
  def self.character_pic(id)
    file = case id
    when 1 then 'Aluxes'
    when 2 then 'Hilda'
    when 3 then 'Basil'
    end
    return file != nil ? RPG::Cache.picture("Journal/#{file}") : Bitmap.new(1,1)
  end
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Launian

Quote from: ForeverZer0 on March 11, 2012, 02:46:45 am
Take a closer look at the config:

Spoiler: ShowHide
  # Filenames of character pictures. 
  def self.character_pic(id)
    file = case id
    when 1 then 'Aluxes'
    when 2 then 'Hilda'
    when 3 then 'Basil'
    end
    return file != nil ? RPG::Cache.picture("Journal/#{file}") : Bitmap.new(1,1)
  end



Thanks a lot, I finally found it! Have to replace the code line from the first post with:

Quotebitmap = RPG::Cache.battler("Bio/#{@actor.battler_name}", @actor.battler_hue)


:haha:

Now my problem is that the battlers end up "over" the text (if you think of it as layers, they're on the highest layer), so I can't read the text =/ Any idea how to fix that?

If I were to leave tonight, would your hand try to reach me?