RMXP to RMVX script?

Started by BetaGod, August 15, 2013, 10:36:28 pm

Previous topic - Next topic

BetaGod

Sup' guys!

So a while ago, KK20 helped me with a script that allowed the player to see some basic performance info ingame.

Recently i got into RMVX and although i am know some coding, i am still not used to most of the new stuff in RGSS2.

So i was wondering if someone could adapt this RMXP script into RMVX (Mostly because i want to learn how would you guys do it).
I just need the "Game Stats" screen, and not the "Special Abilities" stuff, so it should be quite simple.

Spoiler: ShowHide
=begin
/////////////////////////////////////////////////////////////////////////////
Special Abilities and Stats Scenes                               May 2, 2013
By KK20
/////////////////////////////////////////////////////////////////////////////

[ Instructions ]
Configure the script below. Make your special abilities in the Skill tab of the
database. The script only requires that the skill have a name, icon, and
description--all other values do not matter.

To process an event after using a special ability, use the script call:
      used_ability(id)
where 'id' is the ID of the skill in the database. It works much in the same
way as G_G's Key Items script.

To add/remove special abilities to the party:
      $game_party.add_ability(id)
      $game_party.remove_ability(id)

To call upon the 'Jobs' scene, use
      $scene = Scene_SpecialAbilities.new
To call upon the 'Statistics' scene, use
      $scene = Scene_Statistics.new
You will have to manually add these lines to your Scene_Menu class if you wish
to access them in the game menu.
     
=end
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# C O N F I G U R A T I O N
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Input key to bring up the Special Abilities window on map
USE_SPECIAL_ABILITY_KEY = Input::X
# Return index to Menu screen when exiting 'Jobs'
JOBS_MENU_INDEX = 2
# Return index to Menu screen when exiting 'Statistics'
STATS_MENU_INDEX = 3
# The names of the five traits drawn in the 'Statistics' window. The names
# should be the same as the graphic files located in the \Pictures folder.
FIVE_MASTERIES = ['Alignment','Discretion','Conjuration','Alteration','Inquisition']
# Input the variables used to store the player's mastery levels.
# Please put them in quotes to prevent startup errors
MASTERY_VAR = ['$game_party.alignment','$game_party.discretion','$game_party.conjuration','$game_party.alteration','$game_party.inquisition']

STAT_RECORDS = [
# Used in 'Statistics'. Draws the player's records.

# Configure setup:
# [Description of record, Variable called to display, (optional) Total Number]

# If 'Total Number' is specified, draws a '/' in between the two values.
# If 'Total Number' is a decimal value, the game will create a percentage.
# If using game variables, please put them in quotes to prevent startup errors.
['Enemies defeated:', "$game_party.actors.size"],
['Bosses killed:', '$game_variables[20]'],
['Total party deaths:', '$game_party.death_count'],
['Quests completed:', '$game_party.completed_quests', 200],
['Number of saves:', '$game_system.save_count'],
['Percent complete:', '$game_system.percent_complete', 100.0]
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# E N D    O F    C O N F I G U R A T I O N
#=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
]

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  Creates a special abilities array and defines methods for adding/removing
#==============================================================================
class Game_Party
  attr_reader :special_abilities
 
  alias init_special_abilities initialize
  def initialize
    @special_abilities = []
    init_special_abilities
  end
 
  def add_ability(id)
    @special_abilities.push(id) unless @special_abilities.include?(id)
  end
 
  def remove_ability(id)
    @special_abilities.delete(id)
  end
 
end
#==============================================================================
# Interpreter (Edit)
#------------------------------------------------------------------------------
#  Added the method "used_ability(id)"
#==============================================================================
class Interpreter
  def used_ability(id)
    flag = id == $game_temp.ability_id
    $game_temp.ability_id = 0
    return flag
  end
end
#==============================================================================
# Scene_Map (Edit)
#------------------------------------------------------------------------------
#  Modified to add Window_SpecialAbility_Map
#==============================================================================
class Scene_Map
  #----------------------------------------------------------------------------
  # Initializes Map
  #----------------------------------------------------------------------------
  alias create_special_abilities_win main
  def main
    @spcabl_window = Window_SpecialAbility_Map.new
    create_special_abilities_win
    @spcabl_window.dispose
  end
  #----------------------------------------------------------------------------
  # Updates Map
  #----------------------------------------------------------------------------
  alias update_special_abilities_win update
  def update
    @spcabl_window.update
    update_special_abilities_win
  end
end
#==============================================================================
# Game_Temp
#------------------------------------------------------------------------------
#  Added @ability_id to keep track of used special ability
#==============================================================================
class Game_Temp
  attr_accessor :ability_id
end

#==============================================================================
# Window_SpecialAbility_Map
#------------------------------------------------------------------------------
#  On map window to display "special abilities" that can be used with events
#==============================================================================
class Window_SpecialAbility_Map < Window_Selectable
  #----------------------------------------------------------------------------
  # Creates Window
  #----------------------------------------------------------------------------
  def initialize
    super(220, 304, 200, 160)
    @column_max = 1
    self.back_opacity = 160
    self.active = false
    self.visible = false
    refresh
    @menu_disabled = $game_system.menu_disabled
  end
  #----------------------------------------------------------------------------
  # Updates Window
  #----------------------------------------------------------------------------
  def update
    super
    $game_system.menu_disabled = @menu_disabled
    if Input.trigger?(Input::C) && self.active
      $game_system.se_play($data_system.decision_se)
      self.active = false
      self.visible = false
      $game_temp.ability_id = selected_item.id
      $game_temp.message_window_showing = false
      return
    elsif Input.trigger?(USE_SPECIAL_ABILITY_KEY) &&
        !$game_temp.message_window_showing &&
        !$game_system.map_interpreter.running?
      $game_system.se_play($data_system.decision_se)
      refresh
      self.index = 0
      self.active = true
      self.visible = true
      $game_temp.message_window_showing = true
      return
    elsif Input.trigger?(Input::B) && self.active
      $game_system.se_play($data_system.cancel_se)
      self.active = false
      self.visible = false
      $game_temp.message_window_showing = false
      @menu_disabled = $game_system.menu_disabled
      $game_system.menu_disabled = true
    end
  end
  #----------------------------------------------------------------------------
  # Refreshes Window
  #----------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @items = []
    $game_party.special_abilities.each{|ability|
      @items.push($data_skills[ability])
    }
    @item_max = @items.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #----------------------------------------------------------------------------
  # Draws Item
  #----------------------------------------------------------------------------
  def draw_item(index)
    skill = @items[index]
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.draw_text(x + 28, y, 200, 32, skill.name, 0)
  end
  #----------------------------------------------------------------------------
  # Returns Selected Item
  #----------------------------------------------------------------------------
  def selected_item
    return @items[self.index]
  end
end
#==============================================================================
# ** Window_SpecialAbility_Menu
#------------------------------------------------------------------------------
#  This window displays party's special abilities
#==============================================================================
class Window_SpecialAbility_Menu < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize
    super(0, 64, 640, 416)
    @column_max = 2
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # * Acquiring Skill
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    $game_party.special_abilities.each{|ability|
      @data.push($data_skills[ability])
    }
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  end
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.skill == nil ? "" : self.skill.description)
  end
end

#==============================================================================
# ** Scene_SpecialAbilities
#------------------------------------------------------------------------------
#  This class processes the special abilities scene
#==============================================================================
class Scene_SpecialAbilities
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, status window, and skill window
    @help_window = Window_Help.new
    @skill_window = Window_SpecialAbility_Menu.new
    # Associate help window
    @skill_window.help_window = @help_window
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @help_window.dispose
    @skill_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @skill_window.update
    # call update_skill
    update_skill
  end
  #--------------------------------------------------------------------------
  # * Frame Update (if skill window is active)
  #--------------------------------------------------------------------------
  def update_skill
    # 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_Menu.new(JOBS_MENU_INDEX)
      return
    end
  end
end
#==============================================================================
# ** Window_Statistics
#------------------------------------------------------------------------------
#  This window displays party's accomplishments and traits
#==============================================================================
class Window_Statistics < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 640, 480)
    self.contents = Bitmap.new(width-32, height-32)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    # Draw title
    self.contents.font.size = 50
    self.contents.draw_text(0,0,640,60,"Game Stats",1)
    # Draw accomplishments/statistics
    self.contents.font.size = 18
    index = 0
    x,y = 0,40
    STAT_RECORDS.each{|data|
      record = data[0]
      value = data[1].is_a?(String) ? eval(data[1]) : data[1]
      total = data[2].is_a?(String) ? eval(data[2]) : data[2]
      # If display percentage
      value /= total if total != nil and total.is_a?(Float)
      string = record + ' ' + value.to_s
      string += '%' if total.is_a?(Float)
      string += ' / ' + total.to_s if total.is_a?(Integer)
      a = index % 2 == 0 ? 0 : 2
      self.contents.draw_text(x + 320*(index%2),y + 24*(index/2),320-32,32,string,a)
      index += 1
    }
    # Draw Alignment
    self.contents.font.size = 28
    img = RPG::Cache.picture(FIVE_MASTERIES[0])
    self.contents.blt(170,30+40,img,Rect.new(0,0,img.width,img.height))
    self.contents.draw_text(245, 160+40, 150, 40, FIVE_MASTERIES[0], 1)
    c1,c2,c3= Color.new(255,55,0),Color.new(185,25,0),Color.new(0, 0, 0)
    rate = (eval(MASTERY_VAR[0]) / 100.0).abs
    self.contents.gradient_bar(220, 185+40, 200, c1, c2, c3, rate)
    case eval(MASTERY_VAR[0]) <=> 0
    when -1 then str = 'Evil'
    when 0 then str = 'Neutral'
    when 1 then str = 'Good'
    end
    self.contents.draw_text(220,265,200,40,str, 1)
    self.contents.draw_text(220,295,200,40,'Lv. ' + eval(MASTERY_VAR[0]).to_s, 1)
    # Draw the 4 mastery symbols
    x = 4
    y = 300 #260
    FIVE_MASTERIES.each{|trait|
      # Skip the first mastery (which should be alignment)
      next if FIVE_MASTERIES.index(trait) == 0
      self.contents.font.size = 18
      img = RPG::Cache.picture(trait)
      dest_rect = Rect.new(x,y,img.width/2,img.height/2)
      self.contents.stretch_blt(dest_rect,img,Rect.new(0,0,img.width,img.height))
      self.contents.draw_text(x+25, y+110, 100, 32, trait, 1)
      # Determine gradient bar colors
      case x/150
      when 0 # Discretion
        c1 = Color.new(0, 240, 0)
        c2 = Color.new(0, 70, 0)
      when 1 # Conjuration
        c1 = Color.new(0, 240, 0)
        c2 = Color.new(0, 70, 0)
      when 2 # Alteration
        c1 = Color.new(0, 240, 0)
        c2 = Color.new(0, 70, 0)
      when 3 # Inquisition
        c1 = Color.new(0, 240, 0)
        c2 = Color.new(0, 70, 0)
      end
      rate = (eval(MASTERY_VAR[x/150+1]) / 100.0)
      self.contents.gradient_bar(x+25, y+78, 100, c1, c2, c3, rate)
      self.contents.font.size = 22
      self.contents.draw_text(x+25,y+88,100,28,eval(MASTERY_VAR[x/150+1]).to_s,1)
      x += 150
    }
  end
end
#==============================================================================
# ** Scene_Statistics
#------------------------------------------------------------------------------
#  This class performs statistics processing.
#==============================================================================
class Scene_Statistics
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make statistics window
    @status_window = Window_Statistics.new
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @status_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  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_Menu.new(STATS_MENU_INDEX)
      return
    end
  end
end


Thanks in advance!
I am a god in BETA status and therefore, i may contain bugs and such.

BetaGod

I am a god in BETA status and therefore, i may contain bugs and such.

PhoenixFire

I think your best bet to solve these issues, would be to learn Ruby in the first place. It will give you a better understanding of RGSS, RGSS2, etc.

If you simply cannot do that, or choose not to, I would suggest doing some research of your own first... Look into the calls of each method (like $game_menu or others) and see what the public reference is for each, and compare it to the method that should be used for VX. Alot of things should be a matter of referencing or calling, the proper method.



If there's a scripter that understands what I'm saying and can explain it better, please feel free to re-word what I just said haha
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

BetaGod

Well, actually. I've alredy try (several times) and failed. Since i am still learning, i made this request in the first place to see "how would a pro do it?".

Sure, i can get it done if i keep trying, but it won't be optimal and it won't be the best way to do it, wich is what i am aming for.

I AM learning, and that's why i want to see how would a well trained person in RGSS2 do it  :^_^':
I am a god in BETA status and therefore, i may contain bugs and such.

KK20

I don't think there is anyone else here who would be willing to convert that script for you. I'm also not willing to learn RGSS2 either. :\

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!

PhoenixFire

Quote from: BetaGod on August 19, 2013, 12:13:37 pm
i made this request in the first place to see "how would a pro do it?".


Well, although I could -try- to help, I am nowhere near as expert level as KK20 here, nor would my version be optimized either. I looked through a few other forums for you too, and it looks like alot of people are saying the same thing to similar requests. On the bright side, this would be a great learning opportunity for you to try out your knowledge on this, and it will refine your knowledge of what does and does not work.
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

BetaGod

Damn... I was hoping to see exactly how would be the proper way to do it, but it's fine, as you say, this could be a very good chance for me to improve quite a lot.

Anyway, thanks for the support  ;)
I am a god in BETA status and therefore, i may contain bugs and such.

PhoenixFire

No problemo. One thing you could do would be to work on it, and post what you've done to it, and what it caused to happen. Like say you change the call method a little bit, and it produces a new error. Post up what you did to fix different things. Might prove to be useful for someone down the road that has a similar issue. Plus, it would give some of the rest of us a chance to have a start on a tutorial or something for conversion of code.
Quote from: Subsonic_Noise on July 01, 2011, 02:42:19 amNext off, how to create a first person shooter using microsoft excel.

Quote from: Zeriab on September 09, 2011, 02:58:58 pm<Remember when computers had turbo buttons?

BetaGod

In case anyone else wonders how to convert this sort of simple scripts, someone got the job done for me in this forum.
I am a god in BETA status and therefore, i may contain bugs and such.

Blizzard

Yeah, we're not really big on VX and VXA support. We're more focused on XP here at CP.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.