Battle arena

Ver o tópico anterior Ver o tópico seguinte Ir em baixo

Battle arena

Mensagem  roberto em Sab Mar 13, 2010 8:25 pm

traduzido por :messa
tutorial feito também por ele,por tanto preditos a ele
pagina original
Spoiler:
esse script permiti criar uma arena de batalha,com o essencial raking e inimigos
script:
Spoiler:
#==============================================================================
# Star Ocean Battle Arena
#==============================================================================
# SephirothSpawn
# Version 1
# 12.22.05
#==============================================================================

#==============================================================================
# ** Scene_BattleArena
#==============================================================================
class Scene_BattleArena
RANK_D = [
['',[35] ], ['Basilisk *3', [2, 2, 2] ],
['Shagin * 2', [3, 3] ], ['Hell Hound * 2', [4, 4] ],
['King Kobold', [5] ] ]
RANK_C = [
['Cockatrice * 3', [6, 6, 6] ], ['Imp *3', [7, 7, 7] ],
['Angel * 2', [8, 8] ], ['Zombie * 2', [9, 9] ],
['Lamia', [10] ] ]
RANK_B = [
['Lizard Man * 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
# Memorize map BGM and stop BGM
$game_temp.map_bgm = $game_system.playing_bgm
$game_system.bgm_stop
# Play battle BGM
$game_system.bgm_play(RPG::AudioFile.new('012 - Theme01.mid'))
# Background
@sprite_set = Spriteset_Map.new
# Help Window
@help_window = Window_Help.new
@help_window.y = - 64
@help_window.opacity = 200
# Gold Window
@gold_window = Window_Gold.new
@gold_window.x, @gold_window.y = 640, 80
@gold_window.opacity = 200
# Stores Objects
@objects = [@sprite_set, @help_window, @gold_window]
# Checks if Returning from Arena Battle
if $game_temp.arena_battle
# Proceeds to Returning Setup
main_return_setup
else
# Proceeds to Main Setup
main_main_setup
end
# Execute transition
Graphics.transition
# Main loop
while $scene == self
# Update game screen
Graphics.update
# Update input information
Input.update
# Updates Objects
@objects.each {|x| x.update}
# Frame update
update
end
# Prepare for transition
Graphics.freeze
# Disposes Objects
@objects.each {|object| object.dispose}
# Plays MAP Bgm
if $scene.is_a?(Scene_Map)
$game_system.bgm_play($game_temp.map_bgm)
end
end
#--------------------------------------------------------------------------
# * Returning Setup
#--------------------------------------------------------------------------
def main_return_setup
# Clears Flag
$game_temp.arena_battle = false
# Stores Troop Name & Deletes From Data Troops
@troop_name = $data_troops.pop.name
# Current Prize
current_prize = $game_temp.arena_prize
# Determines if Won or Lost
if $game_temp.arena_win
rank = TROOPS[$game_temp.arena_progress[0]]
if $game_temp.arena_progress[1] == rank.size
# Set Help Text
@help_window.set_text("Completed Rank", 1)
# Restores Actors
unless $temp_actors.empty?
$game_party.actors = $temp_actors
end
# Gain Gold
$game_party.gain_gold($game_temp.arena_prize)
# Proceeds to Continue Phase
@phase, @exit = 99, false
return
else
# Set Help Text
@help_window.set_text("#{@troop_name} Vocíª foi derrotado! Deseja tentar novamente?", 1)
# Continue Window
@continue_window = Window_Command.new(576, ["Sim (Try for #{current_prize * 2})",
"Sair (Pegar seu premio atual #{current_prize} e ir embora.)"])
@continue_window.x, @continue_window.y = 32, 480
@continue_window.opacity = 200
# Adds to Objects
@objects.push(@continue_window)
end
# Proceeds to Continue Phase
@phase = 3
else
# Set Help Text
@help_window.set_text('Vocíª Perdeu', 1)
# Clears Arena Battle Flags
$game_temp.arena_progress = [0, 0]
$game_temp.arena_battle = false
# Proceeds to Exit Phase
@phase, @exit = 99, false
end
end
#--------------------------------------------------------------------------
# * Main Setup
#--------------------------------------------------------------------------
def main_main_setup
# Battle Type Window
@battle_type_window = Window_Command.new(200, ['Individual', 'Batalha em Equipe'])
@battle_type_window.x, @battle_type_window.y = - 200, 368
@battle_type_window.opacity = 200
@battle_type_window.active = false
# Individual Actors Window
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
# Ranking Window
@ranks_window = Window_Command.new(576, [
'Rank D: Batalhas para Iniciantes. (100 G)', 'Rank C: Batalhas Medianas. (250 G)',
'Rank B: Batalhas Avançadas. (500 G)', 'Rank A: Batalhas Expert. (1000 G)',
'Rank S: Mestre de batalhas. (5000 G)'])
@ranks_window.x, @ranks_window.y = 32, - 192
@ranks_window.opacity = 200
@ranks_window.active = false
# Adds To Objects Array
@objects.push(@battle_type_window, @actors_window, @ranks_window)
# Sets Phase to Main
@phase = 0
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
case @phase
# For New Battles
when 0 # Battle Type Select
@help_window.set_text('Em qual genero de batalha vocíª gostaria de competir?' , 1)
select_battle_type
when 1 # Select Actor (if Single Battle)
@help_window.set_text('Qual personagem ira competir?' , 1)
select_battle_actor
when 2 # Select Battling Rank
@help_window.set_text('Em qual rank vocíª deseja competir?' , 1)
select_battle_rank
# For Continuing Battles
when 3 # Select Continue or Quit
select_battle_continue
# For Proceeding to Battle or Exiting
when 4 # Battle Engaging
@help_window.set_text('Iniciando Batalha... ... ... ... ...', 1)
start_new_Battle
when 99 # Exit Battle Arena
exit_battle_arena
end
end
#--------------------------------------------------------------------------
# * Frame Update : Select Battle Type
#--------------------------------------------------------------------------
def select_battle_type
# Activates Battle Type Window
@battle_type_window.active = true
# Fades In Windows
@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 Windows
@actors_window.x += 16 if @actors_window.x < 648
@ranks_window.y -= 32 if @ranks_window.y > - 192
# If B is Pressed
if Input.trigger?(Input::B)
# Plays Cancel SE
$game_system.se_play($data_system.cancel_se)
# Disables Battle Type Window
@battle_type_window.active = false
# Sets Help Text
@help_window.set_text('Certo, Volta novamente', 1)
# Exit Phase Setup
@phase, @exit = 99, false
end
# If C is Pressed
if Input.trigger?(Input::C)
# Plays Decision SE
$game_system.se_play($data_system.decision_se)
# Deactivates Window
@battle_type_window.active = false
case @battle_type_window.index
when 0 # Single Battle
$temp_actors = $game_party.actors.dup
@type, @phase = 'Individual', 1
when 1
$temp_actors = []
@type, @phase = 'Equipe', 2
end
end
end
#--------------------------------------------------------------------------
# * Frame Update : Select Actor
#--------------------------------------------------------------------------
def select_battle_actor
# Activates Actors Window
@actors_window.active = true
# Fades In Windows
@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 Windows
@ranks_window.y -= 32 if @ranks_window.y > - 192
# If B is Pressed
if Input.trigger?(Input::B)
# Plays Cancel SE
$game_system.se_play($data_system.cancel_se)
# Disables Actors Window
@actors_window.active = false
# Restore Actors
$game_party.actors = $temp_actors
# Battle Type Window Phase
@phase = 0
end
# If C is Pressed
if Input.trigger?(Input::C)
# Plays Decision SE
$game_system.se_play($data_system.decision_se)
# Deactivates Window
@actors_window.active = false
# Removes Actors
$game_party.actors = [$temp_actors[@actors_window.index]]
# Proceeds to Battle Rank Selection
@phase = 2
end
end
#--------------------------------------------------------------------------
# * Frame Update : Select Actor
#--------------------------------------------------------------------------
def select_battle_rank
# Actives Ranks Window
@ranks_window.active = true
# Fades In Windows
@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 Windows
@battle_type_window.x -= 12 if @battle_type_window.x > - 200
@actors_window.x += 16 if @actors_window.x < 648
# If B is Pressed
if Input.trigger?(Input::B)
# Plays Cancel SE
$game_system.se_play($data_system.cancel_se)
# Disables Ranks Window
@ranks_window.active = false
# Moves to Previous Method
@phase = @type == 'Individual' ? 1 : 0
end
# If C is Pressed
if Input.trigger?(Input::C)
# Gets Cost
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
# Checks to Make Sure You have enough Money
if $game_party.gold < cost
# Plays Buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Plays Decision SE
$game_system.se_play($data_system.decision_se)
# Disables Ranks Window
@ranks_window.active = false
# Deletes Gold
$game_party.lose_gold(cost)
# Sets Rank
$game_temp.arena_progress = [@ranks_window.index, 0]
# Sets Prize
$game_temp.arena_prize = cost / 2
# Procees to New Battle Phase
@phase = 4
end
end
#--------------------------------------------------------------------------
# * Frame Update : Continue Battle
#--------------------------------------------------------------------------
def select_battle_continue
# Fades In Help Window
@help_window.y += 8 if @help_window.y < 0
# Fades In Gold Window
@gold_window.x -= 16 if @gold_window.x > 464
# Fades In Continue Window
@continue_window.y -= 16 if $game_temp.arena_win && @continue_window.y > 160
# If C is pressed
if Input.trigger?(Input::C)
# Continue
if @continue_window.index == 0
if @help_window.y >= 0 && @gold_window.x <= 464 && @continue_window.y <= 160
# Proceeds to Start Battle Phase
@phase = 4
end
else
# Gain Gold
$game_party.gain_gold($game_temp.arena_prize)
# Proceeds to Exit Scene Phase
@phase, @exit = 99, true
# Restores Actors
unless $temp_actors.empty?
$game_party.actors = $temp_actors
end
end
end
end
#--------------------------------------------------------------------------
# * Frame Update : Start New Battle
#--------------------------------------------------------------------------
def start_new_Battle
# Sets Up Enemy Troop
troop = TROOPS[$game_temp.arena_progress[0]][$game_temp.arena_progress[1]]
set_troop_setup(troop[0], troop[1])
# Set Arena Battle Flag
$game_temp.arena_battle = true
# Set it so You can't escape
$game_temp.battle_can_escape = false
# Set it so You can't lose
$game_temp.battle_can_lose = true
# Fades Out Windows
@gold_window.x += 10 if @gold_window.x < 640
# Exit Phase
@phase, @exit = 99, true
end
#--------------------------------------------------------------------------
# * Frame Update : Exit Arena
#--------------------------------------------------------------------------
def exit_battle_arena
# Fades in Help Window
if @exit == false
@help_window.y += 4 if @help_window.y < 0
end
# Varaible for exit scene
exit = true
# Fades Out Help Window
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 Window
unless @gold_window == nil
if @gold_window.x < 640
exit = false
@gold_window.x += 10
end
end
# Fades Out Battle Type Window
unless @battle_type_window == nil
if @battle_type_window.x > - 200
exit = false
@battle_type_window.x -= 12
end
end
# Fades Out Actors Window
unless @actors_window == nil
if @actors_window.x < 648
exit = false
@actors_window.x += 16
end
end
# Fades Out Ranks Window
unless @ranks_window == nil
if @ranks_window.y > - 192
exit = false
@ranks_window.y -= 16
end
end
# Fades Out Continue Window
unless @continue_window == nil
if @continue_window.y < 640
exit = false
@continue_window.y += 16
end
end
# If Button is Pressed
if Input.trigger?(Input::B) or Input.trigger?(Input::C)
@exit = true
end
if @exit && exit
# Proceeds to Next Scene
$scene = $game_temp.arena_battle ? Scene_Battle.new : Scene_Map.new
end
end
#--------------------------------------------------------------------------
# * Troop Setup (and Battle Information)
#--------------------------------------------------------------------------
def set_troop_setup(name = 'troop', enemies = [1], battleback = $game_map.battleback_name)
# Creates New Troop
troop = RPG::Troop.new
# Gives Troop Name
troop.name = name
# Adds Members into Troop
for i in 0...enemies.size
# Creates New Member
member = RPG::Troop::Member.new
# Sets Member ID
member.enemy_id = enemies[i]
# Sets Member Coordinates
member.x = (640 / (enemies.size + 1)) * (i + 1)
member.y = 300
# Adds Memeber to Troop Array
troop.members.push(member)
end
# Adds New Troop to Data Troops
$data_troops.push(troop)
# Sets Troop ID
$game_temp.battle_troop_id = $data_troops.size - 1
# Sets Battle Back
$game_map.battleback_name = battleback
end
end

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

class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :arena_progress # Both Group and Opponent Level
attr_accessor :arena_prize
attr_accessor :arena_battle # Returns to Battle Arena after Battle
attr_accessor :arena_win
alias seph_battlearena_gametemp_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Old Initialize Method
seph_battlearena_gametemp_init
# Adds Battle Arena Variables
@arena_progress = [0, 0]
@arena_prize = 0
@arena_battle = false
@arena_win = false
end
end

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

class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :actors
end

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

class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias seph_battlearena_scenebattle_battleend battle_end
#--------------------------------------------------------------------------
# * Battle Ends
# result : results (0:win 1:lose 2:escape)
#--------------------------------------------------------------------------
def battle_end(result)
if $game_temp.arena_battle
# Clear in battle flag
$game_temp.in_battle = false
# Clear entire party actions flag
$game_party.clear_actions
# Remove battle states
for actor in $game_party.actors
actor.remove_states_battle
end
# Clear enemies
$game_troop.enemies.clear
# Call battle callback
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
# If Win
if result == 0
$game_temp.arena_win = true
$game_temp.arena_progress[1] += 1
$game_temp.arena_prize *= 2
# If Lose
else
$game_temp.arena_win = false
end
# Proceeds to Battle Arena
$scene = Scene_BattleArena.new
return
end
# Old Battle End Method
seph_battlearena_scenebattle_battleend(result)
end
end
Para chamar a arena de batalha durante o jogo basta criar uma evento "Chama Script" na terceira aba e escreva o seguite:


tutorial
Para alterar os inimigos ou adicionar inimigos vá no começo do script
Spoiler:
class Scene_BattleArena
RANK_D = [
['',[35] ], ['Basilisk *3', [2, 2, 2] ],
['Shagin * 2', [3, 3] ], ['Hell Hound * 2', [4, 4] ],
['King Kobold', [5] ] ]
RANK_C = [
['Cockatrice * 3', [6, 6, 6] ], ['Imp *3', [7, 7, 7] ],
['Angel * 2', [8, 8] ], ['Zombie * 2', [9, 9] ],
['Lamia', [10] ] ]
RANK_B = [
['Lizard Man * 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]
Para adicionar um inimigo apenas insira o nome (o nome não precisa ser obrigatoriamente insirido) e a ID dele da seguinte forma

Ou

Coloque uma virgula entre cada novo inimigo em sequencia para que não de erro de script
Spoiler:
['Arcanjo'], [32]], ['Diablo'], [31]]
Para alterar a musica da Arena vá em:
Spoiler:
$game_system.bgm_play(RPG::AudioFile.new('012 - Theme01.mid'))
e altere "012 - Theme01.mid" pela musica que vocíª quer que seja tocada, a musica deve estar na pasta audio/BGM do seu projeto
Para alterar o valor de cada ranking vá em:
Spoiler:
# Gets Cost
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
é so alterar o valor de cada ranking, o numero 4 equivale ao ranking "Mestre de Batalhas", o 0 equivale ao ranking "Batalhas para Iniciantes"

Funciona com qualquer script até onde eu sei
avatar
roberto
Admin

Mensagens : 75
Pontos : 204
Reputação : 3
Data de inscrição : 03/03/2010

Ver perfil do usuário http://morpgmaker.mo-rpg.com

Voltar ao Topo Ir em baixo

Ver o tópico anterior Ver o tópico seguinte Voltar ao Topo


 
Permissão deste fórum:
Você não pode responder aos tópicos neste fórum