Advertisement
Raizen

Akea Toggle Target(English/VE Compatibility)

Mar 13th, 2015
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.84 KB | None | 0 0
  1. #=======================================================
  2. #        Akea Toggle Target
  3. # Author: Raizen
  4. # Community: http://www.centrorpg.com/
  5. # Compatibility: RMVXAce
  6. #
  7. #=======================================================
  8. # ==================================================================
  9. # Funcionality:
  10. # The script allows target toggle, which means a single target skill can be
  11. # switched to multi-target, also you can allow skills to affect both allies and enemies
  12. # ----------------------- Don't Modify -------------------------
  13. $imported ||= Hash.new
  14. $imported[:akea_toggletarget] = true
  15. module Akea_Toggle_Target
  16. # ----------------------- Here starts the configuration -------------------------
  17. # Keys that affect the toggle for multiple targets
  18. # You can have more then one key, just separate then by commas Ex: [:L, :X, :Q]
  19.  
  20. # Key Mapping on RPG Maker
  21. # X = Key A  ;  Y = Key S  ;  Z = Key D
  22. # L = Key Q  ;  R = Key W  ;  SHIFT
  23. Toggle_Input = [:L]
  24.  
  25. # Keys that affect the toggle to switch between allies and enemies
  26. # You can have more then one key, just separate then by commas Ex: [:L, :X, :Q]
  27. Change_Input = [:R]
  28.  
  29.  
  30. # Put these on notetags on the skills on database
  31. # <target toggle>
  32. # Allows that skill to toggle for all targets
  33.  
  34. # <scope toggle>
  35. # Allows that skill to toggle different sides
  36.  
  37. # <all rate:  n%>
  38. # Allows for a skill to split damage, that means it will reduce damage
  39. # when targeting multiple targets, where n is the %
  40. # For example
  41. # <all rate:  100%>
  42. # For two enemies, will split damage to 50% for each one.
  43.  
  44.  
  45. end
  46. # =========================Don't Modify==============================
  47.  
  48. #==============================================================================
  49. # ** Scene_Battle
  50. #------------------------------------------------------------------------------
  51. #  Esta classe executa o processamento da tela de batalha.
  52. #==============================================================================
  53.  
  54. class Scene_Battle < Scene_Base
  55. alias :akea_tt_update_basic :update_basic
  56. alias :akea_tt_on_skill_ok :on_skill_ok
  57. alias :akea_tt_on_enemy_cancel :on_enemy_cancel
  58. alias :akea_tt_on_actor_cancel :on_actor_cancel
  59.   #--------------------------------------------------------------------------
  60.   # * Atualização da tela (básico)
  61.   #--------------------------------------------------------------------------
  62.   def update_basic
  63.     akea_tt_update_basic
  64.     if @enemy_window.active
  65.       Akea_Toggle_Target::Toggle_Input.each{|input| change_toggle_enemy if Input.trigger?(input)}
  66.       Akea_Toggle_Target::Change_Input.each{|input| change_input_enemy if Input.trigger?(input)}
  67.     elsif @actor_window.active
  68.       Akea_Toggle_Target::Toggle_Input.each{|input| change_toggle_actor if Input.trigger?(input)}
  69.       Akea_Toggle_Target::Change_Input.each{|input| change_input_actor if Input.trigger?(input)}
  70.     end
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # * Ativar Toggle(Actor)
  74.   #--------------------------------------------------------------------------
  75.   def change_toggle_actor
  76.     return unless BattleManager.actor.current_action.item.note.include?("<target toggle>")
  77.     @actor_window.set_rect_cursor
  78.     BattleManager.actor.current_action.akea_toggle = @actor_window.cursor_set_all
  79.     @akea_target_all = BattleManager.actor.current_action.akea_toggle
  80.     Sound.play_cursor
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # * Mudança de Alvo(Para Inimigos)
  84.   #--------------------------------------------------------------------------
  85.   def change_input_actor
  86.     return unless BattleManager.actor.current_action.item.note.include?("<scope toggle>")
  87.     #BattleManager.actor.current_action.akea_toggle = false
  88.     #@akea_target_all = false
  89.     BattleManager.actor.current_action.cursor_opposit_set = !BattleManager.actor.current_action.item.for_opponent?
  90.     @actor_window.hide
  91.     @actor_window.deactivate
  92.     @skill_window.deactivate
  93.     Sound.play_cursor
  94.     select_enemy_selection
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # * Ativar Toggle(Enemy)
  98.   #--------------------------------------------------------------------------
  99.   def change_toggle_enemy
  100.     return unless BattleManager.actor.current_action.item.note.include?("<target toggle>")
  101.     @enemy_window.set_rect_cursor
  102.     BattleManager.actor.current_action.akea_toggle = @enemy_window.cursor_set_all
  103.     @akea_target_all = BattleManager.actor.current_action.akea_toggle
  104.     Sound.play_cursor
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # * Mudança de Alvo(Para Personagens)
  108.   #--------------------------------------------------------------------------
  109.   def change_input_enemy
  110.     return unless BattleManager.actor.current_action.item.note.include?("<scope toggle>")
  111.     #BattleManager.actor.current_action.akea_toggle = false
  112.     #@akea_target_all = false
  113.     BattleManager.actor.current_action.cursor_opposit_set = BattleManager.actor.current_action.item.for_opponent?
  114.     @enemy_window.hide
  115.     @enemy_window.deactivate
  116.     @skill_window.deactivate
  117.     Sound.play_cursor
  118.     select_actor_selection
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # * Habilidade [Confirmação]
  122.   #--------------------------------------------------------------------------
  123.   def on_skill_ok
  124.     akea_tt_on_skill_ok
  125.     BattleManager.actor.current_action.akea_toggle = false
  126.     BattleManager.actor.current_action.cursor_opposit_set = false
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # * Tela Inimigos [Cancelamento]
  130.   #--------------------------------------------------------------------------
  131.   def on_enemy_cancel
  132.     akea_tt_on_enemy_cancel
  133.     BattleManager.actor.current_action.akea_toggle = false
  134.     BattleManager.actor.current_action.cursor_opposit_set = false
  135.   end
  136.   #--------------------------------------------------------------------------
  137.   # * Tela Persnagens [Cancelamento]
  138.   #--------------------------------------------------------------------------
  139.   def on_actor_cancel
  140.     akea_tt_on_actor_cancel
  141.     @actor_command_window.activate if @actor_command_window.current_symbol == :attack
  142.     BattleManager.actor.current_action.akea_toggle = false
  143.     BattleManager.actor.current_action.cursor_opposit_set = false
  144.   end
  145. end
  146.  
  147.  
  148. #==============================================================================
  149. # ** Window_BattleEnemy
  150. #------------------------------------------------------------------------------
  151. #  Esta janela para seleção de inimigos na tela de batalha.
  152. #==============================================================================
  153.  
  154. class Window_BattleEnemy < Window_Selectable
  155. alias :akea_tt_item_rect :item_rect
  156. attr_reader :cursor_set_all
  157.   #--------------------------------------------------------------------------
  158.   # * Ativar a Janela
  159.   #--------------------------------------------------------------------------
  160.   def activate
  161.     @cursor_set_all = false
  162.     super
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # * Selecionar o cursor
  166.   #--------------------------------------------------------------------------
  167.   def set_rect_cursor
  168.     @cursor_set_all = !@cursor_set_all
  169.     update_cursor
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # * Aquisição do retangulo para desenhar o item
  173.   #     index : índice do item
  174.   #--------------------------------------------------------------------------
  175.   def item_rect(index)
  176.     if @cursor_set_all
  177.       rect = Rect.new
  178.       rect.width = item_width * [col_max, item_max].min + spacing
  179.       rect.height = item_height * (item_max.to_f/col_max).ceil
  180.       rect.x = 0
  181.       rect.y = 0
  182.       rect
  183.     else
  184.       akea_tt_item_rect(index)
  185.     end
  186.   end
  187.   #--------------------------------------------------------------------------
  188.   # * Aquisição do retangulo para desenhar o item (para texto)
  189.   #     index : índice do item
  190.   #--------------------------------------------------------------------------
  191.   def item_rect_for_text(index)
  192.     rect = akea_tt_item_rect(index)
  193.     rect.x += 4
  194.     rect.width -= 8
  195.     rect
  196.   end
  197. end
  198.  
  199. #==============================================================================
  200. # ** Window_BattleActor
  201. #------------------------------------------------------------------------------
  202. #  Esta janela para seleção de heróis na tela de batalha.
  203. #==============================================================================
  204.  
  205. class Window_BattleActor < Window_BattleStatus
  206. alias :akea_tt_item_rect :item_rect
  207. attr_reader :cursor_set_all
  208.   #--------------------------------------------------------------------------
  209.   # * Ativar a Janela
  210.   #--------------------------------------------------------------------------
  211.   def activate
  212.     @cursor_set_all = false
  213.     super
  214.   end
  215.   #--------------------------------------------------------------------------
  216.   # * Selecionar o cursor
  217.   #--------------------------------------------------------------------------
  218.   def set_rect_cursor
  219.     @cursor_set_all = !@cursor_set_all
  220.     update_cursor
  221.   end
  222.   #--------------------------------------------------------------------------
  223.   # * Aquisição do retangulo para desenhar o item
  224.   #     index : índice do item
  225.   #--------------------------------------------------------------------------
  226.   def item_rect(index)
  227.     if @cursor_set_all
  228.       rect = Rect.new
  229.       rect.width = item_width * col_max + spacing
  230.       rect.height = item_height * (item_max.to_f/col_max).ceil
  231.       rect.x = 0
  232.       rect.y = 0
  233.       rect
  234.     else
  235.       akea_tt_item_rect(index)
  236.     end
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # * Aquisição do retangulo para desenhar o item (para texto)
  240.   #     index : índice do item
  241.   #--------------------------------------------------------------------------
  242.   def item_rect_for_text(index)
  243.     rect = akea_tt_item_rect(index)
  244.     rect.x += 4
  245.     rect.width -= 8
  246.     rect
  247.   end
  248. end
  249.  
  250.  
  251. #==============================================================================
  252. # ** Game_Action
  253. #------------------------------------------------------------------------------
  254. #  Esta classe gerencia as ações do combate.
  255. # Esta classe é usada internamente pela classe Game_Battler.
  256. #==============================================================================
  257.  
  258. class Game_Action
  259. alias :akea_tt_initialize :initialize
  260. alias :akea_tt_targets_for_opponents :targets_for_opponents
  261. alias :akea_tt_targets_for_friends :targets_for_friends
  262. attr_accessor   :akea_toggle
  263. attr_accessor :cursor_opposit_set
  264.   #--------------------------------------------------------------------------
  265.   # * Inicialização do objeto
  266.   #--------------------------------------------------------------------------
  267.   def initialize(subject, forcing = false)
  268.     @akea_toggle = false
  269.     @cursor_opposit_set = false
  270.     akea_tt_initialize(subject, forcing = false)
  271.   end
  272.   #--------------------------------------------------------------------------
  273.   # * Alvos para inimigos
  274.   #--------------------------------------------------------------------------
  275.   def targets_for_opponents
  276.     return opponents_unit.alive_members if @akea_toggle || (@cursor_opposit_set && !item.for_one?)
  277.     if @cursor_opposit_set && item.for_one?
  278.       num = 1 + (attack? ? subject.atk_times_add.to_i : 0)
  279.       if @target_index < 0
  280.         return [opponents_unit.random_target] * num
  281.       else
  282.         return [opponents_unit.smooth_target(@target_index)] * num
  283.       end
  284.     end
  285.     akea_tt_targets_for_opponents
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # * Alvos para aliados
  289.   #--------------------------------------------------------------------------
  290.   def targets_for_friends
  291.     return friends_unit.alive_members if @akea_toggle || (@cursor_opposit_set && !item.for_one?)
  292.     if @cursor_opposit_set && item.for_one?
  293.       return [friends_unit.smooth_target(@target_index)]
  294.     end
  295.     akea_tt_targets_for_friends
  296.   end
  297.   #--------------------------------------------------------------------------
  298.   # * Criação da lista de alvos
  299.   #--------------------------------------------------------------------------
  300.   def make_targets
  301.     return unless item
  302.     if !forcing && subject.confusion?
  303.       [confusion_target]
  304.     elsif item.for_opponent?
  305.       if @cursor_opposit_set
  306.         targets_for_friends
  307.       else
  308.         targets_for_opponents
  309.       end
  310.     elsif item.for_friend?
  311.       if @cursor_opposit_set
  312.         targets_for_opponents
  313.       else
  314.         targets_for_friends
  315.       end
  316.     else
  317.       []
  318.     end
  319.   end
  320. end
  321.  
  322. #==============================================================================
  323. # ** Game_ActionResult
  324. #------------------------------------------------------------------------------
  325. #  Esta classe gerencia os resultados das ações nos combates.
  326. # Esta classe é usada internamente pela classe Game_Battler.
  327. #==============================================================================
  328.  
  329. class Game_ActionResult
  330. alias :akea_tt_make_damage :make_damage
  331.   #--------------------------------------------------------------------------
  332.   # * Criação do dano
  333.   #     value : valor do dano
  334.   #     item  : objeto
  335.   #--------------------------------------------------------------------------
  336.   def make_damage(value, item)
  337.     akea_tt_make_damage(value, item)
  338.   end
  339. end
  340. #==============================================================================
  341. # ** Game_Battler
  342. #------------------------------------------------------------------------------
  343. #  Esta classe gerencia os battlers. Controla a adição de sprites e ações
  344. # dos lutadores durante o combate.
  345. # É usada como a superclasse das classes Game_Enemy e Game_Actor.
  346. #==============================================================================
  347. class Game_Battler < Game_BattlerBase
  348.   #--------------------------------------------------------------------------
  349.   # * Cálculo de dano
  350.   #     user : usuário
  351.   #     item : habilidade/item
  352.   #--------------------------------------------------------------------------
  353.   def make_damage_value(user, item)
  354.     value = item.damage.eval(user, self, $game_variables)
  355.     if user.current_action && user.current_action.akea_toggle
  356.       note = /<all rate: *(\d+)%?>/i
  357.       if  item.note =~ note
  358.         value *= ($1.to_f/$game_troop.alive_members.size)/100.0
  359.       end
  360.     end
  361.     value *= item_element_rate(user, item)
  362.     value *= pdr if item.physical?
  363.     value *= mdr if item.magical?
  364.     value *= rec if item.damage.recover?
  365.     value = apply_critical(value) if @result.critical
  366.     value = apply_variance(value, item.damage.variance)
  367.     value = apply_guard(value)
  368.     @result.make_damage(value.to_i, item)
  369.   end
  370. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement