Advertisement
Raizen

Akea Toggle Target(English)

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