Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Learn Skills from Items Script
#1
Learn Skills from Items Script
by Khatharr
Jul 14 2005

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.


Here's a script that teaches a character a skill when a specific item is used on them. This was in response to a request by kouato_terra. It occurs to me that there's probably another script out there that does this, but I really don't give a rip, 'cuz I wanted to code this. So here:

First go into Scene_Item and find the section that begins "def update_target". Within that section, find the line that reads "used = target.item_effect(@item)". Replace that line with the following code block:
Code:
#----------------------------script insertion begin---------------------------------
        sound = false
        case @item.id
        when 33  #the ID from the database of the item that teaches the skill
          used = learn_from_item(target, 81)  #database ID of the skill it teaches
        when 34  #the ID from the database of the item that teaches the skill
          used = learn_from_item(target, 82)  #database ID of the skill it teaches
        else
          used = target.item_effect(@item)  #this line executes the "normal" item code.
          sound = true
        end
        #----------------------------script insertion end-----------------------------------
We'll come back to that in a minute.

The next step is simple. Just make a new section (right-click on "main" in the left-hand list and select "insert") and call it whatever, and paste the following code into it:
Code:
#==============================================================================
#Script that teaches skills from items.
#Coded sloppily by Khatharr
#Idea by kouato_terra.
#Check out some hot, steamy RPG Maker XP action at www.dubealex.com
#Oh, and do whatever you want with this script.  I don't care.
#==============================================================================

class Window_Tada < Window_Base
  #--------------------------------------------------------------------------
  def initialize(text)
    super(0, 208, 640, 64)
    self.z = 9999
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype
    self.contents.font.size = $defaultfontsize == nil ? $fontsize : $defaultfontsize
    self.width = self.contents.text_size(text).width + 64
    self.contents = Bitmap.new(width - 32, height - 32)
    #edit by midge
    self.contents.font.name = $fontface.is_a?(String) ? $fontface : $defaultfonttype
    self.contents.font.size =  $defaultfontsize == nil ? $fontsize : $defaultfontsize
    #end o midge's edit
    self.x = 320 - (self.width / 2)
    set_text(text)
  end
  #--------------------------------------------------------------------------
  def set_text(text, align = 0)
    if text != @text or align != @align
      self.contents.clear
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, self.width - 40, 32, text, align)
      @text = text
      @align = align
      @actor = nil
    end
    self.visible = true
  end
end
  #--------------------------------------------------------------------------
class Scene_Item
  def learn_from_item(dude, trick)
    unless dude.skill_learn?(trick)
      text = dude.name + " learned the skill ''" + $data_skills[trick].name + "''!"
      @temp_window = Window_Tada.new(text)
      $game_system.se_play(@item.menu_se)
      Input.update
      until Input.trigger?(Input::C)
        Graphics.update
        Input.update
      end
      @temp_window.dispose
      $game_system.se_play($data_system.decision_se)
      dude.learn_skill(trick)
      return true
    end
  end
end
Now the script should be technically working, but you still have to define what item teaches what skill, so let's look back at that first code insertion. You'll see a couple examples. The first is:
Code:
when 33  #the ID from the database of the item that teaches the skill
          used = learn_from_item(target, 81)  #database ID of the skill it teaches
There's a brief explanation in it already, but what this basically does is say that when you use item# 33, it should teach skill# 81. The "when 33" part assigns item#33, and the "(target, 81)" part assigns skill# 81. That should be straightforward enough. You can add as many as you like. Please note that if the item also heals or does some other item-ish thing, it won't do that part, but will only teach the skill.

When you set the item up in the database make sure usability is "Menu", target is "One Ally". Then just give it a name and an icon and a description and you're good. And for the record, it won't work in battle, it won't work on multiple people, and it will work with a common event, but unless you're really creative that might get kinda silly....

It worked okay for me when I tested it, but (like most of my scripts) it may have bugs, so if it does, please make a note of it here and send me a PM with a link to this thread.
}


Possibly Related Threads…
Thread Author Replies Views Last Post
  Encounter Restrictions Script modern algebra 0 2,049 08-25-2007, 01:00 PM
Last Post: modern algebra
  Credit Script 1.4 REAL Acoole 0 2,030 05-01-2007, 01:00 PM
Last Post: Acoole
  Addon or Update Script System BETA samamanjaro 0 2,074 11-15-2006, 01:00 PM
Last Post: samamanjaro
  Item Count Script KaotiX 0 2,111 09-04-2005, 01:00 PM
Last Post: KaotiX
  Script Generator Dubealex 0 2,069 05-30-2005, 01:00 PM
Last Post: Dubealex
  Memorize Location Script - Release 2 Dubealex 0 1,867 11-10-2004, 01:00 PM
Last Post: Dubealex



Users browsing this thread: