Advertisement
dsiver144

Untitled

Jan 29th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.85 KB | None | 0 0
  1. #==============================================================================
  2. # DSI Pre-Skills
  3. # -- Last Updated: 2017.01.29
  4. # -- Author: dsiver144
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #==============================================================================
  8.  
  9. $imported = {} if $imported.nil?
  10. $imported["DSI-PreSkills"] = true
  11.  
  12. #==============================================================================
  13. # + Updates
  14. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. # 2017.01.27 - Finish first version.
  16. #==============================================================================
  17. # + Instructions
  18. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  19. # To install this script, open up your script editor and copy/paste this script
  20. # to an open slot below �� Materials/�f�� but above �� Main. Remember to save.
  21. # -----------------------------------------------------------------------------
  22. # Skill Notetags - These notetags go in the skills notebox in the database.
  23. # -----------------------------------------------------------------------------
  24. # <Common Event Run: id> : Run common event id before a skill is being executed.
  25. # <variable #id:operate,value> Set, Plus, Minus, Multi, Divide, Mod an variable
  26. # by value.
  27. # ex: <variable #45:'+',45> : Add 45 to variable id 45
  28. # <variable #45:'=',v[5]>: Set the value of variable 45 equal to value of
  29. # variable id 5
  30. #==============================================================================
  31. # + Compatibility
  32. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  33. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  34. # it will run with RPG Maker VX without adjusting.
  35. #==============================================================================
  36. module DSIVER144
  37. module PRE_SKILL
  38. CME_NOTE = /<Common Event Run:\s*(\w+)>/i
  39. VAR_SET_NOTE = /<variable #(\w+):\s*(\W+),\s*(.+)>/i
  40. end
  41. end #DSIVER144
  42. #==============================================================================
  43. # DataManager
  44. #==============================================================================
  45. module DataManager
  46. #--------------------------------------------------------------------------
  47. # alias method: load_database
  48. #--------------------------------------------------------------------------
  49. class <<self; alias load_database_pre_skill load_database; end
  50. def self.load_database
  51. load_database_pre_skill
  52. load_notetags_pre_skill
  53. end
  54. #--------------------------------------------------------------------------
  55. # Load Notetag State Animation
  56. #--------------------------------------------------------------------------
  57. def self.load_notetags_pre_skill
  58. for skill in $data_skills
  59. next if skill.nil?
  60. skill.load_notetags_pre_skill
  61. end
  62. end
  63. end # DataManager
  64. #==============================================================================
  65. # �� RPG::State
  66. #==============================================================================
  67. class RPG::Skill
  68. #--------------------------------------------------------------------------
  69. # public instance variables
  70. #--------------------------------------------------------------------------
  71. attr_accessor :pre_skill_cme
  72. attr_accessor :pre_skill_variables
  73. #--------------------------------------------------------------------------
  74. # common cache: load_notetags_sani
  75. #--------------------------------------------------------------------------
  76. def load_notetags_pre_skill
  77. @pre_skill_cme = nil
  78. @pre_skill_variables = nil
  79. self.note.split(/[\r\n]+/).each do |line|
  80. if line =~ DSIVER144::PRE_SKILL::CME_NOTE
  81. @pre_skill_cme = $1.to_i
  82. end
  83. if line =~ DSIVER144::PRE_SKILL::VAR_SET_NOTE
  84. a = $1.to_i
  85. b = $2.to_s
  86. c = $3
  87. symbol = b.scan(/['|"]\s*(.+)\s*['|"]/i)[0][0]
  88. if symbol == "="
  89. symbol = ""
  90. end
  91. variable = c.gsub(/v\[(\w+)\]/i) {"$game_variables[#{$1.to_i}]"}
  92. if !$1
  93. variable = c.to_f.round(0).to_s
  94. end
  95. @pre_skill_variables = [a,symbol,variable]
  96. end
  97. end
  98. end
  99. end # RPG::State
  100. #=============================================================================
  101. # ♦ Scene_Battle
  102. #=============================================================================
  103. class Scene_Battle
  104. alias dark_use_item_pre_skill use_item
  105. #--------------------------------------------------------------------------
  106. # * alias method: use_item
  107. #--------------------------------------------------------------------------
  108. def use_item
  109. item_check = @subject.current_action.item
  110. if item_check.pre_skill_variables
  111. pre_adjust_variable(item_check)
  112. end
  113. if item_check.pre_skill_cme
  114. $game_temp.reserve_common_event(item_check.pre_skill_cme)
  115. process_common_event
  116. end
  117. dark_use_item_pre_skill
  118. end
  119. #--------------------------------------------------------------------------
  120. # * new method: process_common_event
  121. #--------------------------------------------------------------------------
  122. def process_common_event
  123. while !scene_changing?
  124. $game_troop.interpreter.update
  125. $game_troop.setup_battle_event
  126. wait_for_message
  127. wait_for_effect if $game_troop.all_dead?
  128. break unless $game_troop.interpreter.running?
  129. update_for_wait
  130. end
  131. end
  132. #--------------------------------------------------------------------------
  133. # * new method: pre_adjust_variable
  134. #--------------------------------------------------------------------------
  135. def pre_adjust_variable(skill)
  136. _vars = skill.pre_skill_variables
  137. str = "$game_variables[#{_vars[0]}] #{_vars[1]}= #{_vars[2]}"
  138. eval(str)
  139. end
  140. end # Scene_Battle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement