Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # Battle Dome by Nathmatt
- # Version: 1.25
- # Type: Add On
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #
- # PART 2
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #
- # This work is protected by the following license:
- # #-----------------------------------------------------------------------------
- # #
- # # Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
- # # ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
- # #
- # # 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.
- # #
- # #-----------------------------------------------------------------------------
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #
- # This is the part of the script that runs everything.
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- module Battle_Dome
- # version of Battle_Dome
- Version = 1.23
- Enemy_Data = Struct.new(:id,:character_name,:character_hue)
- #============================================================================
- # Battle_Dome::Processor
- #----------------------------------------------------------------------------
- # This class provides methods for Battle Dome's handling.
- #============================================================================
- class Processor
- # setting all accessible variables
- attr_accessor :escape_time,:exp,:gold,:items,:list
- attr_reader :in_battle,:result,:returns
- #--------------------------------------------------------------------------
- # Initialization
- #--------------------------------------------------------------------------
- def initialize
- @result = nil
- reset
- end
- #--------------------------------------------------------------------------
- # reset
- # resets all my variables.
- #--------------------------------------------------------------------------
- def reset
- @exp,@gold,@items,@in_battle,@result,@bar_opacity,@enemies_called,@escape_bar,
- @escape_time,@phase = 0,0,[],false,false,255,false,nil,Config::Escape_Time,0
- @evented = RPG::Event.new(0, 0)
- end
- #--------------------------------------------------------------------------
- # Call_Battle
- # Calls the battle map and sets a few necessary variables
- #--------------------------------------------------------------------------
- def Call_Battle
- @in_battle,@escaped,$game_temp.battle_calling,$game_temp.menu_calling,
- $game_temp.menu_beep,$game_temp.map_bgm = true,false,false,false,false,
- $game_system.playing_bgm
- $game_player.make_encounter_count
- $game_system.bgm_stop
- $game_system.se_play($data_system.battle_start_se)
- $game_system.bgm_play($game_system.battle_bgm)
- @returns = [$game_map.map_id,$game_player.x,$game_player.y,$game_player.direction]
- @data = []
- @troop_id = $game_temp.battle_troop_id
- @t_Name = $data_troops[@troop_id].name
- $game_troop.setup(@troop_id)
- (0...$game_troop.enemies.size).each {|e|
- id = $data_troops[@troop_id].members[e].enemy_id
- character_name = $game_troop.enemies[e].battler_name
- character_hue = $game_troop.enemies[e].battler_hue
- @data[e] = Enemy_Data.new(id,character_name,character_hue)}
- teleport = check_terrain
- if teleport == nil
- raise 'No map was Dectected please use the config to create a terrain for this map'
- end
- Transfer(true,teleport)
- @phase = 1
- end
- #--------------------------------------------------------------------------
- # check_terrain
- # returns the terrain id from the current map id
- #--------------------------------------------------------------------------
- def check_terrain
- (1...Terrains::Terrain.size).each {|i|
- return Terrains::Terrain[i] if Terrain_Maps.Terrains(i).include?(@returns[0])}
- return nil
- end
- #--------------------------------------------------------------------------
- # Transfer
- # Teleports the player to the difined location
- #--------------------------------------------------------------------------
- def Transfer(battle=false,array=[])
- $game_temp.player_new_map_id = (battle ? array[0]:@returns[0])
- $game_temp.player_new_x = (battle ? array[1]:@returns[1])
- $game_temp.player_new_y = (battle ? array[2]:@returns[2])
- $game_temp.player_new_direction = (battle ? array[3]:@returns[3])
- (battle ? $scene.transfer_battle : $scene.transfer_player)
- end
- #--------------------------------------------------------------------------
- # delay
- # delays all actions for the defined secounds
- #--------------------------------------------------------------------------
- def delay(frames)
- wait = 0
- while frames * 40 > wait; wait += 1; Graphics.update; Input.update; end
- end
- #--------------------------------------------------------------------------
- # create_event
- # Creates an event with the defined graphic
- #--------------------------------------------------------------------------
- def create_event(data)
- @evented.pages[0].graphic.character_name = data.character_name
- @evented.pages[0].graphic.character_hue = data.character_hue
- id = $BlizzABS.create_event(0, 0, "\\e[#{data.id}]",@evented.pages)
- x, y = $BlizzABS.get_respawn_coordinates($game_map.events[id])
- $game_map.events[id].moveto(x,y)
- end
- #--------------------------------------------------------------------------
- # can_escape
- # This checks to see if you can escape
- #--------------------------------------------------------------------------
- def can_escape?
- enemies_agi = actors_agi = 0
- enemies = $game_map.battlers_group(BlizzABS::Alignments::ENEMY_GROUP)
- actors = ($game_party.actors.find_all {|a| !a.dead?})
- en = enemies.size
- an = actors.size
- enemies.each{|battler|enemies_agi += battler.enemy.agi}
- enemies_agi /= en if en > 0
- actors.each{|actor|actors_agi += actor.agi}
- actors_agi /= actors.size if actors.size > 0
- return rand(100) < 50 * actors_agi / enemies_agi
- end
- #--------------------------------------------------------------------------
- # update
- # Updates Battle Dome's processes.
- #--------------------------------------------------------------------------
- def update
- reset if $game_temp.gameover
- case @phase; when 1; create_enemies; when 2; battle_check; when 3;
- escape; when 4; finish;
- end
- end
- #--------------------------------------------------------------------------
- # create_enemies
- # Creates the enemies on the map.
- #--------------------------------------------------------------------------
- def create_enemies
- return if $game_map.map_id == @map_id
- (0...$game_troop.enemies.size).each {|e| create_event(@data[e])}
- @phase = 2
- end
- #--------------------------------------------------------------------------
- # battle_check
- # Checks whether you win or escape the battle.
- #--------------------------------------------------------------------------
- def battle_check
- if Input.trigger?(Input::Escape)
- @escape_bar = Window_Escape_Bar.new
- @phase = 3
- end
- @phase = 4 if $game_map.battlers_group(BlizzABS::Alignments::ENEMY_GROUP).size == 0
- end
- #--------------------------------------------------------------------------
- # escape
- # Runs the escape proccesing.
- #--------------------------------------------------------------------------
- def escape
- @escape_bar.update
- @escape_time -= 1
- return if @escape_time != 0
- @escape_time = Config::Escape_Time
- @escape_bar.dispose
- @escape_bar = nil
- @phase = 2
- return if !can_escape?
- $game_system.se_play($data_system.escape_se)
- $game_system.bgm_play($game_temp.map_bgm)
- @result = 2
- reset
- Transfer()
- @phase = 0
- end
- #--------------------------------------------------------------------------
- # finish
- # Runs the win proccesing.
- #--------------------------------------------------------------------------
- def finish
- $game_system.me_play($game_system.battle_end_me)
- treasures = @items
- $game_party.gain_gold(@gold)
- @escape_time = Battle_Dome::Config::Escape_Time
- $game_party.actors.each {|actor|
- actor.exp += @exp if !actor.cant_get_exp?}
- treasures = treasures[0..5]
- treasures.each {|item|
- case item
- when RPG::Item
- $game_party.gain_item(item.id, 1)
- when RPG::Weapon
- $game_party.gain_weapon(item.id, 1)
- when RPG::Armor
- $game_party.gain_armor(item.id, 1)
- end}
- @result_window = Window_BattleResult.new(@exp, @gold, treasures)
- @result_window.y += 50
- @result_window.visible = true
- delay(Config::Wait_Time)
- @result_window.dispose
- @result_window = nil
- @result = 0
- Transfer()
- $game_system.bgm_play($game_temp.map_bgm)
- reset
- end
- end
- end
- # load Battle Dome's Processor
- $Battle_Dome = Battle_Dome::Processor.new
- #============================================================================
- # Scene Map
- #============================================================================
- class Scene_Map
- # Calls the battle scene
- def call_battle; $Battle_Dome.Call_Battle; end
- # updates the battle proccessing
- alias battle_dome_update update
- def update
- $Battle_Dome.update if $Battle_Dome.in_battle
- if !$Battle_Dome.in_battle && $Battle_Dome.list != nil
- end
- battle_dome_update
- end
- # adds the ability to refresh spriteset
- def sprite_refresh; @spriteset = Spriteset_Map.new; end
- # disables menu during battle
- alias battle_dome_call_menu call_menu
- def call_menu
- if $Battle_Dome.in_battle && Battle_Dome::Config::Disable_menu
- $game_temp.menu_calling = false
- if Battle_Dome::Config::Menu != false
- eval("$scene = #{Battle_Dome::Config::Menu}.new")
- end
- else
- battle_dome_call_menu
- end
- end
- def transfer_battle
- Graphics.freeze
- t = Battle_Dome::Transition_Pack
- $scene = Transition.new($scene,t::Type , t::Args) if t::Using
- if $game_map.map_id != $game_temp.player_new_map_id
- $game_map.setup($game_temp.player_new_map_id)
- end
- $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
- case $game_temp.player_new_direction
- when 2 # down
- $game_player.turn_down
- when 4 # left
- $game_player.turn_left
- when 6 # right
- $game_player.turn_right
- when 8 # up
- $game_player.turn_up
- end
- $game_player.straighten
- $game_map.update
- @spriteset.dispose
- @spriteset = Spriteset_Map.new
- if !t::Using
- Graphics.transition(40, "Graphics/Transitions/" +
- $data_system.battle_transition,100)
- end
- $game_map.autoplay
- Graphics.frame_reset
- Input.update
- end
- end
- #============================================================================
- # Scene Gameover
- #============================================================================
- class Scene_Gameover
- alias battle_dome_main main
- def main
- $Battle_Dome.reset
- battle_dome_main
- end
- end
- #============================================================================
- # Map_Enemy
- #----------------------------------------------------------------------------
- # Get enemy id
- #============================================================================
- class Map_Enemy < Map_Battler; attr_reader :enemy; end
- #============================================================================
- # BlizzABS::Processor
- #----------------------------------------------------------------------------
- # This edits the part of bliz'z script that controls
- # how you get exp, gold, and items so you get it after battle.
- #============================================================================
- class BlizzABS::Processor
- #--------------------------------------------------------------------------
- # drop_items
- # enemy - the killed enemy event
- # Returns array of items that will be dropped.
- #--------------------------------------------------------------------------
- def drop_items(enemy)
- # initialize array
- items = []
- if $tons_version != nil && $tons_version >= 5.98 &&
- TONS_OF_ADDONS::MULTI_DROP
- $Battle_Dome.items += BlizzCFG.dropped_items(enemy.battler)
- elsif rand(100) < enemy.battler.treasure_prob
- if enemy.battler.item_id > 0
- $Battle_Dome.items.push($data_items[enemy.battler.item_id])
- elsif enemy.battler.weapon_id > 0
- $Battle_Dome.items.push($data_weapons[enemy.battler.weapon_id])
- elsif enemy.battler.armor_id > 0
- $Battle_Dome.items.push($data_armors[enemy.battler.armor_id])
- end
- end
- return items
- end
- #--------------------------------------------------------------------------
- # exp_result
- # enemy - the killed enemy event
- # Processes EXP gain after the death of an enemy.
- #--------------------------------------------------------------------------
- def exp_result(enemy)
- return 0 if enemy.exp == 0
- exp = enemy.exp
- if $tons_version != nil
- if $tons_version >= 6.4 && TONS_OF_ADDONS::DIFFICULTY
- exp = exp * $game_system.exp_rate / 100
- end
- end
- $Battle_Dome.exp += exp
- exp = 0
- return exp
- end
- #--------------------------------------------------------------------------
- # gold_result
- # enemy - the killed enemy event
- # Processes gold gain after the death of an enemy.
- #--------------------------------------------------------------------------
- def gold_result(enemy)
- return 0 if enemy.gold == 0
- gold = enemy.gold
- if $tons_version != nil
- if $tons_version >= 6.4 && TONS_OF_ADDONS::DIFFICULTY
- gold = gold * $game_system.gold_rate / 100
- end
- end
- $Battle_Dome.gold += gold
- return gold
- end
- alias battle_dome_create_event_page create_event_page
- def create_event_page(data)
- if data.is_a?(RPG::Event::Page)
- return data
- end
- return battle_dome_create_event_page
- end
- end
- #============================================================================
- # BlizzABS::Cache
- #----------------------------------------------------------------------------
- # This class was enhanced to support the yellow escpae bar
- #============================================================================
- class BlizzABS::Cache
- alias battle_dome_initialize initialize
- def initialize
- battle_dome_initialize
- # add image
- @data['empty_hud_yellow_bar'] = @data['empty_hud_green_bar'].clone
- @data['empty_hud_yellow_bar'].hue_change(-60)
- # prevent "Script is hanging" error
- Graphics.update
- # add image
- @data['hud_yellow_bar'] = @data['hud_green_bar'].clone
- @data['hud_yellow_bar'].hue_change(-60)
- # prevent "Script is hanging" error
- Graphics.update
- end
- end
- # load Blizz-ABS Processor
- $BlizzABS = BlizzABS::Processor.new
- #==============================================================================
- # Window_Escape_Bar
- #==============================================================================
- class Window_Escape_Bar < Sprite
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super
- # create bitmap
- self.bitmap = Bitmap.new(206, 96)
- self.x, self.y = 200, 0
- self.z = 1000
- update
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def update
- rate = (Battle_Dome::Config::Escape_Time > 0 ? $Battle_Dome.escape_time.to_f /
- Battle_Dome::Config::Escape_Time : 0)
- if rate > 0.6
- color1 = Color.new(80 - 150 * (rate-0.6), 80, 50 * (rate-0.6), 192)
- color2 = Color.new(240 - 450 * (rate-0.6), 240, 150 * (rate-0.6), 192)
- elsif rate > 0.2 && rate <= 0.6
- color1 = Color.new(80, 200 * (rate-0.2), 0, 192)
- color2 = Color.new(240, 600 * (rate-0.2), 0, 192)
- elsif rate <= 0.2
- color1 = Color.new(400 * rate, 0, 0, 192)
- color2 = Color.new(240, 0, 0, 192)
- end
- color3 = Color.new(0, 80, 0, 192)
- self.bitmap.font.color = normal_color
- if Battle_Dome::Config::Use_Tons && $tons_version != nil
- self.bitmap.gradient_bar(55,10,114, color1, color2, color3, rate)
- else
- self.bitmap.gradient_bar_hud(55, 32, 114, rate, 'hud_yellow_bar')
- end
- self.bitmap.draw_text_full(65,-6,100,32,Battle_Dome::Config::Escape_Text.to_s)
- end
- end
- #==============================================================================
- # Input
- #==============================================================================
- module Input ; Escape = [Key[Battle_Dome::Control::Escape]]; end
- #==============================================================================
- # Interpreter
- #==============================================================================
- class Interpreter
- attr_accessor :branch
- alias battle_dome_command_301 command_301
- def command_301
- list = @list[@index+1..@list.size]
- $Battle_Dome.list = list
- battle_dome_command_301
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement