Advertisement
Zetu

Solace CM 1.00

Jun 27th, 2013
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.74 KB | None | 0 0
  1. #===============================================================================
  2. # Zetu Engine X4 - Solace Core Script
  3. # by Zetu
  4. # --- Created: 06/20/2013
  5. # --- Updated: 06/27/2013 v1.00
  6. #===============================================================================
  7.  
  8. module ZEX4S
  9. Imp = {}
  10. module REGEX
  11. Float = "[\+\-]?\d+\.\d+"
  12. Int = "[\+\-]?\d+"
  13. Param = "mhp|hp|mmp|mp|atk|def|mat|mdf|agi|luk"
  14. XParam = "hit|eva|cri|cev|mev|mrf|cnt|hrg|mrg|trg"
  15. SParam = "tgr|grd|rec|pha|mcr|tcr|pdr|mdr|fdr|exr"
  16. FullParam = "#{Param}|#{XParam}|#{SParam}"
  17. end
  18.  
  19. class MetaTag
  20.  
  21. def initialize
  22. @data = {}
  23. @data.default = MetaTag.new
  24. end
  25.  
  26. def []=(*params)
  27. return if params.size == 0
  28. @data[params[0]] = MetaTag.new unless @data[params[0]]
  29. @data[params[0]] = params.drop(1)
  30. end
  31.  
  32. def [](*params)
  33. return @data if params.size == 0
  34. return @data[params[0]][params.drop(1)]
  35. end
  36.  
  37. end
  38.  
  39. end
  40.  
  41. class Object
  42.  
  43. def convert(string)
  44. case string
  45. when /#{ZEX4S::REGEX::Float}/
  46. return string.to_f
  47. when /#{ZEX4S::REGEX::Int}/
  48. return string.to_i
  49. else
  50. return string
  51. end
  52. end
  53.  
  54. def convert_battler_formula(string, battler, ext = {})
  55. REGEX::FullParam.split("|").each do |param|
  56. string.gsub(param, battler.send(param.to_sym))
  57. end
  58. convert_formula(string, ext)
  59. end
  60.  
  61. def convert_formula(string, ext = {})
  62. ext.each do |key, value|
  63. string.gsub!(key, "ext[\"#{key}\"]")
  64. end
  65. eval(string)
  66. end
  67.  
  68. def rand_range(min, max)
  69. min + rand(max - min + 1)
  70. end
  71.  
  72. def get_image(path, filename)
  73. Cache.load_bitmap(path, filename) rescue nil
  74. end
  75.  
  76. def get_animation(filename)
  77. get_image("Graphics/Animations/", filename)
  78. end
  79.  
  80. def get_battler(filename)
  81. get_image("Graphics/Battlers/", filename)
  82. end
  83.  
  84. def get_character(filename)
  85. get_image("Graphics/Characters/", filename)
  86. end
  87.  
  88. def get_face(filename)
  89. get_image("Graphics/Faces/", filename)
  90. end
  91.  
  92. def get_parallax(filename)
  93. get_image("Graphics/Parallaxes/", filename)
  94. end
  95.  
  96. def get_picture(filename)
  97. get_image("Graphics/Pictures/", filename)
  98. end
  99.  
  100. def get_system(filename)
  101. get_image("Graphics/System/", filename)
  102. end
  103.  
  104. def get_tileset(filename)
  105. get_image("Graphics/Tilesets/", filename)
  106. end
  107.  
  108.  
  109. def in_rect(x, y, rect)
  110. return false unless rect.x >= x
  111. return false unless rect.x + rect.width <= x
  112. return false unless rect.y >= y
  113. return false unless rect.y + rect.height <= y
  114. return true
  115. end
  116.  
  117. def in_range(x, y, x1, y1, width, height)
  118. in_rect(x, y, Rect.new(x1, y1, width, height))
  119. end
  120.  
  121. end
  122.  
  123. class String
  124.  
  125. def get_value(tag, recieve, default = "")
  126. self =~ /<#{tag}[:\s]+(#{recieve})>/i ? $1 : default
  127. end
  128.  
  129. def get_integer(tag, default = 0)
  130. get_value(tag, ZEX4S::REGEX::Int, default).to_i
  131. end
  132.  
  133. def get_float(tag, default = 1.0)
  134. get_value(tag, ZEX4S::REGEX::Float, default).to_f
  135. end
  136.  
  137. def get_hash(regex, oc1 = nil, oc2 = nil, default = nil)
  138. hash = Hash.new
  139. hash.default = default
  140. self.scan(regex) do |i,j|
  141. hash[i.convert_to(oc1)] = j.convert_to(oc2)
  142. end
  143. return hash
  144. end
  145.  
  146. def convert_to(symbol)
  147. case symbol
  148. when :int
  149. self.to_i
  150. when :float
  151. self.to_f / 100
  152. else
  153. -1
  154. end
  155. end
  156.  
  157. def get_full_tag(tag)
  158. ary = []
  159. self.scan(/<#{tag}(?:\:\s?(.*?))?>\n?\s*(.*?)\n?\s*<\/#{tag}>/imx) do
  160. ary.push( [$1, $2.gsub(/\n\s*/, "\n")] )
  161. end
  162. return ary
  163. end
  164.  
  165. def each_line
  166. self.split(/\s*[\n;]+\s*/)
  167. end
  168.  
  169. def get_all_by_tag(string, recieve = ".+", method = nil)
  170. ary = []
  171. self.each_line.each do |line|
  172. if line =~ /<#{string}[:\s]+(#{recieve})>/i
  173. ary.push $1
  174. end
  175. end
  176. method ? ary.map{|v| v.send(method)} : ary
  177. end
  178.  
  179. end
  180.  
  181. class Game_Battler < Game_BattlerBase
  182.  
  183. alias zex4s_i initialize
  184. def initialize
  185. zex4s_i
  186. zex4s_initialize
  187. refresh
  188. end
  189.  
  190. alias zex4s_ier item_element_rate
  191. def item_element_rate(user, item)
  192. zex4s_ier(user, item) * post_damage_rate(user, item)
  193. end
  194.  
  195. alias zex4s_mdv make_damage_value
  196. def make_damage_value(user, item)
  197. value = item.damage.eval(user, self, $game_variables)
  198. value *= item_element_rate(user, item)
  199. value *= pdr if item.physical?
  200. value *= mdr if item.magical?
  201. value *= rec if item.damage.recover?
  202. value = apply_critical(value) if @result.critical
  203. value = apply_variance(value, item.damage.variance)
  204. value = apply_guard(value)
  205. value += post_damage(user, item)
  206. value *= post_damage_rate(user, item)
  207. apply_post_effects(user, item)
  208. @result.make_damage(value.to_i, item)
  209. end
  210.  
  211. def post_damage(user, item)
  212. 0
  213. end
  214.  
  215. def post_damage_rate(user, item)
  216. 1.0
  217. end
  218.  
  219. def apply_post_effects(user, item)
  220. end
  221.  
  222. def data_set
  223. states
  224. end
  225.  
  226. def zex4s_initialize
  227. end
  228.  
  229. end
  230.  
  231. class Game_Actor < Game_Battler
  232.  
  233. def data_set
  234. super + [actor] + [self.class]
  235. end
  236.  
  237. def zex4s_initialize
  238. super
  239. end
  240.  
  241. end
  242.  
  243. class Game_Enemey < Game_Battler
  244.  
  245. def data_set
  246. super + [enemy]
  247. end
  248.  
  249. def zex4s_initialize
  250. super
  251. end
  252.  
  253. end
  254.  
  255. #==
  256. class RPG::BaseItem; def add_note_data; end; end
  257. class RPG::Actor < RPG::BaseItem; def add_note_data;super;end; end
  258. class RPG::EquipItem < RPG::BaseItem; def add_note_data;super;end; end
  259. class RPG::Weapon < RPG::EquipItem; def add_note_data;super;end; end
  260. class RPG::Armor < RPG::EquipItem; def add_note_data;super;end; end
  261. class RPG::UsableItem < RPG::BaseItem; def add_note_data;super;end; end
  262. class RPG::Item < RPG::UsableItem; def add_note_data;super;end; end
  263. class RPG::Skill < RPG::UsableItem; def add_note_data;super;end; end
  264. class RPG::State < RPG::BaseItem; def add_note_data;super;end; end
  265. class RPG::Class < RPG::BaseItem; def add_note_data;super;end; end
  266. #==
  267.  
  268. class Array
  269.  
  270. def sum
  271. self.compact.inject(0) { |r, i| r += i }
  272. end
  273.  
  274. def pi
  275. self.compact.inject(1.0) { |r, i| r *= i }
  276. end
  277.  
  278. def map_by(symbol)
  279. self.map do |x|
  280. x.send symbol
  281. end
  282. end
  283.  
  284. end
  285.  
  286. module DataManager
  287. class << self; alias zex4s_lnd load_normal_database; end
  288. def self.load_normal_database
  289. zex4s_lnd
  290. zex4s_add_note_data
  291. end
  292.  
  293. def self.zex4s_add_note_data
  294. [$data_actors, $data_classes, $data_skills, $data_weapons,
  295. $data_armors, $data_enemies, $data_states].flatten.each do |obj|
  296. obj.add_note_data if obj
  297. end
  298. end
  299.  
  300. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement