Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Skill Details
#1
SKILL DETAILS VERION 0.9
by Me™ (aka Derk-Jan)
Dec 31 2005

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given.


Function: press shift at an skill and get detailed information read by a text file.

Script:
:
Code:
#==================================================================
#**Skill Detail
#  Me™
#  Version 0.9 - Me™
#  21-12-2005
#==================================================================

class Window_SkillDetail < Window_Base
  
  #-----------------------------------------
  #Begin Creates the window for usage.
  #-----------------------------------------
  def initialize
    super(0, 40, 640, 400)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface = $defaultfonttype = "Arial"
    self.contents.font.size = $fontsize = $defaultfontsize = 20
    self.contents.font.color = normal_color
    # z acts as "layer order."
    self.z += 10
    @skilldetail = []
    # ------------------------------
    # @leadingcharacters is set for the script to delete X amount of
    # characters in each line of the .rxdata
    # In this case, the first 5 characters will be deleted in each line.
    # ------------------------------
    @leadingcharacters = 5
    # Clears and resets the window everytime it is requested by Scene_Item.
    refresh2    
  end
  
  def refresh2
    self.contents.font.name = $fontface = $defaultfonttype
    self.contents.font.size = $fontsize = $defaultfontsize
    self.contents.font.color = normal_color
    self.contents.clear
  end
  
  def refresh
    skill_id = $currenthighlightedskill.id
    # The three huge if-then statements check the current highlighted
    # item and its property, and executes the appropriate script
    # when it is true.
    # <-----------------------------------ITEM---------------------------->
      skill_icon = $data_skills[skill_id].icon_name
      getskill_scope = $data_skills[skill_id].scope
      # The Item Scope descriptions can be edited if needed.
      if getskill_scope == 0
        getskill_scope = "Nobody"
      end
      if getskill_scope == 1
        getskill_scope = "One Enemy"
      end
      if getskill_scope == 2
        getskill_scope = "All Enemies"
      end
      if getskill_scope == 3
        getskill_scope = "One Ally"
      end
      if getskill_scope == 4
        getskill_scope = "All Allies"
      end
      if getskill_scope == 5
        getskill_scope = "One Dead (hp = 0) Ally"
      end
      if getskill_scope == 6
        getskill_scope = "All Dead (hp = 0) Ally"
      end
      if getskill_scope == 7
        getskill_scope = "User of the Skill"
      end
      # </> #
      self.contents.font.color = system_color
      self.contents.draw_text(310 + 50, 44, 100, 24, "Type:", 2)
      self.contents.font.color = normal_color
      self.contents.draw_text(426 + 50, 44, 250, 24, getskill_scope, 0)
      
      getskill_occasion = $data_skills[skill_id].occasion
      if getskill_occasion == 0
        getskill_occasion = "Menu + Battle"
      end
      if getskill_occasion == 1
        getskill_occasion = "Only in Battle"
      end
      if getskill_occasion == 2
        getskill_occasion = "Only in Menu"
      end
      if getskill_occasion == 3
        getskill_occasion = "Not Useable"
      end
      self.contents.font.color = system_color
      self.contents.draw_text(310 + 50, 44 + 32, 100, 24, "Occasion:", 2)
      self.contents.font.color = normal_color
      self.contents.draw_text(426 + 50, 44 + 32, 250, 24, getskill_occasion, 0)
      
      # ---------------------------------------------------
      # Start inserting appropriate variables from database.
      # ---------------------------------------------------
      skill_spc   = $data_skills[skill_id].sp_cost.to_s
      skill_atk   = $data_skills[skill_id].atk_f.to_s
      skill_eva   = $data_skills[skill_id].eva_f.to_s
      skill_pwr   = $data_skills[skill_id].power.to_s
      skill_str   = $data_skills[skill_id].str_f.to_s
      skill_dex   = $data_skills[skill_id].dex_f.to_s
      skill_agi   = $data_skills[skill_id].agi_f.to_s
      skill_int   = $data_skills[skill_id].int_f.to_s
      skill_acc   = $data_skills[skill_id].hit.to_s  
      skill_pdf   = $data_skills[skill_id].pdef_f.to_s
      skill_mdf   = $data_skills[skill_id].mdef_f.to_s
      skill_var   = $data_skills[skill_id].variance.to_s
            
      # Sets Elemental and Status attributes of weapon string along with
      # suffix slashes when there are two or more attributes.
      skill_element = ""
      flag = false
      for i in $data_skills[skill_id].element_set
        if flag
          skill_element += "/"
        end
        skill_element += $data_system.elements[i]
        flag = true
      end
      # Checks whether item_element is blank. If it is, then sets it
      # to "None".
      if skill_element == ""
        skill_element = "None"
      end
      skill_status = ""
      flag = false
      for i in $data_skills[skill_id].plus_state_set
        if flag
          skill_status += "/"
        end
        skill_status += $data_states[i].name
        flag = true
      end
      if skill_status == ""
        skill_status = "None"
      end
      
      skill_minstatus = ""
      flag = false
      for i in $data_skills[skill_id].minus_state_set
        if flag
          skill_minstatus += "/"
        end
        skill_minstatus += $data_states[i].name
        flag = true
      end
      if skill_minstatus == ""
        skill_minstatus = "None"
      end
      # ------------------------------
      # Start drawing attribute names.
      # ------------------------------
      # x and y can be changed to easily affect other attributes.
      x = 33
      y = 66
      self.contents.font.color = system_color
      self.contents.font.size = $fontsize - 4
      self.contents.font.color = Color.new(255, 255, 0, 255)
      self.contents.draw_text(x, y, 256, 24, $data_system.words.atk)
      self.contents.draw_text(x, y - 14, 256, 24, $data_system.words.sp + " Costs")
      self.contents.font.color = system_color
      self.contents.draw_text(x, y + 28, 256, 24, $data_system.words.str)
      self.contents.draw_text(x, y + 42, 256, 24, $data_system.words.dex)
      self.contents.draw_text(x, y + 56, 256, 24, $data_system.words.agi)
      self.contents.draw_text(x, y + 70, 256, 24, $data_system.words.int)
      self.contents.font.color = Color.new(255, 255, 255, 128)
      if $data_skills[skill_id].power >= 0
      self.contents.draw_text(x + 170 + 200, y + 56, 256, 24, "Power")
      else if $data_skills[skill_id].power <= 0
      self.contents.draw_text(x + 170 + 200, y + 56, 256, 24, "Heal Pwr")
      end
      end
      self.contents.draw_text(x + 170 + 200, y + 70, 256, 24, "Accuracy")
      self.contents.draw_text(x + 170 + 200, y + 84, 256, 24, "Variance")
      self.contents.font.color = system_color
      self.contents.draw_text(x, y + 84, 256, 24, $data_system.words.pdef)
      self.contents.draw_text(x, y + 98, 256, 24, $data_system.words.mdef)
      self.contents.draw_text(x + 170, y, 256, 24, "Elemental Attack:")
      self.contents.draw_text(x + 170, y + 32, 256, 24, "Status Attack:")
      self.contents.draw_text(x + 170, y + 32 + 32, 256, 24, "Status Removal:")
      # ------------------------------
      # Start drawing attribute values.
      # ------------------------------
      self.contents.font.color = normal_color
      self.contents.draw_text(x + 74, y, 64, 24, skill_atk, 2)
      self.contents.draw_text(x + 74, y - 14, 64, 24, skill_spc, 2)
      self.contents.draw_text(x + 74, y + 28, 64, 24, skill_str, 2)
      self.contents.draw_text(x + 74, y + 42, 64, 24, skill_dex, 2)
      self.contents.draw_text(x + 74, y + 56, 64, 24, skill_agi, 2)
      self.contents.draw_text(x + 74, y + 70, 64, 24, skill_int, 2)
      if $data_skills[skill_id].power >= 0
      self.contents.draw_text(x + 74 + 170 + 200, y + 56, 64, 24, skill_pwr, 2)
      else if $data_skills[skill_id].power <= 0
      skill_pwr = $data_skills[skill_id].power * -1
      self.contents.font.color = Color.new(128, 255, 128, 255)
      self.contents.draw_text(x + 74 + 170 + 200, y + 56, 64, 24, skill_pwr.to_s, 2)
      self.contents.font.color = normal_color
      end
      end
      self.contents.draw_text(x + 74 + 170 + 200, y + 70, 64, 24, skill_acc, 2)
      self.contents.draw_text(x + 74 + 170 + 200, y + 84, 64, 24, skill_var, 2)
      self.contents.draw_text(x + 74, y + 84, 64, 24, skill_pdf, 2)
      self.contents.draw_text(x + 74, y + 98, 64, 24, skill_mdf, 2)
      self.contents.draw_text(x + 170, y + 14, 420, 24, "   " + skill_element, 0)
      self.contents.font.color = Color.new(255, 128, 128, 255)
      self.contents.draw_text(x + 170, y + 14 + 32, 420, 24, "   " + skill_status, 0)
      self.contents.font.color = Color.new(128, 255, 128, 255)
      self.contents.draw_text(x + 170, y + 14 + 64, 420, 24, "   " +       skill_minstatus, 0)
      self.contents.font.color = normal_color
      # Resets font size.
      self.contents.font.size = $fontsize  
    # <-------------------------------------------------------------------->
    
    # Stores skill's icon graphic.
    skill = $currenthighlightedskill
    bitmap = RPG::Cache.icon(skill.icon_name)
    # Draws item's icon.
    self.contents.blt(5, 8, bitmap, Rect.new(0, 0, 24, 24), 255)
    self.contents.font.color = normal_color
    skill_name = $data_skills[skill_id].name
    self.contents.draw_text(33, 8, 256, 24, skill_name)
    self.contents.font.color = normal_color
    # Two lines below calls the two definitions to write the skill's
    # detailed description.
    get_skill_detail(skill_id)
    write_skill_detail(5, 223)
  end
  
  def get_skill_detail(skill_id)
    # descarray stores the line numbers needed to call the right
    # detail description into an array.
    descarray =
    [
    skill_id * 7,
    skill_id * 7 + 1,
    skill_id * 7 + 2,
    skill_id * 7 + 3,
    skill_id * 7 + 4,
    skill_id * 7 + 5,
    skill_id * 7 + 6
    ]
    # The if-then statements below checks the highlighted item and use
    # the right .rxdata.
    if $currenthighlightedskill.is_a?(RPG::Skill)
      f = File.open("Data/Skill_Detail.rxdata")
    end
    # Stores _every_ line of the file into @itemdetail as an array.
    @skilldetail = f.readlines
    # Clears first seven lines for Lines 1-7 (0..6), as it will never be used.
    for i in 0..6
      @skilldetail[i] = ""
    end
    # Crops the first 6 characters in each line.
    for i in 0..6
      cropheadcharacters(descarray[i])
    end
    # Stores the cropped lines into description array.
    @description = []
    for i in 0..6
      @description[i] = @skilldetail[descarray[i]]
    end
    return
  end
  
  def cropheadcharacters(descarray)
    # Checks to see if any lines are nil. If so, then sets them
    # as blank lines after cropping.
    if @skilldetail[descarray] == nil
      @skilldetail[descarray] = "123456 "
    end
    # Crops the first (@leadingcharacters) characters in each line.
    # Default: 5.
    @skilldetail[descarray].slice!(0..@leadingcharacters)
    return
  end
  
  def write_skill_detail(x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y - 20, 640, 32, "Description:")
    self.contents.font.color = normal_color
    self.contents.font.size = $fontsize - 2
    # Draws the first six lines in normal color.
    for i in 0..5
      self.contents.draw_text(x, y, 640, 32, @description[i])
      y += 18
    end
    # Draws the seventh line in another color.
    self.contents.font.color = Color.new(255, 255, 0, 255)
    self.contents.draw_text(x, y, 640, 32, @description[6])
  end  
end


you also need to copy/merge scene_skill with this:

Code:
#======================================================================
========
# ** Scene_Skill
#------------------------------------------------------------------------------
#  This class performs skill screen processing.
#==============================================================================

class Scene_Skill
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor_index : actor index
  #--------------------------------------------------------------------------
  def initialize(actor_index = 0, equip_index = 0)
    @actor_index = actor_index
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Get actor
    @actor = $game_party.actors[@actor_index]
    # Make help window, status window, and skill window
    @help_window = Window_Help.new
    @status_window = Window_SkillStatus.new(@actor)
    @skill_window = Window_Skill.new(@actor)
    # Associate help window
    @skill_window.help_window = @help_window
    # Make target window (set to invisible / inactive)
    @target_window = Window_Target.new
    @target_window.visible = false
    @target_window.active = false
    #==========================================================
    # <Skill Detail Script> #
    # Creates the window and hides it until user input.
    @skilldetail_window = Window_SkillDetail.new
    @skilldetail_window.visible = false
    @skilldetail_window.active = false
    # <Skill Detail Script> #
    #=========================================================
    
    # 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
    @status_window.dispose
    @skill_window.dispose
    @target_window.dispose    
    #==========================================================
    # <Skill Detail  Script>
    #Below line required for disposal when needed.
    @skilldetail_window.dispose
    #</Skill Detail Script>
    #==========================================================
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    #==========================================================
    # <Skill Detail >
    # Below line sets highlighted item into global variable.
    $currenthighlightedskill = @skill_window.skill
    #</Skill Detail Script>
    #==========================================================
    
    # Update windows
    @help_window.update
    @status_window.update
    @skill_window.update
    @target_window.update
    # If skill window is active: call update_skill
    if @skill_window.active
      update_skill
      return
    end
    # If skill target is active: call update_target
    if @target_window.active
      update_target
      return
    end
    #==========================================================
    # <Skill Detail >
    # Tells window to update when active.
    if @skilldetail_window.active
      update_detail
      return
    end
    # </Skill Detail >
    #==========================================================
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (when DETAIL window is active) <SKILL DETAIL SCRIPT!>
  #--------------------------------------------------------------------------
    def update_detail
    if Input.trigger?(Input::cool.gif
      $game_system.se_play($data_system.cancel_se)
      @skill_window.active = true
      @skilldetail_window.visible = false
      @skilldetail_window.active = false
      @skilldetail_window.refresh2
      return    
    end
  end
  
  #--------------------------------------------------------------------------
  # * Frame Update (if skill window is active)
  #--------------------------------------------------------------------------
  def update_skill
    
    #==========================================================
    # <Skill Detail > #
    # Below if-then statement is to check user's input.
    # If user presses Button A (Shift), then Item Detail Window
    # is turned active and visible.
    if Input.trigger?(Input::A)
      # Below if-then statement checks for blank item, and cancels
      # input effect is true.
      if $currenthighlightedskill == nil
        return
      end      
      $game_system.se_play($data_system.decision_se)
      @skilldetail_window.refresh
      @skill_window.active = false      
      @skilldetail_window.visible = true
      @skilldetail_window.active = true
      #create help window
    end
    # </Skill Detail > #
    #==========================================================
    
    # If B button was pressed
    if Input.trigger?(Input::cool.gif
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Switch to menu screen
      $scene = Scene_Menu.new(1)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the skill window
      @skill = @skill_window.skill
      # If unable to use
      if @skill == nil or not @actor.skill_can_use?(@skill.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # If effect scope is ally
      if @skill.scope >= 3
        # Activate target window
        @skill_window.active = false
        @target_window.x = (@skill_window.index + 1) % 2 * 304
        @target_window.visible = true
        @target_window.active = true
        # Set cursor position to effect scope (single / all)
        if @skill.scope == 4 || @skill.scope == 6
          @target_window.index = -1
        elsif @skill.scope == 7
          @target_window.index = @actor_index - 10
        else
          @target_window.index = 0
        end
      # If effect scope is other than ally
      else
        # If common event ID is valid
        if @skill.common_event_id > 0
          # Common event call reservation
          $game_temp.common_event_id = @skill.common_event_id
          # Play use skill SE
          $game_system.se_play(@skill.menu_se)
          # Use up SP
          @actor.sp -= @skill.sp_cost
          # Remake each window content
          @status_window.refresh
          @skill_window.refresh
          @target_window.refresh
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
    # If R button was pressed
    if Input.trigger?(Input::R)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To next actor
      @actor_index += 1
      @actor_index %= $game_party.actors.size
      # Switch to different skill screen
      $scene = Scene_Skill.new(@actor_index)
      return
    end
    # If L button was pressed
    if Input.trigger?(Input::L)
      # Play cursor SE
      $game_system.se_play($data_system.cursor_se)
      # To previous actor
      @actor_index += $game_party.actors.size - 1
      @actor_index %= $game_party.actors.size
      # Switch to different skill screen
      $scene = Scene_Skill.new(@actor_index)
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when target window is active)
  #--------------------------------------------------------------------------
  def update_target
    # If B button was pressed
    if Input.trigger?(Input::cool.gif
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # Erase target window
      @skill_window.active = true
      @target_window.visible = false
      @target_window.active = false
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If unable to use because SP ran out
      unless @actor.skill_can_use?(@skill.id)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If target is all
      if @target_window.index == -1
        # Apply skill use effects to entire party
        used = false
        for i in $game_party.actors
          used |= i.skill_effect(@actor, @skill)
        end
      end
      # If target is user
      if @target_window.index <= -2
        # Apply skill use effects to target actor
        target = $game_party.actors[@target_window.index + 10]
        used = target.skill_effect(@actor, @skill)
      end
      # If single target
      if @target_window.index >= 0
        # Apply skill use effects to target actor
        target = $game_party.actors[@target_window.index]
        used = target.skill_effect(@actor, @skill)
      end
      # If skill was used
      if used
        # Play skill use SE
        $game_system.se_play(@skill.menu_se)
        # Use up SP
        @actor.sp -= @skill.sp_cost
        # Remake each window content
        @status_window.refresh
        @skill_window.refresh
        @target_window.refresh
        # If entire party is dead
        if $game_party.all_dead?
          # Switch to game over screen
          $scene = Scene_Gameover.new
          return
        end
        # If command event ID is valid
        if @skill.common_event_id > 0
          # Command event call reservation
          $game_temp.common_event_id = @skill.common_event_id
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      # If skill wasn't used
      unless used
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
      end
      return
    end
  end
end


Last step: Create a text file name: Skill_Detail and save it as: Skill_Detail.rxdata ^^

BETTER CHECK THE DAMN DEMO

Me™
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Skill Screen Fugly 0 2,433 10-24-2006, 01:00 PM
Last Post: Fugly
  Actor's Weapon Skill Leon Westbrooke 0 2,417 09-21-2006, 01:00 PM
Last Post: Leon Westbrooke
  Equip Weapon Gain Skill makeamidget 0 2,065 08-17-2005, 01:00 PM
Last Post: makeamidget



Users browsing this thread: