Battle Arena

Battle Arena Version: 1.0
By: ForeverZer0

Introduction

Pretty simple idea, will allow you to easily create a Battle Arena system (very much like the one in Final Fantasy VI). The player can wager items, weapons, and armors and then fight in the arena against different enemies and receive awards if they win. It's a 'winner-take-all' system, where the winner gets to keep their original bet, and the enemy's bet if they are victorious. If they lose they lose their original bet.

Features
  • Can easily configure to most battle systems
  • Fully configurable results for every item, weapon, and armor
  • Allows for 'one-time' rewards for specific bets
  • Simple to setup, and uses only two script calls in game to use
  • Logs wins/losses in game variables for easy access to stats

Screenshots

Register Show
Image

Fight Show
Image

Reward Show
Image


Demo

Demo Link

Script

  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # Battle Arena  
  3. # Author: ForeverZer0
  4. # Date: 4.28.2010
  5. # Version: 1.0
  6. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  7. #
  8. # Explanation:
  9. #
  10. #   Relatively simple idea. Let's the player bet an item, weapon, or armor and
  11. #   then fight against an enemy to receive a different item in return. Very
  12. #   much like the system used in Final Fantasy VI for the SNES. If they win,
  13. #   they get to keep their own item and get the enemy's item, if they lose, they
  14. #   will lose the item they bet.
  15. #
  16. # Feature:
  17. #
  18. #   - Can easily configure to most battle systems
  19. #   - Fully configurable results for any item, weapon, or armor
  20. #   - Allows for 'one-time' rewards for specific bets
  21. #   - Simple to install. After configuration, uses only two script
  22. #     calls in game
  23. #   - All wins/losses are logged in variables for easy access
  24. #
  25. # Instructions:
  26. #
  27. #   - Place script below default scripts and above main
  28. #   - Instructions for each configuration are below
  29. #   - Use these script calls:
  30. #
  31. #  --> $scene = Scene_BattleArena.new  
  32. #
  33. #      - calls the 'registration' scene
  34. #
  35. #  --> $game_temp.arena_battle_call(MAP_ID, X, Y)    
  36. #
  37. #      - after registering, use this where the actual battle will occur
  38. #      - the values in ( ) will be where the player is transfered to after
  39. #        battle. If you do not want them to move, just don't include the ( )
  40. #                                          
  41. #  --> $game_temp.arena_battle = false
  42. #
  43. #      - place this at every exit to your 'arena', otherwise it will cause
  44. #        errors if the player leaves after registering, but before fighting
  45. #
  46. # Author's Notes:
  47. #
  48. #   - Make sure the player cannot save in between registering and fighting.
  49. #     Anytime before or after is fine, but if they register then save and quit,
  50. #     once the game is loaded the 'registraion' will have been lost.
  51. #   - This system only uses one aliased method of the actual battle system. It
  52. #     is basically just a redirect to the Arena Result screen if the flag was
  53. #     present, so you can easily use any battle system you wish.
  54. #   - The only problem you may have is if your battle system is not triggered
  55. #     by the "$game_temp.battle_calling" flag, which most non-ABSs use.
  56. #   - If your game freezes with the "$game_temp.arena_battle = false" script
  57. #     call, it is not a problem with this script. You need to fix your
  58. #     Interpreter command_355. Just look around where you found this script for
  59. #     a fix for it, which you will likely want even if you don't use this system.
  60. #
  61. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  62.  
  63. module Zer0_CFG
  64. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  65. #                         BEGIN CONFIGURATION
  66. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  67.  
  68.   WIN_VARIABLE = 1
  69.   LOSS_VARIABLE = 2
  70.   
  71.   # These are the IDs of the variables that the will keep track of your wins
  72.   # and losses.
  73.  
  74.   NO_BET_ITEMS = []
  75.   NO_BET_WEAPONS = []
  76.   NO_BET_ARMORS = []
  77.   
  78.   # Include IDs of any items/weapon/armors that the player cannot bet.
  79.   # Any item that is "NO_BET" will not even show up as a choice in the window.
  80.   
  81.   ONLY_ONCE_ITEMS = []
  82.   ONLY_ONCE_WEAPONS = []
  83.   ONLY_ONCE_ARMORS = []
  84.   
  85.   # Include IDs of items/weapons/armors that the player will receive the reward
  86.   # for only once. After that, if they re-bet the same item again it will only
  87.   # return the DEFAULT_REWARD as the prize.
  88.   
  89. #-------------------------------------------------------------------------------
  90. #                         BEGIN BATTLE ARENA DATABASE
  91. #-------------------------------------------------------------------------------
  92. #
  93. #   There are 3 sections that will need configured; one each for Items, Weapons,
  94. #   and Armors. Set each section up like this:
  95. #
  96. #         when ID then return [TROOP, REWARD_TYPE, REWARD_ID]
  97. #
  98. #   ID       - The database ID of the Item, Weapon, or Armor that is being bet.
  99. #   TROOP    - The database ID of the troop that will be fought.
  100. #
  101. #   REWARD_TYPE - The 'type' of the reward that will be given if victorious  
  102. #                 0 = Item
  103. #                 1 = Weapon
  104. #                 2 = Armor
  105. #   REWARD_ID   - The ID in the database of the item (depending on type) that
  106. #                 will be received.
  107. #
  108. #   Here's an example:
  109. #
  110. #     when 5 then return [4, 2, 34]  (let's pretend it is in the Item Database)
  111. #
  112. #     This would mean that if the player chose to wager Item with ID(5), they
  113. #     would have to fight Troop with ID(4), and if they won would receive
  114. #     Armor with ID(34). It is an armor because the TYPE is 2.
  115. #
  116. #-------------------------------------------------------------------------------
  117.   
  118.   DEFAULT_REWARD = [1, 0, 1]
  119.   # This will be the configuration for any item/weapon/armor not defined.
  120.  
  121.   def self.wagers(item)
  122.     if item.is_a?(RPG::Item)
  123.       return DEFAULT_REWARD if $game_system.arena_one_time[0].include?(item.id)
  124.       case item.id
  125. #-------------------------------------------------------------------------------
  126. # * Begin Item Wager Database
  127. #-------------------------------------------------------------------------------
  128.     
  129.       when 1 then return [1, 0, 2]
  130.       when 2 then return [3, 0, 3]
  131.       when 3 then return [5, 0, 4]
  132.       when 4 then return [8, 1, 1]
  133.       when 5 then return [9, 2, 1]
  134.         
  135. #-------------------------------------------------------------------------------
  136. # * End Item Wager Database
  137. #-------------------------------------------------------------------------------
  138.       end
  139.     elsif item.is_a?(RPG::Weapon)
  140.       return DEFAULT_REWARD if $game_system.arena_one_time[1].include?(item.id)
  141.       case item.id
  142. #-------------------------------------------------------------------------------
  143. # * Begin Weapon Wager Database
  144. #-------------------------------------------------------------------------------
  145.  
  146.       when 1 then return [1, 2, 1]
  147.       when 2 then return [12, 1, 3]
  148.       when 3 then return [20, 1, 5]
  149.       when 4 then return [15, 2, 4]
  150.       when 5 then return [25, 0, 10]
  151.         
  152. #-------------------------------------------------------------------------------
  153. # * End Weapon Wager Database
  154. #-------------------------------------------------------------------------------
  155.       end
  156.     elsif item.is_a?(RPG::Armor)
  157.       return DEFAULT_REWARD if $game_system.arena_one_time[2].include?(item.id)
  158.       case item.id
  159. #-------------------------------------------------------------------------------
  160. # * Begin Armor Wager Database
  161. #-------------------------------------------------------------------------------
  162.       
  163.       when 1 then return [1, 1, 1]
  164.       when 2 then return [5, 2, 3]
  165.       when 3 then return [13, 2, 5]
  166.       when 4 then return [10, 1, 5]
  167.       when 5 then return [21, 2, 10]
  168.         
  169. #-------------------------------------------------------------------------------
  170. # * End Armor Wager Database
  171. #-------------------------------------------------------------------------------
  172.  
  173. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  174. #                           END CONFIGURATION
  175. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  176.       end
  177.     end
  178.     return DEFAULT_REWARD
  179.   end
  180. end
  181.  
  182. #-------------------------------------------------------------------------------
  183. # ** Game_System
  184. #-------------------------------------------------------------------------------
  185.  
  186. class Game_System
  187.   
  188.   attr_accessor :arena_one_time   # Retains data on all the ONCE_ONLY bets
  189.   
  190.   alias zer0_arena_once_only_init initialize
  191.   def initialize
  192.     zer0_arena_once_only_init
  193.     @arena_one_time = [[],[],[]]
  194.   end
  195. end
  196.  
  197. #-------------------------------------------------------------------------------
  198. # ** Game_Temp
  199. #-------------------------------------------------------------------------------
  200.  
  201. class Game_Temp
  202.   
  203.   attr_accessor :arena_data      # Holds info for bet, reward, battler, etc
  204.   attr_accessor :arena_battle    # Arena Battle flag
  205.   attr_accessor :party_memory    # Memorizes party pre-battle to return after
  206.   
  207.   alias zer0_battle_arena_temp_init initialize
  208.   def initialize
  209.     zer0_battle_arena_temp_init
  210.     @arena_data = []
  211.     @party_memory = []
  212.     @arena_battle = false
  213.   end
  214.   
  215.   def arena_battle_call(map_id=$game_map.map_id, x=$game_player.x , y=$game_player.y)
  216.     @party_memory.clear
  217.     $game_party.actors.each {|actor| @party_memory.push(actor.id)}
  218.     $game_party.actors.clear
  219.     $game_party.add_actor(@arena_data[2])
  220.     @battle_calling = true
  221.     @battle_can_escape = false
  222.     @battle_can_lose = true
  223.     @battle_proc = nil
  224.     @player_new_map_id = map_id
  225.     @player_new_x = x
  226.     @player_new_y = y
  227.     @player_new_direction = 2
  228.     Graphics.freeze
  229.     @player_transferring = true
  230.   end
  231. end
  232.  
  233. #-------------------------------------------------------------------------------
  234. # ** Scene_BattleArena
  235. #-------------------------------------------------------------------------------
  236.  
  237. class Scene_BattleArena
  238.  
  239.   def main
  240.     @help_window = Window_Help.new
  241.     @item_window = Window_ItemBet.new
  242.     @item_window.help_window = @help_window
  243.     @status_window = Window_ArenaStatus.new
  244.     @header1 = Window_Base.new(320, 64, 320, 64)
  245.     @header1.contents = Bitmap.new(288, 32)
  246.     @header1.contents.draw_text(0, 0, 288, 32, 'Which item will you wager?', 1)
  247.     @header2 = Window_Base.new(176, 128, 288, 64)
  248.     @header2.contents = Bitmap.new(256, 32)
  249.     @header2.contents.draw_text(0, 0, 256, 32, 'Who will battle?', 1)
  250.     @header2.z = 5000
  251.     @actor_window = Window_BattlerSelect.new
  252.     @actor_window.active = @actor_window.visible = @header2.visible = false
  253.     Graphics.transition
  254.     loop {Graphics.update; Input.update; update; break if $scene != self}
  255.     [@help_window, @item_window, @status_window, @header1, @header2,
  256.      @actor_window].each {|window| window.dispose}
  257.   end
  258.   
  259.   def update
  260.     [@help_window, @status_window, @item_window,
  261.       @actor_window].each {|window| window.update}
  262.     if @item_window.active
  263.        @status_window.data = @item_window.item
  264.       if Input.trigger?(Input::B)
  265.         $game_system.se_play($data_system.cancel_se)
  266.         $scene = Scene_Map.new
  267.       elsif Input.trigger?(Input::C)
  268.         $game_system.se_play($data_system.decision_se)
  269.         @data = Zer0_CFG.wagers(@item_window.item)
  270.         @actor_window.active = @actor_window.visible = @header2.visible = true
  271.         @item_window.active = false
  272.         return
  273.       end
  274.     elsif @actor_window.active
  275.       if Input.trigger?(Input::B)
  276.         $game_system.se_play($data_system.cancel_se)
  277.         @actor_window.active = @actor_window.visible = @header2.visible = false
  278.         @item_window.active = true
  279.         return
  280.       elsif Input.trigger?(Input::C)
  281.         if $game_party.actors[@actor_window.index].dead?
  282.           $game_system.se_play($data_system.buzzer_se)
  283.           return
  284.         end
  285.         $game_system.se_play($data_system.decision_se)
  286.         if $data_troops[@data[0]] != nil
  287.           $game_temp.battle_troop_id = @data[0]
  288.           $game_temp.arena_data[2] = $game_party.actors[@actor_window.index].id
  289.           $game_temp.arena_data[0] = @item_window.item
  290.           $game_temp.arena_data[1] = case @data[1]
  291.           when 0 then $data_items[@data[2]]
  292.           when 1 then $data_weapons[@data[2]]
  293.           when 2 then $data_armors[@data[2]]
  294.           end
  295.           $game_temp.arena_battle = true
  296.           $scene = Scene_Map.new
  297.         end  
  298.       end
  299.     end
  300.   end
  301. end
  302.  
  303. #-------------------------------------------------------------------------------
  304. # ** Scene_ArenaResult
  305. #-------------------------------------------------------------------------------
  306.  
  307. class Scene_ArenaResult
  308.   
  309.   def initialize(battle_result)
  310.     @result = battle_result
  311.   end
  312.   
  313.   def main
  314.     @map = Spriteset_Map.new
  315.     $game_party.actors[0].hp = 1 if @result != 0
  316.     $game_party.actors.clear
  317.     $game_temp.party_memory.each_index {|i|
  318.       $game_party.add_actor($game_temp.party_memory[i])}
  319.     @message_window = Window_Message.new
  320.     Graphics.transition
  321.     bet_item = $game_temp.arena_data[0]
  322.     case bet_item
  323.     when RPG::Item
  324.       if Zer0_CFG::ONLY_ONCE_ITEMS.include?(bet_item.id)
  325.         unless $game_system.arena_one_time[0].include?(bet_item.id)
  326.           $game_system.arena_one_time[0].push(bet_item.id)
  327.         end
  328.       end
  329.     when RPG::Weapon
  330.       if Zer0_CFG::ONLY_ONCE_WEAPONS.include?(bet_item.id)
  331.         unless $game_system.arena_one_time[1].include?(bet_item.id)
  332.           $game_system.arena_one_time[1].push(bet_item.id)
  333.         end
  334.       end
  335.     when RPG::Armor
  336.       if Zer0_CFG::ONLY_ONCE_ARMORS.include?(bet_item.id)
  337.         unless $game_system.arena_one_time[2].include?(bet_item.id)
  338.         $game_system.arena_one_time[2].push(bet_item.id)
  339.         end
  340.       end
  341.     end
  342.     if @result == 0
  343.       Audio.se_play('Audio/SE/060-Cheer01', 80, 100)
  344.       $game_variables[Zer0_CFG::WIN_VARIABLE] += 1
  345.       reward = $game_temp.arena_data[1].name
  346.       id = $game_temp.arena_data[1].id
  347.       case $game_temp.arena_data[1]
  348.       when RPG::Item then $game_party.gain_item(id, 1)
  349.       when RPG::Weapon then $game_party.gain_weapon(id, 1)
  350.       when RPG::Armor then $game_party.gain_armor(id, 1)
  351.       end
  352.       text = "Congratulations!\n" + 'You have won a ' + reward + '!'
  353.     else      
  354.       $game_variables[Zer0_CFG::LOSS_VARIABLE] += 1
  355.       id = $game_temp.arena_data[0].id
  356.       case $game_temp.arena_data[0]
  357.       when RPG::Item then $game_party.lose_item(id, 1)
  358.       when RPG::Weapon then $game_party.lose_weapon(id, 1)
  359.       when RPG::Armor then $game_party.lose_armor(id, 1)
  360.       end
  361.       text = 'Lost...'
  362.     end
  363.     $game_temp.message_text = text
  364.     loop {Graphics.update; Input.update; update; break if $scene != self}
  365.     $game_temp.arena_battle = false
  366.     $game_temp.arena_data.clear
  367.     $scene = Scene_Map.new
  368.     [@map, @message_window].each {|sprite| sprite.dispose}
  369.   end
  370.   
  371.   def update
  372.     [@map, @message_window].each {|sprite| sprite.update}
  373.     if Input.trigger?(Input::C)
  374.       $scene = Scene_Map.new
  375.     end
  376.   end
  377. end
  378.  
  379. #-------------------------------------------------------------------------------
  380. # ** Scene_Battle
  381. #-------------------------------------------------------------------------------
  382.  
  383. class Scene_Battle
  384.   
  385.   alias zer0_battle_arena_result battle_end
  386.   def battle_end(result)
  387.     # This will just redirect the scene to the Arena Result screen instead
  388.     # of Scene_Map if the arena flag is present
  389.     zer0_battle_arena_result(result)
  390.     if $game_temp.arena_battle
  391.       $scene = Scene_ArenaResult.new(result)
  392.     end
  393.   end
  394. end
  395.  
  396. #-------------------------------------------------------------------------------
  397. # ** Window_ArenaStatus
  398. #-------------------------------------------------------------------------------
  399.  
  400. class Window_ArenaStatus < Window_Base
  401.   
  402.   def initialize
  403.     super(320, 128, 320, 352)
  404.     self.contents = Bitmap.new(width - 32, height - 32)
  405.     @data = nil
  406.     refresh
  407.   end
  408.   
  409.   def refresh
  410.     self.contents.clear
  411.     return if @data == nil
  412.     @data = Zer0_CFG.wagers(@data)
  413.     self.contents.font.color = system_color
  414.     self.contents.draw_text(4, 0, 288, 32, 'Enemies:')
  415.     self.contents.draw_text(4, 256, 288, 32, 'Reward:')
  416.     self.contents.font.color = normal_color
  417.     member = $data_troops[@data[0]].members
  418.     names = []
  419.     member.each_index {|i| names[i] = $data_enemies[member[i].enemy_id].name
  420.       y = (i * 32) + 32
  421.       self.contents.draw_text(4, y, 288, 32, names[i]) if y < 256}  
  422.     case @data[1]
  423.     when 0
  424.       reward = $data_items[@data[2]].name
  425.       icon = $data_items[@data[2]].icon_name
  426.     when 1
  427.       reward = $data_weapons[@data[2]].name
  428.       icon = $data_weapons[@data[2]].icon_name
  429.     when 2
  430.       reward = $data_armors[@data[2]].name
  431.       icon = $data_armors[@data[2]].icon_name
  432.     end
  433.     self.contents.draw_text(32, 288, 288, 32, reward)
  434.     rect = Rect.new(x, y, self.width - 32, 32)
  435.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  436.     self.contents.blt(4, 292, RPG::Cache.icon(icon), Rect.new(0, 0, 24, 24))
  437.   end
  438.   
  439.   def data=(data)
  440.     if @data != data
  441.       @data = data
  442.       refresh
  443.     end
  444.   end
  445. end
  446.  
  447. #-------------------------------------------------------------------------------
  448. # ** Window_ItemBet
  449. #-------------------------------------------------------------------------------
  450.  
  451. class Window_ItemBet < Window_Selectable
  452.  
  453.   def initialize
  454.     super(0, 64, 320, 416)
  455.     @column_max, self.index = 1, 0
  456.     refresh
  457.   end
  458.  
  459.   def item
  460.     return @data[self.index]
  461.   end
  462.  
  463.   def refresh
  464.     if self.contents != nil
  465.       self.contents.dispose
  466.       self.contents = nil
  467.     end
  468.     @data = []
  469.     (1...$data_items.size).each {|i|
  470.       if $game_party.item_number(i) > 0
  471.         unless Zer0_CFG::NO_BET_ITEMS.include?(i)
  472.           @data.push($data_items[i])
  473.         end
  474.       end
  475.     }
  476.     (1...$data_weapons.size).each {|i|
  477.       if $game_party.weapon_number(i) > 0
  478.         unless Zer0_CFG::NO_BET_WEAPONS.include?(i)
  479.           @data.push($data_weapons[i])
  480.         end
  481.       end
  482.     }
  483.     (1...$data_armors.size).each {|i|
  484.       if $game_party.armor_number(i) > 0
  485.         unless Zer0_CFG::NO_BET_ARMORS.include?(i)
  486.           @data.push($data_armors[i])
  487.         end
  488.       end
  489.     }
  490.     @item_max = @data.size
  491.     if @item_max > 0
  492.       self.contents = Bitmap.new(width - 32, row_max * 32)
  493.       (0...@item_max).each {|i| draw_item(i)}
  494.     end
  495.   end
  496.  
  497.   def draw_item(index)
  498.     item = @data[index]
  499.     number = case item
  500.     when RPG::Item then $game_party.item_number(item.id)
  501.     when RPG::Weapon then $game_party.weapon_number(item.id)
  502.     when RPG::Armor then $game_party.armor_number(item.id)
  503.     end
  504.     x = 4
  505.     y = index * 32
  506.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  507.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  508.     bitmap = RPG::Cache.icon(item.icon_name)
  509.     opacity = self.contents.font.color == normal_color ? 255 : 128
  510.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  511.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  512.     self.contents.draw_text(x + 240, y, 16, 32, ':', 1)
  513.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  514.   end
  515.  
  516.   def update_help
  517.     @help_window.set_text(self.item == nil ? '' : self.item.description)
  518.   end
  519. end
  520.  
  521. #-------------------------------------------------------------------------------
  522. # ** Window_BattlerSelect
  523. #-------------------------------------------------------------------------------
  524.  
  525. class Window_BattlerSelect < Window_Selectable
  526.   
  527.   def initialize
  528.     w = ($game_party.actors.size * 64) + 32
  529.     x = (640 - w) / 2
  530.     super(x, 192, w, 96)
  531.     self.contents = Bitmap.new(width - 32, height - 32)
  532.     @row_max, self.index, self.z = 1, 0, 5000
  533.     @item_max = @column_max = $game_party.actors.size
  534.     refresh
  535.   end
  536.   
  537.   def refresh
  538.     $game_party.actors.each_index {|i|
  539.     x = 32 + i * 64
  540.     self.draw_actor_graphic($game_party.actors[i], x, 64)}
  541.   end
  542.   
  543.   def update_cursor_rect
  544.     cursor_width = 48
  545.     x = @index * 64 + 8
  546.     y = @index / @column_max * 32 - self.oy
  547.     self.cursor_rect.set(x, y, cursor_width, 64)
  548.   end
  549. end
Expand to see the code.


Instructions

Within the script.

Compatibility

No known compatibility issues.

Author's Notes

Download the demo first if you have any questions, they may be answered in there. I have included examples and a little more in-depth explanations than can be found in just the script.

Please report any bugs/issues so that they can be resolved. Enjoy!

Terms and Conditions

Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
Content Hidden Show
You are free:

to Share - to copy, distribute and transmit the work
to Remix - to adapt the work

Under the following conditions:

Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work).

Noncommercial. You may not use this work for commercial purposes.

Share alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one.

- For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.

- Any of the above conditions can be waived if you get permission from the copyright holder.

- Nothing in this license impairs or restricts the author's moral rights.
Sorry to bump a 4 month old post but I want to give this some love...

I think my project is a little notorious for having an unbelievable lack of scripts. And even the scripts that it does feature are extremely simple. Now that I'm (finally) finishing the project up, I'm going to be combing this forum for any scripts that make sense within my game (and are easy enough for non-scripters like me to figure out how to use).

Anyway;

I was going to do a Final Fantasy VI coliseum style arena in events. I think it would have worked, but this script is perfect. I think it'll make my game a little more unique/customized and it probably saved me a couple dozen hours of eventing.

Thanks.

Will give credit.

:box:




edit: Is there an easy way to remove "Items" from the list of items you can wager (and only leave "armor" and "weapons")? It's just not really practical for my game to have hundreds and hundreds of items to scroll through. (I have a lot of items.) Thanks.
Glad you like.

To omit weapons and armors, in the "refresh" method of the class "Window_ItemBet", you can simply remove the following lines:

  1.    (1...$data_weapons.size).each {|i|
  2.       if $game_party.weapon_number(i) > 0
  3.         unless Zer0_CFG::NO_BET_WEAPONS.include?(i)
  4.           @data.push($data_weapons[i])
  5.         end
  6.       end
  7.     }
  8.     (1...$data_armors.size).each {|i|
  9.       if $game_party.armor_number(i) > 0
  10.         unless Zer0_CFG::NO_BET_ARMORS.include?(i)
  11.           @data.push($data_armors[i])
  12.         end
  13.       end
  14.     }
Expand to see the code.
Okay, I'm getting a weird bug that I tried to figure out on my own, but failed.

Someone in my project thread posted this:

deividdo wrote:
The coliseum looks nifty, but when I went to try it out the a script crashed. This is the last thing I see right before the crash:



Content Hidden Show
Image


This is the error being produced:

Image




That error is references this line:

  1.        elsif item.is_a?(RPG::Weapon)
  2.           return DEFAULT_REWARD if $game_system.arena_one_time[1].include?(item.id)
  3.           case item.id
Expand to see the code.


Trial & Error:

-When I was testing it, I just created a Start Position next to the event, added about 50 weapons, and it works fine.
-I checked multiple times from a brand new Start Position and multiple "add weapons" and it works fine.

-I then went into the game with a normal save, through normal gameplay, and went to the arena and I got the same error.
-I sold off the majority of weapons I had in my inventory and still got the same error.
-I sold off every single item, armor, and all weapons except for 1 and I got the same error.
-I finally sold off my entire inventory and the battle arena window popped up blank (as it should because I had no weapons). I didn't get an error.
-After that, I sold off everything again, and bought a random weapon from a blacksmith. I then went back to the arena and got the same error.

So confused.

If I were just looking at the error alone, I would figure that the default just isn't set correctly. But like I posted above, I can try to enter the arena with the exact same weapon, but one time it crashes and the other time it doesn't, and the only difference is that one is a brand new start position vs. a normal game save. (I'm sure there's more than that, but that's all that I can figure.)

Here's the full script that I'm working with right now:

  1.    #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2.     # Battle Arena  
  3.     # Author: ForeverZer0
  4.     # Date: 4.28.2010
  5.     # Version: 1.0
  6.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  7.     #
  8.     # Explanation:
  9.     #
  10.     #   Relatively simple idea. Let's the player bet an item, weapon, or armor and
  11.     #   then fight against an enemy to receive a different item in return. Very
  12.     #   much like the system used in Final Fantasy VI for the SNES. If they win,
  13.     #   they get to keep their own item and get the enemy's item, if they lose, they
  14.     #   will lose the item they bet.
  15.     #
  16.     # Feature:
  17.     #
  18.     #   - Can easily configure to most battle systems
  19.     #   - Fully configurable results for any item, weapon, or armor
  20.     #   - Allows for 'one-time' rewards for specific bets
  21.     #   - Simple to install. After configuration, uses only two script
  22.     #     calls in game
  23.     #   - All wins/losses are logged in variables for easy access
  24.     #
  25.     # Instructions:
  26.     #
  27.     #   - Place script below default scripts and above main
  28.     #   - Instructions for each configuration are below
  29.     #   - Use these script calls:
  30.     #
  31.     #  --> $scene = Scene_BattleArena.new  
  32.     #
  33.     #      - calls the 'registration' scene
  34.     #
  35.     #  --> $game_temp.arena_battle_call(MAP_ID, X, Y)    
  36.     #
  37.     #      - after registering, use this where the actual battle will occur
  38.     #      - the values in ( ) will be where the player is transfered to after
  39.     #        battle. If you do not want them to move, just don't include the ( )
  40.     #                                          
  41.     #  --> $game_temp.arena_battle = false
  42.     #
  43.     #      - place this at every exit to your 'arena', otherwise it will cause
  44.     #        errors if the player leaves after registering, but before fighting
  45.     #
  46.     # Author's Notes:
  47.     #
  48.     #   - Make sure the player cannot save in between registering and fighting.
  49.     #     Anytime before or after is fine, but if they register then save and quit,
  50.     #     once the game is loaded the 'registraion' will have been lost.
  51.     #   - This system only uses one aliased method of the actual battle system. It
  52.     #     is basically just a redirect to the Arena Result screen if the flag was
  53.     #     present, so you can easily use any battle system you wish.
  54.     #   - The only problem you may have is if your battle system is not triggered
  55.     #     by the "$game_temp.battle_calling" flag, which most non-ABSs use.
  56.     #   - If your game freezes with the "$game_temp.arena_battle = false" script
  57.     #     call, it is not a problem with this script. You need to fix your
  58.     #     Interpreter command_355. Just look around where you found this script for
  59.     #     a fix for it, which you will likely want even if you don't use this system.
  60.     #
  61.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  62.      
  63.     module Zer0_CFG
  64.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  65.     #                         BEGIN CONFIGURATION
  66.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  67.      
  68.       WIN_VARIABLE = 1
  69.       LOSS_VARIABLE = 2
  70.      
  71.       # These are the IDs of the variables that the will keep track of your wins
  72.       # and losses.
  73.      
  74.       NO_BET_ITEMS = []
  75.       NO_BET_WEAPONS = []
  76.       NO_BET_ARMORS = []
  77.      
  78.       # Include IDs of any items/weapon/armors that the player cannot bet.
  79.       # Any item that is "NO_BET" will not even show up as a choice in the window.
  80.      
  81.       ONLY_ONCE_ITEMS = []
  82.       ONLY_ONCE_WEAPONS = []
  83.       ONLY_ONCE_ARMORS = []
  84.      
  85.       # Include IDs of items/weapons/armors that the player will receive the reward
  86.       # for only once. After that, if they re-bet the same item again it will only
  87.       # return the DEFAULT_REWARD as the prize.
  88.      
  89.     #-------------------------------------------------------------------------------
  90.     #                         BEGIN BATTLE ARENA DATABASE
  91.     #-------------------------------------------------------------------------------
  92.     #
  93.     #   There are 3 sections that will need configured; one each for Items, Weapons,
  94.     #   and Armors. Set each section up like this:
  95.     #
  96.     #         when ID then return [TROOP, REWARD_TYPE, REWARD_ID]
  97.     #
  98.     #   ID       - The database ID of the Item, Weapon, or Armor that is being bet.
  99.     #   TROOP    - The database ID of the troop that will be fought.
  100.     #
  101.     #   REWARD_TYPE - The 'type' of the reward that will be given if victorious  
  102.     #                 0 = Item
  103.     #                 1 = Weapon
  104.     #                 2 = Armor
  105.     #   REWARD_ID   - The ID in the database of the item (depending on type) that
  106.     #                 will be received.
  107.     #
  108.     #   Here's an example:
  109.     #
  110.     #     when 5 then return [4, 2, 34]  (let's pretend it is in the Item Database)
  111.     #
  112.     #     This would mean that if the player chose to wager Item with ID(5), they
  113.     #     would have to fight Troop with ID(4), and if they won would receive
  114.     #     Armor with ID(34). It is an armor because the TYPE is 2.
  115.     #
  116.     #-------------------------------------------------------------------------------
  117.      
  118.       DEFAULT_REWARD = [5, 0, 952]
  119.       # This will be the configuration for any item/weapon/armor not defined.
  120.      
  121.       def self.wagers(item)
  122.         if item.is_a?(RPG::Item)
  123.           return DEFAULT_REWARD if $game_system.arena_one_time[0].include?(item.id)
  124.           case item.id
  125.     #-------------------------------------------------------------------------------
  126.     # * Begin Item Wager Database
  127.     #-------------------------------------------------------------------------------
  128.        
  129.           when 1 then return [5, 0, 952]
  130.            
  131.     #-------------------------------------------------------------------------------
  132.     # * End Item Wager Database
  133.     #-------------------------------------------------------------------------------
  134.           end
  135.         elsif item.is_a?(RPG::Weapon)
  136.           return DEFAULT_REWARD if $game_system.arena_one_time[1].include?(item.id)
  137.           case item.id
  138.     #-------------------------------------------------------------------------------
  139.     # * Begin Weapon Wager Database
  140.     #-------------------------------------------------------------------------------
  141.      
  142.           when 24 then return [39, 0, 952]
  143.           when 42 then return [7, 0, 953]
  144.           when 60 then return [8, 0, 953]
  145.           when 78 then return [10, 0, 954]
  146.           when 96 then return [30, 0, 955]
  147.           when 114 then return [31, 0, 956]
  148.           when 132 then return [54, 0, 957]
  149.           when 150 then return [74, 0, 958]
  150.           when 168 then return [40, 0, 952]
  151.           when 169 then return [42, 0, 953]
  152.           when 170 then return [51, 0, 954]
  153.           when 171 then return [56, 0, 955]
  154.           when 172 then return [54, 0, 956]
  155.           when 173 then return [127, 0, 957]
  156.           when 174 then return [79, 0, 958]
  157.           when 175 then return [65, 0, 954]
  158.           when 176 then return [59, 0, 954]
  159.           when 177 then return [64, 0, 954]
  160.           when 178 then return [91, 0, 952]
  161.           when 179 then return [46, 0, 952]
  162.           when 180 then return [28, 0, 953]
  163.           when 181 then return [24, 0, 953]
  164.           when 182 then return [20, 0, 954]
  165.           when 183 then return [146, 0, 955]
  166.           when 184 then return [151, 0, 956]
  167.           when 185 then return [161, 0, 957]
  168.           when 186 then return [165, 0, 958]
  169.           when 188 then return [188, 0, 952]
  170.           when 189 then return [172, 0, 952]
  171.           when 190 then return [190, 0, 953]
  172.           when 191 then return [195, 0, 953]
  173.           when 192 then return [180, 0, 954]
  174.           when 193 then return [189, 0, 955]
  175.           when 194 then return [182, 0, 956]
  176.           when 195 then return [197, 0, 957]
  177.           when 196 then return [237, 0, 958]
  178.           when 203 then return [149, 0, 952]
  179.           when 204 then return [150, 0, 952]
  180.           when 205 then return [128, 0, 953]
  181.           when 206 then return [146, 0, 953]
  182.           when 207 then return [135, 0, 954]
  183.           when 208 then return [18, 0, 955]
  184.           when 209 then return [111, 0, 956]
  185.           when 210 then return [112, 0, 957]
  186.           when 211 then return [108, 0, 958]
  187.           when 213 then return [140, 0, 952]
  188.           when 214 then return [141, 0, 952]
  189.           when 215 then return [179, 0, 953]
  190.           when 216 then return [207, 0, 953]
  191.           when 217 then return [210, 0, 954]
  192.           when 218 then return [235, 0, 955]
  193.           when 219 then return [236, 0, 956]
  194.           when 220 then return [194, 0, 957]
  195.           when 221 then return [156, 0, 958]
  196.           when 223 then return [193, 0, 952]
  197.           when 224 then return [188, 0, 952]
  198.           when 225 then return [92, 0, 953]
  199.           when 226 then return [67, 0, 953]
  200.           when 227 then return [115, 0, 954]
  201.           when 228 then return [116, 0, 955]
  202.           when 229 then return [138, 0, 956]
  203.           when 230 then return [237, 0, 957]
  204.           when 231 then return [231, 0, 958]
  205.           when 325 then return [165, 0, 959]
  206.           when 326 then return [117, 0, 959]
  207.           when 336 then return [148, 0, 958]
  208.           when 753 then return [238, 0, 957]
  209.           when 758 then return [238, 0, 957]
  210.           when 763 then return [238, 0, 957]
  211.           when 754 then return [222, 0, 958]
  212.           when 759 then return [222, 0, 958]
  213.           when 764 then return [222, 0, 958]
  214.           when 784 then return [152, 0, 957]
  215.           when 789 then return [152, 0, 957]
  216.           when 794 then return [152, 0, 957]
  217.           when 785 then return [238, 0, 958]
  218.           when 790 then return [238, 0, 958]
  219.           when 795 then return [238, 0, 958]
  220.           when 750 then return [61, 0, 953]
  221.           when 751 then return [106, 0, 954]
  222.           when 752 then return [125, 0, 955]
  223.           when 755 then return [142, 0, 953]
  224.           when 756 then return [146, 0, 954]
  225.           when 757 then return [168, 0, 955]
  226.           when 760 then return [188, 0, 953]
  227.           when 761 then return [190, 0, 954]
  228.           when 762 then return [196, 0, 955]
  229.           when 765 then return [184, 0, 953]
  230.           when 766 then return [172, 0, 953]
  231.           when 767 then return [175, 0, 954]
  232.           when 768 then return [173, 0, 953]
  233.           when 769 then return [174, 0, 953]
  234.           when 770 then return [176, 0, 954]
  235.           when 771 then return [132, 0, 953]
  236.           when 772 then return [134, 0, 953]
  237.           when 773 then return [128, 0, 954]
  238.           when 774 then return [62, 0, 955]
  239.           when 775 then return [66, 0, 955]
  240.           when 776 then return [52, 0, 956]
  241.           when 777 then return [43, 0, 955]
  242.           when 778 then return [11, 0, 955]
  243.           when 779 then return [57, 0, 956]
  244.            
  245.     #-------------------------------------------------------------------------------
  246.     # * End Weapon Wager Database
  247.     #-------------------------------------------------------------------------------
  248.           end
  249.         elsif item.is_a?(RPG::Armor)
  250.           return DEFAULT_REWARD if $game_system.arena_one_time[2].include?(item.id)
  251.           case item.id
  252.     #-------------------------------------------------------------------------------
  253.     # * Begin Armor Wager Database
  254.     #-------------------------------------------------------------------------------
  255.          
  256.           when 1 then return [1, 1, 1]
  257.            
  258.     #-------------------------------------------------------------------------------
  259.     # * End Armor Wager Database
  260.     #-------------------------------------------------------------------------------
  261.      
  262.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  263.     #                           END CONFIGURATION
  264.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  265.           end
  266.         end
  267.         return DEFAULT_REWARD
  268.       end
  269.     end
  270.      
  271.     #-------------------------------------------------------------------------------
  272.     # ** Game_System
  273.     #-------------------------------------------------------------------------------
  274.      
  275.     class Game_System
  276.      
  277.       attr_accessor :arena_one_time   # Retains data on all the ONCE_ONLY bets
  278.      
  279.       alias zer0_arena_once_only_init initialize
  280.       def initialize
  281.         zer0_arena_once_only_init
  282.         @arena_one_time = [[],[],[]]
  283.       end
  284.     end
  285.      
  286.     #-------------------------------------------------------------------------------
  287.     # ** Game_Temp
  288.     #-------------------------------------------------------------------------------
  289.      
  290.     class Game_Temp
  291.      
  292.       attr_accessor :arena_data      # Holds info for bet, reward, battler, etc
  293.       attr_accessor :arena_battle    # Arena Battle flag
  294.       attr_accessor :party_memory    # Memorizes party pre-battle to return after
  295.      
  296.       alias zer0_battle_arena_temp_init initialize
  297.       def initialize
  298.         zer0_battle_arena_temp_init
  299.         @arena_data = []
  300.         @party_memory = []
  301.         @arena_battle = false
  302.       end
  303.      
  304.       def arena_battle_call(map_id=$game_map.map_id, x=$game_player.x , y=$game_player.y)
  305.         @party_memory.clear
  306.         $game_party.actors.each {|actor| @party_memory.push(actor.id)}
  307.         $game_party.actors.clear
  308.         $game_party.add_actor(@arena_data[2])
  309.         @battle_calling = true
  310.         @battle_can_escape = false
  311.         @battle_can_lose = true
  312.         @battle_proc = nil
  313.         @player_new_map_id = map_id
  314.         @player_new_x = x
  315.         @player_new_y = y
  316.         @player_new_direction = 2
  317.         Graphics.freeze
  318.         @player_transferring = true
  319.       end
  320.     end
  321.      
  322.     #-------------------------------------------------------------------------------
  323.     # ** Scene_BattleArena
  324.     #-------------------------------------------------------------------------------
  325.      
  326.     class Scene_BattleArena
  327.      
  328.       def main
  329.         @help_window = Window_Help.new
  330.         @item_window = Window_ItemBet.new
  331.         @item_window.help_window = @help_window
  332.         @status_window = Window_ArenaStatus.new
  333.         @header1 = Window_Base.new(320, 64, 320, 64)
  334.         @header1.contents = Bitmap.new(288, 32)
  335.         @header1.contents.draw_text(0, 0, 288, 32, 'Which weapon will you wager?', 1)
  336.         @header2 = Window_Base.new(176, 128, 288, 64)
  337.         @header2.contents = Bitmap.new(256, 32)
  338.         @header2.contents.draw_text(0, 0, 256, 32, 'Who will battle?', 1)
  339.         @header2.z = 5000
  340.         @actor_window = Window_BattlerSelect.new
  341.         @actor_window.active = @actor_window.visible = @header2.visible = false
  342.         Graphics.transition
  343.         loop {Graphics.update; Input.update; update; break if $scene != self}
  344.         [@help_window, @item_window, @status_window, @header1, @header2,
  345.          @actor_window].each {|window| window.dispose}
  346.       end
  347.      
  348.       def update
  349.         [@help_window, @status_window, @item_window,
  350.           @actor_window].each {|window| window.update}
  351.         if @item_window.active
  352.            @status_window.data = @item_window.item
  353.           if Input.trigger?(Input::B)
  354.             $game_system.se_play($data_system.cancel_se)
  355.             $scene = Scene_Map.new
  356.           elsif Input.trigger?(Input::C)
  357.             $game_system.se_play($data_system.decision_se)
  358.             @data = Zer0_CFG.wagers(@item_window.item)
  359.             @actor_window.active = @actor_window.visible = @header2.visible = true
  360.             @item_window.active = false
  361.             return
  362.           end
  363.         elsif @actor_window.active
  364.           if Input.trigger?(Input::B)
  365.             $game_system.se_play($data_system.cancel_se)
  366.             @actor_window.active = @actor_window.visible = @header2.visible = false
  367.             @item_window.active = true
  368.             return
  369.           elsif Input.trigger?(Input::C)
  370.             if $game_party.actors[@actor_window.index].dead?
  371.               $game_system.se_play($data_system.buzzer_se)
  372.               return
  373.             end
  374.             $game_system.se_play($data_system.decision_se)
  375.             if $data_troops[@data[0]] != nil
  376.               $game_temp.battle_troop_id = @data[0]
  377.               $game_temp.arena_data[2] = $game_party.actors[@actor_window.index].id
  378.               $game_temp.arena_data[0] = @item_window.item
  379.               $game_temp.arena_data[1] = case @data[1]
  380.               when 0 then $data_items[@data[2]]
  381.               when 1 then $data_weapons[@data[2]]
  382.               when 2 then $data_armors[@data[2]]
  383.               end
  384.               $game_temp.arena_battle = true
  385.               $scene = Scene_Map.new
  386.             end  
  387.           end
  388.         end
  389.       end
  390.     end
  391.      
  392.     #-------------------------------------------------------------------------------
  393.     # ** Scene_ArenaResult
  394.     #-------------------------------------------------------------------------------
  395.      
  396.     class Scene_ArenaResult
  397.      
  398.       def initialize(battle_result)
  399.         @result = battle_result
  400.       end
  401.      
  402.       def main
  403.         @map = Spriteset_Map.new
  404.         $game_party.actors[0].hp = 1 if @result != 0
  405.         $game_party.actors.clear
  406.         $game_temp.party_memory.each_index {|i|
  407.           $game_party.add_actor($game_temp.party_memory[i])}
  408.         @message_window = Window_Message.new
  409.         Graphics.transition
  410.         bet_item = $game_temp.arena_data[0]
  411.         case bet_item
  412.         when RPG::Item
  413.           if Zer0_CFG::ONLY_ONCE_ITEMS.include?(bet_item.id)
  414.             unless $game_system.arena_one_time[0].include?(bet_item.id)
  415.               $game_system.arena_one_time[0].push(bet_item.id)
  416.             end
  417.           end
  418.         when RPG::Weapon
  419.           if Zer0_CFG::ONLY_ONCE_WEAPONS.include?(bet_item.id)
  420.             unless $game_system.arena_one_time[1].include?(bet_item.id)
  421.               $game_system.arena_one_time[1].push(bet_item.id)
  422.             end
  423.           end
  424.         when RPG::Armor
  425.           if Zer0_CFG::ONLY_ONCE_ARMORS.include?(bet_item.id)
  426.             unless $game_system.arena_one_time[2].include?(bet_item.id)
  427.             $game_system.arena_one_time[2].push(bet_item.id)
  428.             end
  429.           end
  430.         end
  431.         if @result == 0
  432.           Audio.se_play('Audio/SE/060-Cheer01', 80, 100)
  433.           $game_variables[Zer0_CFG::WIN_VARIABLE] += 1
  434.           reward = $game_temp.arena_data[1].name
  435.           id = $game_temp.arena_data[1].id
  436.           case $game_temp.arena_data[1]
  437.           when RPG::Item then $game_party.gain_item(id, 1)
  438.           when RPG::Weapon then $game_party.gain_weapon(id, 1)
  439.           when RPG::Armor then $game_party.gain_armor(id, 1)
  440.           end
  441.           text = "Congratulations!\n" + 'You win a ' + reward + '!'
  442.         else      
  443.           $game_variables[Zer0_CFG::LOSS_VARIABLE] += 1
  444.           id = $game_temp.arena_data[0].id
  445.           case $game_temp.arena_data[0]
  446.           when RPG::Item then $game_party.lose_item(id, 1)
  447.           when RPG::Weapon then $game_party.lose_weapon(id, 1)
  448.           when RPG::Armor then $game_party.lose_armor(id, 1)
  449.           end
  450.           text = 'You lose.'
  451.         end
  452.         $game_temp.message_text = text
  453.         loop {Graphics.update; Input.update; update; break if $scene != self}
  454.         $game_temp.arena_battle = false
  455.         $game_temp.arena_data.clear
  456.         $scene = Scene_Map.new
  457.         [@map, @message_window].each {|sprite| sprite.dispose}
  458.       end
  459.      
  460.       def update
  461.         [@map, @message_window].each {|sprite| sprite.update}
  462.         if Input.trigger?(Input::C)
  463.           $scene = Scene_Map.new
  464.         end
  465.       end
  466.     end
  467.      
  468.     #-------------------------------------------------------------------------------
  469.     # ** Scene_Battle
  470.     #-------------------------------------------------------------------------------
  471.      
  472.     class Scene_Battle
  473.      
  474.       alias zer0_battle_arena_result battle_end
  475.       def battle_end(result)
  476.         # This will just redirect the scene to the Arena Result screen instead
  477.         # of Scene_Map if the arena flag is present
  478.         zer0_battle_arena_result(result)
  479.         if $game_temp.arena_battle
  480.           $scene = Scene_ArenaResult.new(result)
  481.         end
  482.       end
  483.     end
  484.      
  485.     #-------------------------------------------------------------------------------
  486.     # ** Window_ArenaStatus
  487.     #-------------------------------------------------------------------------------
  488.      
  489.     class Window_ArenaStatus < Window_Base
  490.      
  491.       def initialize
  492.         super(320, 128, 320, 352)
  493.         self.contents = Bitmap.new(width - 32, height - 32)
  494.         @data = nil
  495.         refresh
  496.       end
  497.      
  498.       def refresh
  499.         self.contents.clear
  500.         return if @data == nil
  501.         @data = Zer0_CFG.wagers(@data)
  502.         self.contents.font.color = system_color
  503.         self.contents.draw_text(4, 0, 288, 32, 'Enemies:')
  504.         self.contents.draw_text(4, 256, 288, 32, 'Reward:')
  505.         self.contents.font.color = normal_color
  506.         member = $data_troops[@data[0]].members
  507.         names = []
  508.         member.each_index {|i| names[i] = $data_enemies[member[i].enemy_id].name
  509.           y = (i * 32) + 32
  510.           self.contents.draw_text(4, y, 288, 32, names[i]) if y < 256}  
  511.         case @data[1]
  512.         when 0
  513.           reward = $data_items[@data[2]].name
  514.           icon = $data_items[@data[2]].icon_name
  515.         when 1
  516.           reward = $data_weapons[@data[2]].name
  517.           icon = $data_weapons[@data[2]].icon_name
  518.         when 2
  519.           reward = $data_armors[@data[2]].name
  520.           icon = $data_armors[@data[2]].icon_name
  521.         end
  522.         self.contents.draw_text(32, 288, 288, 32, reward)
  523.         rect = Rect.new(x, y, self.width - 32, 32)
  524.         self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  525.         self.contents.blt(4, 292, RPG::Cache.icon(icon), Rect.new(0, 0, 24, 24))
  526.       end
  527.      
  528.       def data=(data)
  529.         if @data != data
  530.           @data = data
  531.           refresh
  532.         end
  533.       end
  534.     end
  535.      
  536.     #-------------------------------------------------------------------------------
  537.     # ** Window_ItemBet
  538.     #-------------------------------------------------------------------------------
  539.      
  540.     class Window_ItemBet < Window_Selectable
  541.      
  542.       def initialize
  543.         super(0, 64, 320, 416)
  544.         @column_max, self.index = 1, 0
  545.         refresh
  546.       end
  547.      
  548.       def item
  549.         return @data[self.index]
  550.       end
  551.      
  552.       def refresh
  553.         if self.contents != nil
  554.           self.contents.dispose
  555.           self.contents = nil
  556.         end
  557.         @data = []
  558.         (1...$data_weapons.size).each {|i|
  559.           if $game_party.weapon_number(i) > 0
  560.             unless Zer0_CFG::NO_BET_WEAPONS.include?(i)
  561.               @data.push($data_weapons[i])
  562.             end
  563.           end
  564.         }
  565.         @item_max = @data.size
  566.         if @item_max > 0
  567.           self.contents = Bitmap.new(width - 32, row_max * 32)
  568.           (0...@item_max).each {|i| draw_item(i)}
  569.         end
  570.       end
  571.      
  572.       def draw_item(index)
  573.         item = @data[index]
  574.         number = case item
  575.         when RPG::Item then $game_party.item_number(item.id)
  576.         when RPG::Weapon then $game_party.weapon_number(item.id)
  577.         when RPG::Armor then $game_party.armor_number(item.id)
  578.         end
  579.         x = 4
  580.         y = index * 32
  581.         rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  582.         self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  583.         bitmap = RPG::Cache.icon(item.icon_name)
  584.         opacity = self.contents.font.color == normal_color ? 255 : 128
  585.         self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  586.         self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  587.         self.contents.draw_text(x + 240, y, 16, 32, ':', 1)
  588.         self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  589.       end
  590.      
  591.       def update_help
  592.         @help_window.set_text(self.item == nil ? '' : self.item.description)
  593.       end
  594.     end
  595.      
  596.     #-------------------------------------------------------------------------------
  597.     # ** Window_BattlerSelect
  598.     #-------------------------------------------------------------------------------
  599.      
  600.     class Window_BattlerSelect < Window_Selectable
  601.      
  602.       def initialize
  603.         w = ($game_party.actors.size * 64) + 32
  604.         x = (640 - w) / 2
  605.         super(x, 192, w, 96)
  606.         self.contents = Bitmap.new(width - 32, height - 32)
  607.         @row_max, self.index, self.z = 1, 0, 5000
  608.         @item_max = @column_max = $game_party.actors.size
  609.         refresh
  610.       end
  611.      
  612.       def refresh
  613.         $game_party.actors.each_index {|i|
  614.         x = 32 + i * 64
  615.         self.draw_actor_graphic($game_party.actors[i], x, 64)}
  616.       end
  617.      
  618.       def update_cursor_rect
  619.         cursor_width = 48
  620.         x = @index * 64 + 8
  621.         y = @index / @column_max * 32 - self.oy
  622.         self.cursor_rect.set(x, y, cursor_width, 64)
  623.       end
  624.     end
Expand to see the code.


Note: Because it's crashing from the menu alone, the error begins with this called script: $scene = Scene_BattleArena.new

And I'm never getting to the actual fight, with this: $game_temp.arena_battle_call(MAP_ID, X, Y)

I'm sure that part of the script works fine (I hope). It did in my other play tests.

Very confused. I mean, I can't even think of why it would matter if I used a normal game save or not.
Are you putting the proper call at the exits of the "arena"?

From the sounds of it, its probably not compatible with old save games that were created before the script was added. When you add a script that adds variables to a class, and then load the old data whose classes do not contain them variables it will crash when they are referenced. You can work around this by including a check when they are called and re-initialize the variables if they are undefined, but I don't do this with my scripts. It means that the variables needs checked every time throughout the course of your game every time they are referenced, which is not very efficient, and the proper fix is to create a new file.
I guess I won't know until I play from the beginning. Hm...

And for the exits:

  1.    #  --> $game_temp.arena_battle = false
  2.     #
  3.     #      - place this at every exit to your 'arena', otherwise it will cause
  4.     #        errors if the player leaves after registering, but before fighting
Expand to see the code.


Instead of adding this, I just placed a switch in the game when you registered that prevented you from leaving until you fought. You're just stuck in the room with no other option but go to the event that starts the fight.

(I didn't add that call anywhere. Will this cause a problem?)

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=74934