Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #======================================================================
- # Skill Transformation by Use - 0.8
- # Script by Nyx (20, april, 2012)
- # edmilsonrobson@gmail.com
- #
- # E-mail me for suggestions, questions, bugs, etc
- #======================================================================
- # Feel free to change at your own will. :)
- #======================================================================
- #======================================================================
- #
- # HOW TO USE:
- #
- # At the "notes" box on your skill databases, put the following text:
- #
- # stransid:x:y
- #
- # "x" being the ID of the new skill that will be learned and "y" being
- # the number of uses needed for transformation.
- #
- # e.g:
- #
- # stransid:131:10
- #
- # means that the skill with that note will
- # transform into the Skill which ID is 131 after 10 uses.
- #
- #======================================================================
- # Future updates:
- # - Better note recognition
- # - Better battle notification
- #======================================================================
- #===============================
- # CONFIG
- #===============================
- module STrans
- NOTIFY_TRANS = true # If true, show a battle message notifying
- # the transformation
- TRANS_VOCAB = "%s's skill evolved to \"%s\"!" # Notify message
- OVERRIDES_ON_TRANS = false # If true, the old skill will be deleted
- # If false, the old and new skills will coexist
- SHOW_USES = true # If true, shows a number that represents how many
- # times the skill was used next to its name on
- # the skill menu and on battle
- end
- #===============================
- # END OF CONFIG
- #===============================
- class Game_Actor < Game_Battler
- attr_accessor :times_used
- #=======================================================
- # Modified setup so I can declare the @times_used array
- #=======================================================
- alias su_setup setup
- def setup(actor_id)
- @times_used = []
- su_setup(actor_id)
- end
- #====================================================
- # An altered version of learn_skill from Game_Actor.
- # The changes include notifying the transformation
- #====================================================
- def learn_skill(skill_id)
- unless skill_learn?($data_skills[skill_id])
- @skills.push(skill_id)
- @skills.sort!
- @times_used[skill_id]=0
- if $game_party.in_battle
- @transformed=true
- $game_message.add(sprintf(STrans::TRANS_VOCAB,@name,$data_skills[skill_id].name))
- end
- end
- end
- #====================================================
- # Altered version of the method use_item.
- # The values 2 and 1 for item.id represents Guard
- # and Attack, respectively (they're skills!)
- #====================================================
- def use_item(item)
- pay_skill_cost(item) if item.is_a?(RPG::Skill)
- consume_item(item) if item.is_a?(RPG::Item)
- item.effects.each {|effect| item_global_effect_apply(effect) }
- if item.is_a?(RPG::Skill) and item.id!=2 and item.id!=1
- @times_used[item.id] = @times_used[item.id] + 1
- if item.note.include?("stransid")
- exp_needed = item.note.split(":")[2].to_i
- upgrade_skill(item) if @times_used[item.id]==exp_needed and STrans::NOTIFY_TRANS
- end
- end
- end
- #==========================
- # Upgrades the skill.
- #==========================
- def upgrade_skill(item)
- note = item.note
- upgrade_id = note.split(":")[1].to_i
- forget_skill(item.id) if STrans::OVERRIDES_ON_TRANS
- learn_skill(upgrade_id)
- end
- end
- #====================================================
- # The two modified classes below add the possibility
- # of showing the number of uses of the skill
- # if SHOW_USES was set to true.
- #====================================================
- class Window_SkillList < Window_Selectable
- def draw_item_name(item, x, y, enabled = true, width = 172)
- return unless item
- draw_icon(item.icon_index, x, y, enabled)
- change_color(normal_color, enabled)
- if STrans::SHOW_USES
- draw_text(x + 24, y, width, line_height, item.name + " (" + (@actor.times_used[item.id]).to_s + ")")
- else
- draw_text(x + 24, y, width, line_height, item.name)
- end
- end
- end
- class Window_BattleSkill < Window_SkillList
- def draw_item_name(item, x, y, enabled = true, width = 172)
- return unless item
- draw_icon(item.icon_index, x, y, enabled)
- change_color(normal_color, enabled)
- if STrans::SHOW_USES
- draw_text(x + 24, y, width, line_height, item.name + " (" + (@actor.times_used[item.id]).to_s + ")")
- else
- draw_text(x + 24, y, width, line_height, item.name)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement