Arena de Batalha no RMXP

12 de setembro de 2011

Este script para o RPG Maker XP, o Star Ocean Battle Arena do SephirothSpawn, cria uma arena de batalha que lhe possibilita escolher entre lutar sozinho ou em grupos, contra monstros ou inimigos de diferentes níveis de dificuldade.

Os comentários do script foram traduzidos por alguém para o português, o que ajuda bastante a implementação e a personalização do mesmo! Ele precisa do SDK para funcionar, que já está na demo, disponível para download neste post.

Screenshots

Código

#==============================================================================
# Star Ocean Battle Arena
#==============================================================================
# SephirothSpawn
# Version 1
# 12.22.05
# clss.rgss
#==============================================================================
# DESCRIÇÃO
#==============================================================================
# Este Scrip cria uma arena de batalha que lhe posibilita escolher entre lutar
# sozinho ou em grupos, com varios leveis diferentes de dificuldade. Uma Arena
# de Batalha!
#==============================================================================
# INSTRUÇÕES
#==============================================================================
# Para usar este script você deve ter instalado o SDK.
# Cole este script abaixo do SDK
# Para usar o script chame ele com: $scene = Scene_BattleArena.new
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log("Star Ocean Battle Arena", "SephirothSpawn", 1, "12.17.05")

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state("Star Ocean Battle Arena") == true

#==============================================================================
# ** Scene_BattleArena
#==============================================================================
class Scene_BattleArena
RANK_D = [
['Fantasma * 3', [1, 1, 1] ], ['Basilisco *3', [2, 2, 2] ],
['Shagin * 2', [3, 3] ], ['Catoblepas * 2', [4, 4] ],
['King Kobold', [5] ] ]
RANK_C = [
['Cockatrice * 3', [6, 6, 6] ], ['Imp *3', [7, 7, 7] ],
['Anjo * 2', [8, 8] ], ['Zombi * 2', [9, 9] ],
['Lamia', [10] ] ]
RANK_B = [
['Lagarto * 3', [11, 11, 11] ], ['Cerebus *3', [12, 12, 12] ],
['Goblin * 2', [13, 13] ], ['Harpy * 2', [14, 14] ],
['Gargoyle', [15] ] ]
RANK_A = [
['Archangel * 3', [16, 16, 16] ], ['Skeleton *3', [17, 17, 17] ],
['Hydra * 3', [18, 18, 18] ], ['Krakan * 3', [19, 19, 19] ],
['Griffon * 2', [20, 20] ], ['Orge * 2', [21, 21] ],
['Wyvern *2', [22, 22] ],['Demon * 2', [23, 23] ],
['Cherub', [24] ], ['Lich', [25] ] ]
RANK_S = [
['Quetzacoatel', [26]], ['Leviathan', [27]],
['Behemoth', [28]], ['Troll', [29]],
['Goruda', [30]], ['Diablos', [31]],
['Seraphim', [32] ] ]
TROOPS = [RANK_D, RANK_C, RANK_B, RANK_A, RANK_S]
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Memoriza o mapa e o BGM e para BGM
$game_temp.map_bgm = $game_system.playing_bgm
$game_system.bgm_stop
# Toca a BGM da batalha
$game_system.bgm_play(RPG::AudioFile.new('042-Dungeon08'))
# Background
@sprite_set = Spriteset_Map.new
# Janela de Ajuda
@help_window = Window_Help.new
@help_window.y = - 64
@help_window.opacity = 200
# Janela de Dinheiro
@gold_window = Window_Gold.new
@gold_window.x, @gold_window.y = 640, 80
@gold_window.opacity = 200
# Objetos
@objects = [@sprite_set, @help_window, @gold_window]
# Chegar se Retornou a Arena 
if $game_temp.arena_battle
# Processa o retorno
main_return_setup
else
# Processa o retorno princpal
main_main_setup
end
# Executa a Transição
Graphics.transition
# Volta a principal
while $scene == self
# Atualiza os graficos
Graphics.update
# Atualiza a colocação de informações
Input.update
# Atualiza os Objetos
@objects.each {|x| x.update}
# Atualiza os Frames
update
end
# Prepara a Transição
Graphics.freeze
# Aliena objetos
@objects.each {|object| object.dispose}
# Toca BGM do mapa
if $scene.is_a?(Scene_Map)
$game_system.bgm_play($game_temp.map_bgm)
end
end
#--------------------------------------------------------------------------
# * Retorno Setup
#--------------------------------------------------------------------------
def main_return_setup
# Limpa as Bandeiras
$game_temp.arena_battle = false
# Se agrupam Nome & Deleta dados agrupados
@troop_name = $data_troops.pop.name
# Premio Atual
current_prize = $game_temp.arena_prize
# Determina Vitoria ou derrota
if $game_temp.arena_win
rank = TROOPS[$game_temp.arena_progress[0]]
if $game_temp.arena_progress[1] == rank.size
# Seta o texto de ajuda
@help_window.set_text("Rank Completo", 1)
# Restora os Personagens
unless $temp_actors.empty?
$game_party.actors = $temp_actors
end
# Ganha Dinheiro
$game_party.gain_gold($game_temp.arena_prize)
# Procede Continuar Fase
@phase, @exit = 99, false
return
else
# Seta o texto de ajuda
@help_window.set_text("#{@troop_name} Derrotado!!! Você quer Continuar?", 1)
# Continue na Janela
@continue_window = Window_Command.new(576, ["Sim (Apostar #{current_prize * 2})",
"Não (Pegar #{current_prize} e sair)"])
@continue_window.x, @continue_window.y = 32, 480
@continue_window.opacity = 200
# Inserio Objetos
@objects.push(@continue_window)
end
# Processa continuar de Fase
@phase = 3
else
# Seta o texto de ajuda
@help_window.set_text('Você Perdeu', 1)
# Limpa os grupos de batalha
$game_temp.arena_progress = [0, 0]
$game_temp.arena_battle = false
# Processa a saida da Fase
@phase, @exit = 99, false
end
end
#--------------------------------------------------------------------------
# * Principal Stup
#--------------------------------------------------------------------------
def main_main_setup
# Tipo de Batalha / Janela
@battle_type_window = Window_Command.new(200, ['Batalhar Sozinho', 'Batalhar com Time'])
@battle_type_window.x, @battle_type_window.y = - 200, 368
@battle_type_window.opacity = 200
@battle_type_window.active = false
# Individual Personagnes / Janela
actors = []
$game_party.actors.each {|actor| actors << actor.name}
@actors_window = Window_Command.new(200, actors)
@actors_window.x, @actors_window.y = 648, 432 - (actors.size * 32) #X - 424
@actors_window.opacity = 200
@actors_window.active = false
# Janela do Rank
@ranks_window = Window_Command.new(576, [
'Rank D: Cadetes (100 G)', 'Rank C: Tenentes (250 G)',
'Rank B: Soldados (500 G)', 'Rank A: Generais (1000 G)',
'Rank S: Chefes (5000 G)'])
@ranks_window.x, @ranks_window.y = 32, - 192
@ranks_window.opacity = 200
@ranks_window.active = false
# Acrescenta A Ordem de Objetos
@objects.push(@battle_type_window, @actors_window, @ranks_window)
# Seta a fase do principal
@phase = 0
end
#--------------------------------------------------------------------------
# * Atualização de Frames
#--------------------------------------------------------------------------
def update
case @phase
# Nova Batalha
when 0 # Tipo de Batalha Selecionado
@help_window.set_text('Qual o tipo de Batalha que você gostaria de competir?' , 1)
select_battle_type
when 1 # Seleção de Personagem (se for Batalhar Sozinho)
@help_window.set_text('Qual Lutador?' , 1)
select_battle_actor
when 2 # Seleção de Rank
@help_window.set_text('Qual o Rank que irá competir?' , 1)
select_battle_rank
# Continuar a Batalhar
when 3 # Selecionar Continuar ou sair
select_battle_continue
# Processa Batalhar ou Sair
when 4 # Começar a Batalha
@help_window.set_text('Começe a Batalha... ... ... ... ...', 1)
start_new_Battle
when 99 # Siar da Arena de Batalha
exit_battle_arena
end
end
#--------------------------------------------------------------------------
# * Atualização de Frames : Tipo de Batalha
#--------------------------------------------------------------------------
def select_battle_type
# Ativa Tipo de Batalha / Janela
@battle_type_window.active = true
# Fades In / Janela
@help_window.y += 8 if @help_window.y < 0
@gold_window.x -= 16 if @gold_window.x > 464
@battle_type_window.x += 24 if @battle_type_window.x < 16
# Fades Out / Janela
@actors_window.x += 16 if @actors_window.x < 648
@ranks_window.y -= 32 if @ranks_window.y > - 192
# Se B estiver Pressionado
if Input.trigger?(Input::B)
# Cancela SE
$game_system.se_play($data_system.cancel_se)
# Desativa janela do tipo de batalha
@battle_type_window.active = false
# Seta Texto de Ajuda
@help_window.set_text('Pronto. Venha aqui', 1)
# Sai do setup das fases
@phase, @exit = 99, false
end
# Se C estiver presionado
if Input.trigger?(Input::C)
# Toca Decisão SE
$game_system.se_play($data_system.decision_se)
# Desativa Janela
@battle_type_window.active = false
case @battle_type_window.index
when 0 # Batalhar Sozinho
$temp_actors = $game_party.actors.dup
@type, @phase = 'Sozinho', 1
when 1
$temp_actors = []
@type, @phase = 'Time', 2
end
end
end
#--------------------------------------------------------------------------
# * Atualização de Frames : Selecionar Personagem
#--------------------------------------------------------------------------
def select_battle_actor
# Ativa Personagem / Janela
@actors_window.active = true
# Fades In / Janela
@help_window.y += 8 if @help_window.y < 0
@gold_window.x -= 16 if @gold_window.x > 464
@battle_type_window.x += 24 if @battle_type_window.x < 16
@actors_window.x -= 16 if @actors_window.x > 424
# Fades Out / Janela
@ranks_window.y -= 32 if @ranks_window.y > - 192
# Se B estiver Pressionado
if Input.trigger?(Input::B)
# Cancela SE
$game_system.se_play($data_system.cancel_se)
# Desativa Personagens / Janela
@actors_window.active = false
# Restora Personagens
$game_party.actors = $temp_actors
# Janela do estilo de batalha
@phase = 0
end
# Se C estive pressionado
if Input.trigger?(Input::C)
# Toca Decisão SE
$game_system.se_play($data_system.decision_se)
# Desativa Janela
@actors_window.active = false
# Remove os Personagens
$game_party.actors = [$temp_actors[@actors_window.index]]
# Processa a seleção do Rank de Batalha
@phase = 2
end
end
#--------------------------------------------------------------------------
# * Atualização de Frames : Seleção de Personagens
#--------------------------------------------------------------------------
def select_battle_rank
# Ativa Rank / Janela
@ranks_window.active = true
# Fades In / Janela
@help_window.y += 8 if @help_window.y < 0
@gold_window.x -= 16 if @gold_window.x > 464
@ranks_window.y += 16 if @ranks_window.y < 160
# Fades Out / Janela
@battle_type_window.x -= 12 if @battle_type_window.x > - 200
@actors_window.x += 16 if @actors_window.x < 648
# Se B estiver Pressionado
if Input.trigger?(Input::B)
# Cancela SE
$game_system.se_play($data_system.cancel_se)
# Desativa Rank / Janela
@ranks_window.active = false
# Move o modo previsto
@phase = @type == 'Sozinho' ? 1 : 0
end
# Se C estiver Pressionado
if Input.trigger?(Input::C)
# Quanto Custa
case @ranks_window.index
when 0
cost = 100
when 1
cost = 250
when 2
cost = 500
when 3
cost = 1000
when 4
cost = 5000
end
# Checa se à dinheiro suficiente
if $game_party.gold < cost
# Toca Busina SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Toca Decisão SE
$game_system.se_play($data_system.decision_se)
# Desativa Rank / Janela
@ranks_window.active = false
# Deleta Dinheiro
$game_party.lose_gold(cost)
# Seta Rank
$game_temp.arena_progress = [@ranks_window.index, 0]
# Seta Preço
$game_temp.arena_prize = cost / 2
# Processa a nova batalha
@phase = 4
end
end
#--------------------------------------------------------------------------
# * Atualização de Frames : Continuar a Batalha
#--------------------------------------------------------------------------
def select_battle_continue
# Fades In Ajuda / Janela
@help_window.y += 8 if @help_window.y < 0
# Fades In Gold / Janela
@gold_window.x -= 16 if @gold_window.x > 464
# Fades In Continua / Janela
@continue_window.y -= 16 if $game_temp.arena_win && @continue_window.y > 160
# Se C estiver Pressionado
if Input.trigger?(Input::C)
# Continua
if @continue_window.index == 0
if @help_window.y >= 0 && @gold_window.x <= 464 && @continue_window.y <= 160
# Processa a Nova Batalha
@phase = 4
end
else
# Ganha dinheiro
$game_party.gain_gold($game_temp.arena_prize)
# Processa a a saida da scenas
@phase, @exit = 99, true
# Restora os Personagens
unless $temp_actors.empty?
$game_party.actors = $temp_actors
end
end
end
end
#--------------------------------------------------------------------------
# * Atualização de Frames : Começa nova Batalha
#--------------------------------------------------------------------------
def start_new_Battle
# Seta o grupo de inimigo
troop = TROOPS[$game_temp.arena_progress[0]][$game_temp.arena_progress[1]]
set_troop_setup(troop[0], troop[1])
# Seta o lugar da batalha
$game_temp.arena_battle = true
# Seta se pode escapar
$game_temp.battle_can_escape = false
# Seta se você perdeu
$game_temp.battle_can_lose = true
# Fades Out / Janela
@gold_window.x += 10 if @gold_window.x < 640
# Sai da Fase
@phase, @exit = 99, true
end
#--------------------------------------------------------------------------
# * Atualização de Frames : Sair da Batalha
#--------------------------------------------------------------------------
def exit_battle_arena
# Fades in Ajuda / Janela
if @exit == false
@help_window.y += 4 if @help_window.y < 0
end
# Variavel de Sair
exit = true
# Fades Out Ajuda / Janela
unless $game_temp.arena_battle
unless @help_window == nil
if @help_window.y > - 64 && @exit
exit = false
@help_window.y -= 4
end
end
end
# Fades Out Gold / Janela
unless @gold_window == nil
if @gold_window.x < 640
exit = false
@gold_window.x += 10
end
end
# Fades Out Tipo de Batalha / Janela
unless @battle_type_window == nil
if @battle_type_window.x > - 200
exit = false
@battle_type_window.x -= 12
end
end
# Fades Out Personagens / Janela
unless @actors_window == nil
if @actors_window.x < 648
exit = false
@actors_window.x += 16
end
end
# Fades Out Rank / Janela
unless @ranks_window == nil
if @ranks_window.y > - 192
exit = false
@ranks_window.y -= 16
end
end
# Fades Out Continuar / Janela
unless @continue_window == nil
if @continue_window.y < 640
exit = false
@continue_window.y += 16
end
end
# Se botão estiver pressionado
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
@exit = true
end
if @exit && exit
# Processa nova scena
$scene = $game_temp.arena_battle ? Scene_Battle.new : Scene_Map.new
end
end
#--------------------------------------------------------------------------
# * Grupo Stup (e Informações de Batalha)
#--------------------------------------------------------------------------
def set_troop_setup(name = 'Grupo', enemies = [1], battleback = $game_map.battleback_name)
# Cria novo Grupo
troop = RPG::Troop.new
# Nome do novo grupo
troop.name = name
# Inseri um no novo grupo
for i in 0...enemies.size
# Cria a Novo membro
member = RPG::Troop::Member.new
# Seta o ID do membro
member.enemy_id = enemies[i]
# Seta a coordenada do Membro
member.x = (640 / (enemies.size + 1)) * (i + 1)
member.y = 300
# Ordem do novo membro
troop.members.push(member)
end
# Informações do novo grupo
$data_troops.push(troop)
# Seta ID do grupo
$game_temp.battle_troop_id = $data_troops.size - 1
# seta o fundo de batalha
$game_map.battleback_name = battleback
end
end

#==============================================================================
# ** Game_Temp
#==============================================================================

class Game_Temp
#--------------------------------------------------------------------------
# * Publicação de Variaveis
#--------------------------------------------------------------------------
attr_accessor :arena_progress # Ambos grupos e Level do Oponente
attr_accessor :arena_prize
attr_accessor :arena_battle # Retorna a batalha arena depois da batalha
attr_accessor :arena_win
alias seph_battlearena_gametemp_init initialize
#--------------------------------------------------------------------------
# * Inicialização de Objetos
#--------------------------------------------------------------------------
def initialize
# Velho metodo de Inicialização
seph_battlearena_gametemp_init
# Inseri a variaveis 
@arena_progress = [0, 0]
@arena_prize = 0
@arena_battle = false
@arena_win = false
end
end

#==============================================================================
# ** Game_Party
#==============================================================================

class Game_Party
#--------------------------------------------------------------------------
# * Publicação de Variaveis
#--------------------------------------------------------------------------
attr_accessor :actors
end

#==============================================================================
# ** Scene_Battle (part 1)
#==============================================================================

class Scene_Battle
#--------------------------------------------------------------------------
# * Lista de Aliados
#--------------------------------------------------------------------------
alias seph_battlearena_scenebattle_battleend battle_end
#--------------------------------------------------------------------------
# * Final da Batalha
# resultado : resultado (0:ganhou 1:perdeu 2:escapou)
#--------------------------------------------------------------------------
def battle_end(result)
if $game_temp.arena_battle
# Limpa a batalha
$game_temp.in_battle = false
# Limpa os grupos da batalha
$game_party.clear_actions
# Remove status da batalha
for actor in $game_party.actors
actor.remove_states_battle
end
# Limpa inimigos
$game_troop.enemies.clear
# Chama batalha rechama
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
# Se ganhou
if result == 0
$game_temp.arena_win = true
$game_temp.arena_progress[1] += 1
$game_temp.arena_prize *= 2
# Se perdeu
else
$game_temp.arena_win = false
end
# Processa a ida a Batalha Arena
$scene = Scene_BattleArena.new
return
end
# Velha batalha e encerra
seph_battlearena_scenebattle_battleend(result)
end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end

Mais RPG Maker XP

autor, site, canal ou publisher SephirothSpawn tamanho 1,5KB licençaGrátis sistemas operacionais compativeisWindows 98/98SE/Me/2000/XP/Vista/7 download link DOWNLOAD

Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Clique aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!