| Villageois (Nv 1) |
 |
Inscrit le: 16 Fév 2011, 13:11 Messages: 8 Localisation: Nord (59) Niveau RPG Maker: Noob en devenir ! Logiciel(s) préféré(s): Rpg Maker VX Sexe: Masculin Points d'aide: 0/60
Créations :
Voir ses créations
|
Suite aux petites difficultés d'un membre sur un script similaire je me suis proposé de traduire un script alternatif. Il est testé et fonctionnel, la licence à laquelle il est soumis autorise la modification et la distribution à condition de lier la source. Ce script de Modern Algebra vous permettra de faire voyager le joueur à la manière du jeu Baldur's Gate, il vous sera possible de disposer de plusieurs types de voyages chacun ayant son coût, ou ayant besoin d'une compétence particulière (Téléportation). Chaque destination/carte possède sa propre image, ses coordonnés d'arrivées, ses destinations possibles et ses moyens de les atteindre. (Comprenez que vous pourrez interdire un type de voyage sur certaines cartes ou au contraire faire qu'on ne puisse s'y rendre que par un type de voyage particulier.) Un système d'embuscade obligera parfois le joueur à se battre pendant les voyages. Le tout étant entièrement paramétrable. J'ai traduit l'entête et toutes les parties configurables tout est expliqué dans le script qui suit, j'ai ajouté la démo, traduite elle aussi au passage. - Code: Tout sélectionner
#============================================================================== # Baldur's Gate Travel System/Système de transport à la Baldur's Gate # Version 1.0 # Auteur : modern algebra # Date : 21 Juin, 2008 # # Traduction française : Enki # Date : 22 Mars, 2011 # #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Remerciements : # Baldur's Gate pour le concept original dont le script s'inspire. # Anaxim pour la requête et les détails prépondérants au système, incluant # les différentes possibilités du système original. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Instructions: # Pour appeler cette scene, il suffit d'insérer ce code : # $scene = Scene_TravelMenu.new # # Pour reconfigurer vos cartes à tout moment vous pouvez insérer ce code : # $game_system.travel_data[map_index].<command> = new stat # # Voici les <command> possibles : # $game_system.travel_data[map_index].travel_types # $game_system.travel_data[map_index].dests # $game_system.travel_data[map_index].dest_xyd # $game_system.travel_data[map_index].prices # $game_system.travel_data[map_index].enemy_troops # $game_system.travel_data[map_index].image # # Le format correct pour toutes ces valeurs se situe au # début de la ligne 120. Mais vous pouvez aussi utilisez : # # $game_system.travel_data[map_index].reset # # Pour restaurer ces valeurs à leur configuration par défaut. # # Pour configurer ce script lisez et modifiez les lignes 39 à 88 et 124 à 194. #==============================================================================
module ModAlg_Travel #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Constantes #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Le mot que vous voulez pour représenter les différentes options de transport. Notez que l'ordre # des mots corresponds à l'ordre de chaque type de transport. Les valeurs par défaut sont # ['A pied', 'A cheval', 'Téléportation'], les types de transport sont : # 0 => A pied, 1 => A cheval, and 2 => Téléportation VOCAB_TRAVELOPTIONS = ['A pied', 'A cheval', 'Téléportation'] # Le nombre d'embuscade possible pour chaque type de voyage. # Par défaut [3, 1, 0], Trois possibilité de se faire prendre en embuscade en marchant # (c'est à dire un maximum de 3 combats et non pas obligatoirement 3, voir en-dessous) # Une possibilité à cheval, et aucune pendant la téléportation. TRAVELOPTIONS_AMBUSHES = [3, 1, 0] # Le pourcentage de chance que l'embuscade débouche sur un combat : # Par défaut [50, 50, 0], c'est à dire 50% de chance que l'embuscade # réussisse pendant le voyage à pied et pendant le voyage à cheval. # Avec les valeurs par défaut, en marchant vous avez pour l'exemple 50% de chance que # l'embuscade débouche sur un combat pour chacune des trois embuscade par défaut. TRAVELOPTIONS_AMBUSH_CHANCE = [50, 50, 0] # IL y a trois types de payement - 0 => Rien, 1 => de l'or, 2 => des PM. Vous devez, # pour chaque type de voyage, configurer le type de payement voulu. Par défaut les # options sont [0, 1, 2], marcher ne coûte donc rien, le voyage à cheval coûte de l'or et # la téléportation coûte une somme de PM. TRAVELOPTIONS_PAYMENT = [0, 1, 2] # Le son/SE joué pour chaque type de destination. # Par défaut c'est ['Move', 'Horse', 'Teleport'], le script jouera SE Move quand # vous irez à pied, le SE Horse en voyageant à cheval, et le SE Teleport quand # vous vous téléporterez TRAVELOPTIONS_SE = ['Move', 'Horse', 'Teleport'] # Ce qui suit ne s'applique qu'à l'option de payement N°2, c'est l'ID de # la compétence requise pour appeler la téléportation. vous ne pourrez pas # vous téléportez sans. Si vous avez plus d'un type de voyage utilisant le type # de payement n°2 (PM), l'array aura besoin de deux déclarations. # La même déclaration peut être répété pour utilisez la même compétence # et autorisé plus d'un type de téléportation. TELEPORT_SKILL_IDS = [83] # C'est la phrase qui s'affiche lorsque que vous vous faites attaquer. # Il y a trois balises que vous pouvez utiliser : # \nt - le nom du groupe qui vous attaque # \nl - le nom du lieu que vous venez de quitter # \nd - le nom de votre destination AMBUSH_NOTE = 'Vous êtes prix par surprise par un groupe de \nt !' # Le nom du SE qui sera joué lorsque vous serez pris dans une embuscade AMBUSH_SE = "Darkness5" RECOVER_HP_AFTER_AMBUSH = true # restauration des PV après le combat ? RECOVER_SP_AFTER_AMBUSH = true # restauration des PM après le combat ? RECOVER_CONDITIONS_AFTER_AMBUSH = true #restauration des statuts après le combat ? # Choisissez si le script se rappel du dernier type de voyage que vous avez utilisé (true), # ou choisissez si vous forcez le joueur à refaire son choix au début de la scene (false)? TRAVEL_TYPE_MEMORY = true #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ** Location #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Location #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_reader :id # L'ID de la carte attr_reader :name # Le nom de la carte attr_accessor :image # L'image qui représente la carte attr_accessor :dests # Un Array contenant les ID de chaque destination de la carte attr_accessor :dest_xyd # Un array 2D correspondant aux positions d'arrivés x, y, d attr_accessor :prices # Un array avec les coût du voyage par type attr_accessor :enemy_troops # Un array avec les groupes que vous pourrez rencontrer vers cette destination attr_accessor :travel_types # Le type de voyage disponible sur cette carte #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization # id : the ID of the location #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def setup (id) @id = id data = load_data("Data/MapInfos.rvdata") @name = data[id].name @travel_types = [] @prices = [] @dests = [] @dest_xyd = [] for i in 0...VOCAB_TRAVELOPTIONS.size @travel_types.push (i) @dests[i] = [] @dest_xyd[i] = [] @prices[i] = [] end @enemy_troops = [] @image = '' #-------------------------------------------------------------------- # Configuration par défaut pour tout : # @id : map ID # @name : le nom de la carte avec cette ID # @travel_types : tous types de transport possible # @dests : [] pour tout @travel_types # @dest_xyd : [] pour tout @travel_types # @prices : [0, etc..] pour tout @travel_types #********************************************************************* # Alors qu'est ce que tout ça ? # @id correspond à l'ID de la carte. quand vous appelez Scene_TravelMenu, # il appelle le Location object qui est marié à cette ID. # @name c'est le nom de la carte donné dans l'éditeur, de cette ID. # @travel_types c'est la liste des ID de voyage possible depuis cette carte # Les types de voyages correspondent à VOCAB_TRAVELOPTIONS, # qui devrait être tel quel ['A pied', 'A cheval', 'Téléportation'], donc # le type 0 c'est à pied, le type 1 ic'est à cheval et # le type 2 c'est la téléportation. Un exemple, si @travel_types = [0, 2], it means that # vous ne pourrez choisir que de partir à pied ou vous téléporter. le voyage # à cheval ne sera pas disponible sur cette carte. # @dests c'est un array 2D par type de voyage. Pour chacun de ces derniers qui seront disponibles # vous devrez configurer l'array correspondant avec chacune des ID des destinations # où vous pourrez vous rendre par type de voyage. # @dest_xyd est une liste mariée à @dest, qui détermine # la localisation de votre arrivé sur la carte qui correspond aux ID des @dest # Ainsi que la direction dans laquelle votre personnage regardera. # pour chaque carte [x, y, direction], x et y sont les coordonnés # de la case où vous serez téléporté et d la direction vers laquelle se tournera le personnage # 'D' pour bas, 'U' pour haut, 'L' pour gauche, ou 'R' pour droite. Juste un # exemple [0, 4, 'D']. cette configuration est à faire pour chaque destination # possible par chacun des types de voyages. # @prices est une liste mariée à @dests, qui détermine le coût # du voyage pour cette carte. # Il n'est pas necessaire de configurer le prix du type 0, # mais il faut un 0. Donc on commencera à le déclarer à 1. # @enemy_troops est la liste des ID des troupes ennemis que vous rencontrerer # en allant à cette carte et non pas en voyageant à partir de cette carte. # @image c'est un string avec le nom de l'image à utiliser dans votre dossier Picture # et c'est cette image qui apparaitra quand cette destination sera mise en surbrillance. #----------------------------------------------------------------------- case id #////////////////////////////////////////////////////////////////////// # Début de la configuration /////////////////////////////////////////////// #//////////////////////////////////////////////////////////////////// # Configurez toutes les zones ou vous voulez vous servir du sytème de transport dans ce format : # when <map ID> # Exemple : when 2 # @travel_types = [<ID de toutes les types de transport disponible sur cette carte>] # Exemple : @travel_types = [0, 1] # @dests[travel_id] = [<map IDs de chaque destination possible à partir de cette carte par type de voyage>] # Exemple : @dests[0] = [1, 4] vous pouvez vous rendre en marchant aux cartes dont les ID sont 1 et 4 # @dests[1] = [3, 4] et à cheval au carte dont les ID sont 3 et 4. # @dest_xyd[travel_id] = [ <[x, y, d]>, pour chaque destination possible à partir de cette carte.] # Exemple : @dest_xyd[0] = [ [0, 8, 'R'], [11, 0, 'D'] ] # @dest_xyd[1] = [ [16, 7, 'L'], [11, 12, 'U'] ] # @prices[travel_type_id] = [ <Coût du transport pour chaque type de voyage> ] # Exemple : @prices[1] = [150, 200] # NB: Le premier prix, celui du transport à cheval est toujours fixé en or. # Le deuxième prix, celui de la téléportion est fixé de deux manières différentes, # vous pouvez retiré un certain pourcentage de PM ou attribuer un coût fixe de ces même PM, # pour le pourcentage il suffit d'inscrire un nombre en 1 et 100, # pour un coût de PM fixe il faut inscrire un nombre supérieur à 100, # le script soustraira 100 au total pour définir le véritable prix ainsi 110 donnera un coût de 10 PM # 250 un coût de 150 PM et 10 un coût de 10% des PM. # @enemy_troops = [ <IDs de tous les groupes d'ennemis que vous pourriez rencontrer vers CETTE destination> ] # Exemple : @enemy_troops = [3, 4, 6] # @image = 'Nom de l'image dans le dossier Picture' # Exemple : @image = '015-ForestTown01' #|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| # Les configurations suivantes sont des exemples pour la démo, libre à vous de les effacer/modifier # quand vous aurez compris leurs fonctionnements. when 1 # I @dests[0] = [2, 5] @dests[1] = [3] @dests[2] = [3, 4, 5] @dest_xyd[0] = [ [8, 12, 'U'], [7, 12, 'U'] ] @dest_xyd[1] = [ [11, 0, 'D'] ] @dest_xyd[2] = [ [13, 4, 'D'], [8, 10, 'D'], [4, 8, 'L'] ] @prices[1] = [100] # Le coût en or pour le transport à cheval. @prices[2] = [10, 10, 10] # Le coût en mana/PM pour la téléportation vers chaque destination. @enemy_troops = [1, 2, 3] @image = '015-ForestTown01' when 2 # II (Il est utile d'inscrire le nom de la carte pour s'y retrouver.) @travel_types = [0, 1] @dests[0] = [1, 4] @dests[1] = [3, 4] @dest_xyd[0] = [ [0, 8, 'R'], [11, 0, 'D'] ] @dest_xyd[1] = [ [16, 7, 'L'], [11, 12, 'U'] ] @prices[1] = [150, 200] # Le coût en or pour le transport à cheval. @enemy_troops = [3, 4, 5] @image = '005-Beach01' when 3 # III @dests[0] = [4, 5] @dests[1] = [1, 2, 4, 5] @dests[2] = [1, 4, 5] @dest_xyd[0] = [ [11, 12, 'U'], [7, 12, 'U'] ] @dest_xyd[1] = [ [10, 0, 'D'], [8, 12, 'U'], [11, 12, 'U'], [7, 12, 'U'] ] @dest_xyd[2] = [ [10, 7, 'D'], [8, 10, 'D'], [4, 8, 'L'] ] @prices[1] = [100, 150, 250, 400] # Le coût en or pour le transport à cheval. @prices[2] = [10, 10, 10] # Le coût en mana/PM pour la téléportation vers chaque destination. @enemy_troops = [5, 6] @image = '004-Mountain01' when 4 # IV @dests[0] = [2, 3, 5] @dests[1] = [2, 3, 5] @dests[2] = [1, 3, 5] @dest_xyd[0] = [ [8, 12, 'U'], [16, 8, 'L'], [7, 12, 'U'] ] @dest_xyd[1] = [ [8, 12, 'U'], [11, 0, 'D'], [7, 12, 'U'] ] @dest_xyd[2] = [ [10, 7, 'D'], [13, 4, 'D'], [4, 8, 'L'] ] @prices[1] = [200, 250, 200] # Le coût en or pour le transport à cheval. @prices[2] = [220, 250, 210] # Le coût en mana/PM pour la téléportation vers chaque destination. @enemy_troops = [1, 2, 3, 4, 5] @image = '008-Snowfield01' when 5 # V @dests[0] = [1, 3, 4] @dests[1] = [1, 3, 4] @dests[2] = [1, 3, 4] @dest_xyd[0] = [ [0, 0, 'D'], [16, 8, 'L'], [11, 0, 'D'] ] @dest_xyd[1] = [ [0, 0, 'D'], [11, 0, 'D'], [11, 12, 'U'] ] @dest_xyd[2] = [ [10, 7, 'D'], [13, 4, 'D'], [8, 10, 'D'] ] @prices[1] = [100, 200] # Le coût en or pour le transport à cheval. @prices[2] = [10, 10, 10] # Le coût en mana/PM pour la téléportation vers chaque destination. @enemy_troops = [4, 5] @image = '016-ForestTown02' #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ # Fin de la configuration \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ end # Make sure all price values that matter exist @travel_types.each { |i| @prices[i] = [] if @prices[i] == nil for j in 0...@dests[i].size @prices[i][j] = 0 if @prices[i][j] == nil end } end #------------------------------------------------------------------------ # * Reset #------------------------------------------------------------------------ def reset setup (@id) end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ** Game_TravelData #---------------------------------------------------------------------------- # This class is a wrapper for the "Hash" class. It holds in-game data about # Travel Locations #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ class Game_TravelData #------------------------------------------------------------------------ # * Object Initialization #------------------------------------------------------------------------ def initialize @data = {} end #------------------------------------------------------------------------ # * Get Location #------------------------------------------------------------------------ def [] (map_id) if @data[map_id] == nil @data[map_id] = Location.new @data[map_id].setup (map_id) end return @data[map_id] end end end
#============================================================================== # ** Game_System #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # new instance variable - travel_data, last_travel_option # aliased method - initialize #==============================================================================
class Game_System #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variable #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_reader :travel_data attr_accessor :last_travel_option #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modalg_anaxim_init_travel_4fd2 initialize def initialize # Run Original method modalg_anaxim_init_travel_4fd2 @travel_data = ModAlg_Travel::Game_TravelData.new @last_travel_option = 0 end end
#============================================================================== # ** Game_Temp #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # new instance variables - num_ambushes, ambush_chance, ambush_troops #==============================================================================
class Game_Temp #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variables #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_accessor :num_ambushes attr_accessor :ambush_chance attr_accessor :destination attr_accessor :destination_xyd attr_accessor :location #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modalg_anaxim_trvl_ambush_init_3ht4 initialize def initialize # Run Original Method modalg_anaxim_trvl_ambush_init_3ht4 # Initialize new instance variables reset_travel_values end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Reset Travel Values #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def reset_travel_values @num_ambushes = 0 @ambush_chance = 0 @destination = nil @destination_xyd = [] @location = nil end end
#============================================================================== # ** Window_TravelMana #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # This window shows the mana of the actor with teleport #==============================================================================
class Window_TravelMana < Window_Base #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Public Instance Variable #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ attr_reader :actor #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization # x : the x position of the window # y : the y position of the window #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def initialize (x, y) super (x, y, 160, WLH + 32) @teleport_actors = [] @last_travel_type = -1 end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Refresh # price : the mana cost percentage #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def refresh (travel_type, price) return if ModAlg_Travel::TRAVELOPTIONS_PAYMENT[travel_type] != 2 # Find which teleport skill is attached to this travel_type port_type = 0 for i in 0...travel_type port_type += 1 if ModAlg_Travel::TRAVELOPTIONS_PAYMENT[i] == 2 end # If teleport actors not already calculated if travel_type != @last_travel_type # Calculate teleport actors @last_travel_type = travel_type @teleport_actors.clear teleport_skill = $data_skills[ModAlg_Travel::TELEPORT_SKILL_IDS[port_type]] $game_party.members.each { |i| @teleport_actors.push (i) if i.skill_learn? (teleport_skill) } end contents.clear return if @teleport_actors.empty? # Sort by lowest mana total to highest @teleport_actors.sort! { |a, b| a.maxmp <= b.maxmp } @teleport_actors.each { |i| price = price > 100 ? price - 100 : (i.maxmp.to_f*(price.to_f / 100.0)).to_i if i.mp >= (price) @actor = i break end } @actor = @teleport_actors[0] if @actor == nil tw = [contents.text_size (@actor.name).width, 60].min contents.draw_text (0, 0, tw, WLH, @actor.name) draw_actor_mp (@actor, tw + 4, 0, 124 - tw) end end
#============================================================================== # ** Window_TravelImage #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # This window displays an image, centred #==============================================================================
class Window_TravelImage < Window_Base #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def initialize super (224, 0, Graphics.width - 224, Graphics.height - 32 - WLH) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Refresh #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def refresh (image) contents.clear image = Cache.picture (image) src_rect = Rect.new (0, 0, image.width, image.height) x = (contents.width - src_rect.width) / 2 y = (contents.height - src_rect.height) / 2 contents.blt (x, y, image, src_rect) end end
#============================================================================== # ** Window_DestinationList #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # This window displays the list of all possible destinations #==============================================================================
class Window_DestinationList < Window_Selectable #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization # location_id : the current map ID # traveloptions_height : the height of the window above it #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def initialize (traveloptions_height) @location = $game_system.travel_data[$game_map.map_id] @disabled = [] super (0, traveloptions_height, 224, Graphics.height - 32 - traveloptions_height - WLH) end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Refresh # travel_type_id : the ID of the travel type selected #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def refresh (travel_type_id, teleport_actor = nil) contents.clear contents.dispose self.contents = Bitmap.new (192, @location.dests[travel_type_id].size*WLH) @disabled.clear @item_max = @location.dests[travel_type_id].size for i in 0...@location.dests[travel_type_id].size destination = $game_system.travel_data[@location.dests[travel_type_id][i]] contents.font.color.alpha = 255 if ModAlg_Travel::TRAVELOPTIONS_PAYMENT[travel_type_id] == 1 # Gold # Draw price price = @location.prices[travel_type_id][i] if $game_party.gold < price @disabled.push (i) contents.font.color.alpha = 160 end contents.draw_text (contents.width - 40, i*WLH, 36, WLH, price, 2) elsif ModAlg_Travel::TRAVELOPTIONS_PAYMENT[travel_type_id] == 2 # Mana # Draw mana cost price = destination.prices[travel_type_id][i] price = price > 100 ? price - 100 : (teleport_actor.maxmp.to_f * (price.to_f / 100.0)).to_i if teleport_actor.mp < price @disabled.push (i) contents.font.color.alpha = 160 end contents.draw_text (contents.width - 36, i*WLH, 36, WLH, price, 2) end # Draw name of Destination contents.draw_text (0, i*WLH, contents.width - 44, WLH, destination.name) end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Option Disabled? #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def option_disabled? return @disabled.include? (self.index) end end
#============================================================================== # ** Window_VaryWidthHelp #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # This window is a basic help window, but with a variable width #==============================================================================
class Window_VaryWidthHelp < Window_Help #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Object Initialization #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def initialize (x = 0, y = 0, wdth = Graphics.width) super () self.x = x self.y = y if wdth != self.width self.width = wdth create_contents end end end
#============================================================================== # ** Scene_TravelMenu #------------------------------------------------------------------------------ # This class performs the travel menu screen processing. #==============================================================================
class Scene_TravelMenu < Scene_Base #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Start processing #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def start super # Get location @location = $game_system.travel_data[$game_map.map_id] # Set up gold/mana window position x, y = Graphics.width - 160, Graphics.height - 32 - Window_Base::WLH @mana_window = Window_TravelMana.new (x, y) @gold_window = Window_Gold.new (x, y) # Make travel options window create_command_window if ModAlg_Travel::TRAVEL_TYPE_MEMORY # Set up travel type memory if @valid_options.include? ($game_system.last_travel_option) @command_window.index = @valid_options.index ($game_system.last_travel_option) else @command_window.index = 0 $game_system.last_travel_option = 0 end else @command_window.index = 0 @command_window.active = true end @travel_type = @valid_options[@command_window.index] @mana_window.refresh (@travel_type, @location.prices[@travel_type][0]) # Check what kind of payment options the current choice is pay_options = ModAlg_Travel::TRAVELOPTIONS_PAYMENT if pay_options[@valid_options[@command_window.index]] == 2 # Show mana window @gold_window.visible = false else # Show gold window @mana_window.visible = false end @destination_window = Window_DestinationList.new (@command_window.height) @destination_window.refresh (@travel_type, @mana_window.actor) @destination_window.active = ModAlg_Travel::TRAVEL_TYPE_MEMORY @destination_window.index = 0 @last_dest_index = 0 @image_window = Window_TravelImage.new destination_id = @location.dests[@travel_type][0] @image_window.refresh ($game_system.travel_data[destination_id].image) @help_window = Window_VaryWidthHelp.new (0, y, Graphics.width - 160) @help_window.set_text ("Choose a Destination") end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Termination Processing #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def terminate super @command_window.dispose @destination_window.dispose @mana_window.dispose @gold_window.dispose @image_window.dispose @help_window.dispose end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Frame Update #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def update super if @command_window.active update_command_selection elsif @destination_window.active update_destination_selection end end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Create Command Window #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def create_command_window # Remove Teleport options unless it is available @valid_options = [] pay_options = ModAlg_Travel::TRAVELOPTIONS_PAYMENT teleport_skills = ModAlg_Travel::TELEPORT_SKILL_IDS counter = 0 # Check each option @location.travel_types.each { |i| if pay_options[i] == 2 teleport_skill = $data_skills[teleport_skills[counter]] counter += 1 # Check if someone in the party has the teleport skill $game_party.members.each { |j| if j.skill_learn? (teleport_skill) # Certify as valid if someone in party has the teleport skill @valid_options.push (i) break end } else # Add it to the options list @valid_options.push (i) end } vocab_options = [] @valid_options.each { |i| vocab_options.push (ModAlg_Travel::VOCAB_TRAVELOPTIONS[i]) } @command_window = Window_Command.new (224, vocab_options) @command_window.active = false end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Update Command Selection #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ def update_command_selection @command_window.update # Select Travel Type @travel_type = @valid_options[@command_window.index] if @travel_type != $game_system.last_travel_option $game_system.last_travel_option = @travel_type @mana_window.refresh (@travel_type, @location.prices[@travel_type][0]) @destination_window.refresh (@travel_type, @mana_window.actor) if ModAlg_Travel::TRAVELOPTIONS_PAYMENT[@travel_type] == 2 @mana_window.visible = true @gold_window.visible = false else @mana_window.visible = false @gold_window.visible = true end end # If Button B is pressed if Input.trigger?(Input::B) # Play Cancel SE Sound.play_cancel # Return to Map $scene = Scene_Map.new # If Button C is pressed elsif Input.trigger?(Input::C) # Play Decision SE Sound.play_decision @command_window.active = false @destination_window.index = 0 @destination_window.active = true destination_id = @location.dests[@travel_type][0] @image_window.refresh ($game_system.travel_data[destination_id].image) @mana_window.refresh (@travel_type, @location.prices[@travel_type][0]) @help_window.set_text ("Choose a Destination") end end #-------------------------------------------------------------------------- # * Update Actor Selection #-------------------------------------------------------------------------- def update_destination_selection @destination_window.update if @last_dest_index != @destination_window.index # Refresh Image and Mana Window destination_id = @location.dests[@travel_type][@destination_window.index] @image_window.refresh ($game_system.travel_data[destination_id].image) @mana_window.refresh (@travel_type, @location.prices[@travel_type][@destination_window.index]) @last_dest_index = @destination_window.index end if Input.trigger?(Input::B) # Play Cancel SE Sound.play_cancel # Select a Travel Type @command_window.active = true @destination_window.active = false @destination_window.index = -1 @image_window.refresh (@location.image) @help_window.set_text ("How would you like to travel?") elsif Input.trigger?(Input::C) if @destination_window.option_disabled? Sound.play_buzzer return end # Play Travel Type SE sound = RPG::SE.new sound.name = ModAlg_Travel::TRAVELOPTIONS_SE[@travel_type] sound.play # Subtract money if Gold payable and mana if actor teleport price = @location.prices[@travel_type][@destination_window.index] case ModAlg_Travel::TRAVELOPTIONS_PAYMENT[@travel_type] when 1 # Money $game_party.gain_gold (-price) when 2 # Mana price = price > 100 ? price - 100 : (@mana_window.actor.maxmp.to_f*(price.to_f / 100.0)).to_i @mana_window.actor.mp -= price end $game_temp.location = @location $game_temp.destination = $game_system.travel_data[@location.dests[@travel_type][@destination_window.index]] $game_temp.destination_xyd = $game_temp.location.dest_xyd[@travel_type][@destination_window.index] $game_temp.ambush_chance = ModAlg_Travel::TRAVELOPTIONS_AMBUSH_CHANCE[@travel_type] $game_temp.num_ambushes = ModAlg_Travel::TRAVELOPTIONS_AMBUSHES[@travel_type] $scene = Scene_Map.new end end end
#============================================================================== # ** Scene_Map #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Summary of Changes: # aliased methods - start, update, terminate #==============================================================================
class Scene_Map < Scene_Base #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Start Processing #-------------------------------------------------------------------------- # Checks to see if travelling and incites encounters #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modalg_anaxim_trvl_encntr_check_strt start def start while $game_temp.num_ambushes > 0 $game_temp.num_ambushes -= 1 # Randomly generate a number between 0 and 100 die_roll = rand (100) # If ambush succeeds if die_roll < $game_temp.ambush_chance # Randomly pick a troop from the list of possibles troops = $game_temp.destination.enemy_troops die_roll = rand (troops.size) troop_id = troops[die_roll] # If the troop is real unless $data_troops[troop_id] == nil ambush_se = RPG # Recover the actors before a battle $game_party.members.each { |actor| actor.hp = actor.maxhp if ModAlg_Travel::RECOVER_HP_AFTER_AMBUSH actor.mp = actor.maxmp if ModAlg_Travel::RECOVER_SP_AFTER_AMBUSH if ModAlg_Travel::RECOVER_CONDITIONS_AFTER_AMBUSH actor.states.each { |i| actor.remove_state (i) } end } # Setup a battle $game_troop.setup(troop_id) $game_troop.can_escape = true $game_troop.can_lose = true $game_temp.battle_proc = nil # Notify the Player of the battle y = (Graphics.height - 32 - Window_Base::WLH) / 2 @ambush_window = Window_VaryWidthHelp.new (0, y, Graphics.width) text = ModAlg_Travel::AMBUSH_NOTE.clone text.gsub! (/\\NT/i) { $game_troop.troop.name } text.gsub! (/\\NL/i) { $game_troop.location.name } text.gsub! (/\\ND/i) { $game_troop.destination.name } @ambush_window.set_text (text, 1) perform_transition # Perform transition loop do Graphics.update Input.update # If Buttons B or C are pressed if Input.trigger? (Input::B) || Input.trigger? (Input::C) # Play Decision SE Sound.play_decision @ambush_window.dispose # Set up Map BGM and Map BGS to avoid error $game_temp.map_bgm = RPG::BGM.new $game_temp.map_bgs = RPG::BGS.new Sound.play_battle_start $game_system.battle_bgm.play # Start the battle $scene = Scene_Battle.new return end end end end end # Transport Party if Travelling if $game_temp.destination != nil map_id = $game_temp.destination.id x, y, direction = $game_temp.destination_xyd direction = case direction when 'D' then 2 when 'L' then 4 when 'R' then 6 when 'U' then 8 end $game_player.reserve_transfer(map_id, x, y, direction) $game_player.perform_transfer $game_map.autoplay # Automatically switch BGM and BGS $game_map.update $game_temp.reset_travel_values end # Start Scene_Map if all encounters are exhausted modalg_anaxim_trvl_encntr_check_strt end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Frame Update #-------------------------------------------------------------------------- # Skip update if going into travel battle #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modalg_anxm_trvl_skipupdt update def update # Skip Update if temp travel values exist return if $game_temp.destination != nil # Otherwise, run as normal modalg_anxm_trvl_skipupdt end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Frame Update (Basic) #-------------------------------------------------------------------------- # Skip update if going into travel battle #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modalg_anaxm_trvel_skip_basupdt_5ht6 update_basic def update_basic # Skip Update if temp travel values exist return if $game_temp.destination != nil # Otherwise, run as normal modalg_anaxm_trvel_skip_basupdt_5ht6 end #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # * Terminate #-------------------------------------------------------------------------- # Skip terminate if going into travel battle #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ alias modalg_anxm_trvl_termnt_skip terminate def terminate # Skip Update if temp travel values exist return if $game_temp.destination != nil # Otherwise, run as normal modalg_anxm_trvl_termnt_skip end end
S'il y a un problème sur la traduction ou un passage pas assez clair faites le moi savoir. Pour le reste à part pour la configuration du script, je ne peux pas vous aider.
|
|