Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: arisenhorizen on December 07, 2009, 03:58:09 am

Title: Which part to change [Skill Upgrade Shop by Nechi][VX]
Post by: arisenhorizen on December 07, 2009, 03:58:09 am
Hi,

I recently found this script that allows you to upgrade your skill but I'm not sure how to operate it.

This is the script.
Spoiler: ShowHide
#==============================================================================
# Upgrade Skill Shop for RMVX
#==============================================================================
# By Nechigawara Sanzenin
# WARNING!! : This script can use on RPG Maker VX Only!! (XP Not Support)
#==============================================================================
# Update Skill with shop
#==============================================================================
=begin

How to Use:

You will add "$scene = Scene_Skill_Upgrade.new"  
To Call Skill Shop Windows.

Example:
$scene = Scene_Skill_Upgrade.new

You can turn on/off option under "# Setting".
You can set text to use in Skill Shop under "# Upgrade Text".

You can add "[up-Skill for upgrade to-]"
for set Next Skill at Note in Skill Database.

Example : For set Skill Id 1 to Upgrade to Skill ID 2

[up2]

You can add "[pu-Price-]" for set Skill Price at Note in Skill Database.

Example : For set Price to 150

[pu150]

=end
#==============================================================================
#module SKILL_SHOP
#==============================================================================
module UP_SKILL_SHOP
 # Setting
 Wait_Lv_Up = true # Wait 1 Lv up for use skill from Upgrade
 Show_cha = false # Show Charactor Graphic in Select Window
 # Upgrade Text
 How_Upgrade = "What 's hero do you want to upgrade?"
 Upgrade = "Upgrade"
 Cant_Upgrade = "Can't Upgrade"
 Cancel = "Cancel"
 Next_Lv = "Next Lv"
 Can_use = "%s can use now!"
 Upgrade_to = "Upgrade to"
 None = "None"
 # Price Data For Non Set
 PRICE = 100
 # Id of Next Skill
 def self.skill_upgrade(id)
   text = $data_skills[id].note
   text.scan(/\[up([0-9]+)\]/)
   upgrade = $1.to_i
   return upgrade
 end
 # Add Price
 def self.skill_upgrade_price(id)
   text = $data_skills[id].note
   ene = self.skill_upgrade(id)
   enable = (ene != 0)
   if enable == true
     text.scan(/\[pu([0-9]+)\]/)
     if $1.to_i != 0 then
       price = $1.to_i
     else
       price = PRICE
     end
     return price
   elsif enable == false
     price = 0
   end
   return price
 end
end
#==============================================================================
#class Game_Actor
#==============================================================================
class Game_Actor < Game_Battler
 #--------------------------------------------------------------------------
 def setup(actor_id)
   actor = $data_actors[actor_id]
   @actor_id = actor_id
   @name = actor.name
   @character_name = actor.character_name
   @character_index = actor.character_index
   @face_name = actor.face_name
   @face_index = actor.face_index
   @class_id = actor.class_id
   @weapon_id = actor.weapon_id
   @armor1_id = actor.armor1_id
   @armor2_id = actor.armor2_id
   @armor3_id = actor.armor3_id
   @armor4_id = actor.armor4_id
   @level = actor.initial_level
   @exp_list = Array.new(101)
   make_exp_list
   @exp = @exp_list[@level]
   @skills = []
   @up_skills = []
   @up = []
   for i in self.class.learnings
     learn_skill(i.skill_id) if i.level <= @level
   end
   clear_extra_values
   recover_all
 end
 #--------------------------------------------------------------------------
 def up_skills
   result = []
   for i in @up_skills
     result.push($data_skills[i])
   end
   return result
 end
 #--------------------------------------------------------------------------
 def learn_up_skill(skill_id)
   unless skill_learn?($data_skills[skill_id])
     @up_skills.push(skill_id)
     @up_skills.sort!
   end
 end
 #--------------------------------------------------------------------------
 def forget_skill(skill_id)
   @skills.delete(skill_id)
   @up_skills.delete(skill_id)
 end
 #--------------------------------------------------------------------------
 def skill_learn?(skill)
   if @skills.include?(skill.id)
     return true
   elsif @up_skills.include?(skill.id)
     return true
   else
     return false
   end
 end
 #--------------------------------------------------------------------------
 def up_learn_skill(skill_id)
   unless @skills.include?(skill_id)
     @skills.push(skill_id)
     @skills.sort!
   end
 end
 #--------------------------------------------------------------------------
 def skill_can_use?(skill)
   return false if @up_skills.include?(skill.id)
   return false unless skill_learn?(skill)
   return super
 end
 #--------------------------------------------------------------------------
 def up_skill?(skill)
   return @up_skills.include?(skill.id)
 end
 #--------------------------------------------------------------------------
 def display_level_up(new_skills)
   $game_message.new_page
   text = sprintf(Vocab::LevelUp, @name, Vocab::level, @level)
   $game_message.texts.push(text)
   for skill in new_skills
     unless @up.include?(skill.id)
       text = sprintf(Vocab::ObtainSkill, skill.name)
       $game_message.texts.push(text)
     end
   end
   for i in 0...@up.size
     id = @up[i]
     name = $data_skills[id].name
     text = sprintf(UP_SKILL_SHOP::Can_use, name)
     $game_message.texts.push(text)
   end
   @up = []
 end
 #--------------------------------------------------------------------------
 alias inc_level_up level_up
 def level_up
   inc_level_up
   @up = []
   for i in 0...@up_skills.size
     id = @up_skills[i]
     up_learn_skill(id)
     @up.push(id)
   end
   @up_skills = []
 end
end
#==============================================================================
#class Window_Skill_ShopBuy
#==============================================================================
class Window_Skill < Window_Selectable
 #--------------------------------------------------------------------------
 def refresh
   @data = []
   for skill in @actor.skills
     @data.push(skill)
     if skill.id == @actor.last_skill_id
       self.index = @data.size - 1
     end
   end
   for skill in @actor.up_skills
     @data.push(skill)
   end
   @item_max = @data.size
   create_contents
   for i in 0...@item_max
     draw_item(i)
   end
 end
 #--------------------------------------------------------------------------
 def draw_item(index)
   rect = item_rect(index)
   self.contents.clear_rect(rect)
   skill = @data[index]
   if skill != nil
     rect.width -= 4
     enabled = @actor.skill_can_use?(skill)
     draw_item_name(skill, rect.x, rect.y, enabled)
     if @actor.up_skill?(skill)
       text = UP_SKILL_SHOP::Next_Lv
     else
       text = @actor.calc_mp_cost(skill)
     end
     self.contents.draw_text(rect, text, 2)
   end
 end
end
#==============================================================================
#class Window_Skill_Upgrade
#==============================================================================
class Window_Skill_Upgrade < Window_Selectable
 #--------------------------------------------------------------------------
 def initialize(x, y, width, height)
   super(x, y, width, height)
   @actor = nil
   self.index = 0
   refresh
 end
 #--------------------------------------------------------------------------
 def actor=(actor)
   if @actor != actor
     @actor = actor
     refresh
   end
 end
 #--------------------------------------------------------------------------
 def skill
   return @data[self.index]
 end
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   unless @actor == nil
     @data = []
     for skill in @actor.skills
       @data.push(skill)
     end
     @item_max = @data.size
     create_contents
     for i in 0...@item_max
       draw_item(i)
     end
   end
 end
 #--------------------------------------------------------------------------
 def draw_item(index)
   rect = item_rect(index)
   self.contents.clear_rect(rect)
   skill = @data[index]
   if skill != nil
     rect.width -= 4
     enabled1 = UP_SKILL_SHOP.skill_upgrade(skill.id) != 0
     id_2 = UP_SKILL_SHOP.skill_upgrade(skill.id)
     skill2 = $data_skills[id_2]
     enabled2 = @actor.skill_learn?(skill2) == false
     price = UP_SKILL_SHOP.skill_upgrade_price(skill.id)
     enabled3 = (price != 0 and $game_party.gold >= price)
     enabled = (enabled1 and enabled2 and enabled3)
     draw_item_name(skill, rect.x, rect.y, enabled)
     unless enabled1 and enabled2
       self.contents.draw_text(rect, UP_SKILL_SHOP::Cant_Upgrade , 2)
     else
       self.contents.draw_text(rect, price , 2)
     end
   end
 end
 #--------------------------------------------------------------------------
 def update_help
   @help_window.set_text(skill == nil ? "" : skill.description)
 end
end
#==============================================================================
#class Window_Next_Skill_Upgrade
#==============================================================================
class Window_Next_Skill_Upgrade < Window_Selectable
 #--------------------------------------------------------------------------
 def initialize(x, y)
   super(x, y, 304, WLH + 32)
   @skill = nil
   refresh
 end
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   if @skill != nil
     self.contents.font.color = system_color
     text = UP_SKILL_SHOP::Upgrade_to
     cx = contents.text_size(text).width
     self.contents.draw_text(4, 0, cx, WLH, text)
     enabled = UP_SKILL_SHOP.skill_upgrade(@skill.id) != 0
     unless enabled
       none_text = UP_SKILL_SHOP::None
       self.contents.draw_text(4, 0, 200, WLH, none_text , 2)
     else
       id_2 = UP_SKILL_SHOP.skill_upgrade(@skill.id)
       skill2 = $data_skills[id_2]
       sx = contents.text_size(skill2.name).width
       set_x = sx + 24
       draw_item_name(skill2, self.contents.width - set_x, 0, enabled)
     end
   end
 end
 #--------------------------------------------------------------------------
 def skill=(skill)
   if @skill != skill
     @skill = skill
     refresh
   end
 end  
end
#==============================================================================
#class Window_Skill_Hero_Upgrade
#==============================================================================
class Window_Skill_Hero_Upgrade < Window_Selectable
 #--------------------------------------------------------------------------
 def initialize(x, y)
   super(x, y, 240, 304)
   refresh
   self.active = false
   self.index = 0
 end
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   @item_max = $game_party.members.size
   self.contents.font.color = system_color
   self.contents.draw_text(4, 0, 200, WLH, UP_SKILL_SHOP::How_Upgrade)
   for actor in $game_party.members
     x = 4
     y = WLH * (2 + actor.index * 2)
     draw_actor(actor, x, y)
   end
 end
 #--------------------------------------------------------------------------
 def draw_actor(actor, x, y)
   self.contents.font.color = normal_color
   if UP_SKILL_SHOP::Show_cha
     name = actor.character_name
     index = actor.character_index
     size = contents.text_size(actor.name).width
     draw_character(name, index, x + 20 + size , y + 30)
   end
   self.contents.draw_text(x, y, 200, WLH, actor.name)
 end
 #--------------------------------------------------------------------------
 def update_cursor
   if @index < 0
     self.cursor_rect.empty
   elsif @index < @item_max
     y = WLH * (2 + @index * 2)
     unless UP_SKILL_SHOP::Show_cha
       self.cursor_rect.set(0, y , contents.width, WLH)
     else
       self.cursor_rect.set(0, y - 4, contents.width,34)
     end
   end
 end
end
#==============================================================================
#class Scene_Skill_Upgrade
#==============================================================================
class Scene_Skill_Upgrade < Scene_Base
 #--------------------------------------------------------------------------
 def start
   super
   create_menu_background
   create_command_window
   @viewport = Viewport.new(0, 0, 544, 416)
   @help_window = Window_Help.new
   @gold_window = Window_Gold.new(384, 56)
   @dummy_window = Window_Base.new(0, 112, 544, 304)
   @skill_window = Window_Skill_Upgrade.new(240, 112, 304 , 248)
   @skill_window.active = false
   @skill_window.visible = false
   @skill_window.help_window = @help_window
   @hero_window = Window_Skill_Hero_Upgrade.new(0, 112)
   @hero_window.visible = false
   @hero_window.active = false
   @upgrade_window = Window_Next_Skill_Upgrade.new(240,360)
   @upgrade_window.visible = false
 end
 #--------------------------------------------------------------------------
 def terminate
   super
   dispose_menu_background
   dispose_command_window
   @help_window.dispose
   @gold_window.dispose
   @dummy_window.dispose
   @skill_window.dispose
   @hero_window.dispose
   @upgrade_window.dispose
 end  
 #--------------------------------------------------------------------------
 def update
   super
   update_menu_background
   @help_window.update
   @command_window.update
   @gold_window.update
   @dummy_window.update
   @skill_window.update
   @hero_window.update
   @upgrade_window.update
   if @command_window.active
     update_command_selection
   elsif @skill_window.active
     update_skill_selection
   elsif @hero_window.active
     update_hero_selection
   end
 end
 #--------------------------------------------------------------------------
 def create_command_window
   s1 = UP_SKILL_SHOP::Upgrade
   s2 = UP_SKILL_SHOP::Cancel
   @command_window = Window_Command.new(384, [s1, s2], 2)
   @command_window.y = 56
 end
 #--------------------------------------------------------------------------
 def dispose_command_window
   @command_window.dispose
 end
 #--------------------------------------------------------------------------
 def update_command_selection
   @help_window.set_text("")
   if Input.trigger?(Input::B)
     Sound.play_cancel
     $scene = Scene_Map.new
   elsif Input.trigger?(Input::C)
     case @command_window.index
     when 0
       Sound.play_decision
       @command_window.active = false
       @dummy_window.visible = false
       @skill_window.visible = true
       @hero_window.visible = true
       @hero_window.active = true
       @upgrade_window.visible = true
     when 1
       Sound.play_decision
       $scene = Scene_Map.new
     end
   end
 end
 #--------------------------------------------------------------------------
 def update_skill_selection
   skill = @skill_window.skill
   @upgrade_window.skill = skill
   if Input.trigger?(Input::B)
     Sound.play_cancel
     @skill_window.active = false
     @hero_window.active = true
   elsif Input.trigger?(Input::C)
     enabled1 = UP_SKILL_SHOP.skill_upgrade(skill.id) != 0
     id_2 = UP_SKILL_SHOP.skill_upgrade(skill.id)
     skill2 = $data_skills[id_2]
     enabled2 = @actor.skill_learn?(skill2) == false
     @price = UP_SKILL_SHOP.skill_upgrade_price(skill.id)
     enabled3 = (@price != 0 and $game_party.gold >= @price)
     enabled = (enabled1 and enabled2 and enabled3)
     unless enabled
       Sound.play_buzzer
     else
       Sound.play_decision
       learn_target(id_2,skill.id)
     end
   end
 end
 #--------------------------------------------------------------------------
 def update_hero_selection
   @help_window.set_text("")
   @actor = $game_party.members[@hero_window.index]
   @skill_window.actor = @actor
   skill = @skill_window.skill
   @upgrade_window.skill = skill
   if Input.trigger?(Input::B)
     Sound.play_cancel
     @command_window.active = true
     @dummy_window.visible = true
     @skill_window.visible = false
     @hero_window.visible = false
     @hero_window.active = false
     @upgrade_window.visible = false
   elsif Input.trigger?(Input::C)
     Sound.play_decision
     @skill_window.active = true
     @hero_window.active = false
   end
 end
 #--------------------------------------------------------------------------
 def learn_target(skill_id1,skill_id2)
   Sound.play_shop
   unless UP_SKILL_SHOP::Wait_Lv_Up
     @actor.learn_skill(skill_id1)
   else
     @actor.learn_up_skill(skill_id1)
   end
   @actor.forget_skill(skill_id2)
   $game_party.lose_gold(@price)
   @skill_window.refresh
   @gold_window.refresh
   @hero_window.refresh
   @upgrade_window.refresh
 end
end


My problem is, I don't know which part of the script that I have to change. Because when I test it, none of my skill is upgradable.

Please use code tags when posting code ~ G_G
Title: Re: Which part to change [Skill Upgrade Shop by Nechi].
Post by: Jackolas on December 07, 2009, 04:09:18 am
would be nice if next time put into the topic title that's it for VX :P
was almost trying to load it into XP....