#==============================================================================
# Baldur's Gate Travel System (this is an ALTERED version!!!!!!!!)
# Version 1.0
# Author: modern algebra
# Date: June 21, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Thanks:
# Baldur's Gate for original concept I thought of while making the script
# Anaxim for the request and the details of the scene, including a different
# design scheme and a number of different features from Baldur's Gate
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Instructions:
# Call this scene using the Script event command with this code:
# $scene = Scene_TravelMenu.new
#
# To change a map's stats at any time, you can use the code:
# $game_system.travel_data[map_index].<command> = new stat
#
# The possible commands are:
# $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
#
# The correct format for any of those values is located in the comments
# starting at line 120. You can also use the command:
#
# $game_system.travel_data[map_index].reset
#
# To restore it to the values you set here in the script editor
#
# To configure this script read all of the directions from line 39-88 and
# from 124-194
#
# Fixed text-merge bug at line: 517
#
# To change window aspects:
# Left window:
# line 488 = changes window width, for traveloptions_height, I use 320
# line 498 = changes marker width, I use 288
# Right window:
# line 458 = changes window width, I use 320
#==============================================================================
module ModAlg_Travel
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Constants
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# The words you want to represent each travel option. Note that the index for
# each word is retained as the index for that travel type. The default is
# ['Walk', 'Stage Coach', 'Teleport'], so travel types are:
# 0 => Walk, 1 => Stage Coach, and 2 => Teleport
VOCAB_TRAVELOPTIONS = ['Walk', 'Stage Coach', 'Teleport']
# How many possibilities for random encounter by travel type. The default is
# [3, 1, 0], which means that Walking will draw three possibilities for
# being ambushed (meaning you can get into a maximum of three battles),
# Stage Coach will draw 1, and Teleport will draw 0
# TRAVELOPTIONS_AMBUSHES = [3, 1, 0]
TRAVELOPTIONS_AMBUSHES = [0, 0, 0]
# The Chance for each possible ambush to result in an actual ambush, in
# percentile. The default is [50, 50, 0], which means that for walking or
# stage coach, the chance of being ambushed is 50% for each possibility. So,
# with default settings, Walking will have three chances of being ambushed
# at 50% chance each time, etc...
# TRAVELOPTIONS_AMBUSH_CHANCE = [50, 50, 0] # Chance of encounters
TRAVELOPTIONS_AMBUSH_CHANCE = [0, 0, 0] # Chance of encounters
# There are three Payment types - 0 => Nothing, 1 => Money, 2 => MP. You must,
# for each travel type, set what type of payment is expected. By default, the
# option is [0, 1, 2], which means that walking costs nothing, Stage Coach
# costs money, and Teleport costs mp
TRAVELOPTIONS_PAYMENT = [0, 1, 2]
# Sound Effect to be played when destination selected for each option.
# The default is ['Move', 'Horse', 'Teleport'], so it plays the Move SE when
# walking somewhere, the Horse SE when Stage Coach, and the Teleport SE when
# teleporting
TRAVELOPTIONS_SE = ['Move', 'Horse', 'Teleport']
# This only applies for Travel types of Payment Option 2, and it is the ID of
# the skill required to cast Teleport. Having the skill is necessary before
# you can teleport anywhere. If, you had more than one travel type with
# payment option 2 (MP), then the array would need to have two elements.
# Elements can be repeated if you want the same skill to enable more than
# one type of Teleport
TELEPORT_SKILL_IDS = [83]
# This is the Sentence that comes up before you are attacked while travelling.
# There are three special message codes you can use:
# \nt - Shows the name of the ambushing troop
# \nl - the name of the location you are leaving
# \nd - the name of the location you are going to
AMBUSH_NOTE = 'You have been waylaid by \nt and must defend yourself'
# This is the name of the SE played when ambushed
AMBUSH_SE = "Darkness5"
RECOVER_HP_AFTER_AMBUSH = true # Recover HP after battle?
RECOVER_SP_AFTER_AMBUSH = true # Recover SP after battle?
RECOVER_CONDITIONS_AFTER_AMBUSH = true #Recover States after battle?
# Should the script remember the last travel type and assume it favoured (true),
# or should it force the player to choose at the start of the scene (false)?
TRAVEL_TYPE_MEMORY = true
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ** Location
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Location
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_reader :id # The Map ID of the location
attr_reader :name # The name of the location
attr_accessor :image # An image representing the location
attr_accessor :dests # An Array containing map IDs of all destinations
attr_accessor :dest_xyd # A 2D array with corresponding x, y, d arrival data
attr_accessor :prices # An array with prices corresponding to dests
attr_accessor :enemy_troops # An array with all monster troops near this location
attr_accessor :travel_types # The types of travel available from this map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * 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 = ''
#--------------------------------------------------------------------
# Default values for everything:
# @id : map ID
# @name : name of map with that ID
# @travel_types : all possible types
# @dests : [] for all @travel_types
# @dest_xyd : [] for all @travel_types
# @prices : [0, etc..] for all @travel_types
#*********************************************************************
# So what are all of those?
# @id corresponds to the ID of the map. When you call Scene_TravelMenu,
# it calls the Location object that is married to it's ID.
# @name is the map name that you set in the editor for that ID
# @travel_types is a list of the IDs of all types of travel available
# from this location. Travel types correspond to VOCAB_TRAVELOPTIONS,
# and so if that is ['Walk', 'Stage Coach', 'Teleport'], then
# travel type 0 is Walk, travel type 1 is Stage Coach, and travel
# type 2 is Teleport. Thus, If @travel_types = [0, 2], it means that
# you can only choose walk or teleport from this location. Stage
# coach would be unavailable in this map.
# @dests is a 2D array separated by travel type. For each valid travel
# type, you should set an array containing the IDs of all maps
# that you can travel to from this map using that type of travel.
# @dest_xyd is a list that is married to @dest, and it determines the
# xy location of your arrival to the map in @dest with corresponding
# index, as well as indicating the direction to face. The format for
# each location is [x, y, direction], where x and y are integer
# values indicating square to teleport to and direction is either
# 'D' for down, 'U' for up, 'L' for left, or 'R' for right. Thus, an
# example is [0, 4, 'D']. One of these must be there for every
# possible destination by any possible travel type.
# @prices is a list also married to @dests, and it holds the cost of
# travelling to the location in @dest with corresponding index. It is
# unnecesary to set this for any travel type with payment option 0,
# but it will be 0 for
# @enemy_troops is a list of enemy troop IDs you encounter if you choose
# to travel TO, not from, this destination.
# @image is a string with the name of a picture in the Pictures folder.
# It is the picture shown when scrolling over this destination.
#-----------------------------------------------------------------------
case id
#//////////////////////////////////////////////////////////////////////
# EDITABLE REGION ///////////////////////////////////////////////
#////////////////////////////////////////////////////////////////////
# Set up all locations from which you can travel in this format:
# when <map ID>
# EXAMPLE: when 2
# @travel_types = [<ID of each type of travel>]
# EXAMPLE: @travel_types = [0, 1]
# @dests[travel_id] = [ <map IDs of each destination> ]
# EXAMPLE: @dests[0] = [1, 4]
# @dests[1] = [3, 4]
# @dest_xyd[travel_id] = [ <[x, y, d]>, for all destinations ]
# EXAMPLE: @dest_xyd[0] = [ [0, 8, 'R'], [11, 0, 'D'] ]
# @dest_xyd[1] = [ [16, 7, 'L'], [11, 12, 'U'] ]
# @prices[travel_type_id] = [ <cost of travel for each destination> ]
# EXAMPLE: @prices[1] = [150, 200]
# NB: Prices for Payment option 1 are always fixed amounts of Gold.
# For Payment Option 2 (Mana), you can set either a percentage
# or a fixed amount. For a percentage, put any number between
# 0 and 100 and it will use it as a percentage. For a fixed
# cost of mana, make the number greater than 100 and the script
# will subtract 100 to get actual cost. Thus, 110 is 10 mana
# cost, 250 is 150 mana cost, and 10 is 10% of the actor's mana.
# @enemy_troops = [ <IDs of all troops to be encountered coming TO this location> ]
# EXAMPLE: @enemy_troops = [3, 4, 6]
# @image = 'Name of Image in Picture folder'
# EXAMPLE: @image = '005-Beach01'
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# The following are examples. Feel free to delete them once you
# understand how to set a Travel Location
# 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] # Gold Cost for Stage Coach
# @prices[2] = [10, 10, 10] # Mana cost for Teleport
# @enemy_troops = [1, 2, 3]
# @image = '015-ForestTown01'
when 1 # I - Map 1: Brecilian Forest
@dests[0] = [1, 2]
# @dests[1] = [3]
# @dests[2] = [3, 4, 5]
@dest_xyd[0] = [ [7, 10, 'U'], [1, 1, 'D'], [1, 1, 'L'], [1, 1, 'R'] ]
# @dest_xyd[1] = [ [11, 0, 'D'] ]
# @dest_xyd[2] = [ [13, 4, 'D'], [8, 10, 'D'], [4, 8, 'L'] ]
@prices[1] = [100] # Gold Cost for Stage Coach
@prices[2] = [10, 10, 10] # Mana cost for Teleport
@enemy_troops = [1, 2, 3]
@image = 'TEMP1'
when 2 # II (Map Name - it is useful to write it as a reminder)
@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] # Gold Cost for Stage Coach
@enemy_troops = [3, 4, 5]
@image = 'TEMP2'
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] # Gold Cost for Stage Coach
@prices[2] = [10, 10, 10] # Mana cost for teleport
@enemy_troops = [5, 6]
@image = 'TEMP'
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] # Gold Cost for Stage Coach
@prices[2] = [220, 250, 210] # Mana Cost for teleport
@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] # Gold Cost for Stage Coach
@prices[2] = [10, 10, 10] # Mana cost for teleport
@enemy_troops = [4, 5]
@image = '016-ForestTown02'
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# END EDITABLE REGION \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
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)
super (320, 0, Graphics.width - 320, Graphics.height)
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)
super (0, traveloptions_height, 320, Graphics.height)
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)
self.contents = Bitmap.new (288, @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)
# Fixed bug: Changed: 0 to 5 so text do not merge with border marker!
contents.draw_text (4, i*WLH, contents.width - 10, 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[0]
@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 (0)
@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)
#~ @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[0]
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::cool.gif
#~ # 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?")
if 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