Advertisement
WCouillard

RGSS3: Actor Escape Bonus v1.03 [RMVXA]

Dec 12th, 2012
1,397
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 17.08 KB | None | 0 0
  1. # ╔══════════════════════════════════════════════════════╤═══════╤════════════╗
  2. # ║ Actor Escape Bonus                                   │ v1.03 │ (09/01/15) ║
  3. # ╠══════════════════════════════════════════════════════╧═══════╧════════════╣
  4. # ║ Author:  William Couillard                                                ║
  5. # ║ Thanks:  Cremno                                                           ║
  6. # ║ E-Mail:  cooliebk18@yahoo.com                                             ║
  7. # ╠═══════════════════════════════════════════════════════════════════════════╣
  8. # ║ ABOUT                                                                     ║
  9. # ╠═══════════════════════════════════════════════════════════════════════════╣
  10. # ║ This script gives your party the ability to escape battles with greater   ║
  11. # ║ success if a certain actor is in the active battle party. For example,    ║
  12. # ║ having a Thief or Elf in the party may make it easier to escape the       ║
  13. # ║ battle. There are also options to allow States to disable the bonus       ║
  14. # ║ chance, and the modifiers that determine the escape chance can be freely  ║
  15. # ║ edited.                                                                   ║
  16. # ╠═══════════════════════════════════════════════════════════════════════════╣
  17. # ║ TERMS OF USE                                                              ║
  18. # ╠═══════════════════════════════════════════════════════════════════════════╣
  19. # ║ ► Do not edit the script's header or comments.                            ║
  20. # ║ ► Free to use in commercial projects as long as proper credit is given to ║
  21. # ║   ALL the names in the above header.                                      ║
  22. # ╠═══════════════════════════════════════════════════════════════════════════╣
  23. # ║ FEATURES                                                                  ║
  24. # ╠═══════════════════════════════════════════════════════════════════════════╣
  25. # ║ ► Escape battles with almost 100% success with the correct actor in the   ║
  26. # ║   active battle party (if alive).                                         ║
  27. # ║ ► Allow States to disable the required actor's ability to enhance the     ║
  28. # ║   escape probability.                                                     ║
  29. # ╠═══════════════════════════════════════════════════════════════════════════╣
  30. # ║ CHANGE LOG                                                                ║
  31. # ╠═══════════════════════════════════════════════════════════════════╤═══════╣
  32. # ║ ■ September 01, 2015 : Added alias to improve compatibility       │ v1.03 ║
  33. # ╟───────────────────────────────────────────────────────────────────┼───────╢
  34. # ║ ■ December 14, 2012  : Check executes every turn. [bugfix]        │ v1.02 ║
  35. # ╟───────────────────────────────────────────────────────────────────┼───────╢
  36. # ║ ■ December 13, 2012  : Added Check States option.                 │ v1.01 ║
  37. # ╟───────────────────────────────────────────────────────────────────┼───────╢
  38. # ║ ■ December 05, 2012  : Initial release.                           │ v1.00 ║
  39. # ╠═══════════════════════════════════════════════════════════════════╧═══════╣
  40. # ║ NEXT VERSION                                                              ║
  41. # ╠═══════════════════════════════════════════════════════════════════════════╣
  42. # ║ ■ Possible update to allow multiple actor IDs to change escape formula.   ║
  43. # ╠═══════════════════════════════════════════════════════════════════════════╣
  44. # ║ METHOD OVERWRITES                                                         ║
  45. # ╠═══════════════════════════════════════════════════════════════════════════╣
  46. # ║   This script overwrites a single method in module BattleManager and one  ║
  47. # ║   method of Scene_Battle.                                                 ║
  48. # ╟───────────────────────────────────────────────────────────────────────────╢
  49. # ║ ■ module BattleManager                                                    ║
  50. # ║    ► def self.make_escape_ratio                                           ║
  51. # ╟───────────────────────────────────────────────────────────────────────────╢
  52. # ║ ■ class Scene_Battle > Scene_Base                                         ║
  53. # ║    ► def turn_start                                                       ║
  54. # ╠═══════════════════════════════════════════════════════════════════════════╣
  55. # ║ INSTRUCTIONS                                                              ║
  56. # ╠═══════════════════════════════════════════════════════════════════════════╣
  57. # ║ Simply paste this script anywhere above the Main script and below the     ║
  58. # ║ BattleManager module.                                                     ║
  59. # ╠═══════════════════════════════════════════════════════════════════════════╣
  60. # ║ IMPORT SETTING                                                            ║
  61. # ╚═══════════════════════════════════════════════════════════════════════════╝
  62. $imported = {} if $imported.nil?
  63. $imported[:wc_actor_escape_bonus] = true
  64. # ╔═══════════════════════════════════════════════════════════════════════════╗
  65. # ║ Coolie's Actor Escape Bonus Module                                        ║
  66. # ╟───────────────────────────────────────────────────────────────────────────╢
  67. # ║ This module manages this script's settings.                               ║
  68. # ╚═══════════════════════════════════════════════════════════════════════════╝
  69. module COOLIE
  70.   module ESCAPE
  71. # ╔═══════════════════════════════════════════════════════════════════════════╗
  72. # ║ Actor Settings                                                            ║
  73. # ╟───────────────────────────────────────────────────────────────────────────╢
  74. # ║ ACTOR_ID     : Input the ID of the actor that will modify the escape      ║
  75. # ║                chance.                                                    ║
  76. # ║ CHECK_STATES : If true, states will be checked for NULL_STATES matches.   ║
  77. # ║                If states in NULL_STATES match current states, escape      ║
  78. # ║                bonus is reset to normal.                                  ║
  79. # ╚═══════════════════════════════════════════════════════════════════════════╝
  80.     ACTOR_ID      = 1
  81.     CHECK_STATES  = true
  82. # ╔═══════════════════════════════════════════════════════════════════════════╗
  83. # ║ Null States Array                                                         ║
  84. # ╟───────────────────────────────────────────────────────────────────────────╢
  85. # ║ The states contained within this array will be checked if CHECK_STATES is ║
  86. # ║ set to true. If any state within this array matches a state currently     ║
  87. # ║ applied to the actor defined in ACTOR_ID, then the escape bonus will be   ║
  88. # ║ nullified.                                                                ║
  89. # ║                                                                           ║
  90. # ║ NOTE: NULL_STATES *MUST* have at least have one state defined. It is a    ║
  91. # ║       good idea to set your death state as a NULL_STATE. Usually, ID 1.   ║
  92. # ╚═══════════════════════════════════════════════════════════════════════════╝
  93.     NULL_STATES   = [1]
  94. # ╔═══════════════════════════════════════════════════════════════════════════╗
  95. # ║ Escape Success Formulas                                                   ║
  96. # ╟───────────────────────────────────────────────────────────────────────────╢
  97. # ║ These constants determine the default and modified chance to escape a     ║
  98. # ║ battle. When the actor defined in ACTOR_ID is in the party, alive, and    ║
  99. # ║ does not have any of the states defined in NULL_STATES, the bonus defined ║
  100. # ║ in ESCAPE_MOD_BONUS will be used to determine the chance of escape.       ║
  101. # ║ Otherwise, the value defined in ESCAPE_MOD_DEFAULT will be used.          ║
  102. # ╚═══════════════════════════════════════════════════════════════════════════╝
  103.     ESCAPE_MOD_DEFAULT = 1.5    # Escape Chance modifier. (Default)
  104.     ESCAPE_MOD_BONUS   = 5.0    # Escape Chance modifier. (Actor Bonus)
  105.   end
  106. end
  107. # ╔═══════════════════════════════════════════════════════════════════════════╗
  108. # ║ BattleManager                                                             ║
  109. # ╚═══════════════════════════════════════════════════════════════════════════╝
  110. module BattleManager
  111. # ╔═══════════════════════════════════════════════════════════════════════════╗
  112. # ║ Make Escape Ratio (Creates Escape Success Probability)                    ║
  113. # ╚═══════════════════════════════════════════════════════════════════════════╝
  114.   def self.make_escape_ratio
  115.     if $game_party.battle_members.include?($game_actors[COOLIE::ESCAPE::ACTOR_ID]) &&
  116.        $game_actors[COOLIE::ESCAPE::ACTOR_ID].hp > 0
  117.       if COOLIE::ESCAPE::CHECK_STATES == true
  118.         if COOLIE::ESCAPE::NULL_STATES.any? { |s| $game_actors[COOLIE::ESCAPE::ACTOR_ID].state?(s) }
  119.           @escape_ratio = COOLIE::ESCAPE::ESCAPE_MOD_DEFAULT - 1.0 * $game_troop.agi / $game_party.agi
  120.         else
  121.           @escape_ratio = COOLIE::ESCAPE::ESCAPE_MOD_BONUS - 1.0 * $game_troop.agi / $game_party.agi
  122.         end
  123.       else
  124.         @escape_ratio = COOLIE::ESCAPE::ESCAPE_MOD_BONUS - 1.0 * $game_troop.agi / $game_party.agi
  125.       end
  126.     else
  127.       @escape_ratio = COOLIE::ESCAPE::ESCAPE_MOD_DEFAULT - 1.0 * $game_troop.agi / $game_party.agi
  128.     end
  129.   end
  130. end
  131. # ╔═══════════════════════════════════════════════════════════════════════════╗
  132. # ║ Scene_Battle                                                              ║
  133. # ╚═══════════════════════════════════════════════════════════════════════════╝
  134. class Scene_Battle < Scene_Base
  135. # ╔═══════════════════════════════════════════════════════════════════════════╗
  136. # ║ START TURN                                                                ║
  137. # ╚═══════════════════════════════════════════════════════════════════════════╝
  138.   alias :wc_actor_escape_bonus_turn_start :turn_start
  139.   def turn_start
  140.     wc_actor_escape_bonus_turn_start
  141.     BattleManager.make_escape_ratio
  142.   end
  143. # ╔═══════════════════════════════════════════════════════════════════════════╗
  144. # ║ END OF FILE                                                               ║
  145. # ╚═══════════════════════════════════════════════════════════════════════════╝
  146. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement