Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # ╔══════════════════════════════════╗
- # ║ ▼ Dark's Pre-Skill Image ║
- # ║ ▼ Author: Nhat Nguyen (Dark Sky) ║
- # ║ ▼ Release Date: March 5th 2016 ║
- # ╚══════════════════════════════════╝
- # ▼ Notetag: <pre_image: "ImageName">
- # -> Ex: <pre_image: "Skill1"> : Where Skill1 is name of a picture in
- # Graphics/Picture
- # To edit the image show time please check line 14.
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["DRK-Pre-Skill_Image"] = true
- module DarkPreSkill
- Delay = 100
- SE_Name = "Skill3"
- REGEXP = /<pre[_*]image:\s*"(\w+)">/i
- end
- class RPG::Skill < RPG::UsableItem
- #--------------------------------------------------------------------------
- # * Load Notetag for Pre Image
- #--------------------------------------------------------------------------
- def load_pre_image
- @pre_image = nil
- note.split(/[\r\n]+/).each do |line|
- if line =~ DarkPreSkill::REGEXP
- @pre_image = $1.to_s
- end
- end
- end
- attr_accessor :pre_image
- end
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # * Initialize
- #--------------------------------------------------------------------------
- alias :dark_pre_skill_init_game_actor :initialize
- def initialize(actor_id)
- dark_pre_skill_init_game_actor(actor_id)
- $data_skills.each do |skill|
- if skill
- skill.load_pre_image
- end
- end
- end
- end
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # * start
- #--------------------------------------------------------------------------
- alias :dark_pre_skill_start :start
- def start
- dark_pre_skill_start
- @pre_wait = 0
- @used_skill = false
- @pre_skill_sprite = Sprite.new
- @pre_skill_sprite.opacity = 0
- @pre_image = ""
- @play_pre_skill = false
- end
- #--------------------------------------------------------------------------
- # * Update Pre Skill
- #--------------------------------------------------------------------------
- def update_pre_skill
- if @pre_wait > (DarkPreSkill::Delay/2) && @play_pre_skill == true
- @pre_skill_sprite.bitmap = Cache.picture(@pre_image)
- @pre_skill_sprite.viewport = @viewport
- @pre_skill_sprite.z = 999
- @pre_skill_sprite.visible = true
- @pre_skill_sprite.opacity += 10
- else
- if @pre_wait > 0
- @pre_skill_sprite.opacity -= 5
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- update_pre_skill
- if @pre_wait > 0 && @used_skill == true
- @pre_wait -= 1
- end
- if BattleManager.in_turn? && @used_skill == false && @pre_wait <= 0
- process_event
- process_action
- end
- if @used_skill == true && @pre_wait <= 0
- @pre_skill_sprite.visible = false
- execute_action
- @subject.remove_current_action
- process_action_end unless @subject.current_action
- @used_skill = false
- @play_pre_skill = false
- end
- BattleManager.judge_win_loss if @used_skill != true
- end
- #--------------------------------------------------------------------------
- # * Battle Action Processing
- #--------------------------------------------------------------------------
- def process_action
- return if scene_changing?
- if !@subject || !@subject.current_action
- @subject = BattleManager.next_subject
- end
- return turn_end unless @subject
- if @subject.current_action
- @subject.current_action.prepare
- if @subject.current_action.valid?
- @status_window.open
- item = @subject.current_action.item
- if @subject.current_action.subject.is_a?(Game_Actor)
- if item.is_a?(RPG::Skill)
- if item.pre_image
- @pre_wait = DarkPreSkill::Delay
- @play_pre_skill = true
- @pre_image = item.pre_image
- Audio.se_play("Audio//SE//#{DarkPreSkill::SE_Name}")
- else
- @play_pre_skill = false
- @pre_wait = 0
- end
- end
- end
- @used_skill = true
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment