Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Shanghai Simple Script - Skill Crack
- # Last Date Updated: 2010.05.27
- # Level: Normal
- #
- # Allow actors to learn skills by killing enemies that possess crackable skills.
- #===============================================================================
- # Instructions
- # -----------------------------------------------------------------------------
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
- #
- # <skill crack: x>
- # <skill crack: x, x, x>
- # This causes actor x to learn the skill when an enemy who knows the skill is
- # killed. Place this inside of the skill's notebox. Use 0 to affect all actors.
- #===============================================================================
- $imported = {} if $imported == nil
- $imported["SkillCrack"] = true
- module SSS
- # This is the message displayed when a skill has learned by killing an enemy.
- SKILL_CRACK_MESSAGE = "%s has learned %s!"
- end
- #==============================================================================
- # RPG::Skill
- #==============================================================================
- class RPG::Skill < RPG::UsableItem
- #--------------------------------------------------------------------------
- # # Skill Crack
- #--------------------------------------------------------------------------
- def skill_crack
- return @skill_crack if @skill_crack != nil
- @skill_crack = []
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when /<(?:SKILL_CRACK|skill crack):[ ](\d+(?:\s*,\s*\d+)*)>/i
- $1.scan(/\d+/).each { |num| @skill_crack.push(num.to_i) }
- end
- }
- return @skill_crack
- end
- end
- #==============================================================================
- # ** Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Apply Skill Crack
- #--------------------------------------------------------------------------
- def apply_skill_crack(skill)
- return if skill.nil?
- return unless skill.skill_crack.include?(0) or
- skill.skill_crack.include?(@actor_id)
- return if skill_learn?(skill)
- learn_skill(skill.id)
- return if $scene.message_window.nil?
- text = sprintf(SSS::SKILL_CRACK_MESSAGE, @name, skill.name)
- $scene.message_window.add_instant_text(text)
- end
- end
- #==============================================================================
- # ** Game_Enemy
- #==============================================================================
- class Game_Enemy < Game_Battler
- #--------------------------------------------------------------------------
- # * Total Skills
- #--------------------------------------------------------------------------
- unless method_defined?(:total_skills)
- def total_skills
- result = []
- for action in enemy.actions
- next unless action.kind == 1
- skill = $data_skills[action.skill_id]
- result.push(skill) unless result.include?(skill)
- end
- result.sort! { |a,b| a.id <=> b.id }
- return result.uniq
- end
- end
- #--------------------------------------------------------------------------
- # * Perform Collapse
- #--------------------------------------------------------------------------
- alias perform_collapse_sss_skill_crack perform_collapse unless $@
- def perform_collapse
- perform_collapse_sss_skill_crack
- return unless $scene.is_a?(Scene_Battle) and dead?
- return if $scene.active_battler.nil?
- return unless $scene.active_battler.actor?
- for skill in total_skills
- $scene.active_battler.apply_skill_crack(skill)
- end
- end
- end
- #==============================================================================
- # ** Scene_Battle
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :active_battler
- attr_accessor :message_window
- end
- #===============================================================================
- #
- # END OF FILE
- #
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement