Advertisement
neonblack

No Target v1.0

Mar 15th, 2014
351
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.96 KB | None | 0 0
  1. ###-----------------------------------------------------------------------------
  2. #  Non-targetable State v1.0
  3. #  Created by Neon Black
  4. #  V1.0 - 3.14.2013 - Version created for release
  5. #  For both commercial and non-commercial use as long as credit is given to
  6. #  Neon Black and any additional authors.  Licensed under Creative Commons
  7. #  CC BY 4.0 - http://creativecommons.org/licenses/by/4.0/
  8. #
  9. #  To use this script, simply tag anything with features with the tag
  10. #  <no target> in the brackets.  A target with this feature cannot be the
  11. #  the target of anything until only non-targetable battlers are all dead.
  12. #  You can also tag enemies with the tag <never target> and these enemies
  13. #  cannot be targetted at all.  They do not need to be killed to win the
  14. #  battle.
  15. ###-----------------------------------------------------------------------------
  16.  
  17.  
  18. class RPG::BaseItem
  19.   alias_method "cp_031514_features", "features"
  20.   def features(*args)
  21.     cp_031514_features(*args)
  22.     make_no_target_features unless @made_no_target_features
  23.     return @features
  24.   end
  25.  
  26.   def make_no_target_features
  27.     @made_no_target_features = true
  28.     self.note.split(/[\r\n]+/).each do |line|
  29.       case line
  30.       when /<no target>/i
  31.         @features.push(RPG::BaseItem::Feature.new(:no_target, 0, 1))
  32.       when /<never target>/i
  33.         @features.push(RPG::BaseItem::Feature.new(:never_target, 0, 1))
  34.       end
  35.     end
  36.   end
  37. end
  38.  
  39.  
  40. class Game_BattlerBase
  41.   def no_target?
  42.     features_sum_all(:no_target) > 0.0
  43.   end
  44.  
  45.   def never_target?
  46.     features_sum_all(:never_target) > 0.0
  47.   end
  48.  
  49.   def cp_targ_ok
  50.     alive? && !no_target? && !never_target?
  51.   end
  52.  
  53.   def cp_targ_no
  54.     alive? && no_target? && !never_target?
  55.   end
  56. end
  57.  
  58.  
  59. class Game_Unit
  60.   def alive_members
  61.     target_ok = members.select {|member| member.cp_targ_ok }
  62.     target_no = members.select {|member| member.cp_targ_no }
  63.     return target_ok.empty? ? target_no : target_ok
  64.   end
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement