Guest User

Untitled

a guest
Dec 13th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 25.88 KB | None | 0 0
  1.   # try to call a summon, return summoned_id if successful
  2.   def summon_battler(id)
  3.     return unless $game_summons.can_summon?(id)
  4.     summoned_id = $game_summons.summon(id)
  5.     return $game_summons[summoned_id]
  6.   end
  7.  
  8.   def add_summon(summon_id)
  9.     $game_summons.summon_actor(summon_id)
  10.     @summons.push(summon_id) unless @summons.include?(summon_id)
  11.   end
  12. ----------------------------------------------------------------------------------------------
  13. =begin
  14. ==============================================================================
  15.  ** Battle Summons
  16.  Author: Tsukihime
  17.  Date: Jul 10, 2012
  18. ------------------------------------------------------------------------------
  19.  ** Change log
  20.  Jul 10
  21.    -added summon_only_battle to game system as a flag
  22.  Jun 24
  23.    -fixed enemy summoning: only refresh newly summoned sprites
  24.  Jun 12
  25.    -assign specific summons to items/skills
  26.    -summon ID is now the same as the actor ID
  27.    -added remove summon functionality.
  28.  May 30
  29.    -summon limits and type limits added
  30.    -summons recover all after battle
  31.    -summon implemented as a skill
  32.    -added Command Setup compatibility
  33.    -added enemy summons
  34.    -summon equip menu added
  35.  May 20
  36.    -option to remove all actors when summon appears
  37.    -actors will return when the summon disappears
  38.  May 19
  39.    -Created summon scene/window
  40.    -added summon command
  41.    -summons are now treated as actors and level accordingly
  42.  May 18
  43.    -Initial release
  44. ------------------------------------------------------------------------------
  45.  Summon battlers to fight for you!
  46.  
  47.  In the configuration, designate skills that should be treated as
  48.  "summon skills". Then set up the skill in the database.
  49.  
  50.  Enemies can also be set up to use the summon skill.
  51.  They will need a list of enemy ID's to choose from.
  52.  Tag enemies with the enemy ID's they should summon
  53.  
  54.     <summons: 1,2,3>
  55.    
  56.  Then give them the summon skill in their action list
  57.  
  58.  To add a summon to your party, use the script call
  59.  
  60.     $game_party.add_summon(summon_id)
  61.    
  62.  To remove a summon from your party,
  63.  
  64.     $game_party.remove_summon(summon_id)
  65.    
  66.  To force summon a party to battle, use the call
  67.  
  68.     $game_summons.summon(id)
  69. ==============================================================================
  70. =end
  71. $imported = {} if $imported.nil?
  72. $imported["Tsuki_BattleSummon"] = true
  73. #==============================================================================
  74. # ** Configuration.
  75. #==============================================================================
  76. module Tsuki
  77.   module Battle_Summon
  78.    
  79.     # Skill IDs that are treated as summon skills
  80.     Summon_Skill = [3, 4, 17,18]
  81.     Summon_Item = []
  82.     Summon_Constraints =
  83.       {[:skill, 3] => [3], [:skill, 4] => [4], [:skill, 17] => [5], [:skill, 18] => [6]}
  84.      
  85.     # variable used to determine the number of turns summoned
  86.     Default_Summon_Turns = 99
  87.     Summon_Turn_Variable = 1
  88.        
  89.     Summon_Limit = 2      # How many summons you can have in battle
  90.     Summon_Type_Limit = 2 # How many different summons you can have in battle
  91.    
  92.     # Messages to display on successful summon in battle
  93.     # format [user name], [summon name]
  94.     Summon_Message = "%s has called %s to battle!"
  95.    
  96.     # Should the summon command be shown in battle?
  97.     Enable_Summon_Command = false
  98.    
  99.     # party members leave when a summon appears
  100.     Summon_Only_Battle = false
  101.    
  102.     # Monster Hunter add-on requires that script. It adds all captured monsters
  103.     # to your summon list rather than the party list.
  104.     Monster_Hunter_Addon = false
  105.  
  106.   #==============================================================================
  107.   # ** Rest of the Script
  108.   #==============================================================================
  109.     def self.summon_effect?(item)
  110.       return Summon_Skill.include?(item.id) if item.is_a?(RPG::Skill)
  111.       return Summon_Item.include?(item.id) if item.is_a?(RPG::Item)
  112.       return false
  113.     end
  114.    
  115.     Enemy_Summon_Regex = /<summons:?\s*(.*)\s*>/i
  116.     Summon_Limit_Regex = /<summon-max:?\s*(\d+)\s*>/i
  117.     Summon_ID_Regex = /<summon:?\s*(\d+)\s*>/i
  118.   end
  119. end
  120.  
  121. module RPG
  122.  
  123.   class Actor < BaseItem
  124.    
  125.     def summon_limit
  126.       return @summon_limit unless @summon_limit.nil?
  127.       res = Tsuki::Battle_Summon::Summon_Limit_Regex.match(self.note)
  128.       return @summon_limit = res ? res[1].to_i : 99
  129.     end
  130.   end
  131.  
  132.   class Enemy < BaseItem
  133.    
  134.     def enemy_summons
  135.       return @enemy_summon unless @enemy_summon.nil?
  136.       return @enemy_summon = load_notetags_enemy_summons
  137.     end
  138.  
  139.     def load_notetags_enemy_summons
  140.       summons = []
  141.       self.note.split(/[\r\n]+/).each do |line|
  142.         case line
  143.         when Tsuki::Battle_Summon::Enemy_Summon_Regex
  144.           $1.scan(/\d+/).each {|id| summons << id.to_i}
  145.         end
  146.       end
  147.       return summons
  148.     end
  149.   end
  150.  
  151.   class UsableItem < BaseItem
  152.    
  153.     def summon_id
  154.       return @summon_id unless @summon_id.nil?
  155.       res = Tsuki::Battle_Summon::Summon_ID_Regex.match(self.note)
  156.       return @summon_id = res ? res[1].to_i : 0
  157.     end
  158.   end
  159. end
  160.  
  161. module DataManager
  162.  
  163.   class << self
  164.     alias :tsuki_battle_summon_create_objects :create_game_objects
  165.     alias :tsuki_battle_summon_make_save_contents :make_save_contents
  166.     alias :tsuki_battle_summon_extract_save_contents :extract_save_contents
  167.   end
  168.  
  169.   def self.create_game_objects
  170.     tsuki_battle_summon_create_objects
  171.     $game_summons = Game_Summons.new
  172.   end
  173.  
  174.   def self.make_save_contents
  175.     contents = tsuki_battle_summon_make_save_contents
  176.     contents[:summons]        = $game_summons
  177.     contents
  178.   end
  179.  
  180.   def self.extract_save_contents(contents)
  181.     tsuki_battle_summon_extract_save_contents(contents)
  182.     $game_summons = contents[:summons]
  183.   end
  184. end
  185.  
  186. module BattleManager
  187.   class << self
  188.     alias :tsuki_battle_summon_turn_end :turn_end
  189.     alias :tsuki_battle_summon_gain_exp :gain_exp
  190.     alias :tsuki_battle_summon_battle_end :battle_end
  191.   end
  192.  
  193.   def self.turn_end
  194.     tsuki_battle_summon_turn_end
  195.     $game_summons.update_summons
  196.   end
  197.  
  198.   def self.gain_exp
  199.     tsuki_battle_summon_gain_exp
  200.     $game_summons.battle_members.each do |summon|
  201.       summon.gain_exp($game_troop.exp_total)
  202.     end
  203.     wait_for_message
  204.   end
  205.  
  206.   def self.battle_end(result)
  207.     tsuki_battle_summon_battle_end(result)
  208.     $game_summons.on_battle_end
  209.   end
  210. end
  211.  
  212. class Spriteset_Battle
  213.   def refresh_enemies
  214.     new_enemies = $game_troop.members.reverse.collect do |enemy|
  215.       @enemy_sprites << Sprite_Battler.new(@viewport1, enemy)  if enemy.summoned?
  216.     end
  217.   end
  218. end
  219.  
  220. class Game_System
  221.  
  222.   attr_accessor :summon_only_battle
  223.  
  224.   alias :th_battle_summon_init_system :initialize
  225.   def initialize
  226.     th_battle_summon_init_system
  227.     @summon_only_battle = Tsuki::Battle_Summon::Summon_Only_Battle
  228.   end
  229. end
  230.  
  231. class Game_Action
  232.  
  233.   attr_accessor :summon_id #id of summon to call
  234.  
  235.   alias :th_battle_summon_clear_action :clear
  236.   def clear
  237.     th_battle_summon_clear_action
  238.     @summon_id = 0
  239.   end
  240. end
  241.  
  242. class Game_ActionResult
  243.    
  244.     attr_accessor :called_summon
  245.    
  246.     alias :th_battle_summon_clear_results :clear
  247.     def clear
  248.       th_battle_summon_clear_results
  249.       clear_summon_result
  250.     end
  251.    
  252.     def clear_summon_result
  253.       @called_summon = nil
  254.     end
  255.    
  256.     def called_summon_text
  257.       if @called_summon
  258.         fmt = Tsuki::Battle_Summon::Summon_Message
  259.         sprintf(fmt, @battler.name, @called_summon.name)
  260.       else
  261.         ""
  262.       end
  263.     end
  264.   end
  265.  
  266. class Game_Battler < Game_BattlerBase
  267.  
  268.   def is_summon_action?(item)
  269.     return false unless item
  270.     Tsuki::Battle_Summon.summon_effect?(item)
  271.   end
  272.  
  273.   alias :th_summon_battler_item_apply :item_apply
  274.   def item_apply(user, item)
  275.     th_summon_battler_item_apply(user, item)
  276.     summon_battler(user, item) if is_summon_action?(item)
  277.   end
  278.  
  279.   def summon_battler(user, item)
  280.     called_summon = user.friends_unit.summon_battler(user.actions[0].summon_id)
  281.     if called_summon
  282.       @result.success = true
  283.       @result.called_summon = called_summon
  284.     end
  285.   end
  286. end
  287.  
  288. class Game_Enemy < Game_Battler
  289.    
  290.   attr_accessor :just_summoned
  291.   alias :th_battle_summon_init_enemy :initialize
  292.   def initialize(index, enemy_id)
  293.     th_battle_summon_init_enemy(index, enemy_id)
  294.     @just_summoned = false
  295.     init_summons
  296.   end
  297.  
  298.   def summoned?
  299.     if @just_summoned
  300.       @just_summoned = false
  301.       return true
  302.     end
  303.     return false
  304.   end
  305.  
  306.   def init_summons
  307.     @summons = enemy.enemy_summons
  308.   end
  309.  
  310.   alias :th_battle_summon_make_enemy_actions :make_actions
  311.   def make_actions
  312.     th_battle_summon_make_enemy_actions
  313.     @actions.each do |action|
  314.       make_summon_action(action) if is_summon_action?(action.item)
  315.     end
  316.   end
  317.  
  318.   # pick a random target to draw a random magic from
  319.   def make_summon_action(action)
  320.     action.summon_id = @summons.sample
  321.   end
  322. end
  323.  
  324. class Game_Summon < Game_Actor
  325.  
  326.   attr_reader :summon_id
  327.   attr_accessor :summon_turns
  328.   attr_accessor :summon_index
  329.   def initialize(actor_id)
  330.     super(actor_id)
  331.     @summon_id = actor_id
  332.     @summon_turns = 0
  333.     @summon_index = 0 # 0 if not summoned
  334.     @dupe = false
  335.   end
  336.  
  337.   def can_dupe?
  338.     @dupe
  339.   end
  340.  
  341.   def update_summon
  342. #~     @summon_turns -= 1
  343. #~     if @summon_turns <= 0 || @mp <= 0
  344. #~       $game_summons.unsummon(@summon_id)
  345.     if @mp == 0; add_state(2)
  346.     end
  347.   end
  348.  
  349.   def die
  350.     $game_summons.unsummon(@summon_id)
  351.     super
  352.   end
  353.  
  354.   def index
  355.     $game_summons.members.index(self)
  356.   end
  357. end
  358.  
  359. class Game_Summons < Game_Unit
  360.   include Tsuki::Battle_Summon
  361.  
  362.   def initialize
  363.     @data = [nil]
  364.     @ids = [nil]
  365.     @dispatched = []
  366.     @summon_count = 0 #how many summons are on the field
  367.     @limit = Summon_Limit
  368.     @type_limit = Summon_Type_Limit
  369.     @menu_actor_id = 0
  370.   end
  371.  
  372.   def [](summon_id)
  373.     @data[summon_id] ||= Game_Summon.new(summon_id)
  374.   end
  375.  
  376.   def members
  377.     in_battle ? battle_members : all_summons
  378.   end
  379.  
  380.   def all_summons
  381.     @data.select {|summon| !summon.nil?}
  382.   end
  383.  
  384.   # summons that are currently in battle
  385.   def battle_members
  386.     @dispatched.collect {|id| @data[id]}
  387.   end
  388.    
  389.   def summon_actor(id)
  390.     return if @ids.include?(id)
  391.     summon = Game_Summon.new(id)
  392.     @data[id] = summon
  393.     @ids << id
  394.   end
  395.  
  396.   def unsummon(id)
  397.     return unless @dispatched.include?(id)
  398.     @dispatched.delete_at(@data[id].summon_index - 1)
  399.     @data[id].summon_index = 0
  400.     @summon_count -= 1
  401.   end
  402.  
  403.   def summon(id)
  404.     return 0 unless @data[id]
  405.     @data[id].summon_turns = [Default_Summon_Turns, $game_variables[Summon_Turn_Variable]].max
  406.     @data[id].make_actions
  407.     @summon_count += 1
  408.     @data[id].summon_index = @summon_count
  409.     @dispatched << id
  410.     return id
  411.   end
  412.  
  413.   def can_summon?(summon_id)
  414.     return false if @data[summon_id].nil?
  415.     return false if @summon_count >= @limit
  416.     return false if @dispatched.include?(summon_id) && !@data[summon_id].can_dupe?
  417.     return true
  418.   end
  419.  
  420.   def update_summons
  421.     members.each {|summon| summon.update_summon}
  422.   end
  423.  
  424.   def on_battle_end
  425.     alive_members.each {|summon| summon.remove_state(2) }
  426.     @dispatched = []
  427.     @summon_count = 0
  428.   end
  429.  
  430.   def menu_actor
  431.     @data[@menu_actor_id] || members[0]
  432.   end
  433.  
  434.   def menu_actor=(summon)
  435.     return unless summon
  436.     @menu_actor_id = summon.summon_id
  437.   end
  438.  
  439.   def menu_actor_next
  440.     index = members.index(menu_actor) || -1
  441.     index = (index + 1) % members.size
  442.     self.menu_actor = members[index]
  443.   end
  444.  
  445.   def menu_actor_prev
  446.     index = members.index(menu_actor) || 1
  447.     index = (index + members.size - 1) % members.size
  448.     self.menu_actor = members[index]
  449.   end
  450. end
  451.  
  452. class Game_Party < Game_Unit
  453.   include Tsuki::Battle_Summon
  454.  
  455.   alias tsuki_battle_summon_initialize_party initialize
  456.   def initialize
  457.     tsuki_battle_summon_initialize_party
  458.     @summons = []
  459.   end
  460.  
  461.   alias tsuki_battle_summon_battle_members battle_members
  462.   def battle_members
  463.     summons = $game_summons.battle_members
  464.     if $game_system.summon_only_battle
  465.       summons.empty? ? tsuki_battle_summon_battle_members : summons
  466.     else
  467.       members = tsuki_battle_summon_battle_members
  468.       members.concat(summons)
  469.     end
  470.   end
  471.  
  472.   def summons
  473.     @summons.collect {|id| $game_summons[id]}
  474.   end
  475.  
  476.   # try to call a summon, return summoned_id if successful
  477.   def summon_battler(id)
  478.     return unless $game_summons.can_summon?(id)
  479.     summoned_id = $game_summons.summon(id)
  480.     return $game_summons[summoned_id]
  481.   end
  482.  
  483.   def add_summon(summon_id)
  484.     $game_summons.summon_actor(summon_id)
  485.     @summons.push(summon_id) unless @summons.include?(summon_id)
  486.   end
  487.  
  488.   def remove_summon(summon_id)
  489.     @summons.delete(summon_id)
  490.   end
  491.  
  492.   def clear_summons
  493.     @summons = []
  494.   end
  495.  
  496. end
  497.  
  498. class Game_Troop < Game_Unit
  499.  
  500.   # create a new enemy on the spot
  501.   def summon_battler(enemy_id)
  502.     return unless $data_enemies[enemy_id]
  503.     new_enemy = Game_Enemy.new(@enemies.size, enemy_id)
  504.     new_enemy.just_summoned = true
  505.     new_enemy.screen_x = rand(Graphics.width / 2) + 100
  506.     new_enemy.screen_y = rand(Graphics.height / 2) + 100
  507.     @enemies.push(new_enemy)
  508.     SceneManager.scene.refresh_enemies
  509.     return new_enemy
  510.   end
  511. end
  512.  
  513. class Game_Interpreter
  514.  
  515.   def add_actor_summon(actor_id)
  516.     $game_party.add_summon(actor_id)
  517.   end
  518.    
  519.   def summon_battler(summon_id)
  520.     $game_party.summon_battler(summon_id)
  521.   end
  522. end
  523.  
  524. #==============================================================================
  525. # ** Menu windows and scenes
  526. #==============================================================================
  527.  
  528. class Window_SummonList < Window_Selectable
  529.   #--------------------------------------------------------------------------
  530.   # * Object Initialization
  531.   #--------------------------------------------------------------------------
  532.   def initialize(x, y, width, height)
  533.     super
  534.     @actor = nil
  535.     @data = []
  536.     refresh
  537.   end
  538.   #--------------------------------------------------------------------------
  539.   # * Set Category
  540.   #--------------------------------------------------------------------------
  541.   def actor=(actor)
  542.     return if @actor == actor
  543.     @actor = actor
  544.     refresh
  545.     self.oy = 0
  546.   end
  547.   #--------------------------------------------------------------------------
  548.   # * Get Digit Count
  549.   #--------------------------------------------------------------------------
  550.   def col_max
  551.     return 2
  552.   end
  553.  
  554.   def item_height
  555.     104
  556.   end
  557.   #--------------------------------------------------------------------------
  558.   # * Get Number of Items
  559.   #--------------------------------------------------------------------------
  560.   def item_max
  561.     @data ? @data.size : 1
  562.   end
  563.   #--------------------------------------------------------------------------
  564.   # * Get Item
  565.   #--------------------------------------------------------------------------
  566.   def item
  567.     @data && index >= 0 ? @data[index] : nil
  568.   end
  569.   #--------------------------------------------------------------------------
  570.   # * Get Activation State of Selection Item
  571.   #--------------------------------------------------------------------------
  572.   def current_item_enabled?
  573.     enable?(@data[index])
  574.   end
  575.  
  576.   def enable?(summon)
  577.     summon && !$game_summons.battle_members.include?(summon) && summon.mp > 0
  578.   end
  579.  
  580.   def select_last
  581.     select(0)
  582.   end
  583.  
  584.   def make_item_list(constraint=nil)
  585.     @data = $game_party.summons
  586.     if constraint
  587.       valid_summons = Tsuki::Battle_Summon::Summon_Constraints[constraint] || []
  588.       @data = @data.select {|s| valid_summons.include?(s.summon_id) }
  589.     end
  590.   end
  591.      
  592.   def draw_item(index)
  593.     summon = @data[index]
  594.     if summon
  595.       rect = item_rect(index)
  596.       rect.width -= 4
  597.       draw_summon_basic(summon, rect.x + 4, rect.y, enable?(summon))
  598.       draw_actor_face(summon, rect.x + rect.width - 96, rect.y)
  599.     end
  600.   end
  601.  
  602.   def draw_summon_name(summon, x, y, enabled, width = 112)
  603.     change_color(normal_color, enabled)
  604.     draw_text(x, y, width, line_height, summon.name)
  605.   end
  606.  
  607.   def draw_summon_basic(summon, x, y, enabled=true, width=172)
  608.     return unless summon
  609.     text_width = text_size(summon.name).width
  610.     draw_summon_name(summon, x, y + line_height*0, enabled)
  611.     draw_actor_level(summon, x, y + line_height*1)
  612.     draw_actor_hp(summon, x, y + line_height*2)
  613.     draw_actor_mp(summon, x, y + line_height*3)
  614.   end
  615.  
  616.   def update_help
  617.     @help_window.set_item(item)
  618.   end
  619.  
  620.   def refresh(constraint=nil)
  621.     make_item_list(constraint)
  622.     create_contents
  623.     draw_all_items
  624.   end
  625. end
  626.  
  627. class Window_SummonCommand < Window_HorzCommand
  628.  
  629.   def window_width
  630.     Graphics.width
  631.   end
  632.  
  633.   def make_command_list
  634.     add_command("Equip", :equip)
  635.     add_command("Skill", :skill)
  636.     add_command("Status", :status)
  637.   end
  638. end
  639.  
  640. class Scene_Summons  < Scene_MenuBase
  641.  
  642.   def start
  643.     super
  644.     create_summon_command
  645.     create_summon_window
  646.   end
  647.  
  648.   def create_summon_command
  649.     @summon_command = Window_SummonCommand.new(0, 0)
  650.     @summon_command.set_handler(:cancel, method(:return_scene))
  651.     @summon_command.set_handler(:equip, method(:command_personal))
  652.     @summon_command.set_handler(:skill, method(:command_personal))
  653.     @summon_command.set_handler(:status, method(:command_personal))
  654.   end
  655.  
  656.   def create_summon_window
  657.     wy = @summon_command.height
  658.     width = Graphics.width
  659.     height = Graphics.height - wy
  660.     @summon_window = Window_SummonList.new(0, wy, width, height)
  661.   end
  662.  
  663.   def command_personal
  664.     @summon_window.select_last
  665.     @summon_window.activate
  666.     @summon_window.set_handler(:ok,     method(:on_personal_ok))
  667.     @summon_window.set_handler(:cancel, method(:on_personal_cancel))
  668.   end
  669.  
  670.   def on_personal_ok
  671.     $game_summons.menu_actor = @summon_window.item
  672.     case @summon_command.current_symbol
  673.     when :equip
  674.       SceneManager.call(Scene_SummonEquip)
  675.     when :skill
  676.       SceneManager.call(Scene_SummonSkill)
  677.     when :status
  678.       SceneManager.call(Scene_SummonStatus)
  679.     end
  680.   end
  681.  
  682.   def on_personal_cancel
  683.     @summon_window.unselect
  684.     @summon_command.activate
  685.   end
  686. end
  687.  
  688. class Scene_SummonSkill < Scene_Skill
  689.  
  690.   def start
  691.     super
  692.     @actor = $game_summons.menu_actor
  693.     on_actor_change
  694.   end
  695.  
  696.   def next_actor
  697.     @actor = $game_summons.menu_actor_next
  698.     on_actor_change
  699.   end
  700.  
  701.   def prev_actor
  702.     @actor = $game_summons.menu_actor_prev
  703.     on_actor_change
  704.   end
  705. end
  706.  
  707. class Scene_SummonEquip < Scene_Equip
  708.  
  709.   def start
  710.     super
  711.     @actor = $game_summons.menu_actor
  712.     on_actor_change
  713.   end
  714.  
  715.   def next_actor
  716.     @actor = $game_summons.menu_actor_next
  717.     on_actor_change
  718.   end
  719.  
  720.   def prev_actor
  721.     @actor = $game_summons.menu_actor_prev
  722.     on_actor_change
  723.   end
  724. end
  725.  
  726. class Scene_SummonStatus < Scene_Status
  727.  
  728.   def start
  729.     super
  730.     @actor = $game_summons.menu_actor
  731.     on_actor_change
  732.   end
  733.  
  734.   def next_actor
  735.     @actor = $game_summons.menu_actor_next
  736.     on_actor_change
  737.   end
  738.  
  739.   def prev_actor
  740.     @actor = $game_summons.menu_actor_prev
  741.     on_actor_change
  742.   end
  743. end
  744.  
  745. #==============================================================================
  746. # ** Battle windows and scenes
  747. #==============================================================================
  748.  
  749. class Window_BattleSummon < Window_SummonList
  750.  
  751.   def initialize(help_window, info_viewport)
  752.     y = 0
  753.     super(0, y, Graphics.width, info_viewport.rect.y - y)
  754.     self.visible = false
  755.     @help_window = help_window
  756.     @info_viewport = info_viewport
  757.     select(0)
  758.   end
  759.  
  760.   def enable?(summon)
  761.     summon && $game_summons.can_summon?(summon.summon_id) && summon.mp > 0
  762.   end
  763. end
  764.  
  765. class Window_BattleStatus < Window_Selectable
  766.  
  767.   def content_height
  768.     $game_party.battle_members.size * line_height - standard_padding * 2
  769.   end
  770.  
  771.   alias tsuki_battle_summon_status_refresh refresh
  772.   def refresh
  773.     create_contents
  774.     tsuki_battle_summon_status_refresh
  775.   end
  776. end
  777.  
  778. class Scene_Battle < Scene_Base
  779.  
  780.   def refresh_enemies
  781.     @spriteset.refresh_enemies
  782.   end
  783.  
  784.   alias :battle_summon_create_battle_windows :create_all_windows
  785.   def create_all_windows
  786.     battle_summon_create_battle_windows
  787.     create_summon_window
  788.   end
  789.  
  790.   def create_summon_window
  791.     @summon_window = Window_BattleSummon.new(@help_window, @info_viewport)
  792.     @summon_window.set_handler(:ok,     method(:on_summon_ok))
  793.     @summon_window.set_handler(:cancel, method(:on_summon_cancel))
  794.   end
  795.  
  796.   alias :th_battle_summon_on_skill_ok :on_skill_ok
  797.   def on_skill_ok
  798.     @skill = @skill_window.item
  799.     if Tsuki::Battle_Summon.summon_effect?(@skill)
  800.       BattleManager.actor.input.set_skill(@skill.id)
  801.       BattleManager.actor.last_skill.object = @skill
  802.       @skill_window.hide
  803.       if @skill.summon_id > 0
  804.         BattleManager.actor.input.summon_id = @skill.summon_id
  805.         next_command
  806.       else
  807.         activate_summon_window([:skill, @skill.id])
  808.       end
  809.     else
  810.       th_battle_summon_on_skill_ok
  811.     end
  812.   end
  813.  
  814.   alias :th_battle_summon_on_item_ok :on_item_ok
  815.   def on_item_ok
  816.     @item = @item_window.item
  817.     if Tsuki::Battle_Summon.summon_effect?(@item)
  818.       BattleManager.actor.input.set_item(@item.id)
  819.       $game_party.last_item.object = @item
  820.       @item_window.hide
  821.       if @item.summon_id > 0
  822.         BattleManager.actor.input.summon_id = @skill.summon_id
  823.         next_command
  824.       else
  825.         activate_summon_window([:item, @item.id])
  826.       end
  827.     else
  828.       th_battle_summon_on_item_ok
  829.     end
  830.   end
  831.  
  832.   def command_summon
  833.     activate_summon_window
  834.   end
  835.  
  836.   def on_summon_ok
  837.     BattleManager.actor.input.summon_id = @summon_window.item.summon_id
  838.     @summon_window.hide
  839.     next_command
  840.   end
  841.  
  842.   def on_summon_cancel
  843.     @summon_window.hide
  844.     @skill_window.show.activate if @skill
  845.     @item_window.show.activate if @item
  846.   end
  847.  
  848.   def activate_summon_window(constraint=nil)
  849.     @summon_window.refresh(constraint)
  850.     @summon_window.show.activate
  851.   end
  852. end
  853.  
  854. class Window_BattleLog < Window_Selectable
  855.    
  856.   alias :th_battle_summon_display_damage :display_damage
  857.   def display_damage(target, item)
  858.     th_battle_summon_display_damage(target, item)
  859.     display_summon_results(target, item)
  860.   end
  861.  
  862.   def display_summon_results(target, item)
  863.     return unless target.result.called_summon && Tsuki::Battle_Summon.summon_effect?(item)
  864.     add_text(target.result.called_summon_text)
  865.     wait
  866.   end
  867. end
  868.  
  869. #==============================================================================
  870. # ** Update menu scene to add option
  871. #==============================================================================
  872.  
  873. class Window_MenuCommand < Window_Command
  874.   #--------------------------------------------------------------------------
  875.   # * Add arena command to List
  876.   #--------------------------------------------------------------------------
  877.   alias tsuki_summons_commands add_main_commands
  878.   def add_main_commands
  879.     tsuki_summons_commands
  880.     add_command("Summons", :summons)
  881.   end
  882. end
  883.  
  884. class Scene_Menu < Scene_MenuBase
  885.   #--------------------------------------------------------------------------
  886.   # * Add arena handler
  887.   #--------------------------------------------------------------------------
  888.   alias tsuki_summons_command_window create_command_window
  889.   def create_command_window
  890.     tsuki_summons_command_window
  891.     @command_window.set_handler(:summons, method(:command_summons))
  892.   end
  893.  
  894.   def command_summons
  895.     SceneManager.call(Scene_Summons)
  896.   end
  897. end
  898.  
  899. #==============================================================================
  900. # ** Compatibility mods
  901. #==============================================================================
  902. if $imported["FP_InventoryPlus"]
  903.  
  904.   class Scene_Battle < Scene_Base
  905.    
  906.     # directly use item from inventory
  907.     def on_item_ok      
  908.       @item = @item_window.item
  909.       if Tsuki::Battle_Summon.summon_effect?(@item)
  910.         BattleManager.actor.input.set_item(@item)
  911.         $game_party.last_item.object = @item
  912.         @item_window.hide
  913.         if @item.summon_id > 0
  914.           BattleManager.actor.input.summon_id = @item.summon_id
  915.           next_command
  916.         else
  917.           activate_summon_window([:item, @item.id])
  918.         end
  919.       else
  920.         th_battle_summon_on_item_ok
  921.       end
  922.     end
  923.   end
  924. end
  925.  
  926. if $imported["Tsuki_CommandSetup"]
  927.  
  928.   class Scene_Battle < Scene_Base
  929.     alias :th_battle_summon_command_use_skill :command_use_skill
  930.     def command_use_skill
  931.       @skill = $data_skills[@actor_command_window.current_data[:ext]]
  932.       if Tsuki::Battle_Summon.summon_effect?(@skill)
  933.         BattleManager.actor.input.set_skill(@skill.id)
  934.         BattleManager.actor.last_skill.object = @skill
  935.         @skill_window.hide
  936.         if @skill.summon_id > 0
  937.           BattleManager.actor.input.summon_id = @skill.summon_id
  938.           next_command
  939.         else
  940.           activate_summon_window([:skill, @skill.id])
  941.         end
  942.       else
  943.         th_battle_summon_command_use_skill
  944.       end
  945.     end      
  946.    
  947.     def on_summon_cancel
  948.       @enemy_draw_window.hide
  949.       if @skill == $data_skills[@actor_command_window.current_data[:ext]]
  950.         @actor_command_window.activate
  951.       else
  952.         @summon_window.hide
  953.         @skill_window.show.activate
  954.       end
  955.     end
  956.   end
  957. end
  958. #==============================================================================
  959. # ** Add-ons
  960. #==============================================================================
  961. if Tsuki::Battle_Summon::Monster_Hunter_Addon
  962.   if $imported["Tsuki_MonsterHunter"]
  963.     module Monster_Hunter
  964.       def self.create_game_actor(actor_id)
  965.         return if $BTEST
  966.         $game_summons.summon_actor(actor_id)
  967.       end
  968.     end
  969.   else
  970.     msgbox("Monster Hunter must placed above this script")
  971.   end
  972. end
Add Comment
Please, Sign In to add comment