Advertisement
mrbubble

Lose Battle on Actor Death

Jul 12th, 2012
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.27 KB | None | 0 0
  1. #==============================================================================
  2. # ++ Lose Battle on Actor Death ++                              v1.0 (7/12/12)
  3. #==============================================================================
  4. # Script by:
  5. #     Mr. Bubble ( http://mrbubblewand.wordpress.com/ )
  6. # Thanks:
  7. #     Mithran, regexp lessons
  8. #--------------------------------------------------------------------------
  9. # Some RPGs out there are arbitrarily increased in difficulty by the simple
  10. # rule that if the lead character dies, it is considered a Game Over.
  11. #
  12. # This small script provides that same functionality to VX Ace projects with
  13. # the added flexibility of flagging any actor you want. This only affects
  14. # battles. Deaths on the map scene are not checked.
  15. #--------------------------------------------------------------------------
  16. #   ++ Changelog ++
  17. #--------------------------------------------------------------------------
  18. # v1.0 : Initial release. (7/12/2012)
  19. #--------------------------------------------------------------------------
  20. #   ++ Installation ++
  21. #--------------------------------------------------------------------------
  22. # Install this script in the Materials section in your project's
  23. # script editor.
  24. #==============================================================================
  25. #   ++ Notetag ++
  26. #==============================================================================
  27. # The following Notetag is for Actors only:
  28. #
  29. # <lose on death>
  30. #   Actors with this tag will cause a battle loss if they are  
  31. #   Incapacitated in battle.
  32. #--------------------------------------------------------------------------
  33. #   ++ Compatibility ++
  34. #--------------------------------------------------------------------------
  35. # This script has built-in compatibility with the following scripts:
  36. #
  37. #     -Auto-Life Effect
  38. #     -Guts Effect
  39. #
  40. # This script aliases the following default VXA methods:
  41. #
  42. #     BattleManager#judge_win_loss
  43. #
  44. #     Game_Actor#setup
  45. #
  46. # There are no default method overwrites.
  47. #--------------------------------------------------------------------------
  48. #   ++ Terms and Conditions ++
  49. #--------------------------------------------------------------------------
  50. # Please do not repost this script elsewhere without permission.
  51. # Free for non-commercial use. For commercial use, contact me first.
  52. #
  53. # Newest versions of this script can be found at
  54. #                                           http://mrbubblewand.wordpress.com/
  55. #==============================================================================
  56.  
  57. $imported = {} if $imported.nil?
  58. $imported["BubsLoseOnDeath"] = true
  59.  
  60. #==============================================================================
  61. # ++ BattleManager
  62. #==============================================================================
  63. module BattleManager
  64.   #--------------------------------------------------------------------------
  65.   # alias : judge_win_loss
  66.   #--------------------------------------------------------------------------
  67.   class << self; alias judge_win_loss_bubs_lose_on_death judge_win_loss; end
  68.   def self.judge_win_loss
  69.     if @phase
  70.       return process_abort    if aborting?
  71.       return process_defeat   if actor_lose_on_death?
  72.     end
  73.     judge_win_loss_bubs_lose_on_death # alias
  74.   end # def self.judge_win_loss
  75.  
  76.   #--------------------------------------------------------------------------
  77.   # new method : actor_lose_on_death?
  78.   #--------------------------------------------------------------------------
  79.   def self.actor_lose_on_death?
  80.     return false if $imported["BubsGuts"] && gutsable_members
  81.     return false if $imported["BubsAutoLife"] && autolifeable_members
  82.     return lose_on_death_actor_dead?
  83.   end # def self.actor_lose_on_death?
  84.  
  85.   #--------------------------------------------------------------------------
  86.   # new method : lose_on_death_actor_dead?
  87.   #--------------------------------------------------------------------------
  88.   def self.lose_on_death_actor_dead?
  89.     $game_party.battle_members.each do |actor|
  90.       return true if actor.lose_on_death && actor.dead?
  91.     end
  92.     return false
  93.   end
  94. end # module BattleManager
  95.  
  96.  
  97. #==============================================================================
  98. # ++ Game_Actor
  99. #==============================================================================
  100. class Game_Actor < Game_Battler
  101.   #--------------------------------------------------------------------------
  102.   # public instance variables
  103.   #--------------------------------------------------------------------------
  104.   attr_accessor :lose_on_death     # lose on actor death flag
  105.   #--------------------------------------------------------------------------
  106.   # alias : setup
  107.   #--------------------------------------------------------------------------
  108.   alias setup_bubs_lose_on_death setup
  109.   def setup(actor_id)
  110.     setup_bubs_lose_on_death(actor_id) # alias
  111.    
  112.     @lose_on_death ||= lose_on_death_noteread
  113.   end
  114.  
  115.   #--------------------------------------------------------------------------
  116.   # new method : lose_on_death_noteread
  117.   #--------------------------------------------------------------------------
  118.   def lose_on_death_noteread
  119.     actor.note =~ /<(?:LOSE[\s_]?ON[\s_]?DEATH)>/i ? true : false
  120.   end
  121. end # class Game_Actor
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement