Advertisement
neutale

Confusion State Improvement

Oct 22nd, 2017
700
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.21 KB | None | 0 0
  1. #==============================================================================
  2. #                     「Confusion State Improvement」(ACE) Ver.1.0
  3. #   Author: Nana
  4. #   Homepage: http://heptanas.mamagoto.com/
  5. #
  6. #   ◇Terms of Use
  7. #   Please credit "Nana" and link http://heptanas.mamagoto.com/ if possible.
  8. #   Feel free to modify this script and/or distribute it.
  9. #   Also please include the credit in the readme or somewhere it's accessible. (Not from credit roll)
  10. #  
  11. #   ◇Non-commercial use
  12. #
  13. #------------------------------------------------------------------------------
  14. #  
  15. #   Confusion by default, attacks enemies or allies.
  16. #   First, decide whether confused state attacks an enemy or ally by 1/2
  17. #   It determines of who will be attacked according to the target rate.
  18. #  
  19. #   Under confused state, it attacks enemy/ party member not yourself.
  20. #   Based on the target rate.
  21. #  
  22. #   Attacking your party member are likely if you have more with you in battle.
  23. #   It's possible to prevent confused state from attacking your ally during battle.
  24. #   Effectiveness of confusion will be reduced if there's 1 party member.
  25. #  
  26. #   Paste this script above Main.
  27. #   (No need to set the scripts in a particular order)
  28. #  
  29. #==============================================================================
  30.  
  31. #==============================================================================
  32. # ■ Game_Action
  33. #------------------------------------------------------------------------------
  34. #  Class that controls battle behavior. Handled inside Game_Battler class.
  35. #==============================================================================
  36.  
  37. class Game_Action
  38.   #--------------------------------------------------------------------------
  39.   # ● Confused Target
  40.   #--------------------------------------------------------------------------
  41.   def confusion_target
  42.     case subject.confusion_level
  43.     when 1
  44.       opponents_unit.random_target
  45.     when 2
  46.       random_target_without_self
  47.     else
  48.       friends_random_target_without_self
  49.     end
  50.   end
  51.   #Game_Unit under processing
  52.   #--------------------------------------------------------------------------
  53.   # ● Random Targets Determined
  54.   #--------------------------------------------------------------------------
  55.   def random_target_without_self
  56.     o = opponents_unit
  57.     f = friends_unit
  58.     s = subject
  59.    
  60.     tgr_rand = rand * (o.tgr_sum + f.tgr_sum - s.tgr)
  61.     o.alive_members.each do |member|
  62.       tgr_rand -= member.tgr
  63.       return member if tgr_rand < 0
  64.     end
  65.     f.alive_members.each do |member|
  66.       next if member == s
  67.       tgr_rand -= member.tgr
  68.       return member if tgr_rand < 0
  69.     end
  70.     o.alive_members[0]
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● Random Ally Targets Determined
  74.   #--------------------------------------------------------------------------
  75.   def friends_random_target_without_self
  76.     f = friends_unit
  77.     s = subject
  78.    
  79.     tgr_rand = rand * (f.tgr_sum - s.tgr)
  80.     f.alive_members.each do |member|
  81.       next if member == s
  82.       tgr_rand -= member.tgr
  83.       return member if tgr_rand < 0
  84.     end
  85.     f.alive_members[0]
  86.   end
  87. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement