SUN_furawa

Battler se script

Sep 19th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.63 KB | None | 0 0
  1. #/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\|/
  2. #~ Battler SE (Default Battle System Version)
  3. #~ By: Rockleedude
  4. #~ Version: 3.0
  5. #~ Latest Update: 10/26/2009
  6. #~
  7. #~ This script allows you to add 13 different sound effects to play for
  8. #~ actors and enemies in battle.
  9. #~
  10. #===============================================================================
  11. #~ Instructions
  12. #===============================================================================
  13. #~ To setup the sound effects played for a battler, use the following tag:
  14. #~ <battler se (type) (name) v(volume) p(pitch)>
  15. #~ (type): One of the 13 types. They are specified in the "For type" section.
  16. #~ (name): The name of the song file for the sound effect. Put playnothing to
  17. #~ mute the sound effects for that type.
  18. #~ (volume): The sound effect's volume.
  19. #~ (pitch): The sound effect's pitch.
  20. #~
  21. #~ The tags for enemies go into the notes box in the database.
  22. #~ The tags for actors go in the customization section below in this script.
  23. #~
  24. #~ For type:
  25. #~ Put the type corresponding to whichever type of sound effect this sound is.
  26. #~ i.e. If this is the sound effect for when the battler takes damage, put take.
  27. #~ The 13 types are the following:
  28. #~ 1. Take - Played when the battler loses hp or mp as a result of the
  29. #~ action of another battler.
  30. #~ 2. Recover - Played when the battler regains hp or mp, loses a negative
  31. #~ state, or is revived from death.
  32. #~ 3. Evade - Played when the battler dodges an attack.
  33. #~ 4. Plus State - Played when the battler receives a positive, good state.
  34. #~ Does not play if both a plus and minus state are received.
  35. #~ 5. Minus State - Played when the battler receives a negative, bad state.
  36. #~ Does not play if both a plus and minus state are received.
  37. #~ 6. Attack - Played when the battler does a regular attack or uses a
  38. #~ skill or item that has physical attack checked.
  39. #~ 7. Target Foe - Played when the battler uses a skill or item that
  40. #~ targets one or more foes.
  41. #~ 8. Target Ally - Played when the battler uses a skill or item that
  42. #~ targets one or more allies. Does not play if the only
  43. #~ target is the battler itself.
  44. #~ 9. Self - Played when the battler uses a skill or item that targets
  45. #~ iteself.
  46. #~ 10. Critical Hit - Played when the battler delivers a critical hit.
  47. #~ 11. Miss - Played when the battler misses with an attack.
  48. #~ 12. Death - Played when the battler dies.
  49. #~ 13. Low Health - Played when the battler's hp falls below a specified
  50. #~ amount.
  51. #~ For name:
  52. #~ This should be the exact name of the file. So if the file name is "Scream"
  53. #~ you should put "Scream" and not "scream" (Notice the difference in first
  54. #~ letters). You can have quotation marks around the name of file if you
  55. #~ choose to. The file type of the sound effect is also optional.
  56. #~ Files for the sound effects should be located in the SE folder that
  57. #~ is inside the Audio folder of your project. You also have the choice of
  58. #~ creating a folder inside the SE folder to store the battler sound effects in.
  59. #~ The purpose of this is to avoid having a name conflict between a regular
  60. #~ sound effect and a sound effect for an battler. This could also help with
  61. #~ organization. This is all up to you. In the customization section below,
  62. #~ type in the exact name of the folder. If you are not using the custom
  63. #~ folder, then put nil instead. Note, if the custom folder exists, it
  64. #~ will be searched first before looking in the SE folder.
  65. #~ To completely mute the sound effects (even the default sound effects) for
  66. #~ particularly type for a battler, put playnothing into the name spot. This
  67. #~ will make it so no sound effect will play for that type for that battler.
  68. #~ Note that playnothing with quotation marks ("playnothing") will not mute
  69. #~ the se. Instead it would search for the sound effect named "playnothing".
  70. #~ For volume:
  71. #~ This is the volume for the sound effect. Be sure to include the "v" before
  72. #~ the volume. Use the sound test to help decide what you want this value to
  73. #~ be. The volume can be left out. If it is left out, then the default
  74. #~ volume will be used instead. You can set the default volume in the
  75. #~ customization section. Must be between 0 and 100.
  76. #~ For pitch:
  77. #~ This is the pitch for the sound effect. Be sure to include the "p" before
  78. #~ the pitch. Use the sound test to help decide what you want this value to
  79. #~ be. The pitch can also be left out. If it is left out, then the default
  80. #~ pitch will be used instead. You can set the default pitch in the
  81. #~ customization section. Must be between 50 and 150.
  82. #~ You can insert more than one sound effect for each type for a battler. Each
  83. #~ sound effect for each type must be in a separate tag. When there is more than
  84. #~ one sound effect for a particular type of a battler, a sound effect will
  85. #~ randomly be chosen to be played. Note, if playnothing is one of the choices,
  86. #~ it can be randomly chosen. Just because playnothing is one of the choices
  87. #~ does not mean it will automatically play nothing for that type. It has to be
  88. #~ chosen randomly.
  89. #~
  90. #~
  91. #~
  92. #~ Examples:
  93. #~
  94. #~ <battler se death Scream v85 p100>
  95. #~ - Will play the sound file "Scream" with the volume as 85 and pitch as 100
  96. #~ for the death sound effect.
  97. #~
  98. #~ <battler se target foe "Roar" p90>
  99. #~ - Will play the sound file "Roar" with the volume as the default and pitch as
  100. #~ 90 for the target foe sound effect. Remember, the quotation marks are not
  101. #~ required.
  102. #~
  103. #~ <battler se minus state Groan>
  104. #~ - Will play the sound file "Groan" with the volume and pitch as the defaults
  105. #~ for the minus state damage sound effect.
  106. #~
  107. #~ <battler se evade playnothing>
  108. #~ - Will play no sound effect, not even the default sound effect chosen in the
  109. #~ database, when the battler evades.
  110. #~
  111. #~
  112. #/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\/|\|/|\|/
  113.  
  114. $imported = {} if $imported == nil
  115. $imported["Battler_SE"] = true
  116.  
  117. module Rockleedude
  118. module Battler_SE
  119. #===============================================================================
  120. # CUSTOMIZATION
  121. #===============================================================================
  122. # Setup for Actors #
  123. # With the addition of the actor part of the script, comes an addition to
  124. # the customization section. Since actors have no notes box like enemies
  125. # do, another method had to be used for setup for actors. Basically, I
  126. # created a notes box for actors in this script (note this "notes box" will
  127. # only work for this script). The syntax for the tag is exactly the same
  128. # as the syntax for enemies. Put ACTOR_SE_SETUP[x] = " y " where x is the
  129. # id of the actor and y is the tags. You can have any number of lines of
  130. # tag between the quotation marks. See the example below if confused.
  131. #
  132. # The following is an example:
  133. # ACTOR_SE_SETUP[1] =
  134. # "<battler se take Ouch>
  135. # <battler se take playnothing>
  136. # <battler se attack Yell>
  137. # <battler se death Scream p125>"
  138. #
  139. ACTOR_SE_SETUP = [] # Do not alter or remove!
  140. #
  141. #
  142. # --> Insert Tags for Actors Below Here <--
  143.  
  144.  
  145.  
  146. # --> Insert Tags for Actors Above Here <--
  147.  
  148.  
  149. BATTLER_SE_FOLDER_NAME = nil
  150. # The name of the folder inside of the SE folder where the battler sound
  151. # effects are stored. Include quotation marks around the name.
  152. # For example: "Battler_SE"
  153. # If the custom folder is not being used, put nil with no quotations.
  154.  
  155. DEFAULT_VOLUME = 100
  156. # The volume used whenever the volume is left out of the tag.
  157. # Can be 0-100
  158. DEFAULT_PITCH = 100
  159. # The pitch used whenever the pitch is left out of the tag.
  160. # Can be 50-150
  161.  
  162. PLUS_STATES = [9, 10, 11, 12]
  163. # The states that are considered positive, good states. When a battler
  164. # receives one of these states, the specified plus state sound effect will
  165. # play. Insert the id of the state in the above array.
  166. MINUS_STATES = [1, 2, 3, 4, 5, 6, 7, 8, 13, 14, 15, 16]
  167. # The states that are considered negative, bad states. When a battler
  168. # receives one of these states, the specified minus state sound effect will
  169. # play. Insert the id of the state in the above array.
  170. #
  171. # States can be left out if they don't fall into either category of plus
  172. # or negative.
  173.  
  174. DEATH_STATE_ID = 1
  175. # The id of the state that represents death, knock-out, incapacitated, etc.
  176. # The default is id 1. There is really no reason to change the id of the
  177. # death state but I had to include this just incase.
  178.  
  179. LOW_HEALTH_PERCENTAGE = 25
  180. # The percentage that determines when the low health sound effect is played.
  181. # This number should be between 0 and 100 since it's a percentage. The color
  182. # of the hp shown in the status changes to yellow when the hp is below 25%
  183. # incase you want to make it as much as the game considers low health.
  184. #===============================================================================
  185. # END CUSTOMIZATION
  186. #===============================================================================
  187.  
  188. BATTLER_SE = /<BATTLER[\s_]?SE[\s_]?(TAKE|RECOVER|EVADE|PLUSSTATE|PLUS[\s]STATE|PLUS_STATE|MINUSSTATE|MINUS[\s]STATE|MINUS_STATE|ATTACK|TARGETFOE|TARGET[\s]FOE|TARGET_FOE|TARGETALLY|TARGET[\s]ALLY|TARGET_ALLY|CRITICALHIT|CRITICAL[\s]HIT|CRITICAL_HIT|MISS|DEATH|LOWHEALTH|LOW[\s]HEALTH|LOW_HEALTH|SELF)[\s_]?(.*?)[\s_]?(v\d*?)?[\s_]?(p\d*?)?>/i
  189. BATTLER_SE_PLAYNOTHING = /<BATTLER[\s_]?SE[\s_]?(TAKE|RECOVER|EVADE|PLUSSTATE|PLUS[\s]STATE|PLUS_STATE|MINUSSTATE|MINUS[\s]STATE|MINUS_STATE|ATTACK|TARGETFOE|TARGET[\s]FOE|TARGET_FOE|TARGETALLY|TARGET[\s]ALLY|TARGET_ALLY|CRITICALHIT|CRITICAL[\s]HIT|CRITICAL_HIT|MISS|DEATH|LOWHEALTH|LOW[\s]HEALTH|LOW_HEALTH|SELF)[\s_]?PLAYNOTHING>/i
  190. end
  191. end
  192.  
  193. #
  194. # SE CLASS
  195. #
  196. class RPG::SE
  197.  
  198. def battler_se_play
  199. folder = Rockleedude::Battler_SE::BATTLER_SE_FOLDER_NAME
  200. unless @name.empty?
  201. unless folder == nil
  202. begin
  203. Audio.se_play("Audio/SE/" + folder + "/" + @name, @volume, @pitch)
  204. #print @name + ": name" if $TEST
  205. rescue
  206. begin
  207. play
  208. rescue
  209. print "The sound effect, " + @name + ", is not found in either folder." if $TEST
  210. return false
  211. end
  212. end
  213. else
  214. begin
  215. play
  216. rescue
  217. print "The sound effect, " + name + ", is not found in the SE folder.
  218. If you created a Battler_SE folder be sure you put the name correctly
  219. in the module as BATTLER_SE_FOLDER_NAME" if $TEST
  220. return false
  221. end
  222. end
  223. else
  224. return false
  225. end
  226. end
  227.  
  228. def play
  229. unless @name.empty?
  230. Audio.se_play("Audio/SE/" + @name, @volume, @pitch)
  231. end
  232. end
  233. end # class end
  234.  
  235. #
  236. # SOUND MODULE
  237. #
  238. module Sound
  239.  
  240. def self.play_enemy_attack
  241. end
  242.  
  243. def self.play_enemy_damage
  244. end
  245.  
  246. def self.play_enemy_collapse
  247. end
  248.  
  249. def self.play_actor_damage
  250. end
  251.  
  252. def self.play_actor_collapse
  253. end
  254.  
  255. def self.play_recovery
  256. end
  257.  
  258. def self.play_miss
  259. end
  260.  
  261. def self.play_evasion
  262. end
  263.  
  264. def self.play_battler_se(battler_id, type, a_or_e, default)
  265. # Type: 0: Take, 1: Recover, 2: Evade, 3: Plus State, 4: Minus State,
  266. # Type: 5: Attack, 6: Target Foe, 7: Target Ally, 8: Critical Hit, 9: Miss,
  267. # Type: 10: Death, 11: Low Health, 12: Self
  268. # a_or_e: 1: Actor 2: Enemy
  269.  
  270. se = $data_actor_se[battler_id] if a_or_e == 1
  271. se = $data_enemy_se[battler_id] if a_or_e == 2
  272. unless se[type].empty?
  273. chosen_se = se[type][rand(se[type].size)]
  274. else
  275. Sound.play_default_se(type, a_or_e)
  276. return
  277. end
  278. #print chosen_se.inspect + ":chosen_se" if $TEST
  279. return if chosen_se == "PLAYNOTHING"
  280. t_or_f = chosen_se.battler_se_play
  281. return if default == false
  282. Sound.play_default_se(type, a_or_e) if t_or_f == false
  283. end
  284.  
  285. def self.play_default_se(type, a_or_e)
  286. if a_or_e == 1
  287. $data_system.sounds[12].play if type == 0
  288. $data_system.sounds[13].play if type == 10
  289. else
  290. $data_system.sounds[9].play if type == 5
  291. $data_system.sounds[10].play if type == 0
  292. $data_system.sounds[11].play if type == 10
  293. end
  294. $data_system.sounds[14].play if type == 1
  295. $data_system.sounds[15].play if type == 9
  296. $data_system.sounds[16].play if type == 2
  297. end
  298.  
  299. end
  300.  
  301. #
  302. # SCENE_BATTLE CLASS
  303. #
  304. class Scene_Battle < Scene_Base
  305.  
  306. # HP: Take(0) and Recover(1)
  307. alias display_hp_damage_orig_rld_battler_se display_hp_damage
  308. def display_hp_damage(target, obj = nil)
  309. if target.hp_damage > 0
  310. if target.actor?
  311. Sound.play_battler_se(target.actor_id, 0, 1, true)
  312. else
  313. Sound.play_battler_se(target.enemy_id, 0, 2, true)
  314. end
  315. elsif target.hp_damage < 0
  316. if target.actor?
  317. Sound.play_battler_se(target.actor_id, 1, 1, true)
  318. else
  319. Sound.play_battler_se(target.enemy_id, 1, 2, true)
  320. end
  321. end
  322. display_hp_damage_orig_rld_battler_se(target, obj = nil)
  323. end
  324.  
  325. # MP: Take(0) and Recover(1)
  326. alias display_mp_damage_orig_rld_battler_se display_mp_damage
  327. def display_mp_damage(target, obj = nil)
  328. if target.hp_damage == 0
  329. if target.mp_damage > 0
  330. if target.actor?
  331. Sound.play_battler_se(target.actor_id, 0, 1, false)
  332. else
  333. Sound.play_battler_se(target.enemy_id, 0, 2, false)
  334. end
  335. elsif target.mp_damage < 0
  336. if target.actor?
  337. Sound.play_battler_se(target.actor_id, 1, 1, true)
  338. else
  339. Sound.play_battler_se(target.enemy_id, 1, 2, true)
  340. end
  341. end
  342. end
  343. display_mp_damage_orig_rld_battler_se(target, obj = nil)
  344. end
  345.  
  346. # Recover(1) for Removed Minus States
  347. def play_if_minus_state_removed(target, obj = nil)
  348. return unless (target.hp_damage == 0) and (target.mp_damage == 0)
  349. plus_a = []
  350. minus_a = []
  351. plus_list = Rockleedude::Battler_SE::PLUS_STATES
  352. minus_list = Rockleedude::Battler_SE::MINUS_STATES
  353. for state in target.removed_states
  354. plus_a.insert(0, state) if plus_list.include?(state.id)
  355. minus_a.insert(0, state) if minus_list.include?(state.id)
  356. if state.id == Rockleedude::Battler_SE::DEATH_STATE_ID
  357. if target.actor?
  358. Sound.play_battler_se(target.actor_id, 1, 1, false)
  359. else
  360. Sound.play_battler_se(target.enemy_id, 1, 2, false)
  361. end
  362. return
  363. end
  364. end
  365. return if (plus_a.size != 0) and (minus_a.size != 0)
  366. return if plus_a.empty? and minus_a.empty?
  367. if plus_a.empty?
  368. if target.actor?
  369. Sound.play_battler_se(target.actor_id, 1, 1, false)
  370. else
  371. Sound.play_battler_se(target.enemy_id, 1, 2, false)
  372. end
  373. end
  374. end
  375.  
  376. # Evade(2)
  377. alias display_evasion_orig_rld_battler_se display_evasion
  378. def display_evasion(target, obj = nil)
  379. if target.actor?
  380. Sound.play_battler_se(target.actor_id, 2, 1, true)
  381. else
  382. Sound.play_battler_se(target.enemy_id, 2, 2, true)
  383. end
  384. display_evasion_orig_rld_battler_se(target, obj = nil)
  385. end
  386.  
  387. # Plus State(3) and Minus State(4)
  388. def play_if_plus_or_minus_added(target, obj = nil)
  389. plus_a = []
  390. minus_a = []
  391. plus_list = Rockleedude::Battler_SE::PLUS_STATES
  392. minus_list = Rockleedude::Battler_SE::MINUS_STATES
  393. for state in target.added_states
  394. plus_a.insert(0, state) if plus_list.include?(state.id)
  395. minus_a.insert(0, state) if minus_list.include?(state.id)
  396. return if state.id == Rockleedude::Battler_SE::DEATH_STATE_ID
  397. end
  398. return if (plus_a.size != 0) and (minus_a.size != 0)
  399. return if plus_a.empty? and minus_a.empty?
  400. return unless (target.hp_damage == 0) and (target.mp_damage == 0)
  401. if minus_a.empty?
  402. if target.actor?
  403. Sound.play_battler_se(target.actor_id, 3, 1, false)
  404. else
  405. Sound.play_battler_se(target.enemy_id, 3, 2, false)
  406. end
  407. elsif plus_a.empty?
  408. if target.actor?
  409. Sound.play_battler_se(target.actor_id, 4, 1, false)
  410. else
  411. Sound.play_battler_se(target.enemy_id, 4, 2, false)
  412. end
  413. end
  414. end
  415. alias display_added_states_orig_rld_battler_se display_added_states
  416. def display_added_states(target, obj = nil)
  417. play_if_plus_or_minus_added(target, obj = nil)
  418. play_if_minus_state_removed(target, obj = nil)
  419. display_added_states_orig_rld_battler_se(target, obj = nil)
  420. end
  421.  
  422. # Attack(5)
  423. alias display_attack_animation_orig_rld_battler_se display_attack_animation
  424. def display_attack_animation(targets)
  425. if @active_battler.actor?
  426. Sound.play_battler_se(@active_battler.actor_id, 5, 1, false)
  427. wait(15, true)
  428. else
  429. Sound.play_battler_se(@active_battler.enemy_id, 5, 2, true)
  430. end
  431. display_attack_animation_orig_rld_battler_se(targets)
  432. end
  433. def play_attack_if_ui_phy_atk
  434. if @active_battler.action.skill?
  435. if @active_battler.action.skill.physical_attack
  436. if @active_battler.actor?
  437. Sound.play_battler_se(@active_battler.actor_id, 5, 1, false)
  438. else
  439. Sound.play_battler_se(@active_battler.enemy_id, 5, 2, false)
  440. end
  441. end
  442. end
  443. if @active_battler.action.item?
  444. if @active_battler.action.item.physical_attack
  445. if @active_battler.actor?
  446. Sound.play_battler_se(@active_battler.actor_id, 5, 1, false)
  447. else
  448. Sound.play_battler_se(@active_battler.enemy_id, 5, 2, false)
  449. end
  450. end
  451. end
  452. end
  453.  
  454. # Target Foe(6) and Target Ally(7) and Self(12)
  455. def play_if_target_foe_or_ally_or_self(targets)
  456. if @active_battler.action.skill?
  457. return if @active_battler.action.skill.physical_attack
  458. elsif @active_battler.action.item?
  459. return if @active_battler.action.item.physical_attack
  460. end
  461. if targets.compact.size == 1
  462. if targets.compact[0] == @active_battler
  463. if @active_battler.actor?
  464. Sound.play_battler_se(@active_battler.actor_id, 12, 1, false)
  465. else
  466. Sound.play_battler_se(@active_battler.enemy_id, 12, 2, false)
  467. end
  468. return
  469. end
  470. end
  471. return if targets.nitems == 0
  472. unless targets.compact[0].actor?
  473. if @active_battler.actor?
  474. Sound.play_battler_se(@active_battler.actor_id, 6, 1, false)
  475. else
  476. Sound.play_battler_se(@active_battler.enemy_id, 7, 2, false)
  477. end
  478. else
  479. if @active_battler.actor?
  480. Sound.play_battler_se(@active_battler.actor_id, 7, 1, false)
  481. else
  482. Sound.play_battler_se(@active_battler.enemy_id, 6, 2, false)
  483. end
  484. end
  485. end
  486. alias display_animation_orig_rld_battler_se display_animation
  487. def display_animation(targets, animation_id)
  488. play_attack_if_ui_phy_atk
  489. play_if_target_foe_or_ally_or_self(targets)
  490. display_animation_orig_rld_battler_se(targets, animation_id)
  491. end
  492.  
  493. # Critical Hit(8)
  494. alias display_critical_orig_rld_battler_se display_critical
  495. def display_critical(target, obj = nil)
  496. if target.critical
  497. if @active_battler.actor?
  498. Sound.play_battler_se(@active_battler.actor_id, 8, 1, false)
  499. else
  500. Sound.play_battler_se(@active_battler.enemy_id, 8, 2, false)
  501. end
  502. end
  503. display_critical_orig_rld_battler_se(target, obj = nil)
  504. end
  505.  
  506. # Miss(9)
  507. alias display_miss_orig_rld_battler_se display_miss
  508. def display_miss(target, obj = nil)
  509. if obj == nil or obj.physical_attack
  510. if @active_battler.actor?
  511. Sound.play_battler_se(@active_battler.actor_id, 9, 1, true)
  512. else
  513. Sound.play_battler_se(@active_battler.enemy_id, 9, 2, true)
  514. end
  515. end
  516. display_miss_orig_rld_battler_se(target, obj = nil)
  517. end
  518.  
  519. end # class end
  520.  
  521. #
  522. # GAME_BATTLER CLASS
  523. #
  524. class Game_Battler
  525.  
  526. # Low Health(11)
  527. alias execute_damage_orig_rld_battler_se execute_damage
  528. def execute_damage(user)
  529. max_hp_b = maxhp
  530. hp_b = self.hp
  531. execute_damage_orig_rld_battler_se(user)
  532. max_hp_a = maxhp
  533. hp_a = self.hp
  534. ratio_b = hp_b.to_f / max_hp_b.to_f
  535. ratio_a = hp_a.to_f / max_hp_a.to_f
  536. #print ratio_b.inspect + ":ratio_b " + ratio_a.inspect + ":ratio_a"
  537. lowh_percent = Rockleedude::Battler_SE::LOW_HEALTH_PERCENTAGE
  538. unless hp_a <= 0
  539. if lowh_percent.between?(0.0, 100.0)
  540. lowh_percent = lowh_percent.to_f / 100.0
  541. if ratio_b > lowh_percent
  542. if ratio_a < lowh_percent
  543. if self.actor?
  544. Sound.play_battler_se(self.actor_id, 11, 1, false)
  545. else
  546. Sound.play_battler_se(self.enemy_id, 11, 2, false)
  547. end
  548. end
  549. end
  550. end
  551. end
  552. end
  553.  
  554. end # class end
  555.  
  556. #
  557. # GAME_ACTOR CLASS
  558. #
  559.  
  560. class Game_Actor < Game_Battler
  561. attr_accessor :battler_se_note
  562.  
  563. alias perform_collapse_orig_rld_battler_se perform_collapse
  564. def perform_collapse
  565. Sound.play_battler_se(@actor_id, 10, 1, true) if $game_temp.in_battle and dead?
  566. perform_collapse_orig_rld_battler_se
  567. end
  568.  
  569. def actor_id
  570. return @actor_id
  571. end
  572.  
  573. alias setup_orig_battler_se setup
  574. def setup(actor_id)
  575. setup_orig_battler_se(actor_id)
  576. @battler_se_note = Rockleedude::Battler_SE::ACTOR_SE_SETUP
  577. end
  578.  
  579. end # class end
  580.  
  581. #
  582. # GAME_ENEMY CLASS
  583. #
  584. class Game_Enemy < Game_Battler
  585. alias perform_collapse_orig_rld_battler_se perform_collapse
  586. def perform_collapse
  587. Sound.play_battler_se(@enemy_id, 10, 2, true) if $game_temp.in_battle and dead?
  588. perform_collapse_orig_rld_battler_se
  589. end
  590.  
  591. end # class end
  592.  
  593. #
  594. # ACTOR CLASS
  595. #
  596. class RPG::Actor
  597. attr_accessor :battler_se_note
  598.  
  599. # Battler Receiving
  600. attr_accessor :take_damage_se
  601. attr_accessor :recover_damage_se
  602. attr_accessor :evade_se
  603. attr_accessor :plus_state_se
  604. attr_accessor :minus_state_se
  605.  
  606. # Battler Delivering
  607. attr_accessor :attack_se
  608. attr_accessor :target_foe_se
  609. attr_accessor :target_ally_se
  610. attr_accessor :critical_hit_se
  611. attr_accessor :miss_se
  612.  
  613. # Random Conditions
  614. attr_accessor :death_se
  615. attr_accessor :low_health_se
  616. attr_accessor :self_se
  617.  
  618. def gsub_without_md(string)
  619. string.gsub!(/ /i, "")
  620. string.gsub!(/_/i, "")
  621. return string
  622. end
  623.  
  624. def prepare_se_cache
  625. # Battler Receiving
  626. @take_damage_se = []
  627. @recover_damage_se = []
  628. @evade_se = []
  629. @plus_state_se = []
  630. @minus_state_se = []
  631.  
  632. # Battler Delivering
  633. @attack_se = []
  634. @target_foe_se = []
  635. @target_ally_se = []
  636. @critical_hit_se = []
  637. @miss_se = []
  638.  
  639. # Random Conditions
  640. @death_se = []
  641. @low_health_se = []
  642. @self_se = []
  643.  
  644. a = Rockleedude::Battler_SE::ACTOR_SE_SETUP[@id]
  645. @battler_se_note = ""
  646. @battler_se_note = a if a != nil
  647. end
  648.  
  649. def create_se_cache
  650. prepare_se_cache
  651. dv = Rockleedude::Battler_SE::DEFAULT_VOLUME
  652. dp = Rockleedude::Battler_SE::DEFAULT_PITCH
  653. self.battler_se_note.split(/[\r\n]+/).each { |line|
  654. case line
  655. when Rockleedude::Battler_SE::BATTLER_SE
  656. type = $1
  657. type.upcase! unless $1 == nil
  658. type = gsub_without_md(type) unless $1 == nil
  659. case type
  660. when "TAKE"
  661. se = RPG::SE.new($2, dv, dp)
  662. se.volume = $3 if $3 != nil
  663. se.volume = se.volume[1,3].to_i if $3.class == String
  664. se.pitch = $4 if $4 != nil
  665. se.pitch = se.pitch[1,3].to_i if $4.class == String
  666. @take_damage_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  667. when "RECOVER"
  668. se = RPG::SE.new($2, dv, dp)
  669. se.volume = $3 if $3 != nil
  670. se.volume = se.volume[1,3].to_i if $3.class == String
  671. se.pitch = $4 if $4 != nil
  672. se.pitch = se.pitch[1,3].to_i if $4.class == String
  673. @recover_damage_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  674. when "EVADE"
  675. se = RPG::SE.new($2, dv, dp)
  676. se.volume = $3 if $3 != nil
  677. se.volume = se.volume[1,3].to_i if $3.class == String
  678. se.pitch = $4 if $4 != nil
  679. se.pitch = se.pitch[1,3].to_i if $4.class == String
  680. @evade_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  681. when "PLUSSTATE"
  682. se = RPG::SE.new($2, dv, dp)
  683. se.volume = $3 if $3 != nil
  684. se.volume = se.volume[1,3].to_i if $3.class == String
  685. se.pitch = $4 if $4 != nil
  686. se.pitch = se.pitch[1,3].to_i if $4.class == String
  687. @plus_state_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  688. when "MINUSSTATE"
  689. se = RPG::SE.new($2, dv, dp)
  690. se.volume = $3 if $3 != nil
  691. se.volume = se.volume[1,3].to_i if $3.class == String
  692. se.pitch = $4 if $4 != nil
  693. se.pitch = se.pitch[1,3].to_i if $4.class == String
  694. @minus_state_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  695. when "ATTACK"
  696. se = RPG::SE.new($2, dv, dp)
  697. se.volume = $3 if $3 != nil
  698. se.volume = se.volume[1,3].to_i if $3.class == String
  699. se.pitch = $4 if $4 != nil
  700. se.pitch = se.pitch[1,3].to_i if $4.class == String
  701. @attack_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  702. when "TARGETFOE"
  703. se = RPG::SE.new($2, dv, dp)
  704. se.volume = $3 if $3 != nil
  705. se.volume = se.volume[1,3].to_i if $3.class == String
  706. se.pitch = $4 if $4 != nil
  707. se.pitch = se.pitch[1,3].to_i if $4.class == String
  708. @target_foe_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  709. when "TARGETALLY"
  710. se = RPG::SE.new($2, dv, dp)
  711. se.volume = $3 if $3 != nil
  712. se.volume = se.volume[1,3].to_i if $3.class == String
  713. se.pitch = $4 if $4 != nil
  714. se.pitch = se.pitch[1,3].to_i if $4.class == String
  715. @target_ally_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  716. when "CRITICALHIT"
  717. se = RPG::SE.new($2, dv, dp)
  718. se.volume = $3 if $3 != nil
  719. se.volume = se.volume[1,3].to_i if $3.class == String
  720. se.pitch = $4 if $4 != nil
  721. se.pitch = se.pitch[1,3].to_i if $4.class == String
  722. @critical_hit_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  723. when "MISS"
  724. se = RPG::SE.new($2, dv, dp)
  725. se.volume = $3 if $3 != nil
  726. se.volume = se.volume[1,3].to_i if $3.class == String
  727. se.pitch = $4 if $4 != nil
  728. se.pitch = se.pitch[1,3].to_i if $4.class == String
  729. @miss_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  730. when "DEATH"
  731. se = RPG::SE.new($2, dv, dp)
  732. se.volume = $3 if $3 != nil
  733. se.volume = se.volume[1,3].to_i if $3.class == String
  734. se.pitch = $4 if $4 != nil
  735. se.pitch = se.pitch[1,3].to_i if $4.class == String
  736. @death_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  737. when "LOWHEALTH"
  738. se = RPG::SE.new($2, dv, dp)
  739. se.volume = $3 if $3 != nil
  740. se.volume = se.volume[1,3].to_i if $3.class == String
  741. se.pitch = $4 if $4 != nil
  742. se.pitch = se.pitch[1,3].to_i if $4.class == String
  743. @low_health_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  744. when "SELF"
  745. se = RPG::SE.new($2, dv, dp)
  746. se.volume = $3 if $3 != nil
  747. se.volume = se.volume[1,3].to_i if $3.class == String
  748. se.pitch = $4 if $4 != nil
  749. se.pitch = se.pitch[1,3].to_i if $4.class == String
  750. @self_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  751. end
  752. end
  753. case line
  754. when Rockleedude::Battler_SE::BATTLER_SE_PLAYNOTHING
  755. type = $1
  756. type.upcase! unless $1 == nil
  757. type.gsub!(/ /i, "") unless $1 == nil
  758. case type
  759. when "TAKE"
  760. @take_damage_se.insert(0, "PLAYNOTHING")
  761. when "RECOVER"
  762. @recover_damage_se.insert(0, "PLAYNOTHING")
  763. when "EVADE"
  764. @evade_se.insert(0, "PLAYNOTHING")
  765. when "PLUSSTATE"
  766. @plus_state_se.insert(0, "PLAYNOTHING")
  767. when "MINUSSTATE"
  768. @minus_state_se.insert(0, "PLAYNOTHING")
  769. when "ATTACK"
  770. @attack_se.insert(0, "PLAYNOTHING")
  771. when "TARGETFOE"
  772. @target_foe_se.insert(0, "PLAYNOTHING")
  773. when "TARGETALLY"
  774. @target_ally_se.insert(0, "PLAYNOTHING")
  775. when "CRITICALHIT"
  776. @critical_hit_se.insert(0, "PLAYNOTHING")
  777. when "MISS"
  778. @miss_se.insert(0, "PLAYNOTHING")
  779. when "DEATH"
  780. @death_se.insert(0, "PLAYNOTHING")
  781. when "LOWHEALTH"
  782. @low_health_se.insert(0, "PLAYNOTHING")
  783. when "SELF"
  784. @self_se.insert(0, "PLAYNOTHING")
  785. end
  786. end
  787. }
  788. end
  789.  
  790. end # class end
  791.  
  792. #
  793. # ENEMY CLASS
  794. #
  795. class RPG::Enemy
  796. # Battler Receiving
  797. attr_accessor :take_damage_se
  798. attr_accessor :recover_damage_se
  799. attr_accessor :evade_se
  800. attr_accessor :plus_state_se
  801. attr_accessor :minus_state_se
  802.  
  803. # Battler Delivering
  804. attr_accessor :attack_se
  805. attr_accessor :target_foe_se
  806. attr_accessor :target_ally_se
  807. attr_accessor :critical_hit_se
  808. attr_accessor :miss_se
  809.  
  810. # Random Conditions
  811. attr_accessor :death_se
  812. attr_accessor :low_health_se
  813. attr_accessor :self_se
  814.  
  815. def gsub_without_md(string)
  816. string.gsub!(/ /i, "")
  817. string.gsub!(/_/i, "")
  818. return string
  819. end
  820.  
  821. def prepare_se_cache
  822. # Battler Receiving
  823. @take_damage_se = []
  824. @recover_damage_se = []
  825. @evade_se = []
  826. @plus_state_se = []
  827. @minus_state_se = []
  828.  
  829. # Battler Delivering
  830. @attack_se = []
  831. @target_foe_se = []
  832. @target_ally_se = []
  833. @critical_hit_se = []
  834. @miss_se = []
  835.  
  836. # Random Conditions
  837. @death_se = []
  838. @low_health_se = []
  839. @self_se = []
  840. end
  841.  
  842. def create_se_cache
  843. prepare_se_cache
  844. dv = Rockleedude::Battler_SE::DEFAULT_VOLUME
  845. dp = Rockleedude::Battler_SE::DEFAULT_PITCH
  846. self.note.split(/[\r\n]+/).each { |line|
  847. case line
  848. when Rockleedude::Battler_SE::BATTLER_SE
  849. type = $1
  850. type.upcase! unless $1 == nil
  851. type = gsub_without_md(type) unless $1 == nil
  852. case type
  853. when "TAKE"
  854. se = RPG::SE.new($2, dv, dp)
  855. se.volume = $3 if $3 != nil
  856. se.volume = se.volume[1,3].to_i if $3.class == String
  857. se.pitch = $4 if $4 != nil
  858. se.pitch = se.pitch[1,3].to_i if $4.class == String
  859. @take_damage_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  860. when "RECOVER"
  861. se = RPG::SE.new($2, dv, dp)
  862. se.volume = $3 if $3 != nil
  863. se.volume = se.volume[1,3].to_i if $3.class == String
  864. se.pitch = $4 if $4 != nil
  865. se.pitch = se.pitch[1,3].to_i if $4.class == String
  866. @recover_damage_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  867. when "EVADE"
  868. se = RPG::SE.new($2, dv, dp)
  869. se.volume = $3 if $3 != nil
  870. se.volume = se.volume[1,3].to_i if $3.class == String
  871. se.pitch = $4 if $4 != nil
  872. se.pitch = se.pitch[1,3].to_i if $4.class == String
  873. @evade_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  874. when "PLUSSTATE"
  875. se = RPG::SE.new($2, dv, dp)
  876. se.volume = $3 if $3 != nil
  877. se.volume = se.volume[1,3].to_i if $3.class == String
  878. se.pitch = $4 if $4 != nil
  879. se.pitch = se.pitch[1,3].to_i if $4.class == String
  880. @plus_state_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  881. when "MINUSSTATE"
  882. se = RPG::SE.new($2, dv, dp)
  883. se.volume = $3 if $3 != nil
  884. se.volume = se.volume[1,3].to_i if $3.class == String
  885. se.pitch = $4 if $4 != nil
  886. se.pitch = se.pitch[1,3].to_i if $4.class == String
  887. @minus_state_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  888. when "ATTACK"
  889. se = RPG::SE.new($2, dv, dp)
  890. se.volume = $3 if $3 != nil
  891. se.volume = se.volume[1,3].to_i if $3.class == String
  892. se.pitch = $4 if $4 != nil
  893. se.pitch = se.pitch[1,3].to_i if $4.class == String
  894. @attack_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  895. when "TARGETFOE"
  896. se = RPG::SE.new($2, dv, dp)
  897. se.volume = $3 if $3 != nil
  898. se.volume = se.volume[1,3].to_i if $3.class == String
  899. se.pitch = $4 if $4 != nil
  900. se.pitch = se.pitch[1,3].to_i if $4.class == String
  901. @target_foe_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  902. when "TARGETALLY"
  903. se = RPG::SE.new($2, dv, dp)
  904. se.volume = $3 if $3 != nil
  905. se.volume = se.volume[1,3].to_i if $3.class == String
  906. se.pitch = $4 if $4 != nil
  907. se.pitch = se.pitch[1,3].to_i if $4.class == String
  908. @target_ally_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  909. when "CRITICALHIT"
  910. se = RPG::SE.new($2, dv, dp)
  911. se.volume = $3 if $3 != nil
  912. se.volume = se.volume[1,3].to_i if $3.class == String
  913. se.pitch = $4 if $4 != nil
  914. se.pitch = se.pitch[1,3].to_i if $4.class == String
  915. @critical_hit_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  916. when "MISS"
  917. se = RPG::SE.new($2, dv, dp)
  918. se.volume = $3 if $3 != nil
  919. se.volume = se.volume[1,3].to_i if $3.class == String
  920. se.pitch = $4 if $4 != nil
  921. se.pitch = se.pitch[1,3].to_i if $4.class == String
  922. @miss_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  923. when "DEATH"
  924. se = RPG::SE.new($2, dv, dp)
  925. se.volume = $3 if $3 != nil
  926. se.volume = se.volume[1,3].to_i if $3.class == String
  927. se.pitch = $4 if $4 != nil
  928. se.pitch = se.pitch[1,3].to_i if $4.class == String
  929. @death_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  930. when "LOWHEALTH"
  931. se = RPG::SE.new($2, dv, dp)
  932. se.volume = $3 if $3 != nil
  933. se.volume = se.volume[1,3].to_i if $3.class == String
  934. se.pitch = $4 if $4 != nil
  935. se.pitch = se.pitch[1,3].to_i if $4.class == String
  936. @low_health_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  937. when "SELF"
  938. se = RPG::SE.new($2, dv, dp)
  939. se.volume = $3 if $3 != nil
  940. se.volume = se.volume[1,3].to_i if $3.class == String
  941. se.pitch = $4 if $4 != nil
  942. se.pitch = se.pitch[1,3].to_i if $4.class == String
  943. @self_se.insert(0, se) if se.name.upcase != "PLAYNOTHING"
  944. end
  945. end
  946. case line
  947. when Rockleedude::Battler_SE::BATTLER_SE_PLAYNOTHING
  948. type = $1
  949. type.upcase! unless $1 == nil
  950. type.gsub!(/ /i, "") unless $1 == nil
  951. case type
  952. when "TAKE"
  953. @take_damage_se.insert(0, "PLAYNOTHING")
  954. when "RECOVER"
  955. @recover_damage_se.insert(0, "PLAYNOTHING")
  956. when "EVADE"
  957. @evade_se.insert(0, "PLAYNOTHING")
  958. when "PLUSSTATE"
  959. @plus_state_se.insert(0, "PLAYNOTHING")
  960. when "MINUSSTATE"
  961. @minus_state_se.insert(0, "PLAYNOTHING")
  962. when "ATTACK"
  963. @attack_se.insert(0, "PLAYNOTHING")
  964. when "TARGETFOE"
  965. @target_foe_se.insert(0, "PLAYNOTHING")
  966. when "TARGETALLY"
  967. @target_ally_se.insert(0, "PLAYNOTHING")
  968. when "CRITICALHIT"
  969. @critical_hit_se.insert(0, "PLAYNOTHING")
  970. when "MISS"
  971. @miss_se.insert(0, "PLAYNOTHING")
  972. when "DEATH"
  973. @death_se.insert(0, "PLAYNOTHING")
  974. when "LOWHEALTH"
  975. @low_health_se.insert(0, "PLAYNOTHING")
  976. when "SELF"
  977. @self_se.insert(0, "PLAYNOTHING")
  978. end
  979. end
  980. }
  981. end
  982.  
  983. end # class end
  984.  
  985. #
  986. # SCENE_TITLE CLASS
  987. #
  988. class Scene_Title < Scene_Base
  989.  
  990. alias load_database_orig_rld_battler_se load_database
  991. def load_database
  992. load_database_orig_rld_battler_se
  993. load_battler_se
  994. end
  995.  
  996. alias load_bt_database_orig_rld_battler_se load_bt_database
  997. def load_bt_database
  998. load_bt_database_orig_rld_battler_se
  999. load_battler_se
  1000. end
  1001.  
  1002. def load_battler_se
  1003. n = 0
  1004. $data_actor_se = []
  1005. $data_enemy_se = []
  1006.  
  1007. # Actor SE's
  1008. for actor in $data_actors
  1009. next if actor == nil
  1010. actor.create_se_cache
  1011. take = actor.take_damage_se
  1012. recover = actor.recover_damage_se
  1013. evade = actor.evade_se
  1014. plusstate = actor.plus_state_se
  1015. minusstate = actor.minus_state_se
  1016. attack = actor.attack_se
  1017. targetfoe = actor.target_foe_se
  1018. targetally = actor.target_ally_se
  1019. criticalhit = actor.critical_hit_se
  1020. miss = actor.miss_se
  1021. death = actor.death_se
  1022. lowhealth = actor.low_health_se
  1023. selfse = actor.self_se
  1024. $data_actor_se[actor.id] = [take, recover, evade, plusstate, minusstate, attack, targetfoe, targetally, criticalhit, miss, death, lowhealth, selfse] #deal,
  1025. end
  1026.  
  1027. # Enemy SE's
  1028. for enemy in $data_enemies
  1029. next if enemy == nil
  1030. enemy.create_se_cache
  1031. take = enemy.take_damage_se
  1032. recover = enemy.recover_damage_se
  1033. evade = enemy.evade_se
  1034. plusstate = enemy.plus_state_se
  1035. minusstate = enemy.minus_state_se
  1036. attack = enemy.attack_se
  1037. targetfoe = enemy.target_foe_se
  1038. targetally = enemy.target_ally_se
  1039. criticalhit = enemy.critical_hit_se
  1040. miss = enemy.miss_se
  1041. death = enemy.death_se
  1042. lowhealth = enemy.low_health_se
  1043. selfse = enemy.self_se
  1044. $data_enemy_se[enemy.id] = [take, recover, evade, plusstate, minusstate, attack, targetfoe, targetally, criticalhit, miss, death, lowhealth, selfse] #deal,
  1045. end
  1046. end
  1047.  
  1048. end # class end
Advertisement
Add Comment
Please, Sign In to add comment