Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-----------------------------------------------------------------------------
- # Script creado por FiaPlay para Pokémon Essentials BES. Créditos si se usa.
- # Discord de FP Systems: https://discord.gg/ds8DWB5NSW
- # Si vas reportar algún bug o preguntar algo recomiendo hacerlo en el hilo del server de PokeLiberty o en FP Systems.
- #-----------------------------------------------------------------------------
- # Demostración
- #-----------------------------------------------------------------------------
- # Modo de uso:
- # *Usa fpDownloadBattle para descargar los datos de la batalla
- # *Usa OnlineBattle.start() para iniciar la batalla
- # ****Los siguientes pasos no deben hacerse en la versión que los jugadores descargarán****
- # *Crea una copia de tu juego para generar los datos
- # *Usa el modo depurador para dejar tu equipo igual al que quieres para el entrenador.
- # *Usa OnlineBattle.new(trtype,trname,doublebattle,endspeech)
- # trtype es el ID del tipo de entrenador
- # trname es el nombre del entrenador
- # doublebattle indica si será un combate doble
- # endspeech es lo que dirá el entrenador al terminar el combate
- # battle_rules un array con las battle rules activas
- # items un array con los objetos del rival
- # Eso creará el archivo OnlineBattle.txt en la capeta del juego.
- # Sube el contenido de OnlineBattle.txt a internet (recomendable pastebin.com)
- =begin Para un ejemplo de como generar el combate:
- r=["2v2",["weather",:Rain]]
- OnlineBattle.new(:LEADER_Brock, "Koga",false,"Buena Pelea.",r)
- =end
- #-----------------------------------------------------------------------------
- URRL = "https://pastebin.com/raw/YLYPMEVK" # Enlace a el txt con los datos encriptados.
- BATTLE_BGM = "" # BGM usado para la batalla (si se deja en blanco se usará la música por defecto del entrenador)
- class OnlineBattle
- attr_accessor :trainer
- attr_accessor :team
- attr_accessor :doublebattle
- attr_accessor :endspeech
- attr_accessor :rules
- attr_accessor :items
- def initialize(trtype,trname,doublebattle=false,endspeech="",battle_rules=[],items=[])
- @team = $player.party
- @trainer = NPCTrainer.new(trname,trtype)
- @doublebattle = doublebattle
- @trainer.lose_text = endspeech
- @rules = battle_rules
- text=pbMysteryGiftEncrypt(self)
- $PokemonGlobal.downloaded_battle=text
- File.open("OnlineBattle.txt","wb"){|f|
- f.write(text)
- }
- end
- #===============================================================================
- # Trainer battles
- #===============================================================================
- def self.start(var=1)
- b=fpLoadDownloandedBattle
- if !b
- pbMessage("No se han podido cargar los datos de la batalla")
- return
- end
- for i in b.rules
- if i.is_a?(Array)
- setBattleRule(i[0],i[1])
- else
- setBattleRule(i)
- end
- end
- outcome_variable = $game_temp.battle_rules["outcomeVar"] || var
- can_lose = $game_temp.battle_rules["canLose"] || false
- # Skip battle if the player has no able Pokémon, or if holding Ctrl in Debug mode
- if BattleCreationHelperMethods.skip_battle?
- return BattleCreationHelperMethods.skip_battle(outcome_variable, true)
- end
- # Record information about party Pokémon to be used at the end of battle (e.g.
- # comparing levels for an evolution check)
- EventHandlers.trigger(:on_start_battle)
- # Generate information for the foes
- foe_trainers = [b.trainer]
- foe_items = []
- foe_party = b.team
- # Generate information for the player and partner trainer(s)
- player_trainers, ally_items, player_party, player_party_starts = BattleCreationHelperMethods.set_up_player_trainers(foe_party)
- # Create the battle scene (the visual side of it)
- scene = BattleCreationHelperMethods.create_battle_scene
- # Create the battle class (the mechanics side of it)
- battle = Battle.new(scene, player_party, foe_party, player_trainers, foe_trainers)
- battle.party1starts = player_party_starts
- battle.party2starts = [0]
- battle.ally_items = ally_items
- battle.items = foe_items
- # Set various other properties in the battle class
- setBattleRule("#{foe_trainers.length}v#{foe_trainers.length}") if $game_temp.battle_rules["size"].nil?
- BattleCreationHelperMethods.prepare_battle(battle)
- $game_temp.clear_battle_rules
- # Perform the battle itself
- outcome = 0
- pbBattleAnimation(pbGetTrainerBattleBGM(foe_trainers), (battle.singleBattle?) ? 1 : 3, foe_trainers) do
- pbSceneStandby { outcome = battle.pbStartBattle }
- BattleCreationHelperMethods.after_battle(outcome, can_lose)
- end
- Input.update
- # Save the result of the battle in a Game Variable (1 by default)
- BattleCreationHelperMethods.set_outcome(outcome, outcome_variable, true)
- return outcome
- end
- end
- def fpDownloadBattle()
- text = pbDownloadToString(URRL)
- if text.length>0
- $PokemonGlobal.downloaded_battle=text
- end
- end
- def fpLoadDownloandedBattle
- text=$PokemonGlobal.downloaded_battle
- return false if !text || text.length==0
- b=Marshal.restore(Zlib::Inflate.inflate(text.unpack("m")[0]))
- return b
- end
- class PokemonGlobalMetadata
- attr_accessor :downloaded_battle
- end
- def pbGetTrainerBattleBGM(trainer,online=false)
- pbStringToAudioFile(BATTLE_BGM) if online && BATTLE_BGM.length>0
- return $PokemonGlobal.nextBattleBGM.clone if $PokemonGlobal.nextBattleBGM
- ret = nil
- music = nil
- trainerarray = (trainer.is_a?(Array)) ? trainer : [trainer]
- trainerarray.each do |t|
- trainer_type_data = GameData::TrainerType.get(t.trainer_type)
- music = trainer_type_data.battle_BGM if trainer_type_data.battle_BGM
- end
- ret = pbStringToAudioFile(music) if music && music != ""
- if !ret
- # Check map metadata
- music = $game_map.metadata&.trainer_battle_BGM
- ret = pbStringToAudioFile(music) if music && music != ""
- end
- if !ret
- # Check global metadata
- music = GameData::Metadata.get.trainer_battle_BGM
- ret = pbStringToAudioFile(music) if music && music != ""
- end
- ret = pbStringToAudioFile("Battle trainer") if !ret
- return ret
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement