Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI Pre-Skills
- # -- Last Updated: 2017.01.29
- # -- Author: dsiver144
- # -- Level: Normal
- # -- Requires: n/a
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-PreSkills"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.01.27 - Finish first version.
- #==============================================================================
- # + Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below �� Materials/�f�� but above �� Main. Remember to save.
- # -----------------------------------------------------------------------------
- # Skill Notetags - These notetags go in the skills notebox in the database.
- # -----------------------------------------------------------------------------
- # <Common Event Run: id> : Run common event id before a skill is being executed.
- # <variable #id:operate,value> Set, Plus, Minus, Multi, Divide, Mod an variable
- # by value.
- # ex: <variable #45:'+',45> : Add 45 to variable id 45
- # <variable #45:'=',v[5]>: Set the value of variable 45 equal to value of
- # variable id 5
- #==============================================================================
- # + Compatibility
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
- # it will run with RPG Maker VX without adjusting.
- #==============================================================================
- module DSIVER144
- module PRE_SKILL
- CME_NOTE = /<Common Event Run:\s*(\w+)>/i
- VAR_SET_NOTE = /<variable #(\w+):\s*(\W+),\s*(.+)>/i
- end
- end #DSIVER144
- #==============================================================================
- # DataManager
- #==============================================================================
- module DataManager
- #--------------------------------------------------------------------------
- # alias method: load_database
- #--------------------------------------------------------------------------
- class <<self; alias load_database_pre_skill load_database; end
- def self.load_database
- load_database_pre_skill
- load_notetags_pre_skill
- end
- #--------------------------------------------------------------------------
- # Load Notetag State Animation
- #--------------------------------------------------------------------------
- def self.load_notetags_pre_skill
- for skill in $data_skills
- next if skill.nil?
- skill.load_notetags_pre_skill
- end
- end
- end # DataManager
- #==============================================================================
- # �� RPG::State
- #==============================================================================
- class RPG::Skill
- #--------------------------------------------------------------------------
- # public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :pre_skill_cme
- attr_accessor :pre_skill_variables
- #--------------------------------------------------------------------------
- # common cache: load_notetags_sani
- #--------------------------------------------------------------------------
- def load_notetags_pre_skill
- @pre_skill_cme = nil
- @pre_skill_variables = nil
- self.note.split(/[\r\n]+/).each do |line|
- if line =~ DSIVER144::PRE_SKILL::CME_NOTE
- @pre_skill_cme = $1.to_i
- end
- if line =~ DSIVER144::PRE_SKILL::VAR_SET_NOTE
- a = $1.to_i
- b = $2.to_s
- c = $3
- symbol = b.scan(/['|"]\s*(.+)\s*['|"]/i)[0][0]
- if symbol == "="
- symbol = ""
- end
- variable = c.gsub(/v\[(\w+)\]/i) {"$game_variables[#{$1.to_i}]"}
- if !$1
- variable = c.to_f.round(0).to_s
- end
- @pre_skill_variables = [a,symbol,variable]
- end
- end
- end
- end # RPG::State
- #=============================================================================
- # ♦ Scene_Battle
- #=============================================================================
- class Scene_Battle
- alias dark_use_item_pre_skill use_item
- #--------------------------------------------------------------------------
- # * alias method: use_item
- #--------------------------------------------------------------------------
- def use_item
- item_check = @subject.current_action.item
- if item_check.pre_skill_variables
- pre_adjust_variable(item_check)
- end
- if item_check.pre_skill_cme
- $game_temp.reserve_common_event(item_check.pre_skill_cme)
- process_common_event
- end
- dark_use_item_pre_skill
- end
- #--------------------------------------------------------------------------
- # * new method: process_common_event
- #--------------------------------------------------------------------------
- def process_common_event
- while !scene_changing?
- $game_troop.interpreter.update
- $game_troop.setup_battle_event
- wait_for_message
- wait_for_effect if $game_troop.all_dead?
- break unless $game_troop.interpreter.running?
- update_for_wait
- end
- end
- #--------------------------------------------------------------------------
- # * new method: pre_adjust_variable
- #--------------------------------------------------------------------------
- def pre_adjust_variable(skill)
- _vars = skill.pre_skill_variables
- str = "$game_variables[#{_vars[0]}] #{_vars[1]}= #{_vars[2]}"
- eval(str)
- end
- end # Scene_Battle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement