The RPG Maker Resource Kit

RMRK RPG Maker Creation => XP => XP Scripts Database => Topic started by: game_guy on May 06, 2009, 12:53:46 AM

Title: [XP] Skill Items
Post by: game_guy on May 06, 2009, 12:53:46 AM
Skill Items
Authors: game_guy
Version: 1.0
Type: Skill Teaching Items
Key Term: Misc Add-on

Introduction

Items now teach actors skills!

Features


Screenshots

Spoiler for:
The actors skills before the item
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi307.photobucket.com%2Falbums%2Fnn318%2Fbahumat27%2Fskillitems.png&hash=166b4370b038e5efd48fe9deaefac5ecf834f6ef)
The item used on the actor
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi307.photobucket.com%2Falbums%2Fnn318%2Fbahumat27%2Fskillitems2.png&hash=58cf7af0ffb474b1515ed5dd134da0372fc58917)
The actors skills after the item
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi307.photobucket.com%2Falbums%2Fnn318%2Fbahumat27%2Fskillitems3.png&hash=18f88d375f0c3a4cf8e4cd8ba773b09118ddb118)

Demo

Demo (http://cid-b4a439303792c7fe.skydrive.live.com/self.aspx/.Public/Skill%20Items.exe)

Script

Script (http://cid-b4a439303792c7fe.skydrive.live.com/self.aspx/.Public/skillitems.txt)
Spoiler for:
Code: [Select]
=begin
#==============================================================================#
# Script : Skill Items                                                         #
# Auther : Game_Guy                                                            #
# Version : 1.0                                                                #
#==============================================================================#

Intro:
Makes items teach players skills.

Instructions:
First go in the database, go to the System Tab and make a new element id and name
it Skill Item. Come back in here and change the 17 below in the module to the id
of the element you just made.

Now go further below and you'll see
# CONFIG use
follow those instructions to set skills to item id's. Then you're set.

One more thing, in items, the ones that are skill items make sure to mark the
element id that you chose in the Elements or else it wont work.

Features:
Makes items teach actors skills.
=end

module GameGuy
  ElementId = 17 # The elemental id in the System tab
end

module RPG
  class Item
    def skill
      case id
      # CONFIG use
      # when x return y
      # x = item id, y = skill id
      # when 2 then return 13
      # The above will make item id 2 make an actor learn the skill id of 13
      when 2 then return 13
      when 1 then return 1
      end
    end
  end
end

#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs item screen processing.
#==============================================================================

class Scene_Item
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make help window, item window
    @help_window = Window_Help.new
    @item_window = Window_Item.new
    # Associate help window
    @item_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
    # 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
    @item_window.dispose
    @target_window.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Update windows
    @help_window.update
    @item_window.update
    @target_window.update
    # If item window is active: call update_item
    if @item_window.active
      update_item
      return
    end
    # If target window is active: call update_target
    if @target_window.active
      update_target
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when item window is active)
  #--------------------------------------------------------------------------
  def update_item
    # 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(0)
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # Get currently selected data on the item window
      @item = @item_window.item
      # If not a use item
      unless @item.is_a?(RPG::Item)
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If it can't be used
      unless $game_party.item_can_use?(@item.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 an ally
      if @item.scope >= 3
        # Activate target window
        @item_window.active = false
        @target_window.x = (@item_window.index + 1) % 2 * 304
        @target_window.visible = true
        @target_window.active = true
        # Set cursor position to effect scope (single / all)
        if @item.scope == 4 || @item.scope == 6
          @target_window.index = -1
        else
          @target_window.index = 0
        end
      # If effect scope is other than an ally
      else
        # If command event ID is valid
        if @item.common_event_id > 0
          # Command event call reservation
          $game_temp.common_event_id = @item.common_event_id
          # Play item use SE
          $game_system.se_play(@item.menu_se)
          # If consumable
          if @item.consumable
            # Decrease used items by 1
            $game_party.lose_item(@item.id, 1)
            # Draw item window item
            @item_window.draw_item(@item_window.index)
          end
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (when target window is active)
  #--------------------------------------------------------------------------
  def update_target
    # If B button was pressed
    if Input.trigger?(Input::B)
      # Play cancel SE
      $game_system.se_play($data_system.cancel_se)
      # If unable to use because items ran out
      unless $game_party.item_can_use?(@item.id)
        # Remake item window contents
        @item_window.refresh
      end
      # Erase target window
      @item_window.active = true
      @target_window.visible = false
      @target_window.active = false
      return
    end
    # If C button was pressed
    if Input.trigger?(Input::C)
      # If items are used up
      if $game_party.item_number(@item.id) == 0
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      # If target is all
      if @target_window.index == -1
        # Apply item effects to entire party
        used = false
        for i in $game_party.actors
          used |= i.item_effect(@item)
        end
      end
      # If single target
      if @target_window.index >= 0
        # Apply item use effects to target actor
        target = $game_party.actors[@target_window.index]
        if @item.element_set.include?(GameGuy::ElementId)
          $game_actors[$game_party.actors[@target_window.index].id].learn_skill(@item.skill)
          used = true
        else
          used = target.item_effect(@item)
        end
       
       
      end
      # If an item was used
      if used
        # Play item use SE
        $game_system.se_play(@item.menu_se)
        # If consumable
        if @item.consumable
          # Decrease used items by 1
          $game_party.lose_item(@item.id, 1)
          # Redraw item window item
          @item_window.draw_item(@item_window.index)
        end
        # Remake target window contents
        @target_window.refresh
        # If all party members are dead
        if $game_party.all_dead?
          # Switch to game over screen
          $scene = Scene_Gameover.new
          return
        end
        # If common event ID is valid
        if @item.common_event_id > 0
          # Common event call reservation
          $game_temp.common_event_id = @item.common_event_id
          # Switch to map screen
          $scene = Scene_Map.new
          return
        end
      end
      # If item wasn't used
      unless used
        # Play buzzer SE
        $game_system.se_play($data_system.buzzer_se)
      end
      return
    end
  end
end



Instructions

First go in the database, go to the System Tab and make a new element id and name
it Skill Item. Come back in here and change the 17 below in the module to the id
of the element you just made.

Now go further below and you'll see
# CONFIG use
follow those instructions to set skills to item id's. Then you're set.

One more thing, in items, the ones that are skill items make sure to mark the
element id that you chose in the Elements or else it wont work.

Compatibility

None yet found. Not tested with SDK.

Credits and Thanks


Author's Notes

If you only want certain Skill Items to work on certain actors I recommend Tons of Add Ons. Fantasist has an add on in there for actor specific items.
Title: Re: [XP] Skill Items
Post by: modern algebra on May 11, 2009, 11:36:04 PM
looks good.
Title: Re: [XP] Skill Items
Post by: Wlachen on May 21, 2009, 02:34:41 AM
im confused...idk wat to do...i want this this script tho it looks like it can add much stuff to the game
Title: Re: [XP] Skill Items
Post by: game_guy on May 23, 2009, 02:07:57 AM
this part
module RPG
  class Item
    def skill
      case id
      # CONFIG use
      # when x return y
      # x = item id, y = skill id
      # when 2 then return 13
      # The above will make item id 2 make an actor learn the skill id of 13
      when 2 then return 13
      when 1 then return 1
      end
    end
  end
end

So right below the last commented line you would do this
when item_id(the item id in the database) then return skill id(the id in the database)

what it does is make items teach players skills. Its a feature from the RPG Maker 200/3 Engine.
Title: Re: [XP] Skill Items
Post by: drakenkanon on September 20, 2009, 12:24:44 PM
cant you just do this with a common event on the item?